Skip to content

Commit 6473f27

Browse files
authored
fix: ui bugs (#3454)
1 parent aff1ab7 commit 6473f27

File tree

10 files changed

+90
-49
lines changed

10 files changed

+90
-49
lines changed

ui/admin.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<base target="_blank" />
88
<title>%VITE_APP_TITLE%</title>
9+
<script>
10+
;((prefix) => {
11+
window.MaxKB = {
12+
prefix: '/admin',
13+
}
14+
})()
15+
</script>
916
</head>
10-
<script>
11-
window.MaxKB = {
12-
prefix: '/admin',
13-
}
14-
</script>
1517
<body>
1618
<div id="app"></div>
1719
<script type="module" src="/src/main.ts"></script>

ui/chat.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<base target="_blank" />
88
<title>%VITE_APP_TITLE%</title>
9+
<script>
10+
;((prefix) => {
11+
window.MaxKB = {
12+
prefix: '/chat',
13+
}
14+
})()
15+
</script>
916
</head>
10-
<script>
11-
window.MaxKB = {
12-
prefix: '/chat',
13-
}
14-
</script>
1517
<body>
1618
<div id="app"></div>
1719
<script type="module" src="/src/chat.ts"></script>

ui/src/components/markdown/MdRenderer.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class="problem-button mt-4 mb-4 flex"
1010
:class="sendMessage ? 'cursor' : 'disabled'"
1111
>
12-
<el-icon class="mr-8" style="margin-top: 2px;">
12+
<el-icon class="mr-8" style="margin-top: 2px">
1313
<EditPen />
1414
</el-icon>
1515
{{ item.content }}
@@ -55,7 +55,7 @@ config({
5555
}
5656
tokens[idx].attrSet(
5757
'onerror',
58-
'this.src="/ui/assets/load_error.png";this.onerror=null;this.height="33px"'
58+
'this.src="/${window.MaxKB.prefix}/assets/load_error.png";this.onerror=null;this.height="33px"',
5959
)
6060
return md.renderer.renderToken(tokens, idx, options)
6161
}
@@ -64,7 +64,7 @@ config({
6464
return md.renderer.renderToken(tokens, idx, options)
6565
}
6666
document.appendChild
67-
}
67+
},
6868
})
6969
const props = withDefaults(
7070
defineProps<{
@@ -79,14 +79,14 @@ const props = withDefaults(
7979
}>(),
8080
{
8181
source: '',
82-
disabled: false
83-
}
82+
disabled: false,
83+
},
8484
)
8585
const editorRef = ref()
8686
const md_view_list = computed(() => {
8787
const temp_source = props.source
8888
return split_form_rander(
89-
split_echarts_rander(split_html_rander(split_quick_question([temp_source])))
89+
split_echarts_rander(split_html_rander(split_quick_question([temp_source]))),
9090
)
9191
})
9292
@@ -108,7 +108,7 @@ const split_quick_question_ = (source: string) => {
108108
.filter((item) => !md_quick_question_list?.includes(item))
109109
const result = Array.from(
110110
{ length: md_quick_question_list.length + split_quick_question_value.length },
111-
(v, i) => i
111+
(v, i) => i,
112112
).map((index) => {
113113
if (index % 2 == 0) {
114114
return { type: 'md', content: split_quick_question_value[Math.floor(index / 2)] }
@@ -117,7 +117,7 @@ const split_quick_question_ = (source: string) => {
117117
type: 'question',
118118
content: md_quick_question_list[Math.floor(index / 2)]
119119
.replace('<quick_question>', '')
120-
.replace('</quick_question>', '')
120+
.replace('</quick_question>', ''),
121121
}
122122
}
123123
})
@@ -142,7 +142,7 @@ const split_html_rander_ = (source: string, type: string) => {
142142
.filter((item) => !md_quick_question_list?.includes(item))
143143
const result = Array.from(
144144
{ length: md_quick_question_list.length + split_quick_question_value.length },
145-
(v, i) => i
145+
(v, i) => i,
146146
).map((index) => {
147147
if (index % 2 == 0) {
148148
return { type: type, content: split_quick_question_value[Math.floor(index / 2)] }
@@ -151,7 +151,7 @@ const split_html_rander_ = (source: string, type: string) => {
151151
type: 'html_rander',
152152
content: md_quick_question_list[Math.floor(index / 2)]
153153
.replace('<html_rander>', '')
154-
.replace('</html_rander>', '')
154+
.replace('</html_rander>', ''),
155155
}
156156
}
157157
})
@@ -177,7 +177,7 @@ const split_echarts_rander_ = (source: string, type: string) => {
177177
.filter((item) => !md_quick_question_list?.includes(item))
178178
const result = Array.from(
179179
{ length: md_quick_question_list.length + split_quick_question_value.length },
180-
(v, i) => i
180+
(v, i) => i,
181181
).map((index) => {
182182
if (index % 2 == 0) {
183183
return { type: type, content: split_quick_question_value[Math.floor(index / 2)] }
@@ -186,7 +186,7 @@ const split_echarts_rander_ = (source: string, type: string) => {
186186
type: 'echarts_rander',
187187
content: md_quick_question_list[Math.floor(index / 2)]
188188
.replace('<echarts_rander>', '')
189-
.replace('</echarts_rander>', '')
189+
.replace('</echarts_rander>', ''),
190190
}
191191
}
192192
})
@@ -212,7 +212,7 @@ const split_form_rander_ = (source: string, type: string) => {
212212
.filter((item) => !md_quick_question_list?.includes(item))
213213
const result = Array.from(
214214
{ length: md_quick_question_list.length + split_quick_question_value.length },
215-
(v, i) => i
215+
(v, i) => i,
216216
).map((index) => {
217217
if (index % 2 == 0) {
218218
return { type: type, content: split_quick_question_value[Math.floor(index / 2)] }
@@ -221,7 +221,7 @@ const split_form_rander_ = (source: string, type: string) => {
221221
type: 'form_rander',
222222
content: md_quick_question_list[Math.floor(index / 2)]
223223
.replace('<form_rander>', '')
224-
.replace('</form_rander>', '')
224+
.replace('</form_rander>', ''),
225225
}
226226
}
227227
})

ui/src/layout/login-layout/LoginLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const loginImage = computed(() => {
7979
return `${fileURL.value}`
8080
} else {
8181
const imgName = getThemeImg(theme.themeInfo?.theme)
82-
const imgPath = `/theme/${imgName}.jpg`
82+
const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg`
8383
const imageUrl = new URL(imgPath, import.meta.url).href
8484
return imageUrl
8585
}

ui/src/layout/login-layout/UserLoginLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const loginImage = computed(() => {
4747
return `${fileURL.value}`
4848
} else {
4949
const imgName = getThemeImg(theme.themeInfo?.theme)
50-
const imgPath = `/theme/${imgName}.jpg`
50+
const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg`
5151
const imageUrl = new URL(imgPath, import.meta.url).href
5252
return imageUrl
5353
}

ui/src/stores/modules/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getBrowserLang } from '@/locales/index'
66
import useUserStore from './user'
77
const useApplicationStore = defineStore('application', {
88
state: () => ({
9-
location: `${window.location.origin}/ui/chat/`,
9+
location: `${window.location.origin}/${window.MaxKB.prefix}/chat/`,
1010
}),
1111
actions: {
1212
async asyncGetAllApplication() {

ui/src/utils/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function filesize(size: number) {
6262
}
6363

6464
// 头像
65-
export const defaultIcon = '/ui/favicon.ico'
65+
export const defaultIcon = '/${window.MaxKB.prefix}/favicon.ico'
6666
export function isAppIcon(url: string | undefined) {
6767
return url === defaultIcon ? '' : url
6868
}

ui/src/views/chat/user-login/components/LoginLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const loginImage = computed(() => {
7979
return `${fileURL.value}`
8080
} else {
8181
const imgName = getThemeImg(theme.themeInfo?.theme)
82-
const imgPath = `/theme/${imgName}.jpg`
82+
const imgPath = `${window.MaxKB.prefix}/theme/${imgName}.jpg`
8383
const imageUrl = new URL(imgPath, import.meta.url).href
8484
return imageUrl
8585
}

ui/src/views/system/resource-authorization/index.vue

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,17 @@
8181
</div>
8282

8383
<div class="submit-button">
84-
<el-button type="primary" @click="submitPermissions"
85-
v-if="hasPermission(permissionObj[(route.meta?.resource as string||'APPLICATION')],'OR')"
86-
>{{ $t('common.save') }}</el-button>
84+
<el-button
85+
type="primary"
86+
@click="submitPermissions"
87+
v-if="
88+
hasPermission(
89+
permissionObj[(route.meta?.resource as string) || 'APPLICATION'],
90+
'OR',
91+
)
92+
"
93+
>{{ $t('common.save') }}</el-button
94+
>
8795
</div>
8896
</div>
8997
</div>
@@ -105,7 +113,7 @@ import { EditionConst, RoleConst, PermissionConst } from '@/utils/permission/dat
105113
import { hasPermission } from '@/utils/permission/index'
106114
import type { WorkspaceItem } from '@/api/type/workspace'
107115
import { ComplexPermission } from '@/utils/permission/type'
108-
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
116+
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
109117
110118
const route = useRoute()
111119
const { user } = useStore()
@@ -118,21 +126,49 @@ const currentType = ref<string>('')
118126
const filterText = ref('')
119127
const tableHeight = ref(0)
120128
121-
const permissionObj=ref<any>({
122-
"APPLICATION":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
123-
[PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
124-
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
125-
"KNOWLEDGE":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
126-
[PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
127-
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
128-
"TOOL":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
129-
[PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
130-
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
131-
"MODEL":new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
132-
[PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
133-
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT.getWorkspacePermissionWorkspaceManageRole],[],'OR')
129+
const permissionObj = ref<any>({
130+
APPLICATION: new ComplexPermission(
131+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
132+
[
133+
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
134+
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT
135+
.getWorkspacePermissionWorkspaceManageRole,
136+
],
137+
[],
138+
'OR',
139+
),
140+
KNOWLEDGE: new ComplexPermission(
141+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
142+
[
143+
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
144+
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT
145+
.getWorkspacePermissionWorkspaceManageRole,
146+
],
147+
[],
148+
'OR',
149+
),
150+
TOOL: new ComplexPermission(
151+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
152+
[
153+
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
154+
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT
155+
.getWorkspacePermissionWorkspaceManageRole,
156+
],
157+
[],
158+
'OR',
159+
),
160+
MODEL: new ComplexPermission(
161+
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
162+
[
163+
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT,
164+
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_EDIT
165+
.getWorkspacePermissionWorkspaceManageRole,
166+
],
167+
[],
168+
'OR',
169+
),
134170
})
135-
console.log(route.meta.resource||'APPLICATION')
171+
console.log(route.meta.resource || 'APPLICATION')
136172
const settingTags = reactive([
137173
{
138174
label: t('views.knowledge.title'),
@@ -338,7 +374,8 @@ const getWholeTree = async (user_id: string) => {
338374
const folderTree = cloneDeep((parentRes as unknown as any).data)
339375
if (Object.keys(childrenRes.data).indexOf(item.type) !== -1) {
340376
item.isRole =
341-
childrenRes.data[item.type].length > 0 && hasPermission([EditionConst.IS_EE], 'OR')
377+
childrenRes.data[item.type].length > 0 &&
378+
hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')
342379
? childrenRes.data[item.type][0].auth_type == 'ROLE'
343380
: false
344381
folderIdMap = getFolderIdMap(childrenRes.data[item.type])

ui/src/views/tool/component/EditAvatarDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const onChange = (file: any) => {
101101
102102
function submit() {
103103
if (radioType.value === 'default') {
104-
emit('refresh', '/ui/favicon.ico')
104+
emit('refresh', '/${window.MaxKB.prefix}/favicon.ico')
105105
dialogVisible.value = false
106106
} else if (radioType.value === 'custom' && iconFile.value) {
107107
const fd = new FormData()

0 commit comments

Comments
 (0)