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
+19 -10
View File
@@ -3,9 +3,10 @@
<div class="grid">
<div v-for="(m, i) in list" :key="m.key" class="item">
<div
class="cell"
class="cell previewable"
:class="{ dragging: dragIndex === i, over: overIndex === i }"
draggable="true"
@click="preview(i)"
@dragstart="onDragStart(i)"
@dragover.prevent="onDragOver(i)"
@drop="onDrop(i)"
@@ -15,7 +16,7 @@
<img v-else class="thumb" :src="m.url" :alt="m.name" />
<div v-if="isVideo(m)" class="play"><n-icon :component="PlayCircleOutline" :size="26" /></div>
<div class="order">{{ i + 1 }}</div>
<button class="del" type="button" :title="t('common.action.delete')" @click="remove(i)">×</button>
<button class="del" type="button" :title="t('common.action.delete')" @click.stop="remove(i)">×</button>
</div>
<n-input
v-if="captionable"
@@ -27,12 +28,10 @@
/>
</div>
<!-- 上传中占位 -->
<div v-for="u in uploading" :key="u.id" class="item">
<div class="cell uploading"><n-spin size="small" /></div>
</div>
<!-- 上传按钮 -->
<label v-if="list.length + uploading.length < max" class="item">
<span class="cell add">
<input ref="inputRef" type="file" accept="image/*,video/*" multiple hidden @change="onPick" />
@@ -52,6 +51,7 @@ import { NIcon, NSpin, NInput } from 'naive-ui';
import { AddOutline, PlayCircleOutline } from '@vicons/ionicons5';
import { post } from '@/api/request';
import { message } from '@/utils/feedback';
import { openMediaViewer } from '@/composables/openMediaViewer';
interface MediaItem {
key: string;
@@ -67,16 +67,16 @@ const props = withDefaults(
const emit = defineEmits<{ (e: 'update:modelValue', v: MediaItem[]): void }>();
const { t } = useI18n();
function updateCaption(i: number, v: string) {
const arr = list.value.map((m, idx) => (idx === i ? { ...m, name: v } : m));
emit('update:modelValue', arr);
}
const inputRef = ref<HTMLInputElement | null>(null);
const list = computed<MediaItem[]>(() => props.modelValue || []);
const uploading = ref<{ id: number }[]>([]);
let seq = 0;
function updateCaption(i: number, v: string) {
const arr = list.value.map((m, idx) => (idx === i ? { ...m, name: v } : m));
emit('update:modelValue', arr);
}
function isVideo(m: MediaItem) {
return m.type === 'video' || /\.(mp4|webm|mov|m4v|ogg)$/i.test(m.url || m.key || '');
}
@@ -117,7 +117,13 @@ function remove(i: number) {
emit('update:modelValue', list.value.filter((_, idx) => idx !== i));
}
/* 拖拽排序 */
function preview(index: number) {
void openMediaViewer(
list.value.map((m) => ({ url: m.url || m.key, name: m.name || m.key, type: m.type })),
index,
);
}
const dragIndex = ref<number | null>(null);
const overIndex = ref<number | null>(null);
function onDragStart(i: number) {
@@ -183,6 +189,9 @@ function onDragEnd() {
.cell[draggable='true'] {
cursor: grab;
}
.previewable {
cursor: zoom-in;
}
.play {
position: absolute;
inset: 0;