From 6473f27cae95f56ba5d612c8e6166e911943a802 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Wed, 2 Jul 2025 16:01:22 +0800 Subject: [PATCH] fix: ui bugs (#3454) --- ui/admin.html | 12 +-- ui/chat.html | 12 +-- ui/src/components/markdown/MdRenderer.vue | 28 +++---- ui/src/layout/login-layout/LoginLayout.vue | 2 +- .../layout/login-layout/UserLoginLayout.vue | 2 +- ui/src/stores/modules/application.ts | 2 +- ui/src/utils/common.ts | 2 +- .../user-login/components/LoginLayout.vue | 2 +- .../system/resource-authorization/index.vue | 75 ++++++++++++++----- .../views/tool/component/EditAvatarDialog.vue | 2 +- 10 files changed, 90 insertions(+), 49 deletions(-) diff --git a/ui/admin.html b/ui/admin.html index 50f2a786e..52b43c40a 100644 --- a/ui/admin.html +++ b/ui/admin.html @@ -6,12 +6,14 @@ %VITE_APP_TITLE% + -
diff --git a/ui/chat.html b/ui/chat.html index ee16b632d..0ce6f40e8 100644 --- a/ui/chat.html +++ b/ui/chat.html @@ -6,12 +6,14 @@ %VITE_APP_TITLE% + -
diff --git a/ui/src/components/markdown/MdRenderer.vue b/ui/src/components/markdown/MdRenderer.vue index e2fc4ee90..d1014a33f 100644 --- a/ui/src/components/markdown/MdRenderer.vue +++ b/ui/src/components/markdown/MdRenderer.vue @@ -9,7 +9,7 @@ class="problem-button mt-4 mb-4 flex" :class="sendMessage ? 'cursor' : 'disabled'" > - + {{ item.content }} @@ -55,7 +55,7 @@ config({ } tokens[idx].attrSet( 'onerror', - 'this.src="/ui/assets/load_error.png";this.onerror=null;this.height="33px"' + 'this.src="/${window.MaxKB.prefix}/assets/load_error.png";this.onerror=null;this.height="33px"', ) return md.renderer.renderToken(tokens, idx, options) } @@ -64,7 +64,7 @@ config({ return md.renderer.renderToken(tokens, idx, options) } document.appendChild - } + }, }) const props = withDefaults( defineProps<{ @@ -79,14 +79,14 @@ const props = withDefaults( }>(), { source: '', - disabled: false - } + disabled: false, + }, ) const editorRef = ref() const md_view_list = computed(() => { const temp_source = props.source return split_form_rander( - split_echarts_rander(split_html_rander(split_quick_question([temp_source]))) + split_echarts_rander(split_html_rander(split_quick_question([temp_source]))), ) }) @@ -108,7 +108,7 @@ const split_quick_question_ = (source: string) => { .filter((item) => !md_quick_question_list?.includes(item)) const result = Array.from( { length: md_quick_question_list.length + split_quick_question_value.length }, - (v, i) => i + (v, i) => i, ).map((index) => { if (index % 2 == 0) { return { type: 'md', content: split_quick_question_value[Math.floor(index / 2)] } @@ -117,7 +117,7 @@ const split_quick_question_ = (source: string) => { type: 'question', content: md_quick_question_list[Math.floor(index / 2)] .replace('', '') - .replace('', '') + .replace('', ''), } } }) @@ -142,7 +142,7 @@ const split_html_rander_ = (source: string, type: string) => { .filter((item) => !md_quick_question_list?.includes(item)) const result = Array.from( { length: md_quick_question_list.length + split_quick_question_value.length }, - (v, i) => i + (v, i) => i, ).map((index) => { if (index % 2 == 0) { return { type: type, content: split_quick_question_value[Math.floor(index / 2)] } @@ -151,7 +151,7 @@ const split_html_rander_ = (source: string, type: string) => { type: 'html_rander', content: md_quick_question_list[Math.floor(index / 2)] .replace('', '') - .replace('', '') + .replace('', ''), } } }) @@ -177,7 +177,7 @@ const split_echarts_rander_ = (source: string, type: string) => { .filter((item) => !md_quick_question_list?.includes(item)) const result = Array.from( { length: md_quick_question_list.length + split_quick_question_value.length }, - (v, i) => i + (v, i) => i, ).map((index) => { if (index % 2 == 0) { return { type: type, content: split_quick_question_value[Math.floor(index / 2)] } @@ -186,7 +186,7 @@ const split_echarts_rander_ = (source: string, type: string) => { type: 'echarts_rander', content: md_quick_question_list[Math.floor(index / 2)] .replace('', '') - .replace('', '') + .replace('', ''), } } }) @@ -212,7 +212,7 @@ const split_form_rander_ = (source: string, type: string) => { .filter((item) => !md_quick_question_list?.includes(item)) const result = Array.from( { length: md_quick_question_list.length + split_quick_question_value.length }, - (v, i) => i + (v, i) => i, ).map((index) => { if (index % 2 == 0) { return { type: type, content: split_quick_question_value[Math.floor(index / 2)] } @@ -221,7 +221,7 @@ const split_form_rander_ = (source: string, type: string) => { type: 'form_rander', content: md_quick_question_list[Math.floor(index / 2)] .replace('', '') - .replace('', '') + .replace('', ''), } } }) diff --git a/ui/src/layout/login-layout/LoginLayout.vue b/ui/src/layout/login-layout/LoginLayout.vue index 4e58de891..2a8645c09 100644 --- a/ui/src/layout/login-layout/LoginLayout.vue +++ b/ui/src/layout/login-layout/LoginLayout.vue @@ -79,7 +79,7 @@ const loginImage = computed(() => { return `${fileURL.value}` } else { const imgName = getThemeImg(theme.themeInfo?.theme) - const imgPath = `/theme/${imgName}.jpg` + const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg` const imageUrl = new URL(imgPath, import.meta.url).href return imageUrl } diff --git a/ui/src/layout/login-layout/UserLoginLayout.vue b/ui/src/layout/login-layout/UserLoginLayout.vue index 1442e9bef..618390d92 100644 --- a/ui/src/layout/login-layout/UserLoginLayout.vue +++ b/ui/src/layout/login-layout/UserLoginLayout.vue @@ -47,7 +47,7 @@ const loginImage = computed(() => { return `${fileURL.value}` } else { const imgName = getThemeImg(theme.themeInfo?.theme) - const imgPath = `/theme/${imgName}.jpg` + const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg` const imageUrl = new URL(imgPath, import.meta.url).href return imageUrl } diff --git a/ui/src/stores/modules/application.ts b/ui/src/stores/modules/application.ts index 3ba9294cc..702161603 100644 --- a/ui/src/stores/modules/application.ts +++ b/ui/src/stores/modules/application.ts @@ -6,7 +6,7 @@ import { getBrowserLang } from '@/locales/index' import useUserStore from './user' const useApplicationStore = defineStore('application', { state: () => ({ - location: `${window.location.origin}/ui/chat/`, + location: `${window.location.origin}/${window.MaxKB.prefix}/chat/`, }), actions: { async asyncGetAllApplication() { diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts index 993e0cd2a..32e32f375 100644 --- a/ui/src/utils/common.ts +++ b/ui/src/utils/common.ts @@ -62,7 +62,7 @@ export function filesize(size: number) { } // 头像 -export const defaultIcon = '/ui/favicon.ico' +export const defaultIcon = '/${window.MaxKB.prefix}/favicon.ico' export function isAppIcon(url: string | undefined) { return url === defaultIcon ? '' : url } diff --git a/ui/src/views/chat/user-login/components/LoginLayout.vue b/ui/src/views/chat/user-login/components/LoginLayout.vue index 4e58de891..2a8645c09 100644 --- a/ui/src/views/chat/user-login/components/LoginLayout.vue +++ b/ui/src/views/chat/user-login/components/LoginLayout.vue @@ -79,7 +79,7 @@ const loginImage = computed(() => { return `${fileURL.value}` } else { const imgName = getThemeImg(theme.themeInfo?.theme) - const imgPath = `/theme/${imgName}.jpg` + const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg` const imageUrl = new URL(imgPath, import.meta.url).href return imageUrl } diff --git a/ui/src/views/system/resource-authorization/index.vue b/ui/src/views/system/resource-authorization/index.vue index 3500e4dda..892731078 100644 --- a/ui/src/views/system/resource-authorization/index.vue +++ b/ui/src/views/system/resource-authorization/index.vue @@ -81,9 +81,17 @@
- {{ $t('common.save') }} + {{ $t('common.save') }}
@@ -105,7 +113,7 @@ import { EditionConst, RoleConst, PermissionConst } from '@/utils/permission/dat import { hasPermission } from '@/utils/permission/index' import type { WorkspaceItem } from '@/api/type/workspace' import { ComplexPermission } from '@/utils/permission/type' -import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts"; +import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts' const route = useRoute() const { user } = useStore() @@ -118,21 +126,49 @@ const currentType = ref('') const filterText = ref('') const tableHeight = ref(0) -const permissionObj=ref({ - "APPLICATION":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], - [PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, - PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'), - "KNOWLEDGE":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], - [PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, - PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'), - "TOOL":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], - [PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, - PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'), - "MODEL":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], - [PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, - PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR') +const permissionObj = ref({ + APPLICATION: new ComplexPermission( + [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], + [ + PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, + PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT + .getWorkspacePermissionWorkspaceManageRole, + ], + [], + 'OR', + ), + KNOWLEDGE: new ComplexPermission( + [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], + [ + PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, + PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT + .getWorkspacePermissionWorkspaceManageRole, + ], + [], + 'OR', + ), + TOOL: new ComplexPermission( + [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], + [ + PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, + PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT + .getWorkspacePermissionWorkspaceManageRole, + ], + [], + 'OR', + ), + MODEL: new ComplexPermission( + [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE], + [ + PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT, + PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT + .getWorkspacePermissionWorkspaceManageRole, + ], + [], + 'OR', + ), }) -console.log(route.meta.resource||'APPLICATION') +console.log(route.meta.resource || 'APPLICATION') const settingTags = reactive([ { label: t('views.knowledge.title'), @@ -338,7 +374,8 @@ const getWholeTree = async (user_id: string) => { const folderTree = cloneDeep((parentRes as unknown as any).data) if (Object.keys(childrenRes.data).indexOf(item.type) !== -1) { item.isRole = - childrenRes.data[item.type].length > 0 && hasPermission([EditionConst.IS_EE], 'OR') + childrenRes.data[item.type].length > 0 && + hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR') ? childrenRes.data[item.type][0].auth_type == 'ROLE' : false folderIdMap = getFolderIdMap(childrenRes.data[item.type]) diff --git a/ui/src/views/tool/component/EditAvatarDialog.vue b/ui/src/views/tool/component/EditAvatarDialog.vue index c1864fccc..a6be04fcd 100644 --- a/ui/src/views/tool/component/EditAvatarDialog.vue +++ b/ui/src/views/tool/component/EditAvatarDialog.vue @@ -101,7 +101,7 @@ const onChange = (file: any) => { function submit() { if (radioType.value === 'default') { - emit('refresh', '/ui/favicon.ico') + emit('refresh', '/${window.MaxKB.prefix}/favicon.ico') dialogVisible.value = false } else if (radioType.value === 'custom' && iconFile.value) { const fd = new FormData()