Bladeren bron

token携带判断

lifanagju_citu 3 maanden geleden
bovenliggende
commit
412cc6dfd7

+ 2 - 4
src/config/axios/service.js

@@ -23,8 +23,6 @@ const errorData = []
 
 const tenantEnable = import.meta.env.VITE_APP_TENANT_ENABLE
 const { result_code, base_url, request_timeout } = config
-// const entUrlStr = '/recruit' // 包含这个就是企业接口,特殊的在api function中设置tokenIndex(优先)
-// let isEnterprise = config.url.includes(entUrlStr)
 
 // 需要忽略的提示。忽略后,自动 Promise.reject('error')
 const ignoreMsgs = [
@@ -67,7 +65,7 @@ service.interceptors.request.use(
     config.headers['Accept-Language'] = getCurrentLocaleLang() ?? 'zh_CN'
     // 是否需要设置 token
     let isToken = (config.headers || {}).isToken === false
-    // token类型
+    // token类型. api》function中设置tokenIndex(优先)
     const tokenIndex = config.tokenIndex ? config.tokenIndex : getIsEnterprise() ? 1 : 2
     // console.log('令牌类型', tokenIndex === 1 ? '企业:' : '个人:', getToken(tokenIndex))
     whiteList.some((v) => {
@@ -208,7 +206,7 @@ service.interceptors.response.use(
     }
     if (code === 401) {
       // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了
-      // token类型
+      // token类型. api》function中设置tokenIndex(优先)
       const tokenIndex = config.tokenIndex ? config.tokenIndex : getIsEnterprise() ? 1 : 2
 
       if (!isRefreshToken) {

+ 4 - 4
src/hooks/web/useIM.js

@@ -6,7 +6,7 @@ import { getConversationSync, getMessageSync, getChatKey, setUnread, deleteConve
 import { Base64 } from 'js-base64'
 
 import { useUserStore } from '@/store/user'
-import { isEnterprise } from '@/utils/auth'
+import { getIsEnterprise } from '@/utils/auth'
 import { useIMStore } from '@/store/im'
 
 
@@ -97,7 +97,7 @@ export function useDataSource () {
     const query = {
       msg_count: 1
     }
-    if (isEnterprise()) {
+    if (getIsEnterprise()) {
       Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
     }
     const resultConversations = []
@@ -130,7 +130,7 @@ export function useDataSource () {
       limit,
       pull_mode,
     }
-    if (isEnterprise()) {
+    if (getIsEnterprise()) {
       Object.assign(query, { enterpriseId: userStore.entBaseInfo.enterpriseId })
     }
     const resp = await getMessageSync(query)
@@ -159,7 +159,7 @@ async function getKey () {
     // userId: userStore.accountInfo.userId
     userId: JSON.parse(localStorage.getItem('accountInfo')).userId
   }
-  if (isEnterprise()) {
+  if (getIsEnterprise()) {
     Object.assign(keyQuery, { enterpriseId: userStore.entBaseInfo.enterpriseId })
     console.log('企业模式', keyQuery)
   }

+ 0 - 15
src/store/loginType.js

@@ -1,15 +0,0 @@
-import { defineStore } from 'pinia'
-import { isEnterprise } from '@/utils/auth'
-
-export const useLoginType = defineStore('changeLoginType', {
-  state: () => ({
-    // loginType: 0
-    loginType: isEnterprise() ? 'enterprise' : 'personal'
-  }),
-  actions: {
-    change(type) {
-      this.loginType = type
-      localStorage.setItem('loginType', type) // 用户登录类型,0:企业, 1:用户
-    }
-  }
-})

+ 8 - 17
src/utils/auth.js

@@ -1,23 +1,14 @@
-import router from '@/router'
+const ENTERPRISE_PATH = '/recruit/enterprise'
 
-export const isEnterprise = () => {
-  const currentRoute = router.currentRoute.value
-  const substr = '/recruit/enterprise'
-
-  // 判断是否是企业路由
-  let bool = currentRoute?.path?.includes(substr)
-  if (currentRoute?.path === '/enterpriseVerification') bool = true
-
-  // 本地环境保存代码热更新会导致路径缺失问题
-  const testUsePath = localStorage.getItem('routerTest')
-  if (currentRoute?.path === '/' && (testUsePath?.includes(substr) || testUsePath?.includes('/enterpriseVerification'))) bool = true
-  // console.log('currentRoute', currentRoute.path)
-  // console.log('isEnterpriseBool', bool, currentRoute.path)
-  return bool
+// 是否是企业路由
+export const getIsEnterprise = () => {
+  const PATH_NAME = window.location.pathname
+  if (PATH_NAME === '/enterpriseVerification') {
+    return true
+  }
+  return PATH_NAME.includes(ENTERPRISE_PATH)
 }
 
-export const getIsEnterprise = () => { return isEnterprise() } // 是否是企业路由
-
 // 获取token
 export const getToken = (index = 2) => { // index=1: 使用招聘token; index=2: 使用求职token
   const arr = ['ENT_ACCESS_TOKEN', 'PER_ACCESS_TOKEN']

+ 1 - 1
src/views/recruit/enterprise/hirePosition/components/item.vue

@@ -115,7 +115,7 @@ const paySuccess = async () => {
   //   handleAction(1, operateObj.value)
   // }
   setTimeout(() => {
-    emit('refresh')
+    emit('refresh', 1)
   }, 1000)
 }
 

+ 1 - 1
src/views/recruit/enterprise/newlyAppointed/index.vue

@@ -1,5 +1,5 @@
 <template>
-	<div>
+	<div style="width: calc(100vw - 271px)">
 		<CtFilter :items="formItems" @reset="handleReset" @search="handleSearch" />
 
 		<v-card elevation="5" class="mt-3">

+ 1 - 1
src/views/recruit/enterprise/statistics/overallAnalysis.vue

@@ -1,6 +1,6 @@
 <template>
   <v-card class="card-box pa-5">
-    <div class="d-flex color-666 font-size-14">
+    <div class="d-flex color-666 font-size-14 align-center">
       <div class="d-flex align-center" style="min-width: 358px;">
         <span>选择时间</span>
         <div class="ml-5 after">

+ 4 - 8
src/views/recruit/enterprise/systemManagement/groupAccount/index.vue

@@ -1,7 +1,6 @@
 <template>
   <v-card class="card-box d-flex pa-3">
-    <v-row no-gutters justify="space-between">
-      <v-col cols="2">
+      <div style="width: 20%; border-right: 1px solid #ccc;">
         <div class="d-flex justify-start pr-3">
           <v-btn prepend-icon="mdi-plus" variant="text" density="compact" color="primary" @click="handleAdd(1)">{{ $t('enterprise.userManagement.addBranchOffice') }}</v-btn>
         </div>
@@ -23,11 +22,9 @@
             </div>
           </template>
         </v-treeview>
-      </v-col>
+      </div>
 
-      <v-divider vertical></v-divider>
-
-      <v-col class="ml-10" cols="9">
+      <div style="width: 80%" class="ml-3">
         <div class="d-flex justify-space-between px-3">
           <TextInput v-model="query.name" :item="textItem" @change="getUserList"></TextInput>
           <v-btn prepend-icon="mdi-plus" color="primary" @click="handleAdd(0)">{{ $t('enterprise.userManagement.inviteNewColleagues') }}</v-btn>
@@ -64,8 +61,7 @@
             <v-btn v-if="item.status === '0' && item.userType !== '1'" color="primary" variant="text" @click="handleAction('', 1, item)">{{ $t('enterprise.userManagement.disable') }}</v-btn>
           </template>
         </CtTable>
-      </v-col>
-    </v-row>
+      </div>
   </v-card>
 
   <CtDialog :visible="showEdit" :widthType="2" titleClass="text-h6" title="编辑员工基本信息" @close="showEdit = false; editId = null" @submit="handleSubmit">