perf: TS Error

This commit is contained in:
fit2cloud-chenyw
2025-06-11 14:43:38 +08:00
parent 2a74b4d69e
commit 80943796ad
5 changed files with 27 additions and 18 deletions
+3 -4
View File
@@ -149,7 +149,6 @@
import {ref, computed, onMounted} from 'vue'
import {useRouter, useRoute} from 'vue-router'
import {useUserStore} from '@/stores/user'
import folder from '@/assets/svg/folder.svg'
import ds from '@/assets/svg/ds.svg'
import dashboard from '@/assets/svg/dashboard.svg'
import chat from '@/assets/svg/chat.svg'
@@ -184,12 +183,12 @@ const sysRouterList = computed(() => {
const showSubmenu = computed(() => {
return route.path.includes('/system')
})
const workspace = ref('1')
const options = [
// const workspace = ref('1')
/* const options = [
{value: '1', label: 'Default workspace'},
{value: '2', label: 'Workspace 2'},
{value: '3', label: 'Workspace 3'}
]
] */
const currentPageTitle = computed(() => {
if (route.path.includes('/system')) {
return 'System Settings'
+1 -1
View File
@@ -8,7 +8,7 @@ import ds from "@/views/ds/index.vue";
import DashboardEditor from "@/views/dashboard/editor/index.vue";
import Dashboard from "@/views/dashboard/index.vue";
import Model from "@/views/system/model/index.vue";
import User from "@/views/system/user/index.vue";
// import User from "@/views/system/user/index.vue";
import { watchRouter } from "./watch";
const router = createRouter({
history: createWebHashHistory(),
+22 -11
View File
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
// import { ref } from 'vue'
import { AuthApi } from '@/api/login'
import { useCache } from '@/utils/useCache'
import { i18n } from '@/i18n'
@@ -17,18 +17,19 @@ interface UserState {
language: string
exp: number
time: number
[key: string]: string | number
}
export const UserStore = defineStore('user', {
state: (): UserState => {
return {
token: null,
uid: null,
name: null,
oid: null,
token: '',
uid: '',
name: '',
oid: '',
language: 'zh-CN',
exp: null,
time: null
exp: 0,
time: 0
}
},
getters: {
@@ -69,13 +70,23 @@ export const UserStore = defineStore('user', {
const res: any = await AuthApi.info()
const res_data = res || {}
const keys: string[] = ['uid', 'name', 'oid', 'language', 'exp', 'time']
// 指定 keys 类型为 UserState 的键
const keys = ['uid', 'name', 'oid', 'language', 'exp', 'time'] as const
keys.forEach(key => {
const dkey = key === 'uid' ? 'id' : key
this[key] = res_data[dkey]
wsCache.set('user.' + key, this[key])
const value = res_data[dkey]
// 使用类型守卫区分数字和字符串类型
if (key === 'exp' || key === 'time') {
this[key] = Number(value)
wsCache.set('user.' + key, value.toString())
} else {
this[key] = String(value)
wsCache.set('user.' + key, value)
}
})
this.setLanguage(this.language)
},
setToken(token: string) {
@@ -8,7 +8,6 @@ import cloneDeep from 'lodash/cloneDeep';
import {storeToRefs} from "pinia";
import {dashboardStoreWithOut} from "@/stores/dashboard/dashboard.ts";
import router from '@/router'
import {dashboardApi} from "@/api/dashboard.ts";
import {initCanvasData} from "@/views/dashboard/utils/canvasUtils.ts";
const dashboardStore = dashboardStoreWithOut()
@@ -1,7 +1,7 @@
<script setup lang="ts">
import icon_add_outlined from '@/assets/svg/icon_add_outlined.svg'
import {reactive, ref, toRefs, onBeforeMount, computed} from 'vue'
import {initCanvasData, load_resource_prepare} from '@/views/dashboard/utils/canvasUtils'
import { load_resource_prepare} from '@/views/dashboard/utils/canvasUtils'
import {Icon} from '@/components/icon-custom'
import ResourceTree from "@/views/dashboard/common/ResourceTree.vue";
import SQPreview from "@/views/dashboard/preview/SQPreview.vue";