mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-10 18:26:55 +08:00
perf: User ws change
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user