feat: 添加分页功能和缓存管理,优化问答记录展示
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<!-- app/components/home/OcsConfigCard.vue - OCS AnswererWrapper 配置片段 -->
|
||||
<script lang="ts" setup>
|
||||
import { RefreshCw } from "lucide-vue-next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardAction,
|
||||
@@ -12,6 +15,14 @@ import { useAuthStore } from "@/stores/auth";
|
||||
const authStore = useAuthStore();
|
||||
const origin = ref("http://localhost:3000");
|
||||
|
||||
const refreshing = ref(false);
|
||||
|
||||
const handleRefreshToken = async () => {
|
||||
refreshing.value = true;
|
||||
await authStore.refreshApiToken();
|
||||
refreshing.value = false;
|
||||
};
|
||||
|
||||
/** 浏览器端读取当前站点地址,避免文档里写死 localhost 或生产域名 */
|
||||
onMounted(() => {
|
||||
origin.value = window.location.origin;
|
||||
@@ -22,7 +33,8 @@ const configText = computed(() => {
|
||||
const data: Record<string, string> = {
|
||||
title: "${title}",
|
||||
type: "${type}",
|
||||
options: "${options}"
|
||||
options: "${options}",
|
||||
token: ""
|
||||
};
|
||||
|
||||
if (authStore.user?.apiToken) {
|
||||
@@ -53,13 +65,25 @@ const configText = computed(() => {
|
||||
<CardHeader>
|
||||
<CardTitle>OCS 配置</CardTitle>
|
||||
<CardAction>
|
||||
<CopyCom :text="configText" :timeout="1200" />
|
||||
<div class="flex items-center gap-2">
|
||||
<Button
|
||||
v-if="authStore.user?.apiToken && authStore.isOnline"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
:disabled="refreshing"
|
||||
@click="handleRefreshToken"
|
||||
>
|
||||
<RefreshCw :class="['size-4', refreshing ? 'animate-spin' : '']" />
|
||||
刷新 Token
|
||||
</Button>
|
||||
<CopyCom :text="configText" :timeout="1200" :disabled="refreshing" />
|
||||
</div>
|
||||
</CardAction>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent>
|
||||
<pre
|
||||
class="max-h-120 overflow-auto rounded-2xl bg-muted p-4 text-xs leading-5 text-muted-foreground"
|
||||
class="h-89.5 overflow-x-auto overflow-y-hidden rounded-2xl bg-muted p-4 text-xs leading-5 text-muted-foreground"
|
||||
><code>{{ configText }}</code>
|
||||
</pre>
|
||||
</CardContent>
|
||||
|
||||
Reference in New Issue
Block a user