Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ui/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 7 additions & 5 deletions ui/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
28 changes: 14 additions & 14 deletions ui/src/components/markdown/MdRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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)
}
Expand All @@ -64,7 +64,7 @@ config({
return md.renderer.renderToken(tokens, idx, options)
}
document.appendChild
}
},
})
const props = withDefaults(
defineProps<{
Expand All @@ -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]))),
)
})

Expand All @@ -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)] }
Expand All @@ -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>', ''),
}
}
})
Expand All @@ -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)] }
Expand All @@ -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>', ''),
}
}
})
Expand All @@ -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)] }
Expand All @@ -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>', ''),
}
}
})
Expand All @@ -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)] }
Expand All @@ -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>', ''),
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layout/login-layout/LoginLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layout/login-layout/UserLoginLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/stores/modules/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/chat/user-login/components/LoginLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
75 changes: 56 additions & 19 deletions ui/src/views/system/resource-authorization/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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()
Expand All @@ -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'),
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/tool/component/EditAvatarDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading