mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 09:43:10 +00:00
fix: ui bugs (#3454)
This commit is contained in:
parent
aff1ab7d1b
commit
6473f27cae
|
|
@ -6,12 +6,14 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base target="_blank" />
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<script>
|
||||
;((prefix) => {
|
||||
window.MaxKB = {
|
||||
prefix: '/admin',
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
</head>
|
||||
<script>
|
||||
window.MaxKB = {
|
||||
prefix: '/admin',
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
|
|
|
|||
12
ui/chat.html
12
ui/chat.html
|
|
@ -6,12 +6,14 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<base target="_blank" />
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<script>
|
||||
;((prefix) => {
|
||||
window.MaxKB = {
|
||||
prefix: '/chat',
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
</head>
|
||||
<script>
|
||||
window.MaxKB = {
|
||||
prefix: '/chat',
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/chat.ts"></script>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
class="problem-button mt-4 mb-4 flex"
|
||||
:class="sendMessage ? 'cursor' : 'disabled'"
|
||||
>
|
||||
<el-icon class="mr-8" style="margin-top: 2px;">
|
||||
<el-icon class="mr-8" style="margin-top: 2px">
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
{{ 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('<quick_question>', '')
|
||||
.replace('</quick_question>', '')
|
||||
.replace('</quick_question>', ''),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -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('<html_rander>', '')
|
||||
.replace('</html_rander>', '')
|
||||
.replace('</html_rander>', ''),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -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('<echarts_rander>', '')
|
||||
.replace('</echarts_rander>', '')
|
||||
.replace('</echarts_rander>', ''),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -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('<form_rander>', '')
|
||||
.replace('</form_rander>', '')
|
||||
.replace('</form_rander>', ''),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,9 +81,17 @@
|
|||
</div>
|
||||
|
||||
<div class="submit-button">
|
||||
<el-button type="primary" @click="submitPermissions"
|
||||
v-if="hasPermission(permissionObj[(route.meta?.resource as string||'APPLICATION')],'OR')"
|
||||
>{{ $t('common.save') }}</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitPermissions"
|
||||
v-if="
|
||||
hasPermission(
|
||||
permissionObj[(route.meta?.resource as string) || 'APPLICATION'],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>{{ $t('common.save') }}</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -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<string>('')
|
|||
const filterText = ref('')
|
||||
const tableHeight = ref(0)
|
||||
|
||||
const permissionObj=ref<any>({
|
||||
"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<any>({
|
||||
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])
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue