Skip to content

Commit 8094379

Browse files
perf: TS Error
1 parent 2a74b4d commit 8094379

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

frontend/src/components/layout/index.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
import {ref, computed, onMounted} from 'vue'
150150
import {useRouter, useRoute} from 'vue-router'
151151
import {useUserStore} from '@/stores/user'
152-
import folder from '@/assets/svg/folder.svg'
153152
import ds from '@/assets/svg/ds.svg'
154153
import dashboard from '@/assets/svg/dashboard.svg'
155154
import chat from '@/assets/svg/chat.svg'
@@ -184,12 +183,12 @@ const sysRouterList = computed(() => {
184183
const showSubmenu = computed(() => {
185184
return route.path.includes('/system')
186185
})
187-
const workspace = ref('1')
188-
const options = [
186+
// const workspace = ref('1')
187+
/* const options = [
189188
{value: '1', label: 'Default workspace'},
190189
{value: '2', label: 'Workspace 2'},
191190
{value: '3', label: 'Workspace 3'}
192-
]
191+
] */
193192
const currentPageTitle = computed(() => {
194193
if (route.path.includes('/system')) {
195194
return 'System Settings'

frontend/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ds from "@/views/ds/index.vue";
88
import DashboardEditor from "@/views/dashboard/editor/index.vue";
99
import Dashboard from "@/views/dashboard/index.vue";
1010
import Model from "@/views/system/model/index.vue";
11-
import User from "@/views/system/user/index.vue";
11+
// import User from "@/views/system/user/index.vue";
1212
import { watchRouter } from "./watch";
1313
const router = createRouter({
1414
history: createWebHashHistory(),

frontend/src/stores/user.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineStore } from 'pinia'
2-
import { ref } from 'vue'
2+
// import { ref } from 'vue'
33
import { AuthApi } from '@/api/login'
44
import { useCache } from '@/utils/useCache'
55
import { i18n } from '@/i18n'
@@ -17,18 +17,19 @@ interface UserState {
1717
language: string
1818
exp: number
1919
time: number
20+
[key: string]: string | number
2021
}
2122

2223
export const UserStore = defineStore('user', {
2324
state: (): UserState => {
2425
return {
25-
token: null,
26-
uid: null,
27-
name: null,
28-
oid: null,
26+
token: '',
27+
uid: '',
28+
name: '',
29+
oid: '',
2930
language: 'zh-CN',
30-
exp: null,
31-
time: null
31+
exp: 0,
32+
time: 0
3233
}
3334
},
3435
getters: {
@@ -69,13 +70,23 @@ export const UserStore = defineStore('user', {
6970
const res: any = await AuthApi.info()
7071
const res_data = res || {}
7172

72-
const keys: string[] = ['uid', 'name', 'oid', 'language', 'exp', 'time']
73-
73+
// 指定 keys 类型为 UserState 的键
74+
const keys = ['uid', 'name', 'oid', 'language', 'exp', 'time'] as const
75+
7476
keys.forEach(key => {
7577
const dkey = key === 'uid' ? 'id' : key
76-
this[key] = res_data[dkey]
77-
wsCache.set('user.' + key, this[key])
78+
const value = res_data[dkey]
79+
80+
// 使用类型守卫区分数字和字符串类型
81+
if (key === 'exp' || key === 'time') {
82+
this[key] = Number(value)
83+
wsCache.set('user.' + key, value.toString())
84+
} else {
85+
this[key] = String(value)
86+
wsCache.set('user.' + key, value)
87+
}
7888
})
89+
7990
this.setLanguage(this.language)
8091
},
8192
setToken(token: string) {

frontend/src/views/dashboard/editor/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import cloneDeep from 'lodash/cloneDeep';
88
import {storeToRefs} from "pinia";
99
import {dashboardStoreWithOut} from "@/stores/dashboard/dashboard.ts";
1010
import router from '@/router'
11-
import {dashboardApi} from "@/api/dashboard.ts";
1211
import {initCanvasData} from "@/views/dashboard/utils/canvasUtils.ts";
1312
1413
const dashboardStore = dashboardStoreWithOut()

frontend/src/views/dashboard/preview/SQPreviewShow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import icon_add_outlined from '@/assets/svg/icon_add_outlined.svg'
33
import {reactive, ref, toRefs, onBeforeMount, computed} from 'vue'
4-
import {initCanvasData, load_resource_prepare} from '@/views/dashboard/utils/canvasUtils'
4+
import { load_resource_prepare} from '@/views/dashboard/utils/canvasUtils'
55
import {Icon} from '@/components/icon-custom'
66
import ResourceTree from "@/views/dashboard/common/ResourceTree.vue";
77
import SQPreview from "@/views/dashboard/preview/SQPreview.vue";

0 commit comments

Comments
 (0)