refactor(frontend): 重构前端第二版
This commit is contained in:
1 parent
2631f78b00
commit
4b562cfa82
205 files changed
+15399
-12015
No files matched your search
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
* features/chat/components/ChatQueryPreviewDialog.vue
|
||||
* Text2SQL 查询结果全量预览弹窗 UI。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { Loader2, X } from 'lucide-vue-next';
|
||||
import type { QueryPreviewState } from '../composables/useChatQueryPreview';
|
||||
|
||||
const open = defineModel<boolean>('open', { required: true });
|
||||
|
||||
const props = defineProps<{
|
||||
loading: boolean;
|
||||
error: string;
|
||||
state: QueryPreviewState;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
'change-page': [delta: number];
|
||||
}>();
|
||||
|
||||
const totalPages = computed(() =>
|
||||
Math.max(1, Math.ceil((props.state.total || 0) / (props.state.pageSize || 100))),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="dialog-overlay z-[120] items-center"
|
||||
@click.self="emit('close')"
|
||||
>
|
||||
<div class="dialog-panel flex max-h-[88vh] w-[min(96vw,1280px)] max-w-[1280px] flex-col">
|
||||
<div class="dialog-header">
|
||||
<div>
|
||||
<h3 class="section-title">查询结果全量预览</h3>
|
||||
<p class="section-desc mt-1">{{ state.query || state.title }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="emit('close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body flex min-h-0 flex-1 flex-col gap-4 border-t-0 pt-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-default bg-surface-soft px-4 py-3 text-sm text-secondary">
|
||||
<div>共 {{ state.total || 0 }} 条,当前第 {{ state.page }} / {{ totalPages }} 页</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="loading || state.page <= 1"
|
||||
@click="emit('change-page', -1)"
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="loading || state.page >= totalPages"
|
||||
@click="emit('change-page', 1)"
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="error" class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
|
||||
{{ error }}
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-auto rounded-2xl border border-default bg-surface">
|
||||
<div v-if="loading" class="flex h-56 items-center justify-center">
|
||||
<Loader2 class="h-6 w-6 animate-spin text-brand-500" />
|
||||
</div>
|
||||
<div v-else-if="!state.columns.length" class="flex h-56 items-center justify-center text-sm text-muted">
|
||||
暂无可预览数据
|
||||
</div>
|
||||
<table v-else class="min-w-full border-collapse text-sm">
|
||||
<thead class="sticky top-0 z-10 bg-slate-50">
|
||||
<tr>
|
||||
<th
|
||||
v-for="column in state.columns"
|
||||
:key="`query-preview-col-${column}`"
|
||||
class="border border-slate-200 px-3 py-2 text-left font-semibold text-primary"
|
||||
>
|
||||
{{ column }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(row, rowIndex) in state.rows"
|
||||
:key="`query-preview-row-${rowIndex}`"
|
||||
class="odd:bg-white even:bg-slate-50/50"
|
||||
>
|
||||
<td
|
||||
v-for="(cell, cellIndex) in row"
|
||||
:key="`query-preview-cell-${rowIndex}-${cellIndex}`"
|
||||
class="max-w-[320px] border border-slate-200 px-3 py-2 align-top text-secondary"
|
||||
>
|
||||
<div class="whitespace-pre-wrap break-all">{{ cell ?? '-' }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user