zhengnaiwen_citu 1 year ago
parent
commit
dc1fd962cb
5 changed files with 33 additions and 5 deletions
  1. 1 0
      package.json
  2. 28 2
      src/layout/personal/navBar.vue
  3. 1 0
      src/permission.js
  4. 1 1
      src/store/user.js
  5. 2 2
      src/views/login/index.vue

+ 1 - 0
package.json

@@ -3,6 +3,7 @@
   "version": "0.0.0",
   "scripts": {
     "dev": "vite --host 0.0.0.0",
+    "build:dev": "vite build --mode dev",
     "build": "vite build",
     "preview": "vite preview",
     "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",

+ 28 - 2
src/layout/personal/navBar.vue

@@ -30,6 +30,27 @@
               <a href="">我要招聘</a>
             </span>
             <v-btn class="half-button" color="primary" size="small" @click="handleLogin">登录/注册</v-btn>
+            <v-menu>
+              <template v-slot:activator="{ props }">
+                <v-btn
+                  class="ml-3"
+                  icon="mdi-translate"
+                  size="x-small"
+                  color="primary"
+                  v-bind="props"
+                >
+                </v-btn>
+              </template>
+              <v-list density="compact" >
+                <v-list-item
+                  v-for="item in localeStore.localeMap"
+                  :key="item.name"
+                  :value="item.name"
+                >
+                  <v-list-item-title>{{ item.name }}</v-list-item-title>
+                </v-list-item>
+              </v-list>
+            </v-menu>
           </div>
         </div>
         <div v-else class="d-flex user-nav">
@@ -62,16 +83,21 @@
 <script setup>
 import { ref } from 'vue'
 import { getToken } from '@/utils/auth'
-import { userLocaleStore } from '@/store/user'
+import { useUserStore } from '@/store/user'
+import { useLocaleStore } from '@/store/locale'
 defineOptions({ name: 'personal-navbar' })
 import Dialog from '@/components/CtDialog'
 import enterpriseRegister from '@/views/enterprise/components/register.vue'
+
 defineProps({
   sticky: {
     type: Boolean,
     default: true
   }
 })
+
+const localeStore = useLocaleStore()
+
 const list = ref([
   { text: '首页', path: '/home' },
   { text: '职位', path: '' },
@@ -92,7 +118,7 @@ const changeRole = () => {
 }
 
 // 退出登录
-const userStore = userLocaleStore()
+const userStore = useUserStore()
 const handleLogout = async () => {
   // try {
     await userStore.userLogout()

+ 1 - 0
src/permission.js

@@ -7,6 +7,7 @@ const { start, done } = useNProgress()
 // 路由不重定向白名单
 const whiteList = [
   '/',
+  '/home',
   '/login',
   '/social-login',
   '/auth-redirect',

+ 1 - 1
src/store/user.js

@@ -6,7 +6,7 @@ import { logout } from '@/api/common/index'
 import { getUserInfo } from '@/api/personal/user'
 import Snackbar from '@/plugins/snackbar'
 
-export const userLocaleStore = defineStore('user',
+export const useUserStore = defineStore('user',
   () => {
     let accountInfo = reactive({}) // 登录返回的信息
     let userInfo = reactive({}) // 当前登录账号信息

+ 2 - 2
src/views/login/index.vue

@@ -53,7 +53,7 @@ import passwordFrom from './components/passwordPage.vue'
 import phoneFrom from '@/components/VerificationCode'
 import qrCode from './components/qrCode.vue'
 
-import { userLocaleStore } from '@/store/user'
+import { useUserStore } from '@/store/user'
 import { useRouter } from 'vue-router'
 import Snackbar from '@/plugins/snackbar'
 defineOptions({ name: 'login-index' })
@@ -73,7 +73,7 @@ const showClose = ref(false)
 const phoneRef = ref()
 const passRef = ref()
 const loginLoading = ref(false)
-const userStore = userLocaleStore()
+const userStore = useUserStore()
 const handleLogin = async () => {
   const { valid } = tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
   if (!valid) return