Skip to content

Commit

Permalink
fix: fix multiple side menus
Browse files Browse the repository at this point in the history
  • Loading branch information
FU-design committed Nov 18, 2024
1 parent dbce690 commit 12b5f1d
Show file tree
Hide file tree
Showing 8 changed files with 4,091 additions and 3,318 deletions.
7,359 changes: 4,059 additions & 3,300 deletions bigtop-manager-ui/pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bigtop-manager-ui/src/components/user-avatar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@
import { storeToRefs } from 'pinia'
import router from '@/router'
import { useI18n } from 'vue-i18n'
import { useMenuStore } from '@/store/menu'

const i18n = useI18n()

const userStore = useUserStore()
const menuStore = useMenuStore()
const { userVO } = storeToRefs(userStore)

const logout = async () => {
const hide = message.loading(i18n.t('login.logging_out'), 0)
try {
await userStore.logout()
message.success(i18n.t('login.logout_success'))
menuStore.cleanUpMenu()
await router.push({ path: '/login' })
} catch (e) {
console.warn(e)
Expand Down
2 changes: 1 addition & 1 deletion bigtop-manager-ui/src/locales/en_US/llm-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
export default {
add_authorization: 'Add authorization',
edit_authorization: 'Edit authorization',
availability: 'Test availability',
test: 'Test',
unavailable: 'Unavailable',
active: 'Active',
available: 'Available',
Expand Down
2 changes: 1 addition & 1 deletion bigtop-manager-ui/src/locales/zh_CN/llm-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
export default {
add_authorization: '新增授权',
edit_authorization: '编辑授权',
availability: '测试可用性',
test: '测试',
unavailable: '不可用',
active: '使用中',
available: '可用',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@
const handleOk = async () => {
const validate = await autoFormRef.value?.getFormValidation()
if (!validate) return
const success = await llmConfigStore.addAuthorizedPlatform()
const api = isEdit.value
? llmConfigStore.updateAuthPlatform
: llmConfigStore.addAuthorizedPlatform
const success = await api()
if (success) {
const text = isEdit.value ? 'common.update_success' : 'common.created'
message.success(t(text))
Expand Down Expand Up @@ -158,7 +161,7 @@
type="primary"
@click="handleTest"
>
{{ $t('llmConfig.availability') }}
{{ $t('llmConfig.test') }}
</a-button>
</a-space>
<a-space size="middle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
<a-image
:width="24"
:height="24"
:preview="false"
:src="usePngImage(LlmLogo[llmConfig.platformId as LlmLogoFlag])"
/>
<a-typography-text
Expand Down
22 changes: 12 additions & 10 deletions bigtop-manager-ui/src/store/llm-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ export const useLlmConfigStore = defineStore(
value: currPlatform.value[`${v.name as currPlatformKeys}`] as string
}))
)
const authorizedPlatformConfig = computed(() => {

const getAuthorizedPlatformConfig = () => {
return {
...currPlatform.value,
testPassed: testPassed.value,
authCredentials: authCredentials.value
} as UpdateAuthorizedPlatformConfig
})
}

const getAuthorizedPlatforms = async () => {
loading.value = true
Expand Down Expand Up @@ -115,10 +116,9 @@ export const useLlmConfigStore = defineStore(

const addAuthorizedPlatform = async () => {
loading.value = true
const authorizedPlatformConfig = getAuthorizedPlatformConfig()
try {
return await llmServer.addAuthorizedPlatform(
authorizedPlatformConfig.value
)
return await llmServer.addAuthorizedPlatform(authorizedPlatformConfig)
} catch (error) {
console.log('error :>> ', error)
return false
Expand All @@ -129,10 +129,9 @@ export const useLlmConfigStore = defineStore(

const updateAuthPlatform = async () => {
loading.value = true
const authorizedPlatformConfig = getAuthorizedPlatformConfig()
try {
return await llmServer.updateAuthPlatform(
authorizedPlatformConfig.value
)
return await llmServer.updateAuthPlatform(authorizedPlatformConfig)
} catch (error) {
console.log('error :>> ', error)
return false
Expand All @@ -143,10 +142,13 @@ export const useLlmConfigStore = defineStore(

const testAuthorizedPlatform = async () => {
loadingTest.value = true
const authorizedPlatformConfig = getAuthorizedPlatformConfig()
try {
return await llmServer.testAuthorizedPlatform(
authorizedPlatformConfig.value
const data = await llmServer.testAuthorizedPlatform(
authorizedPlatformConfig
)
testPassed.value = data
return data
} catch (error) {
console.log('error :>> ', error)
return false
Expand Down
13 changes: 9 additions & 4 deletions bigtop-manager-ui/src/store/menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export const useMenuStore = defineStore(
const isClusterCreateVisible = computed(() =>
RouteExceptions.SPECIAL_ROUTE_PATH.includes(route.matched[0].path)
)
const isDynamicRouteMatched = computed(
() =>
route.matched.at(-1)?.path.includes(RouteExceptions.DYNAMIC_ROUTE_MATCH)
)
const isDynamicRouteMatched = computed(() => {
const path = route.matched.at(-1)?.path
return path?.includes(RouteExceptions.DYNAMIC_ROUTE_MATCH)
})
const siderMenus = computed((): MenuItem[] => {
const siderMenuTemplate =
baseRoutesMap.value.get(headerSelectedKey.value) || []
Expand Down Expand Up @@ -167,6 +167,10 @@ export const useMenuStore = defineStore(
setBaseRoutesMap()
}

const cleanUpMenu = () => {
baseRoutesMap.value.clear()
}

return {
headerMenus,
siderMenus,
Expand All @@ -175,6 +179,7 @@ export const useMenuStore = defineStore(
isClusterCreateVisible,
isDynamicRouteMatched,
setUpMenu,
cleanUpMenu,
setBaseRoutesMap,
onHeaderClick,
onSiderClick,
Expand Down

0 comments on commit 12b5f1d

Please sign in to comment.