Explorar o código

Merge branch 'dev-wyf' into 'dev'

feat:添加首次登录修改密码 & 调整导航的数据结构

See merge request product-group-fe/sfy-safety-group/sfy-safety!298
ai0197(吴云丰) hai 3 meses
pai
achega
81bf512cb7

+ 1 - 1
src/api/system/user.ts

@@ -16,7 +16,7 @@ export interface BasicPageParams {
 /**
 /**
  * @description: 获取用户信息
  * @description: 获取用户信息
  */
  */
-export function getUserInfo(params: { tenantCode?: string }) {
+export function getUserInfoApi(params: { tenantCode?: string }) {
   return http.request(
   return http.request(
     {
     {
       url: '/login/info',
       url: '/login/info',

+ 28 - 15
src/components/Nav.vue

@@ -24,11 +24,11 @@
   </header>
   </header>
   <Login v-if="userStore.showLogin" @close="userStore.showLogin = false" class="fadeIn" />
   <Login v-if="userStore.showLogin" @close="userStore.showLogin = false" class="fadeIn" />
   <SwitchAccount v-if="userStore.showSwitchAccount" @close="userStore.showSwitchAccount = false" class="fadeIn" />
   <SwitchAccount v-if="userStore.showSwitchAccount" @close="userStore.showSwitchAccount = false" class="fadeIn" />
-  <UpdatePwd v-if="userStore.showUpdatePwd" @close="userStore.showUpdatePwd = false" class="fadeIn" />
+  <UpdatePwd v-if="userStore.showUpdatePwd || firstLogin" @close="handleUpdatePwdClose" class="fadeIn" />
 </template>
 </template>
 
 
 <script lang="ts" setup>
 <script lang="ts" setup>
-  import { ref, computed } from 'vue';
+  import { computed } from 'vue';
   import { useRouter, useRoute } from 'vue-router';
   import { useRouter, useRoute } from 'vue-router';
   import UpdatePwd from '@/components/UpdatePwd.vue';
   import UpdatePwd from '@/components/UpdatePwd.vue';
   import UserInfo from '@/components/UserInfo.vue';
   import UserInfo from '@/components/UserInfo.vue';
@@ -40,36 +40,49 @@
   import { SYS_TENANT_ID } from '@/utils/useTargetTenantIdSetting';
   import { SYS_TENANT_ID } from '@/utils/useTargetTenantIdSetting';
   import { NAV_LIST } from '@/constant/nav';
   import { NAV_LIST } from '@/constant/nav';
   import logo from 'assets/images/home/comac-logo@1X.png';
   import logo from 'assets/images/home/comac-logo@1X.png';
-  import searchIcon from 'assets/svg/search.svg';
+  import { ElMessage } from 'element-plus';
+  // import searchIcon from 'assets/svg/search.svg';
 
 
   const userStore = useUserStore();
   const userStore = useUserStore();
-  const activeNav = ref(NAV_LIST[0].name);
+  const firstLogin = userStore.getUserInfo.isFirstLogin;
+  // const activeNav = ref(NAV_LIST[0].name);
   const router = useRouter();
   const router = useRouter();
-  const searchValue = ref('');
+  // const searchValue = ref('');
 
 
   const props = withDefaults(defineProps<{ usePx?: boolean }>(), { usePx: false });
   const props = withDefaults(defineProps<{ usePx?: boolean }>(), { usePx: false });
   const usePx = computed(() => props.usePx === true);
   const usePx = computed(() => props.usePx === true);
 
 
-  const handleSearch = () => {
-    console.log('searchValue', searchValue.value);
-  };
+  // const handleSearch = () => {
+  //   console.log('searchValue', searchValue.value);
+  // };
 
 
   const currentRoute = useRoute();
   const currentRoute = useRoute();
   const { title } = useGlobSetting();
   const { title } = useGlobSetting();
 
 
-  const handleNavClick = (item: { name: string; path: string; isRedrect?: boolean }) => {
-    if (item.isRedrect) {
+  const handleNavClick = (item: { name: string; path: string; meta?: any }) => {
+    if (item.meta?.isExternalLink) {
+      if (item.path === '403') {
+        router.replace(item.path);
+        return;
+      }
       window.open(item.path, '_blank');
       window.open(item.path, '_blank');
       return;
       return;
     }
     }
-    if (!item.path) {
-      router.replace({ name: 'StayTune' });
-      // ElMessage.warning({ message: `${item.name}功能建设中,暂无法访问`, offset: 100, grouping: true });
-      return;
-    }
     router.push(item.path);
     router.push(item.path);
   };
   };
 
 
+  const handleUpdatePwdClose = () => {
+    if (firstLogin) {
+      ElMessage({
+        message: '首次登录请修改密码',
+        type: 'warning',
+        duration: 3000,
+      });
+    } else {
+      userStore.showUpdatePwd = false;
+    }
+  };
+
   const selectedKey = computed(() => {
   const selectedKey = computed(() => {
     return currentRoute.matched[0]?.name;
     return currentRoute.matched[0]?.name;
   });
   });

+ 7 - 6
src/constant/nav.ts

@@ -2,11 +2,12 @@
  * @description 导航常量
  * @description 导航常量
  */
  */
 
 
-import { HOME_PAGE } from '@/router/full-routes';
+import { RouteRecordString, HOME_PAGE } from '@/router/full-routes';
 import { useGlobSetting } from '@/hooks/setting';
 import { useGlobSetting } from '@/hooks/setting';
 const { skyeyePlatformHost, tiansuoHost } = useGlobSetting();
 const { skyeyePlatformHost, tiansuoHost } = useGlobSetting();
+
 // 首页导航列表 根据后端返回权限控制(首页永远存在)
 // 首页导航列表 根据后端返回权限控制(首页永远存在)
-export const NAV_LIST = [
+export const NAV_LIST: Array<RouteRecordString> = [
   {
   {
     ...HOME_PAGE,
     ...HOME_PAGE,
   },
   },
@@ -61,17 +62,17 @@ export const NAV_LIST = [
   },
   },
   {
   {
     name: 'Skyeye',
     name: 'Skyeye',
-    path: skyeyePlatformHost,
-    isRedrect: true,
+    path: skyeyePlatformHost || '403',
     meta: {
     meta: {
+      isExternalLink: true,
       title: '实时监控',
       title: '实时监控',
     },
     },
   },
   },
   {
   {
     name: 'Tiansuo',
     name: 'Tiansuo',
-    path: tiansuoHost,
-    isRedrect: true,
+    path: tiansuoHost || '403',
     meta: {
     meta: {
+      isExternalLink: true,
       title: '物联集成',
       title: '物联集成',
     },
     },
   },
   },

+ 2 - 2
src/hooks/setting/index.ts

@@ -8,7 +8,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
     VITE_GLOB_APP_TITLE,
     VITE_GLOB_APP_TITLE,
     VITE_GLOB_API_URL_PREFIX,
     VITE_GLOB_API_URL_PREFIX,
     VITE_GLOB_DRILL_SIGN_URL,
     VITE_GLOB_DRILL_SIGN_URL,
-    // VITE_GLOB_TENANT_CODE,
+    VITE_GLOB_TENANT_CODE,
     VITE_GLOB_SKYEYE_LOGIN_URL,
     VITE_GLOB_SKYEYE_LOGIN_URL,
     VITE_GLOB_SKYEYE_PLATFORM_URL,
     VITE_GLOB_SKYEYE_PLATFORM_URL,
     VITE_GLOB_SKYEYE_ADMIN_URL,
     VITE_GLOB_SKYEYE_ADMIN_URL,
@@ -24,7 +24,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
 
 
     drillSignUrl: VITE_GLOB_DRILL_SIGN_URL || '',
     drillSignUrl: VITE_GLOB_DRILL_SIGN_URL || '',
 
 
-    // tenantCode: VITE_GLOB_TENANT_CODE,
+    tenantCode: VITE_GLOB_TENANT_CODE,
 
 
     skyeyeLoginHost: VITE_GLOB_SKYEYE_LOGIN_URL,
     skyeyeLoginHost: VITE_GLOB_SKYEYE_LOGIN_URL,
     skyeyePlatformHost: VITE_GLOB_SKYEYE_PLATFORM_URL,
     skyeyePlatformHost: VITE_GLOB_SKYEYE_PLATFORM_URL,

+ 1 - 1
src/router/full-routes.ts

@@ -18,7 +18,7 @@ import {
   campusRoutes,
   campusRoutes,
 } from './routers';
 } from './routers';
 
 
-type RouteRecordString = Omit<AppRouteRecordRaw, 'component'> & { component?: string };
+export type RouteRecordString = Omit<AppRouteRecordRaw, 'component'> & { component?: string };
 
 
 export const RootRoute: RouteRecordString = {
 export const RootRoute: RouteRecordString = {
   path: '/',
   path: '/',

+ 3 - 2
src/store/modules/user.ts

@@ -3,7 +3,7 @@ import { createStorage } from '@/utils/Storage';
 import { store } from '@/store';
 import { store } from '@/store';
 import { ACCESS_TOKEN, CURRENT_USER, IS_LOCKSCREEN, TENANT_TOKEN } from '@/store/mutation-types';
 import { ACCESS_TOKEN, CURRENT_USER, IS_LOCKSCREEN, TENANT_TOKEN } from '@/store/mutation-types';
 import { ResultEnum } from '@/enums/httpEnum';
 import { ResultEnum } from '@/enums/httpEnum';
-import { getUserInfo, login, LoginParams, logoutApi, changePassword, UpdateMyPwdParams } from '@/api/system/user';
+import { getUserInfoApi, login, LoginParams, logoutApi, changePassword, UpdateMyPwdParams } from '@/api/system/user';
 import { storage } from '@/utils/Storage';
 import { storage } from '@/utils/Storage';
 import { useGlobSetting } from '@/hooks/setting';
 import { useGlobSetting } from '@/hooks/setting';
 import { PERM } from '@/types/permission/type';
 import { PERM } from '@/types/permission/type';
@@ -33,6 +33,7 @@ export interface IUserState {
     tenantName: string;
     tenantName: string;
     tenantCode: string;
     tenantCode: string;
     tenantId: number;
     tenantId: number;
+    isFirstLogin: number;
   };
   };
   showLogin: boolean;
   showLogin: boolean;
   showUpdatePwd: boolean;
   showUpdatePwd: boolean;
@@ -109,7 +110,7 @@ export const useUserStore = defineStore({
     // 获取用户信息
     // 获取用户信息
     GetInfo() {
     GetInfo() {
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
-        getUserInfo({ tenantCode })
+        getUserInfoApi({ tenantCode })
           .then((res) => {
           .then((res) => {
             const result = res;
             const result = res;
             if (result.permissions && result.permissions.length) {
             if (result.permissions && result.permissions.length) {

+ 1 - 1
types/config.d.ts

@@ -58,7 +58,7 @@ export interface GlobConfig {
   drillSignUrl: string;
   drillSignUrl: string;
 
 
   // 租户code
   // 租户code
-  // tenantCode?: string;
+  tenantCode?: string;
 
 
   // 天眼外链地址
   // 天眼外链地址
   skyeyeLoginHost: string | undefined;
   skyeyeLoginHost: string | undefined;