chore: 使用常量来处理会员中心的路由页面路径判断

This commit is contained in:
2026-01-07 15:09:49 +08:00
parent 6956841c8b
commit b10fcf02d4
27 changed files with 93 additions and 74 deletions

View File

@@ -66,15 +66,16 @@ export default {
const locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
var value = '';
let value = ''; // 存放解析后的语言值
let langPath = ''; // 存放当前页面语言包路径
try {
//公共语言包(同步加载)
var lang = loadLangPackSync(locale, 'common');
//当前页面语言包(同步加载)
let route = _this.route;
let langPath = processRoutePath(route);
console.log(`当前语言: ${locale}, 当前页面语言包路径: ${langPath}`);
langPath = processRoutePath(route);
// 加载当前页面语言包
let currentPageLang = loadLangPackSync(locale, langPath);
@@ -102,7 +103,7 @@ export default {
}
} catch (e) {
console.error('解析语言包失败:', e);
console.error('解析语言包失败:', e, { langPath, field, locale });
value = field;
}
@@ -115,7 +116,10 @@ export default {
if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field
// 多语言调试,注释后可以关闭控制台输出
console.log(`字段: ${field}, 值: ${value}`)
if (field == value) {
console.warn(`警告: 字段 ${field} 在语言包 ${langPath} 中未找到对应值,使用默认值 ${field} 当前语言: ${locale}`);
}
return value;
},
/**

View File

@@ -7,15 +7,18 @@ import {
// 首页路径
// 关于页面路径,使用常量导出
export const INDEX_PAGE_URL = '/pages/index/index';
export const CATEGORY_PAGE_URL = '/pages_goods/category';
export const CONTACT_PAGE_URL = '/pages_tool/contact/contact';
export const MEMBER_PAGE_URL = '/pages_tool/member/index';
// 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置)
export const systemTabBarList = [
INDEX_PAGE_URL,
'/pages_goods/category',
'/pages_tool/contact/contact',
'/pages_tool/member/index'
CATEGORY_PAGE_URL,
CONTACT_PAGE_URL,
MEMBER_PAGE_URL
];
/**
@@ -109,6 +112,12 @@ export const checkTabBarActive = (linkUrl, currentPageRoute) => {
}
export default {
/** 导出页面URL常量 */
MEMBER_PAGE_URL,
CATEGORY_PAGE_URL,
CONTACT_PAGE_URL,
INDEX_PAGE_URL,
/**
* 页面跳转
* @param {string} to 跳转链接 /pages/idnex/index
@@ -592,6 +601,9 @@ export default {
}
return cloneObj
},
/**
* 自定义模板的跳转链接
* @param {Object} link