chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,82 +1,82 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { computed, watch } from "vue";
|
||||
import { useQuery, useQueryClient } from '@tanstack/vue-query'
|
||||
import { computed, watch } from 'vue'
|
||||
|
||||
import MarkdownPreview from "@/components/MarkdownPreview.vue";
|
||||
import { knowledgeApi } from "@/lib/api";
|
||||
import { formatDateTime } from "@/lib/display";
|
||||
import MarkdownPreview from '@/components/MarkdownPreview.vue'
|
||||
import { knowledgeApi } from '@/lib/api'
|
||||
import { formatDateTime } from '@/lib/display'
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
itemId: number | null;
|
||||
}>();
|
||||
open: boolean
|
||||
itemId: number | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
}>();
|
||||
close: []
|
||||
}>()
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const enabled = computed(() => props.open && Boolean(props.itemId));
|
||||
const queryClient = useQueryClient()
|
||||
const enabled = computed(() => props.open && Boolean(props.itemId))
|
||||
|
||||
const detailQuery = useQuery({
|
||||
queryKey: computed(() => ["knowledge", "detail", props.itemId]),
|
||||
queryKey: computed(() => ['knowledge', 'detail', props.itemId]),
|
||||
enabled,
|
||||
queryFn: () => knowledgeApi.detail(props.itemId as number),
|
||||
});
|
||||
})
|
||||
|
||||
const detail = computed(() => detailQuery.data.value);
|
||||
const hasMarkdown = computed(() => Boolean(detail.value?.markdown_content?.trim()));
|
||||
const isProcessing = computed(() =>
|
||||
detail.value?.status === "pending" || detail.value?.status === "processing",
|
||||
);
|
||||
const isFailed = computed(() => detail.value?.status === "failed");
|
||||
const statusLabel = computed(() => formatKnowledgeStatus(detail.value?.status));
|
||||
const detail = computed(() => detailQuery.data.value)
|
||||
const hasMarkdown = computed(() => Boolean(detail.value?.markdown_content?.trim()))
|
||||
const isProcessing = computed(
|
||||
() => detail.value?.status === 'pending' || detail.value?.status === 'processing',
|
||||
)
|
||||
const isFailed = computed(() => detail.value?.status === 'failed')
|
||||
const statusLabel = computed(() => formatKnowledgeStatus(detail.value?.status))
|
||||
const statusColor = computed(() => {
|
||||
if (detail.value?.status === "completed") return "success";
|
||||
if (detail.value?.status === "failed") return "error";
|
||||
if (isProcessing.value) return "processing";
|
||||
return "default";
|
||||
});
|
||||
if (detail.value?.status === 'completed') return 'success'
|
||||
if (detail.value?.status === 'failed') return 'error'
|
||||
if (isProcessing.value) return 'processing'
|
||||
return 'default'
|
||||
})
|
||||
|
||||
watch(
|
||||
[() => props.open, () => props.itemId, () => detail.value?.status],
|
||||
([open, itemId, status], _prev, onCleanup) => {
|
||||
if (!open || !itemId || (status !== "pending" && status !== "processing")) {
|
||||
return;
|
||||
if (!open || !itemId || (status !== 'pending' && status !== 'processing')) {
|
||||
return
|
||||
}
|
||||
|
||||
const timer = window.setInterval(() => {
|
||||
void Promise.all([
|
||||
detailQuery.refetch(),
|
||||
queryClient.invalidateQueries({ queryKey: ["knowledge", "items"] }),
|
||||
]);
|
||||
}, 2500);
|
||||
queryClient.invalidateQueries({ queryKey: ['knowledge', 'items'] }),
|
||||
])
|
||||
}, 2500)
|
||||
|
||||
onCleanup(() => {
|
||||
window.clearInterval(timer);
|
||||
});
|
||||
window.clearInterval(timer)
|
||||
})
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
)
|
||||
|
||||
function handleClose(): void {
|
||||
emit("close");
|
||||
emit('close')
|
||||
}
|
||||
|
||||
function formatKnowledgeStatus(status?: string): string {
|
||||
switch (status) {
|
||||
case "completed":
|
||||
return "学习完成";
|
||||
case "processing":
|
||||
return "处理中";
|
||||
case "failed":
|
||||
return "解析失败";
|
||||
case "pending":
|
||||
return "待处理";
|
||||
case "deleted":
|
||||
return "已删除";
|
||||
case 'completed':
|
||||
return '学习完成'
|
||||
case 'processing':
|
||||
return '处理中'
|
||||
case 'failed':
|
||||
return '解析失败'
|
||||
case 'pending':
|
||||
return '待处理'
|
||||
case 'deleted':
|
||||
return '已删除'
|
||||
default:
|
||||
return status || "未知状态";
|
||||
return status || '未知状态'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user