mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 06:16:37 +08:00
38b0516937
新增部署源配置与运行态模型、安全下载、租约续期、原子激活和失败补偿。 接入内部任务与脱敏前端交互,并阻止数据库 Trace 和日志展开敏感查询参数。
36 lines
992 B
TypeScript
36 lines
992 B
TypeScript
export function formatBytes(bytes: number, decimals = 2) {
|
|
if (bytes === 0) return '0 B';
|
|
const k = 1024;
|
|
const dm = decimals < 0 ? 0 : decimals;
|
|
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
}
|
|
|
|
export const projectsQueryKey = ['openflare', 'pages', 'projects'] as const;
|
|
|
|
export function projectQueryKey(projectId: string | number) {
|
|
return ['openflare', 'pages', 'project', String(projectId)] as const;
|
|
}
|
|
|
|
export function deploymentsQueryKey(projectId: number) {
|
|
return ['openflare', 'pages', 'deployments', projectId] as const;
|
|
}
|
|
|
|
export function sourceQueryKey(projectId: number) {
|
|
return ['openflare', 'pages', 'source', projectId] as const;
|
|
}
|
|
|
|
export function deploymentFilesQueryKey(
|
|
projectId: number,
|
|
deploymentId: number,
|
|
) {
|
|
return [
|
|
'openflare',
|
|
'pages',
|
|
'deployment-files',
|
|
projectId,
|
|
deploymentId,
|
|
] as const;
|
|
}
|