feat: 实现后台管理前端全部页面与登录布局
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { download } from '@/api/request';
|
||||
|
||||
export function saveBlob(blob: Blob, filename: string): void {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
export async function downloadFile(url: string, filename: string, params?: object): Promise<void> {
|
||||
const res = await download(url, params);
|
||||
saveBlob(res.data, filename);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { createDiscreteApi } from 'naive-ui';
|
||||
import { themeOverrides } from '@/theme';
|
||||
|
||||
// 全局可用的消息/对话框/加载条(含在 setup 之外,如 axios 拦截器)
|
||||
const { message, dialog, loadingBar } = createDiscreteApi(['message', 'dialog', 'loadingBar'], {
|
||||
configProviderProps: { themeOverrides },
|
||||
});
|
||||
|
||||
export { message, dialog, loadingBar };
|
||||
@@ -0,0 +1,34 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export function fmt(d?: string | Date | null): string {
|
||||
return d ? dayjs(d).format('YYYY-MM-DD HH:mm') : '-';
|
||||
}
|
||||
|
||||
export function fmtDate(d?: string | Date | null): string {
|
||||
return d ? dayjs(d).format('YYYY-MM-DD') : '-';
|
||||
}
|
||||
|
||||
const STATUS_TYPE: Record<string, 'default' | 'success' | 'warning' | 'error' | 'info'> = {
|
||||
ENABLED: 'success',
|
||||
ACTIVE: 'success',
|
||||
ONCHAIN: 'success',
|
||||
SUCCESS: 'success',
|
||||
DONE: 'success',
|
||||
DRAFT: 'default',
|
||||
UNBOUND: 'default',
|
||||
INACTIVE: 'info',
|
||||
PENDING: 'info',
|
||||
PROCESSING: 'info',
|
||||
GENERATING: 'info',
|
||||
PARTIAL: 'warning',
|
||||
DISABLED: 'warning',
|
||||
ABNORMAL: 'error',
|
||||
FAILED: 'error',
|
||||
FIRST_ACTIVATE: 'success',
|
||||
REPEAT: 'info',
|
||||
INVALID: 'error',
|
||||
};
|
||||
|
||||
export function statusType(s?: string): 'default' | 'success' | 'warning' | 'error' | 'info' {
|
||||
return (s && STATUS_TYPE[s]) || 'default';
|
||||
}
|
||||
Reference in New Issue
Block a user