From 72cb8c796f0c0a29be8a6c7b9248cae046b643db Mon Sep 17 00:00:00 2001 From: zhengshunjin <2667579369@qq.com> Date: Thu, 7 May 2026 20:20:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E4=BB=A3=E7=A0=81=E4=BB=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=E5=92=8C=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 ResponseData 类型定义,统一返回格式为数组类型 - 更新 API 函数签名以包含正确的返回类型注解 - 简化 AboutView 组件中的统计数据显示逻辑 - 移除未使用的变量和方法,精简组件代码 - 修复 HomeView 中的事件监听器类型定义问题 - 替换接口泛型中的 any 类型为 unknown 提高类型安全 - 注释掉未使用的全局变量避免潜在错误 --- flask-ui/src/api/index.ts | 6 ++-- flask-ui/src/utils/request.ts | 6 ++-- flask-ui/src/views/AboutView.vue | 50 +------------------------------ flask-ui/src/views/HomeView.vue | 8 ++--- instance/flask.db | Bin 36864 -> 36864 bytes 5 files changed, 12 insertions(+), 58 deletions(-) diff --git a/flask-ui/src/api/index.ts b/flask-ui/src/api/index.ts index 8c55f12..77ec1e3 100644 --- a/flask-ui/src/api/index.ts +++ b/flask-ui/src/api/index.ts @@ -1,5 +1,7 @@ import request from "../utils/request.ts" +type ResponseData = Promise<{ code: number, message: Array }> + export function book_download() { return request({ url: "/book/download", @@ -24,7 +26,7 @@ export function video_hasTorrent() { }) } -export function file_rename() { +export function file_rename(): ResponseData { return request({ url: "/file/rename", }) @@ -60,7 +62,7 @@ export function test() { }) } -export function torrent_statistics(){ +export function torrent_statistics(): ResponseData { return request({ url: "/torrent/statistics", }) diff --git a/flask-ui/src/utils/request.ts b/flask-ui/src/utils/request.ts index 66392a7..a2f9ce1 100644 --- a/flask-ui/src/utils/request.ts +++ b/flask-ui/src/utils/request.ts @@ -6,7 +6,7 @@ import axios, { } from "axios" // 定义响应数据结构 -interface ResponseData { +interface ResponseData { code: number msg: string data?: T @@ -18,8 +18,8 @@ interface RequestCache { time: number } -let downloadLoadingInstance: any -export let isRelogin: { show: boolean } = {show: false} +// let downloadLoadingInstance: any +// export let isRelogin: { show: boolean } = {show: false} axios.defaults.headers["Content-Type"] = "application/json; charset=UTF-8" const service: AxiosInstance = axios.create({ diff --git a/flask-ui/src/views/AboutView.vue b/flask-ui/src/views/AboutView.vue index 79b2eb6..7955d36 100644 --- a/flask-ui/src/views/AboutView.vue +++ b/flask-ui/src/views/AboutView.vue @@ -2,70 +2,22 @@ import {onMounted, ref} from 'vue' import {torrent_statistics} from '@/api' -interface StatisticsData { - [key: string]: any -} - -let aa = ref({}) -let bb = ref("") -let cc = ref("") -let dd = ref("") - +const aa = ref([]) onMounted(async () => { const res = await torrent_statistics() console.log(res.message) - aa.value = res.message }) -const getSecondLevelOptions = () => { - if (!bb.value || !aa.value[bb.value]) { - return [] - } - return aa.value[bb.value] -} - -const getThirdLevelOptions = () => { - if (!bb.value || !cc.value || !aa.value[bb.value] || !aa.value[bb.value][cc.value]) { - return [] - } - console.log(aa.value[bb.value]) - return aa.value[bb.value][cc.value] -} -