perf: User ws change

This commit is contained in:
fit2cloud-chenyw
2025-07-24 10:25:29 +08:00
parent 65aaa66384
commit 4687a1e8cb
5 changed files with 17 additions and 47 deletions
@@ -6,13 +6,11 @@ import icon_done_outlined from '@/assets/svg/icon_done_outlined.svg'
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
import { userApi } from '@/api/auth'
import { ElMessage } from 'element-plus-secondary'
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
const { t } = useI18n()
const router = useRouter()
defineProps({
collapse: { type: [Boolean], required: true },
})
@@ -46,7 +44,6 @@ const handleDefaultWorkspaceChange = (item: any) => {
currentWorkspace.value = { id: item.id, name: item.name }
userApi.ws_change(item.id).then(() => {
ElMessage.success(t('common.switch_success'))
router.push('/chat/index')
setTimeout(() => {
location.reload()
}, 300)
-32
View File
@@ -114,38 +114,6 @@ const router = createRouter({
component: DashboardPreview,
meta: { title: 'DashboardPreview', icon: 'dashboard' },
},
/* {
path: "/setting",
component: Layout,
redirect: "/setting/index",
children: [
{
path: "index",
name: "setting",
component: setting,
meta: { title: "Settings", icon: "setting" },
},
],
}, */
// {
// path: '/system',
// component: Layout,
// redirect: '/system/model',
// children: [
// /* {
// path: "user",
// name: "user",
// component: User,
// meta: { title: "User Management", icon: "icon_user" },
// }, */
// {
// path: 'model',
// name: 'model',
// component: Model,
// meta: { title: 'AI Model Configuration', icon: 'icon_ai' },
// },
// ],
// },
{
path: '/system',
component: LayoutDsl,
+9 -4
View File
@@ -26,10 +26,7 @@ export const watchRouter = (router: any) => {
if (!userStore.getUid) {
await userStore.info()
}
/* if (!wsCache.get('user.uid')) {
await userStore.info()
} */
if (to.path === '/') {
if (to.path === '/' || accessCrossPermission(to)) {
next('/chat')
return
}
@@ -41,6 +38,14 @@ export const watchRouter = (router: any) => {
}
})
}
const accessCrossPermission = (to: any) => {
if (!to?.path) return false
return (
(to.path.startsWith('/system') && !userStore.isAdmin) ||
(to.path.startsWith('/set') && !userStore.isSpaceAdmin)
)
}
const loadXpackStatic = () => {
if (document.getElementById('sqlbot_xpack_static')) {
return Promise.resolve()