[游戏管理]36字花字典-来自游戏配置扩展
This commit is contained in:
@@ -37,6 +37,12 @@ router.beforeEach((to, from, next) => {
|
||||
|
||||
// 按需动态加载页面的语言包-start
|
||||
let loadPath: string[] = []
|
||||
const toCamelPath = (path: string): string => {
|
||||
return path
|
||||
.split('/')
|
||||
.map((seg) => seg.replace(/_([a-z])/g, (_m, c: string) => c.toUpperCase()))
|
||||
.join('/')
|
||||
}
|
||||
const config = useConfig()
|
||||
if (to.path in langAutoLoadMap) {
|
||||
loadPath.push(...langAutoLoadMap[to.path as keyof typeof langAutoLoadMap])
|
||||
@@ -47,7 +53,10 @@ router.beforeEach((to, from, next) => {
|
||||
|
||||
// 去除 path 中的 /admin
|
||||
const adminPath = to.path.slice(to.path.indexOf(adminBaseRoutePath) + adminBaseRoutePath.length)
|
||||
if (adminPath) loadPath.push(prefix + adminPath + '.ts')
|
||||
if (adminPath) {
|
||||
loadPath.push(prefix + adminPath + '.ts')
|
||||
loadPath.push(prefix + toCamelPath(adminPath) + '.ts')
|
||||
}
|
||||
} else {
|
||||
prefix = './frontend/' + config.lang.defaultLang
|
||||
loadPath.push(prefix + to.path + '.ts')
|
||||
@@ -55,7 +64,9 @@ router.beforeEach((to, from, next) => {
|
||||
|
||||
// 根据路由 name 加载的语言包
|
||||
if (to.name) {
|
||||
loadPath.push(prefix + '/' + to.name.toString() + '.ts')
|
||||
const routeName = to.name.toString()
|
||||
loadPath.push(prefix + '/' + routeName + '.ts')
|
||||
loadPath.push(prefix + '/' + toCamelPath(routeName) + '.ts')
|
||||
}
|
||||
|
||||
if (!window.loadLangHandle.publicMessageLoaded) window.loadLangHandle.publicMessageLoaded = []
|
||||
|
||||
Reference in New Issue
Block a user