feat: 完善鉴权

This commit is contained in:
2026-05-22 23:10:40 +08:00
parent 3857f77f8b
commit c48d57df14
14 changed files with 118 additions and 117 deletions
+8 -2
View File
@@ -1,4 +1,4 @@
<!-- app/components/CopyCom.vue - 通用复制按钮带图标切换动画 -->
<!-- app/components/CopyCom.vue - 通用复制按钮 -->
<script lang="ts" setup>
import { Check, Copy } from "lucide-vue-next";
import type { HTMLAttributes } from "vue";
@@ -14,10 +14,12 @@ const {
variant = "outline",
size = "sm",
timeout = 2000,
disableDefaultCopy = false
disableDefaultCopy = false,
disabled = false
} = defineProps<{
/** 要复制的文本 */
text?: string;
// eslint-disable-next-line vue/require-default-prop
class?: HTMLAttributes["class"] | undefined;
variant?: ButtonVariants["variant"];
size?: ButtonVariants["size"];
@@ -25,6 +27,8 @@ const {
timeout?: number;
/** 禁用内置复制行为,只触发状态变化(外部自行处理复制) */
disableDefaultCopy?: boolean;
/** 禁用按鈕,不可点击且展示禁用样式 */
disabled?: boolean;
}>();
const emit = defineEmits<{
@@ -34,6 +38,7 @@ const emit = defineEmits<{
const isCopied = ref(false);
const handleCopy = () => {
if (disabled) return;
if (!disableDefaultCopy) {
copy(text);
}
@@ -52,6 +57,7 @@ defineExpose({ isCopied });
type="button"
:variant="variant"
:size="size"
:disabled="disabled"
:class="cn('relative overflow-hidden pl-8', className)"
@click.prevent.stop="handleCopy"
>
+5 -5
View File
@@ -1,6 +1,6 @@
<!-- app/pages/dashboard.vue - 运行状态与最近问答记录页面 -->
<script lang="ts" setup>
import { ArrowPathIcon } from "@heroicons/vue/24/outline";
import { RefreshCw } from "lucide-vue-next";
import QaRecordDetail from "@/components/dashboard/QaRecordDetail.vue";
import QaRecordsTable from "@/components/dashboard/QaRecordsTable.vue";
@@ -64,17 +64,17 @@ const handleRefreshToken = async () => {
>
{{ authStore.user.apiToken }}
</code>
<CopyCom :text="authStore.user.apiToken" />
<CopyCom :text="authStore.user.apiToken" :disabled="refreshing" />
<Button
variant="outline"
size="icon"
:disabled="refreshing"
title="刷新 Token"
class="flex items-center gap-1 w-fit px-2.5"
@click="handleRefreshToken"
>
<ArrowPathIcon
:class="['size-4', refreshing ? 'animate-spin' : '']"
/>
<RefreshCw :class="['size-4', refreshing ? 'animate-spin' : '']" />
<span>刷新 Token</span>
</Button>
</div>
</CardContent>
+1 -1
View File
@@ -32,7 +32,7 @@ export class AnswerService {
);
}
/** 读取运行统计;配置 ACCESS_TOKEN 时由服务端校验 */
/** 读取运行统计(需登录) */
public static getStats() {
return BaseClientService.get<IStatsResponse>(
`${AnswerService.basePath}/stats`