mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-12-31 11:29:19 +00:00
国际化、主题处理
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { useGlobalConfigStore } from '@/stores/globalConfigStore'
|
import { useGlobalConfigStore } from '@/stores/globalConfigStore'
|
||||||
import { $changeLocale, elementLocale } from '@/languages/MessagesConfig'
|
import { $changeLocale, elementLocale } from '@/messages'
|
||||||
|
|
||||||
const globalConfigStore = useGlobalConfigStore()
|
const globalConfigStore = useGlobalConfigStore()
|
||||||
$changeLocale(globalConfigStore.currentLocale)
|
$changeLocale(globalConfigStore.currentLocale)
|
||||||
|
|||||||
9
src/components/common-input/index.vue
Normal file
9
src/components/common-input/index.vue
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<script setup>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template />
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
8
src/icons/index.js
Normal file
8
src/icons/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||||
|
export default {
|
||||||
|
install (app) {
|
||||||
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||||
|
app.component(key, component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main.js
20
src/main.js
@@ -2,27 +2,23 @@ import { createApp } from 'vue'
|
|||||||
import ElementPlus from 'element-plus'
|
import ElementPlus from 'element-plus'
|
||||||
import 'element-plus/dist/index.css'
|
import 'element-plus/dist/index.css'
|
||||||
import 'element-plus/theme-chalk/dark/css-vars.css'
|
import 'element-plus/theme-chalk/dark/css-vars.css'
|
||||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
import stores from '@/stores'
|
||||||
import { usePinia } from '@/stores'
|
import icons from '@/icons'
|
||||||
|
import messages from '@/messages'
|
||||||
import commons from '@/components'
|
import commons from '@/components'
|
||||||
|
|
||||||
import messagesConfig from '@/languages/MessagesConfig'
|
import App from '@/App.vue'
|
||||||
|
import router from '@/router'
|
||||||
import App from './App.vue'
|
|
||||||
import router from './router'
|
|
||||||
|
|
||||||
import './assets/main.css'
|
import './assets/main.css'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(usePinia)
|
app.use(stores)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(messagesConfig)
|
app.use(icons)
|
||||||
|
app.use(messages)
|
||||||
app.use(commons)
|
app.use(commons)
|
||||||
|
|
||||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
||||||
app.component(key, component)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -2,7 +2,13 @@ import { defineStore, createPinia } from 'pinia'
|
|||||||
import piniaPluginPersistedState from 'pinia-plugin-persistedstate'
|
import piniaPluginPersistedState from 'pinia-plugin-persistedstate'
|
||||||
import { useGlobalConfigStore } from '@/stores/globalConfigStore'
|
import { useGlobalConfigStore } from '@/stores/globalConfigStore'
|
||||||
|
|
||||||
export const usePinia = {
|
export const useStore = defineStore('store', () => {
|
||||||
|
return {
|
||||||
|
globalConfig: useGlobalConfigStore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export default {
|
||||||
install (app) {
|
install (app) {
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
pinia.use(piniaPluginPersistedState)
|
pinia.use(piniaPluginPersistedState)
|
||||||
@@ -10,8 +16,3 @@ export const usePinia = {
|
|||||||
return pinia
|
return pinia
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const useStore = defineStore('store', () => {
|
|
||||||
return {
|
|
||||||
globalConfig: useGlobalConfigStore()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user