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
15 changes: 15 additions & 0 deletions ui/src/permission/modules/model/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,25 @@ const system = {
isShare: () => canSys(P.MODEL_READ),

// —— 模型资源 ——
/**
* 系统「模型资源管理」(系统 > 资源管理 > 模型)编辑权限
* */
modify: () => canSys(P.RESOURCE_MODEL_EDIT),
/**
* 系统「模型资源管理」(系统 > 资源管理 > 模型)模型参数设置权限
* */
paramSetting: () => canSys(P.RESOURCE_MODEL_EDIT),
/**
* 系统「模型资源管理」(系统 > 资源管理 > 模型)删除权限
* */
delete: () => canSys(P.RESOURCE_MODEL_DELETE),
/**
* 系统「模型资源管理」(系统 > 资源管理 > 模型)资源授权权限
* */
auth: () => canSys(P.RESOURCE_MODEL_AUTH),
/**
* 系统「模型资源管理」(系统 > 资源管理 > 模型)查看关联资源权限
* */
relateMap: () => canSys(P.RESOURCE_MODEL_RELATE_RESOURCE_VIEW),
}

Expand Down
18 changes: 18 additions & 0 deletions ui/src/permission/modules/model/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { PermissionConstants as P } from '../../core'
const workspace = {
// —— 工作空间级 ——
isShare: () => can(P.MODEL_READ),
/**
* 工作空间「模型」创建权限
*/
create: () => can(P.MODEL_CREATE),
debug: () => false,
authToWorkspace: () => false,
Expand All @@ -19,10 +22,25 @@ const workspace = {
folderDelete: () => can(P.MODEL_DELETE),

// —— 模型资源级 ——
/**
* 工作空间「模型」编辑权限
*/
modify: (id: string) => canRes(P.MODEL_EDIT, id),
/**
* 工作空间「模型」模型参数设置权限
*/
paramSetting: (id: string) => canRes(P.MODEL_EDIT, id),
/**
* 工作空间「模型」删除权限
*/
delete: (id: string) => canRes(P.MODEL_DELETE, id),
/**
* 工作空间「模型」资源授权权限
*/
auth: (id: string) => canRes(P.MODEL_RESOURCE_AUTHORIZATION, id),
/**
* 工作空间「模型」查看关联资源权限
*/
relateMap: (id: string) => canRes(P.MODEL_RELATE_RESOURCE_VIEW, id),
}

Expand Down
13 changes: 7 additions & 6 deletions ui/src/views/model/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ParamSettingAction,
RelatedResourcesModelAction,
} from './model-card/action-dropdown'
import perm from '@/permission/index.ts'

const DEFAULT_MODEL_PROVIDER: ModelProviderItem = { icon: '', name: '全部模型', provider: 'all' }

Expand Down Expand Up @@ -99,7 +100,7 @@ onMounted(() => {
<h4>{{ currentProvider.name }}</h4>
<div class="flex-align-center">
<MkComplexSearch :fields="searchFields" @change="handleSearchChange" />
<ButtonAddModel v-if="!isShared" :current-provider="currentProvider" :providers="modelProviders" @refresh="loadModels" :api="ModelApi" />
<ButtonAddModel v-if="!isShared && perm.model.workspace.create()" :current-provider="currentProvider" :providers="modelProviders" @refresh="loadModels" :api="ModelApi" />
</div>
</component>
<div v-loading="loading">
Expand All @@ -115,15 +116,15 @@ onMounted(() => {
>
<template #action-dropdown>
<!-- 编辑 -->
<EditModelAction label="编辑" :api="ModelApi" :model="model" :provider="getModelProvider(model)" @refresh="loadModels" />
<EditModelAction v-if="perm.model.workspace.modify(model.id)" label="编辑" :api="ModelApi" :model="model" :provider="getModelProvider(model)" @refresh="loadModels" />
<!-- 模型参数设置 -->
<ParamSettingAction v-if="model.model_type !== 'RERANKER'" label="模型参数设置" :api="ModelApi" :model="model" />
<ParamSettingAction v-if="model.model_type !== 'RERANKER' && perm.model.workspace.paramSetting(model.id)" label="模型参数设置" :api="ModelApi" :model="model" />
<!-- 资源授权 -->
<AuthorizeModelAction label="资源授权" :model="model" />
<AuthorizeModelAction v-if="perm.model.workspace.auth(model.id)" label="资源授权" :model="model" />
<!-- 查看关联资源 -->
<RelatedResourcesModelAction label="查看关联资源" :api="RelatedResourcesApi" :model="model" />
<RelatedResourcesModelAction v-if="perm.model.workspace.relateMap(model.id)" label="查看关联资源" :api="RelatedResourcesApi" :model="model" />
<!-- 删除 -->
<DeleteModelAction label="删除" :api="ModelApi" :model="model" @refresh="loadModels" />
<DeleteModelAction v-if="perm.model.workspace.delete(model.id)" label="删除" :api="ModelApi" :model="model" @refresh="loadModels" />
</template>
</ModelCard>
</template>
Expand Down
10 changes: 6 additions & 4 deletions ui/src/views/system/resource-management/model/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useStore } from '@/stores'
import { datetimeFormat } from '@/utils/time'
import { MsgConfirm, MsgSuccess } from '@/utils/message'
import { EditModelAction, AuthorizeModelAction, ParamSettingAction, RelatedResourcesModelAction } from '@/views/model/model-card/action-dropdown'
import perm from '@/permission'

const { auth } = useStore()

Expand Down Expand Up @@ -160,23 +161,24 @@ onMounted(() => {
:provider="getProvider(row)"
:disabled="loading"
@refresh="loadModels"
v-if="perm.model.system.modify()"
/>

<!-- 资源授权 -->
<AuthorizeModelAction display="button" label="资源授权" :model="row" />
<AuthorizeModelAction v-if="perm.model.system.auth()" display="button" label="资源授权" :model="row" />
<!-- 更多模型操作 -->
<MkTableMoreDropdown>
<!-- 模型参数设置 -->
<ParamSettingAction
v-if="['TTS', 'LLM', 'IMAGE', 'TTI', 'STT', 'EMBEDDING'].includes(row.model_type)"
v-if="['TTS', 'LLM', 'IMAGE', 'TTI', 'STT', 'EMBEDDING'].includes(row.model_type) && perm.model.system.paramSetting()"
label="模型参数设置"
:api="SystemModelApi"
:model="row"
/>
<!-- 查看关联资源 -->
<RelatedResourcesModelAction label="查看关联资源" :api="SystemRelatedResourcesApi" :model="row" />
<RelatedResourcesModelAction v-if="perm.model.system.relateMap()" label="查看关联资源" :api="SystemRelatedResourcesApi" :model="row" />
<!-- 删除模型 -->
<MkDropdownItem divided :disabled="loading" @click="handleDeleteModel(row)">
<MkDropdownItem v-if="perm.model.system.delete()" divided :disabled="loading" @click="handleDeleteModel(row)">
<template #icon><MkIcon name="icon_delete-trash_outlined" /></template>
删除
</MkDropdownItem>
Expand Down
Loading