mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-27 02:52:48 +00:00
fix: Workspace shared knowledge button visibility
This commit is contained in:
parent
f627daf231
commit
b6cf80d6ef
|
|
@ -80,7 +80,7 @@ import type { FormInstance } from 'element-plus'
|
|||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
|
||||
const props = defineProps<{
|
||||
apiType: 'systemShare' | 'workspace' | 'systemManage'
|
||||
apiType: 'systemShare' | 'workspace' | 'systemManage' | 'workspaceShare'
|
||||
}>()
|
||||
|
||||
const route = useRoute()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import systemShare from './system-share'
|
||||
import workspace from './workspace'
|
||||
import systemManage from './system-manage'
|
||||
import workspaceShare from './workspace-share'
|
||||
const permission = {
|
||||
systemShare,
|
||||
workspace,
|
||||
systemManage,
|
||||
workspaceShare
|
||||
}
|
||||
export default permission
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
const workspace = {
|
||||
const systemManage = {
|
||||
is_share: () =>
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
|
|
@ -37,4 +37,4 @@ const workspace = {
|
|||
problem_delete: () => false,
|
||||
}
|
||||
|
||||
export default workspace
|
||||
export default systemManage
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
const workspaceShare = {
|
||||
is_share: () => true,
|
||||
create: () => false,
|
||||
sync: () => false,
|
||||
vector: () => false,
|
||||
generate: () => false,
|
||||
setting: () => false,
|
||||
export: () => false,
|
||||
delete: () => false,
|
||||
|
||||
doc_create: () => false,
|
||||
doc_vector: () => false,
|
||||
doc_generate: () => false,
|
||||
doc_migrate: () => false,
|
||||
doc_edit: () => false,
|
||||
doc_sync: () => false,
|
||||
doc_delete: () => false,
|
||||
doc_export: () => false,
|
||||
doc_download: () => false,
|
||||
|
||||
knowledge_chat_user_edit: () => false,
|
||||
|
||||
problem_create: () => false,
|
||||
problem_relate: () => false,
|
||||
problem_delete: () => false,
|
||||
}
|
||||
|
||||
export default workspaceShare
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
const workspace = {
|
||||
const systemManage = {
|
||||
is_share: () =>
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
|
|
@ -18,4 +18,4 @@ const workspace = {
|
|||
delete: () => false,
|
||||
}
|
||||
|
||||
export default workspace
|
||||
export default systemManage
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { hasPermission } from '@/utils/permission/index'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
const workspace = {
|
||||
const systemManage = {
|
||||
is_share: () =>
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
|
|
@ -22,4 +22,4 @@ const workspace = {
|
|||
|
||||
}
|
||||
|
||||
export default workspace
|
||||
export default systemManage
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import problemSystemShareApi from '@/api/system-shared/problem'
|
|||
import chatUserSystemShareApi from '@/api/system-shared/chat-user'
|
||||
import workspaceApi from '@/api/workspace/workspace'
|
||||
import systemUserApi from '@/api/user/user'
|
||||
import workspaceShare from '@/permission/knowledge/workspace-share'
|
||||
|
||||
// 普通 API
|
||||
const workspaceApiMap = {
|
||||
|
|
@ -51,6 +52,7 @@ const data = {
|
|||
systemShare: systemShareApiMap,
|
||||
workspace: workspaceApiMap,
|
||||
systemManage: systemManageApiMap,
|
||||
workspaceShare: workspaceApiMap
|
||||
}
|
||||
/** 动态导入 API 模块的函数
|
||||
* loadSharedApi('knowledge', true,'systemShare')
|
||||
|
|
@ -62,7 +64,7 @@ export function loadSharedApi({
|
|||
}: {
|
||||
type: string
|
||||
isShared?: boolean | undefined
|
||||
systemType?: 'systemShare' | 'workspace' | 'systemManage'
|
||||
systemType?: 'systemShare' | 'workspace' | 'systemManage' | 'workspaceShare'
|
||||
}) {
|
||||
if (isShared) {
|
||||
// 共享 API
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@
|
|||
:disabled="current?.is_auth"
|
||||
@click="handleSave"
|
||||
v-if="
|
||||
hasPermission(
|
||||
route.path.includes('share/') ? false
|
||||
: hasPermission(
|
||||
permissionObj[
|
||||
route.path.includes('shared')
|
||||
? 'SHAREDKNOWLEDGE'
|
||||
|
|
@ -87,7 +88,8 @@
|
|||
<div
|
||||
class="flex align-center"
|
||||
v-if="
|
||||
hasPermission(
|
||||
route.path.includes('share/') ? false
|
||||
: hasPermission(
|
||||
permissionObj[
|
||||
route.path.includes('shared')
|
||||
? 'SHAREDKNOWLEDGE'
|
||||
|
|
|
|||
|
|
@ -655,6 +655,8 @@ const apiType = computed(() => {
|
|||
return 'systemShare'
|
||||
} else if (route.path.includes('resource-management')) {
|
||||
return 'systemManage'
|
||||
} else if (route.path.includes('share/')) {
|
||||
return 'workspaceShare'
|
||||
} else {
|
||||
return 'workspace'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@
|
|||
/>
|
||||
<div class="operate">
|
||||
<el-button
|
||||
v-if="! route.path.includes('share/')"
|
||||
text
|
||||
class="sent-button"
|
||||
:disabled="isDisabledChart || loading"
|
||||
|
|
|
|||
|
|
@ -167,12 +167,7 @@
|
|||
<el-button
|
||||
@click="submit"
|
||||
type="primary"
|
||||
v-hasPermission="[
|
||||
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
||||
RoleConst.ADMIN,
|
||||
PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermissionWorkspaceManageRole,
|
||||
PermissionConst.KNOWLEDGE_EDIT.getKnowledgeWorkspaceResourcePermission(id),
|
||||
]"
|
||||
v-if=" !route.path.includes('share/') && permissionPrecise.setting(id)"
|
||||
>
|
||||
{{ $t('common.save') }}</el-button
|
||||
>
|
||||
|
|
@ -190,6 +185,8 @@ import BaseForm from '@/views/knowledge/component/BaseForm.vue'
|
|||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||
import { t } from '@/locales'
|
||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
import permissionMap from '@/permission'
|
||||
|
||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||
|
||||
const route = useRoute()
|
||||
|
|
@ -206,6 +203,11 @@ const apiType = computed(() => {
|
|||
return 'workspace'
|
||||
}
|
||||
})
|
||||
|
||||
const permissionPrecise = computed(() => {
|
||||
return permissionMap['knowledge'][apiType.value]
|
||||
})
|
||||
|
||||
const webFormRef = ref()
|
||||
const BaseFormRef = ref()
|
||||
const loading = ref(false)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
class="mt-16"
|
||||
:data="problemData"
|
||||
:pagination-config="paginationConfig"
|
||||
:quick-create="permissionPrecise.doc_create(id)"
|
||||
:quick-create="permissionPrecise.problem_create(id)"
|
||||
:quickCreateName="$t('views.problem.quickCreateName')"
|
||||
:quickCreatePlaceholder="$t('views.problem.quickCreateProblem')"
|
||||
:quickCreateMaxlength="256"
|
||||
|
|
@ -178,6 +178,8 @@ const apiType = computed(() => {
|
|||
return 'systemShare'
|
||||
} else if (route.path.includes('resource-management')) {
|
||||
return 'systemManage'
|
||||
} else if (route.path.includes('share/')) {
|
||||
return 'workspaceShare'
|
||||
} else {
|
||||
return 'workspace'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@
|
|||
<el-button :loading="loading" @click="openDebug" v-if="permissionPrecise.debug(form?.id||'or')">{{
|
||||
$t('common.debug')
|
||||
}}</el-button>
|
||||
<el-button type="primary" @click="submit(FormRef)" :loading="loading">
|
||||
<el-button type="primary" @click="submit(FormRef)" :loading="loading" v-if="permissionPrecise.edit(form?.id||'or') || permissionPrecise.create()" >
|
||||
{{ isEdit ? $t('common.save') : $t('common.create') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue