mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	fix: element-plus locale config
This commit is contained in:
		
							parent
							
								
									b87183cb75
								
							
						
					
					
						commit
						1687097e63
					
				
							
								
								
									
										45
									
								
								src/App.vue
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								src/App.vue
									
									
									
									
									
								
							@ -1,25 +1,28 @@
 | 
				
			|||||||
<script setup lang="ts">
 | 
					 | 
				
			||||||
import { getCurrentInstance } from "vue";
 | 
					 | 
				
			||||||
import { ElConfigProvider } from "element-plus";
 | 
					 | 
				
			||||||
import zhCn from "element-plus/lib/locale/lang/zh-cn";
 | 
					 | 
				
			||||||
import en from "element-plus/lib/locale/lang/en";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let locale: string =
 | 
					 | 
				
			||||||
  getCurrentInstance().appContext.config.globalProperties.$storage?.locale
 | 
					 | 
				
			||||||
    ?.locale;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let currentLocale = () => {
 | 
					 | 
				
			||||||
  switch (locale) {
 | 
					 | 
				
			||||||
    case "zh":
 | 
					 | 
				
			||||||
      return zhCn;
 | 
					 | 
				
			||||||
    case "en":
 | 
					 | 
				
			||||||
      return en;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <el-config-provider :locale="currentLocale()">
 | 
					  <el-config-provider :locale="currentLocale">
 | 
				
			||||||
    <router-view />
 | 
					    <router-view />
 | 
				
			||||||
  </el-config-provider>
 | 
					  </el-config-provider>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
					import { ElConfigProvider } from "element-plus";
 | 
				
			||||||
 | 
					import zhCn from "element-plus/lib/locale/lang/zh-cn";
 | 
				
			||||||
 | 
					import en from "element-plus/lib/locale/lang/en";
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  name: "app",
 | 
				
			||||||
 | 
					  components: {
 | 
				
			||||||
 | 
					    [ElConfigProvider.name]: ElConfigProvider
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    // eslint-disable-next-line vue/return-in-computed-property
 | 
				
			||||||
 | 
					    currentLocale() {
 | 
				
			||||||
 | 
					      switch (this.$storage.locale?.locale) {
 | 
				
			||||||
 | 
					        case "zh":
 | 
				
			||||||
 | 
					          return zhCn;
 | 
				
			||||||
 | 
					        case "en":
 | 
				
			||||||
 | 
					          return en;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user