Browse Source

语言切换reload

Xiao_123 11 tháng trước cách đây
mục cha
commit
a367c35f10
2 tập tin đã thay đổi với 15 bổ sung6 xóa
  1. 8 3
      src/layout/personal/navBar.vue
  2. 7 3
      src/layout/personal/slider.vue

+ 8 - 3
src/layout/personal/navBar.vue

@@ -37,7 +37,7 @@
           
           <!-- 头像用户名 -->
           <div class="d-flex align-center" v-if="getToken()">
-            <span style="cursor: pointer;">{{ $t('sys.news') }}</span>
+            <span class="cursor-pointer">{{ $t('sys.news') }}</span>
             <v-menu open-on-hover>
               <template v-slot:activator="{ props }">
                 <div class="d-flex ml-5 pl-2 align-center cursor-pointer" v-bind="props" @click="handleToPersonalCenter">
@@ -71,13 +71,13 @@
               >
               </v-btn>
             </template>
-            <v-list density="compact">
+            <v-list density="compact" color="primary">
               <v-list-item
                 v-for="item in localeStore.localeMap"
                 :key="item.name"
                 :value="item.lang"
                 :active="localeStore.currentLocale.lang === item.lang"
-                @click="localeStore.setCurrentLocale(item)"
+                @click="handleChangeLocale(item)"
               >
                 <v-list-item-title>{{ item.name }}</v-list-item-title>
               </v-list-item>
@@ -174,6 +174,11 @@ const handleLogin = () => {
   router.push({ path: '/login' })
 }
 
+// 语言切换
+const handleChangeLocale = (item) => {
+  localeStore.setCurrentLocale(item)
+  location.reload()
+}
 </script>
 
 <style lang="scss" scoped>

+ 7 - 3
src/layout/personal/slider.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="slider-box">
-    <div v-for="(item, index) in list" :key="index" class="slider-box-item" @click="handleClick(index)">
+    <div v-for="(item, index) in list" :key="index" class="slider-box-item" @click="handleClick(item, index)">
       <v-btn size="30" class="icons" icon variant="text">
         <v-icon class="icons" size="30">{{ item.mdi }}</v-icon>
         <v-tooltip :text="item.tips" location="start" activator="parent">
@@ -17,16 +17,20 @@
 
 <script setup>
 defineOptions({ name: 'personalSlider' })
+import { useRouter } from 'vue-router'
+
+const router = useRouter()
 const list = [
   { mdi: 'mdi-arrow-up-bold', tips: '返回顶部' },
   { mdi: 'mdi-qrcode', tips: '微信公众号', showImg: 'https://minio.citupro.com/dev/static/mendunerCode.jpg' },
   { mdi: 'mdi-face-agent', tips: '客服' },
-  { mdi: 'mdi-list-box-outline', tips: '在线简历' }
+  { mdi: 'mdi-list-box-outline', tips: '在线简历', path: '/resume' }
 ]
 
-const handleClick = (index) => {
+const handleClick = (item, index) => {
   // 回到顶部
   if (index === 0) window.scrollTo({ top: 0, behavior: 'smooth' })
+  if (item.path) router.push(item.path)
 }
 </script>