@@ -6,6 +6,7 @@ import LogoIcon from '@/components/mk-logo/LogoIcon.vue'
66import { copyText } from ' @/utils/clipboard'
77import { resetUrl } from ' @/utils/icon'
88import { MsgSuccess } from ' @/utils/message'
9+ import { perm } from ' @/permission'
910import PortalPreview from ' ./components/PortalPreview.vue'
1011import ButtonEditPortal from ' ./components/ButtonEditPortal.vue'
1112import ButtonPortalAuthSetting from ' ./components/ButtonPortalAuthSetting.vue'
@@ -49,6 +50,8 @@ function loadPortalSetting() {
4950
5051/* 保存门户配置:接口返回完整配置,成功后整体回填作为页面唯一数据来源 */
5152function savePortalSetting(payload : PortalSettingPayload | FormData ): Promise <void > {
53+ if (! canEditPortal .value || saving .value ) return Promise .resolve ()
54+
5255 saving .value = true
5356 return PortalApi .putPortalSetting (payload )
5457 .then ((setting ) => {
@@ -61,7 +64,7 @@ function savePortalSetting(payload: PortalSettingPayload | FormData): Promise<vo
6164}
6265
6366function handleAccessChange(field : AccessField , value : string | number | boolean ) {
64- if (saving .value ) return
67+ if (! canEditPortal . value || saving .value ) return
6568 if (field === ' enable_auth' && value && ! portalSetting .auth_config .login_value ?.length ) {
6669 handleOpenAuthSetting (true )
6770 return
@@ -81,6 +84,8 @@ function savePortalCorsSetting(origins: string[]) {
8184}
8285
8386function handleOpenAuthSetting(enableAfterSave = false ) {
87+ if (! canEditPortal .value || saving .value ) return
88+
8489 authSettingButtonRef .value ?.open (enableAfterSave )
8590}
8691
@@ -97,6 +102,9 @@ const previewName = computed(() => portalSetting.name)
97102const previewLogo = computed (() => resetUrl (portalSetting .logo ))
98103
99104onMounted (() => loadPortalSetting ())
105+
106+ // 权限 控制
107+ const canEditPortal = computed (() => perm .system .portal .edit ())
100108 </script >
101109
102110<template >
@@ -111,7 +119,7 @@ onMounted(() => loadPortalSetting())
111119 <h4 class =" truncate" :title =" previewName" >{{ previewName }}</h4 >
112120 </div >
113121 <!-- 编辑门户名称与 Logo -->
114- <ButtonEditPortal :setting =" portalSetting " :saving =" saving " :save =" savePortalSetting " />
122+ <ButtonEditPortal :setting =" portalSetting " :saving =" saving " :disabled = " ! canEditPortal " : save =" savePortalSetting " />
115123 </div >
116124 </el-card >
117125 <el-card shadow =" never" >
@@ -122,6 +130,7 @@ onMounted(() => loadPortalSetting())
122130 <div class =" flex-between mb-2 gap-2" >
123131 <span >门户公开访问链接</span >
124132 <el-switch
133+ :disabled =" !canEditPortal || saving"
125134 :model-value =" portalSetting.enable_public_access"
126135 size =" small"
127136 @change =" handleAccessChange('enable_public_access', $event)"
@@ -130,7 +139,7 @@ onMounted(() => loadPortalSetting())
130139 <el-input :model-value =" portalAccessUrl" readonly >
131140 <template #suffix >
132141 <!-- 复制门户公开访问链接 -->
133- <el-button text @click =" copyText(portalAccessUrl)" class =" -mr-1" >
142+ <el-button text :disabled = " !canEditPortal " @click =" copyText(portalAccessUrl)" class =" -mr-1" >
134143 <MkIcon name="icon_copy_outlined" class="text-N600" />
135144 </el-button >
136145 </template >
@@ -140,12 +149,17 @@ onMounted(() => loadPortalSetting())
140149 <div >
141150 <div class =" flex-between mb-2 gap-2" >
142151 <span >智能体后端 API 访问</span >
143- <el-switch :model-value =" portalSetting.enable_api" size =" small" @change =" handleAccessChange('enable_api', $event)" />
152+ <el-switch
153+ :disabled =" !canEditPortal || saving"
154+ :model-value =" portalSetting.enable_api"
155+ size =" small"
156+ @change =" handleAccessChange('enable_api', $event)"
157+ />
144158 </div >
145159 <el-input :model-value =" portalApiUrl" readonly >
146160 <template #suffix >
147161 <!-- 复制智能体后端 API 访问 -->
148- <el-button text @click =" copyText(portalApiUrl)" class =" -mr-1" >
162+ <el-button text :disabled = " !canEditPortal " @click =" copyText(portalApiUrl)" class =" -mr-1" >
149163 <MkIcon name="icon_copy_outlined" class="text-N600" />
150164 </el-button >
151165 </template >
@@ -156,6 +170,7 @@ onMounted(() => loadPortalSetting())
156170 <div class =" flex-between mb-2 gap-2" >
157171 <span >知识库后端 API 检索</span >
158172 <el-switch
173+ :disabled =" !canEditPortal || saving"
159174 :model-value =" portalSetting.enable_knowledge_base_api"
160175 size =" small"
161176 @change =" handleAccessChange('enable_knowledge_base_api', $event)"
@@ -164,7 +179,7 @@ onMounted(() => loadPortalSetting())
164179 <el-input :model-value =" portalApiUrl" readonly >
165180 <template #suffix >
166181 <!-- 复制知识库后端 API 检索 -->
167- <el-button text @click =" copyText(portalApiUrl)" class =" -mr-1" >
182+ <el-button text :disabled = " !canEditPortal " @click =" copyText(portalApiUrl)" class =" -mr-1" >
168183 <MkIcon name="icon_copy_outlined" class="text-N600" />
169184 </el-button >
170185 </template >
@@ -174,16 +189,32 @@ onMounted(() => loadPortalSetting())
174189 <span >身份认证</span >
175190 <div class =" flex-align-center gap-2" >
176191 <!-- 配置身份认证 -->
177- <ButtonPortalAuthSetting ref="authSettingButtonRef" :setting =" portalSetting " :saving =" saving " :save =" savePortalAuthSetting " />
178- <el-switch :model-value =" portalSetting.enable_auth" size =" small" @change =" handleAccessChange('enable_auth', $event)" />
192+ <ButtonPortalAuthSetting
193+ ref="authSettingButtonRef"
194+ :setting =" portalSetting "
195+ :saving =" saving "
196+ :disabled =" ! canEditPortal "
197+ :save =" savePortalAuthSetting "
198+ />
199+ <el-switch
200+ :disabled =" !canEditPortal || saving"
201+ :model-value =" portalSetting.enable_auth"
202+ size =" small"
203+ @change =" handleAccessChange('enable_auth', $event)"
204+ />
179205 </div >
180206 </div >
181207 <div class =" flex-between gap-2" >
182208 <span >跨域设置</span >
183209 <div class =" flex-align-center gap-2" >
184210 <!-- 配置跨域地址 -->
185- <ButtonPortalCorsSetting v-model =" portalCorsOrigins " :saving =" saving " :save =" savePortalCorsSetting " />
186- <el-switch :model-value =" portalSetting.enable_cors" size =" small" @change =" handleAccessChange('enable_cors', $event)" />
211+ <ButtonPortalCorsSetting v-model =" portalCorsOrigins " :saving =" saving " :disabled =" ! canEditPortal " :save =" savePortalCorsSetting " />
212+ <el-switch
213+ :disabled =" !canEditPortal || saving"
214+ :model-value =" portalSetting.enable_cors"
215+ size =" small"
216+ @change =" handleAccessChange('enable_cors', $event)"
217+ />
187218 </div >
188219 </div >
189220 </div >
0 commit comments