优化违禁词
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import Icon from '../components/Icon.vue'
|
||||
import Logo from '../components/Logo.vue'
|
||||
@@ -14,7 +14,10 @@ const tabs = [
|
||||
{ label: '账号管理', to: '/admin/accounts', icon: 'plug' },
|
||||
{ label: '用户管理', to: '/admin/users', icon: 'accounts' },
|
||||
{ label: '并发分组', to: '/admin/concurrency', icon: 'shield' },
|
||||
{ label: '违禁词管理', to: '/admin/banned-words', icon: 'ban' },
|
||||
{ label: '违禁词管理', icon: 'ban', children: [
|
||||
{ label: '违禁词列表', to: '/admin/banned-words' },
|
||||
{ label: '违禁词触发列表', to: '/admin/banned-word-hits' },
|
||||
] },
|
||||
{ label: '订单管理', to: '/admin/orders', icon: 'receipt' },
|
||||
{ label: '兑换码管理', to: '/admin/cdks', icon: 'spark' },
|
||||
{ label: '邀请日志', to: '/admin/invites', icon: 'accounts' },
|
||||
@@ -25,6 +28,22 @@ const tabs = [
|
||||
]
|
||||
|
||||
const currentLabel = computed(() => route.meta?.label || '')
|
||||
|
||||
// 二级菜单展开状态:当前路由命中子项时默认展开,也可手动切换。
|
||||
const openGroups = ref(new Set())
|
||||
function groupActive(t) { return (t.children || []).some((c) => route.path.startsWith(c.to)) }
|
||||
function toggleGroup(label) {
|
||||
const s = new Set(openGroups.value)
|
||||
s.has(label) ? s.delete(label) : s.add(label)
|
||||
openGroups.value = s
|
||||
}
|
||||
watch(() => route.path, () => {
|
||||
for (const t of tabs) {
|
||||
if (t.children && groupActive(t) && !openGroups.value.has(t.label)) {
|
||||
const s = new Set(openGroups.value); s.add(t.label); openGroups.value = s
|
||||
}
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -40,16 +59,34 @@ const currentLabel = computed(() => route.meta?.label || '')
|
||||
</div>
|
||||
</router-link>
|
||||
|
||||
<nav class="flex-1 px-3 py-4 space-y-1">
|
||||
<router-link
|
||||
v-for="t in tabs" :key="t.to" :to="t.to"
|
||||
class="admin-link group"
|
||||
active-class="active">
|
||||
<span class="absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full opacity-0 transition-opacity"
|
||||
style="background: linear-gradient(180deg, #f0abfc, #a78bfa)"></span>
|
||||
<Icon :name="t.icon" class="w-4 h-4 shrink-0 opacity-70 group-hover:opacity-100 transition-opacity" />
|
||||
<span class="text-sm">{{ t.label }}</span>
|
||||
</router-link>
|
||||
<nav class="flex-1 px-3 py-4 space-y-1 overflow-y-auto">
|
||||
<template v-for="t in tabs" :key="t.label">
|
||||
<router-link v-if="!t.children" :to="t.to"
|
||||
class="admin-link group"
|
||||
active-class="active">
|
||||
<span class="absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full opacity-0 transition-opacity"
|
||||
style="background: linear-gradient(180deg, #f0abfc, #a78bfa)"></span>
|
||||
<Icon :name="t.icon" class="w-4 h-4 shrink-0 opacity-70 group-hover:opacity-100 transition-opacity" />
|
||||
<span class="text-sm">{{ t.label }}</span>
|
||||
</router-link>
|
||||
<div v-else>
|
||||
<button type="button" @click="toggleGroup(t.label)"
|
||||
class="admin-link group w-full text-left" :class="groupActive(t) && 'active'">
|
||||
<span class="absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full opacity-0 transition-opacity"
|
||||
style="background: linear-gradient(180deg, #f0abfc, #a78bfa)"></span>
|
||||
<Icon :name="t.icon" class="w-4 h-4 shrink-0 opacity-70 group-hover:opacity-100 transition-opacity" />
|
||||
<span class="text-sm">{{ t.label }}</span>
|
||||
<svg class="w-3 h-3 ml-auto transition-transform" :class="openGroups.has(t.label) && 'rotate-90'"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>
|
||||
</button>
|
||||
<div v-if="openGroups.has(t.label)" class="mt-1 space-y-0.5">
|
||||
<router-link v-for="c in t.children" :key="c.to" :to="c.to"
|
||||
class="admin-sublink" active-class="active">
|
||||
<span class="text-sm">{{ c.label }}</span>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<div class="p-3 border-t border-[color:var(--hairline)] space-y-1">
|
||||
@@ -114,6 +151,18 @@ const currentLabel = computed(() => route.meta?.label || '')
|
||||
.admin-link.active { color: var(--fg); background: var(--hover); }
|
||||
.admin-link.active > span:first-child { opacity: 1; }
|
||||
|
||||
.admin-sublink {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.45rem 0.875rem 0.45rem 2.6rem;
|
||||
border-radius: 0.625rem;
|
||||
color: var(--fg-2);
|
||||
font-weight: 500;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
.admin-sublink:hover { background: var(--hover); color: var(--fg); }
|
||||
.admin-sublink.active { color: var(--fg); background: var(--hover); }
|
||||
|
||||
.fade-enter-active, .fade-leave-active { transition: opacity 0.15s ease, transform 0.15s ease; }
|
||||
.fade-enter-from { opacity: 0; transform: translateY(4px); }
|
||||
.fade-leave-to { opacity: 0; }
|
||||
|
||||
@@ -24,6 +24,7 @@ import AccountsView from './views/AccountsView.vue'
|
||||
import UsersView from './views/UsersView.vue'
|
||||
import ConcurrencyView from './views/ConcurrencyView.vue'
|
||||
import BannedWordsView from './views/BannedWordsView.vue'
|
||||
import BannedWordHitsView from './views/BannedWordHitsView.vue'
|
||||
import CdksView from './views/CdksView.vue'
|
||||
import InvitesAdminView from './views/InvitesAdminView.vue'
|
||||
import ImagesView from './views/ImagesView.vue'
|
||||
@@ -57,7 +58,8 @@ const routes = [
|
||||
{ path: 'accounts', component: AccountsView, meta: { label: '账号管理' } },
|
||||
{ path: 'users', component: UsersView, meta: { label: '用户管理' } },
|
||||
{ path: 'concurrency', component: ConcurrencyView, meta: { label: '并发分组' } },
|
||||
{ path: 'banned-words', component: BannedWordsView, meta: { label: '违禁词管理' } },
|
||||
{ path: 'banned-words', component: BannedWordsView, meta: { label: '违禁词列表' } },
|
||||
{ path: 'banned-word-hits', component: BannedWordHitsView, meta: { label: '违禁词触发列表' } },
|
||||
{ path: 'orders', component: AdminOrdersView, meta: { label: '订单管理' } },
|
||||
{ path: 'cdks', component: CdksView, meta: { label: '兑换码管理' } },
|
||||
{ path: 'invites', component: InvitesAdminView, meta: { label: '邀请日志' } },
|
||||
|
||||
@@ -30,6 +30,7 @@ async function load() {
|
||||
loading.value = true
|
||||
const qs = new URLSearchParams({ limit: String(pageSize), offset: String((page.value - 1) * pageSize) })
|
||||
if (status.value) qs.set('status', status.value)
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/pay/admin/orders?' + qs.toString())
|
||||
loading.value = false
|
||||
if (r.ok) {
|
||||
@@ -39,14 +40,9 @@ async function load() {
|
||||
}
|
||||
onMounted(load)
|
||||
|
||||
const displayed = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
if (!q) return items.value
|
||||
return items.value.filter((o) =>
|
||||
(o.id || '').toLowerCase().includes(q) ||
|
||||
(o.user_name || '').toLowerCase().includes(q) ||
|
||||
String(o.amount).includes(q))
|
||||
})
|
||||
// 搜索走服务端(跨页),直接展示服务端返回的当页结果。
|
||||
const displayed = computed(() => items.value)
|
||||
function doSearch() { page.value = 1; load() }
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
const pageStart = computed(() => total.value === 0 ? 0 : (page.value - 1) * pageSize + 1)
|
||||
const pageEnd = computed(() => Math.min(total.value, page.value * pageSize))
|
||||
@@ -84,7 +80,8 @@ function goPage(n) {
|
||||
<button v-for="s in [['','全部'],['pending','待支付'],['paid','已支付'],['cancelled','已取消']]" :key="s[0]"
|
||||
@click="setStatus(s[0])" class="fp" :class="status === s[0] && 'fp-on'">{{ s[1] }}</button>
|
||||
</div>
|
||||
<input v-model="search" class="field !py-1.5 text-xs !w-52" placeholder="搜索 订单号 / 用户名 / 金额…" />
|
||||
<input v-model="search" @keyup.enter="doSearch" @change="doSearch"
|
||||
class="field !py-1.5 text-xs !w-52" placeholder="搜索 订单号 / 用户名 / 金额…" />
|
||||
<button @click="load" class="btn-soft"><Icon name="refresh" class="w-3.5 h-3.5" /> 刷新</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { api } from '../api'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const items = ref([])
|
||||
const total = ref(0)
|
||||
const loading = ref(false)
|
||||
const search = ref('')
|
||||
const page = ref(1)
|
||||
const pageSize = 50
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
const qs = new URLSearchParams({ limit: String(pageSize), offset: String((page.value - 1) * pageSize) })
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/banned-word-hits?' + qs.toString())
|
||||
loading.value = false
|
||||
if (r.ok) {
|
||||
items.value = r.data?.data || []
|
||||
total.value = Number(r.data?.total ?? items.value.length)
|
||||
}
|
||||
}
|
||||
onMounted(load)
|
||||
|
||||
function doSearch() { page.value = 1; load() }
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
const pageStart = computed(() => total.value === 0 ? 0 : (page.value - 1) * pageSize + 1)
|
||||
const pageEnd = computed(() => Math.min(total.value, page.value * pageSize))
|
||||
const pageNumbers = computed(() => {
|
||||
const n = totalPages.value, cur = page.value
|
||||
if (n <= 7) return Array.from({ length: n }, (_, i) => i + 1)
|
||||
const want = new Set([1, n, cur - 1, cur, cur + 1])
|
||||
if (cur <= 3) { want.add(2); want.add(3); want.add(4) }
|
||||
if (cur >= n - 2) { want.add(n - 1); want.add(n - 2); want.add(n - 3) }
|
||||
const list = [...want].filter((x) => x >= 1 && x <= n).sort((a, b) => a - b)
|
||||
const out = []
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (i > 0 && list[i] - list[i - 1] > 1) out.push(null)
|
||||
out.push(list[i])
|
||||
}
|
||||
return out
|
||||
})
|
||||
function goPage(n) {
|
||||
const t = Math.max(1, Math.min(totalPages.value, n))
|
||||
if (t === page.value) return
|
||||
page.value = t; load()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="theme-text space-y-4">
|
||||
<div class="card p-4 flex items-center justify-between gap-3 flex-wrap">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold">违禁词触发列表</h2>
|
||||
<p class="text-xs text-white/45 mt-0.5">{{ total }} 条触发记录 · 每次拦截记一条(违禁词 / 用户 / 时间 / 提示词)</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<input v-model="search" @keyup.enter="doSearch" @change="doSearch"
|
||||
class="field !py-1.5 text-xs !w-56" placeholder="搜索 违禁词 / 用户名 / 提示词…" />
|
||||
<button @click="load" class="btn-soft"><Icon name="refresh" class="w-3.5 h-3.5" /> 刷新</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card overflow-hidden">
|
||||
<table class="w-full text-sm table-fixed">
|
||||
<colgroup>
|
||||
<col class="w-36" />
|
||||
<col class="w-44" />
|
||||
<col />
|
||||
<col class="w-40" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="text-[10px] uppercase tracking-[0.2em] text-white/40 border-b border-white/[0.06]">
|
||||
<th class="text-left px-5 py-3 font-medium">违禁词</th>
|
||||
<th class="text-left px-3 py-3 font-medium">用户</th>
|
||||
<th class="text-left px-3 py-3 font-medium">提示词</th>
|
||||
<th class="text-left px-3 py-3 font-medium">触发时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading && !items.length"><td colspan="4" class="text-center text-xs text-white/40 py-10">加载中…</td></tr>
|
||||
<tr v-else-if="!items.length"><td colspan="4" class="text-center text-xs text-white/40 py-10">{{ search.trim() ? '没有匹配的记录' : '还没有触发记录' }}</td></tr>
|
||||
<tr v-for="h in items" :key="h.id" class="border-b border-white/[0.04] hover:bg-white/[0.03] transition-colors align-top">
|
||||
<td class="px-5 py-3.5 text-sm font-medium text-rose-300">{{ h.word }}</td>
|
||||
<td class="px-3 py-3.5">
|
||||
<div class="text-sm text-white/85 truncate" :title="h.user_name">{{ h.user_name || '—' }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-3.5 text-xs text-white/60">
|
||||
<div class="line-clamp-2 break-all" :title="h.prompt">{{ h.prompt || '—' }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-3.5 text-xs text-white/50 tabular-nums">{{ new Date(h.created_at).toLocaleString() }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-if="totalPages > 1" class="flex items-center justify-between px-5 py-3 border-t border-white/[0.06] text-xs text-white/45">
|
||||
<div><span class="tabular-nums text-white/75">{{ pageStart }}–{{ pageEnd }}</span><span class="ml-1">/ {{ total }} 条</span></div>
|
||||
<div class="flex items-center gap-1">
|
||||
<template v-for="(n, i) in pageNumbers" :key="i">
|
||||
<span v-if="n === null" class="px-1 text-white/30">…</span>
|
||||
<button v-else @click="goPage(n)" class="pg" :class="page === n && 'pg-on'">{{ n }}</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pg { min-width: 1.75rem; padding: 0.3rem 0.55rem; font-size: 0.72rem; font-weight: 500; text-align: center; border-radius: 0.45rem; color: rgb(255 255 255 / 0.7); background: rgb(255 255 255 / 0.04); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08); transition: background 0.15s, color 0.15s; }
|
||||
.pg:hover:not(.pg-on) { background: rgb(255 255 255 / 0.1); color: white; }
|
||||
.pg-on { background: rgb(255 255 255 / 0.92); color: rgb(15 23 42); box-shadow: none; }
|
||||
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
</style>
|
||||
@@ -14,6 +14,7 @@ const kindFilter = ref('') // '' | 'image' | 'video'
|
||||
const statusFilter = ref('') // '' | 'success' | 'failed' | 'pending'
|
||||
const sourceFilter = ref('') // '' | 'v1' | 'user' | 'admin'
|
||||
const search = ref('')
|
||||
const userSearch = ref('') // 服务端用户搜索:名称 / 邮箱 / ID,跨页生效
|
||||
const page = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const total = ref(0)
|
||||
@@ -42,6 +43,8 @@ async function load() {
|
||||
if (kindFilter.value) qs.set('kind', kindFilter.value)
|
||||
if (statusFilter.value) qs.set('status', statusFilter.value)
|
||||
if (sourceFilter.value) qs.set('source', sourceFilter.value)
|
||||
if (userSearch.value.trim()) qs.set('user', userSearch.value.trim())
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/logs?' + qs.toString())
|
||||
items.value = r.data?.data || []
|
||||
total.value = Number(r.data?.total ?? items.value.length)
|
||||
@@ -83,16 +86,10 @@ function goPage(n) {
|
||||
function setKind(v) { kindFilter.value = v; page.value = 1; load() }
|
||||
function setStatus(v) { statusFilter.value = v; page.value = 1; load() }
|
||||
function setSource(v) { sourceFilter.value = v; page.value = 1; load() }
|
||||
function doUserSearch() { page.value = 1; load() }
|
||||
|
||||
const filtered = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
if (!q) return items.value
|
||||
return items.value.filter((e) =>
|
||||
(e.model || '').toLowerCase().includes(q) ||
|
||||
(e.prompt || '').toLowerCase().includes(q) ||
|
||||
(e.error || '').toLowerCase().includes(q),
|
||||
)
|
||||
})
|
||||
// 搜索全部走服务端(跨页),页面直接展示服务端返回的当页结果。
|
||||
const filtered = computed(() => items.value)
|
||||
|
||||
function fmtMs(ms) {
|
||||
if (!ms) return '—'
|
||||
@@ -203,8 +200,13 @@ const sourcePill = (s) => ({
|
||||
<button @click="setSource('v1')" class="fp" :class="sourceFilter === 'v1' && 'fp-on'">API</button>
|
||||
<button @click="setSource('admin')" class="fp" :class="sourceFilter === 'admin' && 'fp-on'">测试</button>
|
||||
</div>
|
||||
<div class="w-44">
|
||||
<input v-model="userSearch" @keyup.enter="doUserSearch" @change="doUserSearch"
|
||||
class="field !py-1.5 text-xs" placeholder="搜索用户 名称/邮箱/ID…" />
|
||||
</div>
|
||||
<div class="flex-1 min-w-[200px]">
|
||||
<input v-model="search" class="field !py-1.5 text-xs" placeholder="搜索 模型 / 提示词 / 错误…" />
|
||||
<input v-model="search" @keyup.enter="doUserSearch" @change="doUserSearch"
|
||||
class="field !py-1.5 text-xs" placeholder="搜索 模型 / 提示词 / 错误…" />
|
||||
</div>
|
||||
<button @click="load" class="btn-soft">
|
||||
<Icon name="refresh" class="w-3.5 h-3.5" /> 刷新
|
||||
@@ -216,9 +218,7 @@ const sourcePill = (s) => ({
|
||||
<div v-if="loading && !items.length" class="text-center text-sm text-white/40 py-20">加载中…</div>
|
||||
<div v-else-if="!filtered.length" class="flex flex-col items-center gap-3 text-white/40 py-20">
|
||||
<span class="w-14 h-14 rounded-2xl bg-white/[0.04] grid place-items-center"><Icon name="files" class="w-6 h-6" /></span>
|
||||
<!-- Search is client-side over the CURRENT page only, so "no match" here
|
||||
doesn't mean the term is absent globally — say so to avoid confusion. -->
|
||||
<span class="text-sm">{{ search.trim() ? '当前页没有匹配的记录(搜索仅作用于本页)' : '还没有日志' }}</span>
|
||||
<span class="text-sm">{{ (search.trim() || userSearch.trim()) ? '没有匹配的记录' : '还没有日志' }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Each row is a thumbnail + a stack of model/prompt + a meta line.
|
||||
|
||||
@@ -38,6 +38,7 @@ async function load() {
|
||||
loading.value = true
|
||||
const qs = new URLSearchParams({ limit: String(pageSize), offset: String((page.value - 1) * pageSize) })
|
||||
if (status.value) qs.set('status', status.value)
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/pay/orders?' + qs.toString())
|
||||
loading.value = false
|
||||
if (r.ok) {
|
||||
@@ -47,14 +48,9 @@ async function load() {
|
||||
}
|
||||
onMounted(load)
|
||||
|
||||
const displayed = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
if (!q) return items.value
|
||||
return items.value.filter((o) =>
|
||||
(o.id || '').toLowerCase().includes(q) ||
|
||||
String(o.amount).includes(q) ||
|
||||
(METHOD[o.pay_type] || '').includes(q))
|
||||
})
|
||||
// 搜索走服务端(跨页),直接展示服务端返回的当页结果。
|
||||
const displayed = computed(() => items.value)
|
||||
function doSearch() { page.value = 1; load() }
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
const pageStart = computed(() => total.value === 0 ? 0 : (page.value - 1) * pageSize + 1)
|
||||
const pageEnd = computed(() => Math.min(total.value, page.value * pageSize))
|
||||
@@ -112,7 +108,8 @@ async function cont(o) {
|
||||
:class="status === s[0] ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-600 hover:bg-slate-200'">{{ s[1] }}</button>
|
||||
</div>
|
||||
<div class="flex-1 min-w-[180px]">
|
||||
<input v-model="search" class="field !py-1.5 text-xs" placeholder="搜索 订单号 / 金额 / 方式…" />
|
||||
<input v-model="search" @keyup.enter="doSearch" @change="doSearch"
|
||||
class="field !py-1.5 text-xs" placeholder="搜索 订单号 / 金额 / 方式…" />
|
||||
</div>
|
||||
<button @click="load" class="btn-soft"><Icon name="refresh" class="w-3.5 h-3.5" /> 刷新</button>
|
||||
</div>
|
||||
|
||||
@@ -54,6 +54,7 @@ async function load() {
|
||||
})
|
||||
if (statusFilter.value) qs.set('status', statusFilter.value)
|
||||
if (SOURCE_PARAM[sourceFilter.value]) qs.set('source', SOURCE_PARAM[sourceFilter.value])
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/logs?' + qs.toString())
|
||||
loading.value = false
|
||||
if (r.ok) {
|
||||
@@ -72,15 +73,9 @@ const sourcePill = (e) => (isApi(e)
|
||||
? 'bg-violet-50 text-violet-700 ring-violet-200'
|
||||
: 'bg-sky-50 text-sky-700 ring-sky-200')
|
||||
|
||||
// 搜索只在当前页内过滤(状态/来源已由服务端筛选并分页)。
|
||||
const displayed = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
if (!q) return items.value
|
||||
return items.value.filter((e) =>
|
||||
(e.model || '').toLowerCase().includes(q) ||
|
||||
(e.prompt || '').toLowerCase().includes(q) ||
|
||||
(e.error || '').toLowerCase().includes(q))
|
||||
})
|
||||
// 搜索走服务端(跨页),直接展示服务端返回的当页结果。
|
||||
const displayed = computed(() => items.value)
|
||||
function doSearch() { page.value = 1; load() }
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
const pageStart = computed(() => total.value === 0 ? 0 : (page.value - 1) * pageSize + 1)
|
||||
const pageEnd = computed(() => Math.min(total.value, page.value * pageSize))
|
||||
@@ -178,7 +173,8 @@ const params = (e) => {
|
||||
:class="sourceFilter === s[0] ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-600 hover:bg-slate-200'">{{ s[1] }}</button>
|
||||
</div>
|
||||
<div class="flex-1 min-w-[180px]">
|
||||
<input v-model="search" class="field !py-1.5 text-xs" placeholder="搜索 提示词 / 模型 / 错误…" />
|
||||
<input v-model="search" @keyup.enter="doSearch" @change="doSearch"
|
||||
class="field !py-1.5 text-xs" placeholder="搜索 提示词 / 模型 / 错误…" />
|
||||
</div>
|
||||
<button @click="load" class="btn-soft"><Icon name="refresh" class="w-3.5 h-3.5" /> 刷新</button>
|
||||
</div>
|
||||
@@ -197,7 +193,6 @@ const params = (e) => {
|
||||
<col class="w-16" /> <!-- preview -->
|
||||
<col class="w-28" /> <!-- time -->
|
||||
<col class="w-24" /> <!-- status -->
|
||||
<col class="w-28" /> <!-- user/account -->
|
||||
<col class="w-56" /> <!-- model -->
|
||||
<col /> <!-- prompt/error -->
|
||||
<col class="w-40" /> <!-- params -->
|
||||
@@ -209,7 +204,6 @@ const params = (e) => {
|
||||
<th class="text-center px-3 py-3 font-medium">预览</th>
|
||||
<th class="text-left px-3 py-3 font-medium">时间</th>
|
||||
<th class="text-left px-3 py-3 font-medium">状态</th>
|
||||
<th class="text-left px-3 py-3 font-medium">用户 / 账号</th>
|
||||
<th class="text-left px-3 py-3 font-medium">模型</th>
|
||||
<th class="text-left px-3 py-3 font-medium">提示词 / 错误</th>
|
||||
<th class="text-left px-3 py-3 font-medium">参数</th>
|
||||
@@ -242,10 +236,6 @@ const params = (e) => {
|
||||
<span class="w-1.5 h-1.5 rounded-full" :class="statusDot(e.status)"></span>{{ statusLabel(e.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-3 align-middle min-w-0">
|
||||
<div class="text-xs text-slate-700 truncate" :title="e.user_name || '匿名'">{{ e.user_name || '匿名' }}</div>
|
||||
<div v-if="e.account" class="mt-0.5 text-[11px] text-slate-400 truncate" :title="e.account">{{ e.account }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-3 align-middle min-w-0">
|
||||
<div class="font-mono text-xs text-slate-800 break-all" :title="e.model">{{ e.model }}</div>
|
||||
<div class="mt-0.5 flex items-center gap-1.5">
|
||||
|
||||
@@ -34,22 +34,16 @@ async function load() {
|
||||
source: 'user', // 创作记录 = 画图台作品;排除 API(v1,无存储文件)+ 测试
|
||||
})
|
||||
if (kindFilter.value) qs.set('kind', kindFilter.value)
|
||||
if (search.value.trim()) qs.set('q', search.value.trim())
|
||||
const r = await api('/logs?' + qs.toString())
|
||||
items.value = (r.data?.data || []).filter((e) => e.status === 'success' && e.file)
|
||||
total.value = Number(r.data?.total ?? items.value.length)
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
// Search narrows the CURRENT page (same as the admin 日志 page); the numbered
|
||||
// pager still reflects the full server-side total.
|
||||
const filtered = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
if (!q) return items.value
|
||||
return items.value.filter((e) =>
|
||||
(e.model || '').toLowerCase().includes(q) ||
|
||||
(e.prompt || '').toLowerCase().includes(q),
|
||||
)
|
||||
})
|
||||
// 搜索走服务端(跨页),直接展示服务端返回的当页结果。
|
||||
const filtered = computed(() => items.value)
|
||||
function doSearch() { page.value = 1; load() }
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)))
|
||||
function setKind(v) { kindFilter.value = v; page.value = 1; load() }
|
||||
@@ -260,7 +254,8 @@ onUnmounted(() => {
|
||||
:class="kindFilter === 'video' ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-600 hover:bg-slate-200'">视频</button>
|
||||
</div>
|
||||
<div class="flex-1 min-w-[180px]">
|
||||
<input v-model="search" class="field !py-1.5 text-xs" placeholder="搜索提示词或模型…" />
|
||||
<input v-model="search" @keyup.enter="doSearch" @change="doSearch"
|
||||
class="field !py-1.5 text-xs" placeholder="搜索提示词或模型…" />
|
||||
</div>
|
||||
<button @click="togglePickAll" class="text-xs rounded-lg px-2.5 py-1.5 transition-colors inline-flex items-center gap-1"
|
||||
:class="pageAllPicked ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-600 hover:bg-slate-200'">
|
||||
|
||||
Reference in New Issue
Block a user