mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-11-12 14:27:49 +00:00
变量定义,title优化
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<title>%VITE_APP_NAME%</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<script setup>
|
||||
import { useGlobalConfigStore } from '@/stores/GlobalConfigStore'
|
||||
import { $changeLocale, elementLocale } from '@/messages'
|
||||
import { $changeLocale, elementLocale, $i18nBundle } from '@/messages'
|
||||
import { useTitle } from '@vueuse/core'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const globalConfigStore = useGlobalConfigStore()
|
||||
$changeLocale(globalConfigStore.currentLocale)
|
||||
const title = computed(() => $i18nBundle('common.label.title'))
|
||||
useTitle(title)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { baseMessages } from '@/messages/base'
|
||||
export const common = baseMessages()
|
||||
|
||||
common.label.title = '简单Element+模板'
|
||||
common.label.login = '登录'
|
||||
common.label.index = '首页'
|
||||
common.label.langCn = '中文'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { baseMessages } from '@/messages/base'
|
||||
export const common = baseMessages()
|
||||
|
||||
common.label.title = 'Simple Element+'
|
||||
common.label.login = 'Login'
|
||||
common.label.index = 'Home'
|
||||
common.label.langCn = '中文'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { createI18n, useI18n } from 'vue-i18n'
|
||||
import { ref } from 'vue'
|
||||
import messagesCn from './messages_cn'
|
||||
import messagesEn from './messages_en'
|
||||
@@ -41,7 +41,7 @@ export const $changeLocale = locale => {
|
||||
* @param {boolean} replaceEmpty 为空是否用不为空的数据代替
|
||||
* @returns {*}
|
||||
*/
|
||||
export const $i18nMsg = function (cn, en, replaceEmpty) {
|
||||
export const $i18nMsg = (cn, en, replaceEmpty) => {
|
||||
const { currentLocale } = useGlobalConfigStore()
|
||||
console.log(currentLocale)
|
||||
if (currentLocale === GlobalLocales.CN) {
|
||||
@@ -50,12 +50,15 @@ export const $i18nMsg = function (cn, en, replaceEmpty) {
|
||||
return replaceEmpty ? (en || cn) : en
|
||||
}
|
||||
|
||||
export const $i18nBundle = i18n.global.t
|
||||
|
||||
export default {
|
||||
install (app) {
|
||||
app.use(i18n)
|
||||
Object.assign(app.config.globalProperties, {
|
||||
$changeLocale,
|
||||
$i18nMsg
|
||||
$i18nMsg,
|
||||
$i18nBundle
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { GlobalLayoutMode, GlobalLocales } from '@/consts/GlobalConstants'
|
||||
import { useGlobalConfigStore } from '@/stores/GlobalConfigStore'
|
||||
import { ref } from 'vue'
|
||||
import { $i18nBundle } from '@/messages'
|
||||
|
||||
export const useBaseTopMenus = () => {
|
||||
const globalConfigStore = useGlobalConfigStore()
|
||||
@@ -86,7 +87,7 @@ export const useBusinessMenus = () => {
|
||||
return ref([
|
||||
{
|
||||
icon: 'HomeFilled',
|
||||
label: 'Simple Element Plus'
|
||||
labelIf: () => $i18nBundle('common.label.title')
|
||||
},
|
||||
{
|
||||
icon: 'setting',
|
||||
|
||||
Reference in New Issue
Block a user