feat: 完善后台导入日志权限与备份恢复

This commit is contained in:
Nixevol
2026-07-04 09:06:35 +08:00
parent 5ae3b12fff
commit d484da3862
61 changed files with 2743 additions and 436 deletions
+12 -1
View File
@@ -13,5 +13,16 @@ export function saveBlob(blob: Blob, filename: string): void {
export async function downloadFile(url: string, filename: string, params?: object): Promise<void> {
const res = await download(url, params);
saveBlob(res.data, filename);
saveBlob(res.data, pickFilename(res.headers, filename));
}
function pickFilename(headers: Record<string, string>, fallback: string): string {
const disposition = headers['content-disposition'] || headers['Content-Disposition'];
const match = disposition?.match(/filename\*?=(?:UTF-8''|")?([^";]+)/i);
if (!match?.[1]) return fallback;
try {
return decodeURIComponent(match[1].replace(/"/g, ''));
} catch {
return match[1].replace(/"/g, '');
}
}
+41
View File
@@ -0,0 +1,41 @@
import { h } from 'vue';
import { NButton, NDropdown, NIcon, type DropdownOption } from 'naive-ui';
import { FilterOutline } from '@vicons/ionicons5';
export interface TableFilterOption {
label: string;
value: string | number;
}
export function renderTableFilterTitle(
label: string,
value: string | number | null | undefined,
options: TableFilterOption[],
onSelect: (value: string | number | null) => void,
allLabel = '全部',
) {
const active = value !== null && value !== undefined && value !== '';
const dropdownOptions: DropdownOption[] = [
{ label: allLabel, key: '__all__' },
...options.map((item) => ({ label: item.label, key: item.value })),
];
return h('div', { class: 'filter-title' }, [
h('span', { class: 'filter-title-text' }, label),
h(
NDropdown,
{
trigger: 'click',
options: dropdownOptions,
onSelect: (key) => onSelect(key === '__all__' ? null : (key as string | number)),
},
{
default: () =>
h(
NButton,
{ quaternary: true, circle: true, size: 'tiny', class: ['filter-trigger', { active }], title: '筛选' },
{ icon: () => h(NIcon, null, { default: () => h(FilterOutline) }) },
),
},
),
]);
}