Browse Source

feat: 合并原有UpdateConfig分支

sunxiao 2 weeks ago
parent
commit
ebeb4b0641

+ 5 - 2
src/components/Layout/TheArchival.vue

@@ -18,13 +18,16 @@ import { NPopover } from 'naive-ui';
       <ul class="text-[#606266]">
         <li>
           <span class="inline-block w-[60px]">网信算备</span>
-          <span>110188164437号</span>
+          <span>申请中</span>
         </li>
         <li>
           <span class="inline-block w-[60px]">京ICP备</span>
           <span>2021020520号-1</span>
         </li>
-        <li>beijing-libraai-2024</li>
+        <li>
+          <span class="inline-block">大模型上线备案 申请中</span>
+          <!-- <span>申请中</span> -->
+        </li>
       </ul>
     </n-popover>
   </div>

+ 98 - 70
src/components/Layout/TheMenu.vue

@@ -3,9 +3,12 @@ import { h, watch, ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router';
 import { NMenu, NScrollbar } from 'naive-ui'
 import SvgIcon from '@/components/SvgIcon/index.vue'
+import { useUserStore } from '@/stores/modules/userStore';
 
+let menuOptions = []
 const route = useRoute();
 const router = useRouter();
+const userStore = useUserStore();
 
 const activeMenuKey = ref(route.path);
 
@@ -13,11 +16,11 @@ watch(() => route.path, currentPath => {
   activeMenuKey.value = currentPath;
 })
 
-function renderIcon (props) {
+function renderIcon(props) {
   return () => h(SvgIcon, { ...props })
 }
 
-function renderChildrenIcon ({ name, size = '20' }) {
+function renderChildrenIcon({ name, size = '20' }) {
   return () => (
     <div class="flex items-center justify-center">
       {renderIcon({ name, size, class: ['icon-default'] })()}
@@ -26,86 +29,112 @@ function renderChildrenIcon ({ name, size = '20' }) {
   )
 }
 
-function renderLabel (val, url) {
-  return url ? (<a href={ url } target="_blank" class="pl-1">{ val }</a>) : (<span class="">{ val }</span>) ;
+function renderLabel(val, url) {
+  return url ? (<a href={url} target="_blank" class="pl-1">{val}</a>) : (<span class="">{val}</span>);
 }
 
-const menuOptions = [
-  {
-    label: () => renderLabel('智慧总控'),
-    icon: renderIcon({ name: 'menu-control' }),
-    key: '/'
-  },
-  {
-    label: () => renderLabel('专家问答'),
-    icon: renderIcon({ name: 'menu-answers' }),
-    key: '/answer'
-  },
-  {
-    label: () => renderLabel('工艺管控'),
-    icon: renderIcon({ name: 'menu-analyse' }),
-    key: '/analyse',
-    children: [
-      {
-        label: '水质报警',
-        icon: renderChildrenIcon({ name: 'menu-analyse-water' }),
-        key: '/water-warn',
-      },
+
+
+const updateMenOptions = () => {
+  if (userStore.isCheckUser) {
+    menuOptions = [
       {
-        label: '生化报警',
-        icon: renderChildrenIcon({ name: 'menu-analyse-pymol' }),
-        key: '/pymol-warn',
+        label: () => renderLabel('专家问答'),
+        icon: renderIcon({ name: 'menu-answers' }),
+        key: '/answer'
       },
       {
-        label: '预测预警',
-        icon: renderChildrenIcon({ name: 'menu-analyse-notice' }),
-        key: '/forecast-warn',
+        label: () => renderLabel('智慧办公'),
+        icon: renderIcon({ name: 'menu-work' }),
+        key: '/work'
       },
       {
-        label: '智能工单',
-        icon: renderChildrenIcon({ name: 'menu-analyse-order' }),
-        key: '/work-order',
+        label: () => renderLabel('用户中心'),
+        icon: renderIcon({ name: 'menu-user' }),
+        key: '/user',
       }
     ]
-  },
-  {
-    label: () => renderLabel('成本管控'),
-    icon: renderIcon({ name: 'menu-cost-control' }),
-    key: '/control',
-    children: [
+  } else {
+    menuOptions = [
+      {
+        label: () => renderLabel('智慧总控'),
+        icon: renderIcon({ name: 'menu-control' }),
+        key: '/'
+      },
+      {
+        label: () => renderLabel('专家问答'),
+        icon: renderIcon({ name: 'menu-answers' }),
+        key: '/answer'
+      },
       {
-        label: '智适应碳源投加',
-        icon: renderChildrenIcon({ name: 'menu-cost-drug' }),
-        key: 'medicinal',
+        label: () => renderLabel('工艺管控'),
+        icon: renderIcon({ name: 'menu-analyse' }),
+        key: '/analyse',
+        children: [
+          {
+            label: '水质报警',
+            icon: renderChildrenIcon({ name: 'menu-analyse-water' }),
+            key: '/water-warn',
+          },
+          {
+            label: '生化报警',
+            icon: renderChildrenIcon({ name: 'menu-analyse-pymol' }),
+            key: '/pymol-warn',
+          },
+          {
+            label: '预测预警',
+            icon: renderChildrenIcon({ name: 'menu-analyse-notice' }),
+            key: '/forecast-warn',
+          },
+          {
+            label: '智能工单',
+            icon: renderChildrenIcon({ name: 'menu-analyse-order' }),
+            key: '/work-order',
+          }
+        ]
       },
-      // {
-      //   label: '精准曝气',
-      //   icon: renderChildrenIcon({ name: 'menu-cost-accurate' }),
-      //   key: 'normal-2',
-      // },
-      // {
-      //   label: '微生物镜检',
-      //   icon: renderChildrenIcon({ name: 'menu-cost-microorganism' }),
-      //   key: 'normal-3',
-      // },
       {
-        label: '碳排放管理',
-        icon: renderChildrenIcon({ name: 'menu-carbon-emission' }),
-        key: '/carbon',
+        label: () => renderLabel('成本管控'),
+        icon: renderIcon({ name: 'menu-cost-control' }),
+        key: '/control',
+        children: [
+          {
+            label: '智适应碳源投加',
+            icon: renderChildrenIcon({ name: 'menu-cost-drug' }),
+            key: 'medicinal',
+          },
+          // {
+          //   label: '精准曝气',
+          //   icon: renderChildrenIcon({ name: 'menu-cost-accurate' }),
+          //   key: 'normal-2',
+          // },
+          // {
+          //   label: '微生物镜检',
+          //   icon: renderChildrenIcon({ name: 'menu-cost-microorganism' }),
+          //   key: 'normal-3',
+          // },
+          {
+            label: '碳排放管理',
+            icon: renderChildrenIcon({ name: 'menu-carbon-emission' }),
+            key: '/carbon',
+          },
+        ]
       },
+      {
+        label: () => renderLabel('智慧办公'),
+        icon: renderIcon({ name: 'menu-work' }),
+        key: '/work'
+      },
+      {
+        label: () => renderLabel('用户中心'),
+        icon: renderIcon({ name: 'menu-user' }),
+        key: '/user',
+      }
     ]
-  },
-  {
-    label: () => renderLabel('智慧办公'),
-    icon: renderIcon({ name: 'menu-work' }),
-    key: '/work'
-  },
-  {
-    label: () => renderLabel('用户中心'),
-    icon: renderIcon({ name: 'menu-user' }),
-    key: '/user',
-  },
-]
+  }
+}
+
+updateMenOptions();
 
 const handleUpdateValue = (key, { url }) => {
   if (url) return window.open(url);
@@ -173,5 +202,4 @@ const handleUpdateValue = (key, { url }) => {
 //   svg {
 //     display: none;
 //   }
-// }
-</style>
+// }</style>

+ 3 - 1
src/components/Layout/ThePublicLayout.vue

@@ -3,9 +3,11 @@ import { ref, onMounted, onUnmounted } from 'vue';
 import { RouterView, useRouter } from 'vue-router';
 import { NScrollbar } from 'naive-ui';
 import { SvgIcon, TheLogo, TheMenu } from '@/components';
+import { useUserStore } from '@/stores/modules/userStore';
 import { waterApi } from '@/api/water';
 
 const router = useRouter();
+const userStore = useUserStore();
 
 const warningCountMseeage = ref([]);
 
@@ -41,7 +43,7 @@ onUnmounted(() => clearInterval(initWraingListData))
           </NScrollbar>
         </div>
       </div>
-      <div class="aside-main_bottom w-full px-[20px]" v-if="warningCountMseeage.length">
+      <div class="aside-main_bottom w-full px-[20px]" v-if="warningCountMseeage.length && !userStore.isCheckUser">
         <dl class="warn-content px-[12px] py-[12px]">
           <dt class="w-[64px] h-[20px] mb-[12px] text-[16px] flex items-center justify-center">
             <img src="@/assets/images/menu/bg-warn-text.png" alt="">

+ 4 - 1
src/components/Layout/userTop.vue

@@ -2,6 +2,7 @@
 import { ref, unref, computed } from 'vue';
 import { NSelect } from 'naive-ui';
 import { SvgIcon, BasePopover, editPassword } from '@/components';
+import { useUserStore } from '@/stores/modules/userStore';
 import TheUserAvatar from './TheUserAvatar.vue';
 
 defineProps({
@@ -11,6 +12,8 @@ defineProps({
   }
 })
 
+const userStore = useUserStore();
+
 const selectValue = ref('water');
 const voiceSwitchStatus = ref(false);
 
@@ -40,7 +43,7 @@ const changeVoiceStatus = () => {
    <!-- 分割线 -->
   <!-- <div class="h-[24px] border-r-[1px] border-color-[#D3D0E1]"></div> -->
   <NSelect v-model:value="selectValue" class="w-[114px]" size="medium" :options="options"
-    :consistent-menu-width="false" />
+    :consistent-menu-width="false" v-if="!userStore.isCheckUser"/>
   <TheUserAvatar></TheUserAvatar>
   <editPassword></editPassword>
 </template>

+ 5 - 1
src/permission.js

@@ -17,9 +17,13 @@ const { loadingBar } = createDiscreteApi(['loadingBar'], {
 router.beforeEach(async (to, from, next) => {
 
   loadingBar.start();
- 
 
   const isRouterAuth = whiteList.includes(to.path);
+  const userStore = useUserStore();
+
+  if ( to.path === '/' && userStore.isCheckUser) {
+    return next('/answer');
+  }
 
   if (isRouterAuth) {
 

+ 1 - 1
src/router/index.js

@@ -1,4 +1,4 @@
-import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
+import { createRouter, createWebHistory } from 'vue-router'
 
 const constantRouterMap = [
   {

+ 7 - 1
src/stores/modules/userStore.js

@@ -1,9 +1,14 @@
-import { ref, unref } from 'vue'
+import { ref, unref, computed } from 'vue'
 import { defineStore } from 'pinia'
 
 export const useUserStore = defineStore('user', () => {
   const userInfo = ref({});
   const dialogStatus = ref(false);
+  
+  const isCheckUser = computed(() => {
+    const whiteList = ['xinyi001', 'lixiaowei01', 'chenchao1985', 'lijie1981', 'zhujinlong1988'];
+    return whiteList.includes(userInfo.value.userName);
+  })
 
   const setUserInfo = params => {
     userInfo.value = { ...unref(userInfo), ...params };
@@ -22,6 +27,7 @@ export const useUserStore = defineStore('user', () => {
     clearUserInfo,
     dialogStatus,
     setDialogStatus,
+    isCheckUser
   }
 }, {
   persist: true,

+ 13 - 1
src/utils/request.ts

@@ -14,8 +14,20 @@ const useStore = useUserStore();
 
 export const url = import.meta.env.VITE_BASE_URL;
 export const prefix = import.meta.env.VITE_BASE_PREFIX;
-export const baseURL = url + prefix;
+export let baseURL = url + prefix;
+function isIPAddress(hostname:string) {
+  const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}$|^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
+  return ipRegex.test(hostname);
+}
+
 
+const hostname = window.location.hostname;
+
+if (isIPAddress(hostname)) {
+  baseURL= `http://${hostname}:8080/`
+} else {
+  baseURL= `/apiServe`
+}
 enum errorCode {
   '请求错误'          = 400,
   '未授权,请重新登录' = 401,

+ 1 - 1
src/views/login/LoginView.vue

@@ -35,7 +35,7 @@ const handleSubmit = async () => {
     const { user } = await userApi.getUserInfo();
     errorMsg.value = '';
     userStore.setUserInfo({ ...user });
-    router.push("/");
+    router.push(user.userName === 'xinyi001' ? "/answer" : "/");
   }
   catch (error) {
     errorMsg.value = error.msg;