Sfoglia il codice sorgente

feat(setting): 增加超级权限开关供售后调试

- 设置页连点标题后可开启/关闭超级权限,无需重启
- 开启后与惠利玛1300相同的高级设置、演示模式、开发工具
- 关闭立即恢复客户权限,惠利玛账号不受影响
panqiuyao 14 ore fa
parent
commit
7f03dd54b3

+ 32 - 2
frontend/src/stores/modules/user.ts

@@ -27,11 +27,38 @@ export const useUserInfo = defineStore('userInfo', () => {
     return supportCameraCounts.value > 1 ? 'multi' : 'single'
   })
 
-  // HLM用户判断
+  const SUPER_PERMISSION_KEY = 'STAFF_SUPER_PERMISSION'
+  const superPermission = ref(false)
+  try {
+    superPermission.value = localStorage.getItem(SUPER_PERMISSION_KEY) === '1'
+  } catch {
+    superPermission.value = false
+  }
+  if (typeof window !== 'undefined') {
+    window.addEventListener('storage', (event) => {
+      if (event.key === SUPER_PERMISSION_KEY) {
+        superPermission.value = event.newValue === '1'
+      }
+    })
+  }
+
+  const isHLMAccount = computed(() => {
+    return String(userInfo.value?.brand_company_code ?? '') === '1300'
+  })
+
+  // 惠利玛账号,或本机开启的超级权限(售后调试,无需重启)
   const isHLM = computed(() => {
-    return userInfo.value?.brand_company_code === '1300'
+    return isHLMAccount.value || superPermission.value
   })
 
+  const setSuperPermission = (on: boolean) => {
+    superPermission.value = !!on
+    try {
+      if (on) localStorage.setItem(SUPER_PERMISSION_KEY, '1')
+      else localStorage.removeItem(SUPER_PERMISSION_KEY)
+    } catch { /* ignore */ }
+  }
+
   // 定时检查相关
   let checkInterval: NodeJS.Timeout | null = null; // 定时器
   const CHECK_INTERVAL = 10 * 60 * 1000; // 10分钟检查一次
@@ -248,6 +275,9 @@ export const useUserInfo = defineStore('userInfo', () => {
     isMultiCameraMode,
     cameraMode,
     isHLM,
+    isHLMAccount,
+    superPermission,
+    setSuperPermission,
     updateUserInfo,
     updateLoginShow,
     loginAction,

+ 1 - 1
frontend/src/views/Photography/check.vue

@@ -201,7 +201,7 @@ const menu = computed(() => {
   }
 
   // 开发者模式:设置 + 快捷操作 + 开发工具 + 生成图目录
-  if (useUserInfoStore.userInfo.brand_company_code === '1300' || configInfoStore.appConfig.debug) {
+  if (useUserInfoStore.isHLM || configInfoStore.appConfig.debug) {
     return [
       {
         type: 'setting'

+ 2 - 4
frontend/src/views/Photography/detail.vue

@@ -140,7 +140,7 @@
           <div class="scard">
             <div class="stitle">工具</div>
             <div
-              v-if="useUserInfoStore.userInfo.brand_company_code == 1300"
+              v-if="useUserInfoStore.isHLM"
               class="trow"
               @click="addCustomTemplate"
               v-log="{ describe: { action: '点击新增自定义详情页模板', service: '新增自定义详情页模板' } }"
@@ -1056,9 +1056,7 @@ const loadTemplateFromCache = () => {
 
 
 // HLM用户判断
-const isHLM = computed(() => {
-  return userInfo.value?.brand_company_code === '1300'
-})
+const isHLM = computed(() => useUserInfoStore.isHLM)
 
 
 const openModelDialog = (eventOrDefaultTab?: MouseEvent | 'female' | 'male') => {

+ 1 - 1
frontend/src/views/Photography/mixin/usePhotography.ts

@@ -633,7 +633,7 @@ export default function usePhotography() {
           outputDirMenu
         ]
       }
-      if (useUserInfoStore.userInfo.brand_company_code === '1300' || configInfoStore.appConfig.debug) {
+      if (useUserInfoStore.isHLM || configInfoStore.appConfig.debug) {
         return [
           {
             type: 'setting'

+ 40 - 2
frontend/src/views/Setting/components/DebugPanel.vue

@@ -3,17 +3,29 @@
     <div class="form-item flex left">
         <el-button @click="openResourceDirectory" v-log="{ describe: { action: '打开资源目录' } }">打开资源目录</el-button>
     </div>
+    <div class="form-item flex left super-row">
+      <span class="super-label">超级权限</span>
+      <el-switch
+        :model-value="userInfoStore.isHLM"
+        :disabled="userInfoStore.isHLMAccount"
+        @change="onSuperChange"
+      />
+      <span class="super-hint">{{ superHint }}</span>
+    </div>
   </div>
 </template>
 
 <script setup>
-import { ref } from 'vue';
+import { ref, computed } from 'vue';
+import { ElMessage } from 'element-plus';
 import client from "@/stores/modules/client";
 import  configInfo  from '@/stores/modules/config';
+import useUserInfo from '@/stores/modules/user';
 import icpList from '@/utils/ipc';
 
 const clientStore = client();
 const configInfoStore = configInfo();
+const userInfoStore = useUserInfo();
 
 const isVisible = ref(false);
 
@@ -38,7 +50,17 @@ function openResourceDirectory() {
   clientStore.ipc.send(icpList.utils.shellFun, params);
 }
 
-// 挂载时注册事件监听器
+const superHint = computed(() => {
+  if (userInfoStore.isHLMAccount) return '当前已是惠利玛账号'
+  if (userInfoStore.superPermission) return '已开启,高级设置/演示模式/开发工具立即生效,关闭后立刻恢复'
+  return '开启后与惠利玛员工相同的配置,无需重启'
+})
+
+function onSuperChange(val) {
+  userInfoStore.setSuperPermission(!!val)
+  ElMessage.success(val ? '超级权限已开启' : '超级权限已关闭')
+}
+
 defineExpose({
   showDebugPanel,
   hideDebugPanel,
@@ -50,4 +72,20 @@ defineExpose({
 .debug-panel {
   padding-bottom: 10px;
 }
+.super-row {
+  align-items: center;
+  gap: 12px;
+  margin-top: 8px;
+}
+.super-label {
+  font-size: 14px;
+  font-weight: 600;
+  color: #1a2233;
+  white-space: nowrap;
+}
+.super-hint {
+  font-size: 12px;
+  color: #8b95ab;
+  line-height: 1.4;
+}
 </style>

+ 6 - 0
frontend/src/views/Setting/index.vue

@@ -545,6 +545,12 @@ const getConfig =  async (typeValue)=>{
 /**
  * 组件挂载时初始化activeIndex。
  */
+watch(() => userInfoStore.isHLM, (on) => {
+  if (!on && activeIndex.value === 5) {
+    activeIndex.value = 0
+  }
+})
+
 onMounted(async () => {
   // 确保用户信息已加载,特别是 brand_company_code 字段
   if (!userInfoStore.userInfo?.brand_company_code) {