@tushi11/elpis 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/pages/common/curl.js
CHANGED
|
@@ -68,26 +68,6 @@ const curl = ({
|
|
|
68
68
|
const { value: token } = JSON.parse(data);
|
|
69
69
|
headers[tokenName] = token;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
// try {
|
|
73
|
-
// const data = window.localStorage.getItem(tokenKey);
|
|
74
|
-
// // 检查 data 是否存在且不为空
|
|
75
|
-
// if (!data) {
|
|
76
|
-
// // 可选:如果需要提示 token 不存在,可添加 feedback.msgWarning('未找到登录信息');
|
|
77
|
-
// return; // 或跳过设置 token
|
|
78
|
-
// }
|
|
79
|
-
// // 解析 JSON 并容错
|
|
80
|
-
// const parsedData = JSON.parse(data);
|
|
81
|
-
// // 检查解析后的数据是否为对象且存在 value 属性
|
|
82
|
-
// if (parsedData && typeof parsedData === 'object' && 'value' in parsedData) {
|
|
83
|
-
// headers[tokenName] = parsedData.value;
|
|
84
|
-
// } else {
|
|
85
|
-
// feedback.msgWarning('登录信息格式错误');
|
|
86
|
-
// }
|
|
87
|
-
// } catch (error) {
|
|
88
|
-
// // 捕获 JSON 解析错误或其他异常
|
|
89
|
-
// feedback.msgError(`处理登录信息失败: ${error.message}`);
|
|
90
|
-
// }
|
|
91
71
|
}
|
|
92
72
|
|
|
93
73
|
// 处理请求头
|
|
@@ -160,10 +160,6 @@ const axiosHooks = {
|
|
|
160
160
|
feedback.closeLoading();
|
|
161
161
|
|
|
162
162
|
if (!error.isCancel) {
|
|
163
|
-
if (error.message.includes('code 401')) {
|
|
164
|
-
console.log(error.message);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
163
|
// 排除主动取消请求的错误(避免误提示)
|
|
168
164
|
error.message && feedback.msgError(error.message);
|
|
169
165
|
} else {
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { createI18n } from 'vue-i18n';
|
|
2
|
-
import cache from '$elpisCommon/cache';
|
|
3
|
-
import { SETTING_KEY } from '$elpisPages/enums/cacheEnums';
|
|
4
|
-
import pageConfigs from '$elpisPages/configs/configs.js';
|
|
5
|
-
import { merge } from 'lodash';
|
|
6
|
-
|
|
7
|
-
// 导入业务语言包
|
|
8
|
-
import enLocale from './locales/en';
|
|
9
|
-
import zhLocale from './locales/zh-CN';
|
|
10
|
-
|
|
11
|
-
// 导入Element Plus语言包
|
|
12
|
-
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
13
|
-
// import en from 'element-plus/dist/locale/en.mjs';
|
|
14
|
-
import en from 'element-plus/es/locale/lang/en';
|
|
15
|
-
|
|
16
|
-
// 业务拓展 i18n-config 配置
|
|
17
|
-
import businessI18nConfig from '$businessI18nConfig';
|
|
18
|
-
|
|
19
|
-
const elpisI18nConfig = {
|
|
20
|
-
'zh-cn': {
|
|
21
|
-
name: '简体中文',
|
|
22
|
-
business: zhLocale, // 业务翻译(页面文本等)
|
|
23
|
-
element: zhCn, // Element Plus组件翻译
|
|
24
|
-
},
|
|
25
|
-
en: {
|
|
26
|
-
name: 'English',
|
|
27
|
-
business: enLocale, // 业务翻译
|
|
28
|
-
element: en, // Element Plus组件翻译
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const languageMap = merge(elpisI18nConfig, businessI18nConfig);
|
|
33
|
-
|
|
34
|
-
// 提取业务语言包(供Vue I18n使用)
|
|
35
|
-
const messages = Object.fromEntries(
|
|
36
|
-
Object.entries(languageMap).map(([lang, { business }]) => [lang, business])
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// 提取Element Plus语言包映射
|
|
40
|
-
export const elLocaleMap = Object.fromEntries(
|
|
41
|
-
Object.entries(languageMap).map(([lang, { element }]) => [lang, element])
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// 提取语言选择列表(带lang和name)
|
|
45
|
-
export const localeMap = Object.entries(languageMap).map(([lang, { name }]) => ({
|
|
46
|
-
lang,
|
|
47
|
-
name,
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 获取当前语言设置
|
|
52
|
-
* @returns {string} 当前语言标识(如 'zh-cn' 或 'en')
|
|
53
|
-
*/
|
|
54
|
-
export function getLanguage() {
|
|
55
|
-
const storageSetting = cache.get(SETTING_KEY);
|
|
56
|
-
if (storageSetting) return storageSetting.language || 'zh-cn';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 创建i18n实例
|
|
60
|
-
const i18n = createI18n({
|
|
61
|
-
silentTranslationWarn: process.env.NODE_ENV === 'production', // 生产环境关闭翻译警告
|
|
62
|
-
missingWarn: process.env.NODE_ENV === 'production', // 关闭缺失翻译警告
|
|
63
|
-
silentFallbackWarn: process.env.NODE_ENV === 'production', // 关闭 fallback 警告
|
|
64
|
-
legacy: false,
|
|
65
|
-
globalInjection: true, // 允许全局使用 $t 函数
|
|
66
|
-
locale: getLanguage(), // 当前语言
|
|
67
|
-
messages, // 语言包
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
sysSetting: { useI18n },
|
|
72
|
-
} = pageConfigs;
|
|
73
|
-
|
|
74
|
-
// 基础翻译方法
|
|
75
|
-
export const { t: i18nT } = i18n.global;
|
|
76
|
-
/**
|
|
77
|
-
* 条件翻译方法
|
|
78
|
-
* @param {string} content - 翻译键或原始内容
|
|
79
|
-
* @param {object} [interpolations={}] - 插值变量(如 { name: '张三' })
|
|
80
|
-
* @param {object} [options={}] - 翻译配置
|
|
81
|
-
* @returns {string} 处理后的内容
|
|
82
|
-
*/
|
|
83
|
-
export const t = (content = '', interpolations = {}, options = { silent: true }) => {
|
|
84
|
-
let needTranslate = false;
|
|
85
|
-
if (typeof content === 'string' && content.startsWith('t::')) {
|
|
86
|
-
content = content.slice(3);
|
|
87
|
-
needTranslate = true;
|
|
88
|
-
}
|
|
89
|
-
if (useI18n || needTranslate) {
|
|
90
|
-
// 需要翻译时,使用t方法并默认关闭动态内容的警告
|
|
91
|
-
return i18nT(content, interpolations, options);
|
|
92
|
-
}
|
|
93
|
-
// 不需要翻译时,直接返回原始内容
|
|
94
|
-
return content;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default i18n;
|
|
1
|
+
import { createI18n } from 'vue-i18n';
|
|
2
|
+
import cache from '$elpisCommon/cache';
|
|
3
|
+
import { SETTING_KEY } from '$elpisPages/enums/cacheEnums';
|
|
4
|
+
import pageConfigs from '$elpisPages/configs/configs.js';
|
|
5
|
+
import { merge } from 'lodash';
|
|
6
|
+
|
|
7
|
+
// 导入业务语言包
|
|
8
|
+
import enLocale from './locales/en';
|
|
9
|
+
import zhLocale from './locales/zh-CN';
|
|
10
|
+
|
|
11
|
+
// 导入Element Plus语言包
|
|
12
|
+
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
13
|
+
// import en from 'element-plus/dist/locale/en.mjs';
|
|
14
|
+
import en from 'element-plus/es/locale/lang/en';
|
|
15
|
+
|
|
16
|
+
// 业务拓展 i18n-config 配置
|
|
17
|
+
import businessI18nConfig from '$businessI18nConfig';
|
|
18
|
+
|
|
19
|
+
const elpisI18nConfig = {
|
|
20
|
+
'zh-cn': {
|
|
21
|
+
name: '简体中文',
|
|
22
|
+
business: zhLocale, // 业务翻译(页面文本等)
|
|
23
|
+
element: zhCn, // Element Plus组件翻译
|
|
24
|
+
},
|
|
25
|
+
en: {
|
|
26
|
+
name: 'English',
|
|
27
|
+
business: enLocale, // 业务翻译
|
|
28
|
+
element: en, // Element Plus组件翻译
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const languageMap = merge(elpisI18nConfig, businessI18nConfig);
|
|
33
|
+
|
|
34
|
+
// 提取业务语言包(供Vue I18n使用)
|
|
35
|
+
const messages = Object.fromEntries(
|
|
36
|
+
Object.entries(languageMap).map(([lang, { business }]) => [lang, business])
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// 提取Element Plus语言包映射
|
|
40
|
+
export const elLocaleMap = Object.fromEntries(
|
|
41
|
+
Object.entries(languageMap).map(([lang, { element }]) => [lang, element])
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// 提取语言选择列表(带lang和name)
|
|
45
|
+
export const localeMap = Object.entries(languageMap).map(([lang, { name }]) => ({
|
|
46
|
+
lang,
|
|
47
|
+
name,
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 获取当前语言设置
|
|
52
|
+
* @returns {string} 当前语言标识(如 'zh-cn' 或 'en')
|
|
53
|
+
*/
|
|
54
|
+
export function getLanguage() {
|
|
55
|
+
const storageSetting = cache.get(SETTING_KEY);
|
|
56
|
+
if (storageSetting) return storageSetting.language || 'zh-cn';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 创建i18n实例
|
|
60
|
+
const i18n = createI18n({
|
|
61
|
+
silentTranslationWarn: process.env.NODE_ENV === 'production', // 生产环境关闭翻译警告
|
|
62
|
+
missingWarn: process.env.NODE_ENV === 'production', // 关闭缺失翻译警告
|
|
63
|
+
silentFallbackWarn: process.env.NODE_ENV === 'production', // 关闭 fallback 警告
|
|
64
|
+
legacy: false,
|
|
65
|
+
globalInjection: true, // 允许全局使用 $t 函数
|
|
66
|
+
locale: getLanguage(), // 当前语言
|
|
67
|
+
messages, // 语言包
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
sysSetting: { useI18n },
|
|
72
|
+
} = pageConfigs;
|
|
73
|
+
|
|
74
|
+
// 基础翻译方法
|
|
75
|
+
export const { t: i18nT } = i18n.global;
|
|
76
|
+
/**
|
|
77
|
+
* 条件翻译方法
|
|
78
|
+
* @param {string} content - 翻译键或原始内容
|
|
79
|
+
* @param {object} [interpolations={}] - 插值变量(如 { name: '张三' })
|
|
80
|
+
* @param {object} [options={}] - 翻译配置
|
|
81
|
+
* @returns {string} 处理后的内容
|
|
82
|
+
*/
|
|
83
|
+
export const t = (content = '', interpolations = {}, options = { silent: true }) => {
|
|
84
|
+
let needTranslate = false;
|
|
85
|
+
if (typeof content === 'string' && content.startsWith('t::')) {
|
|
86
|
+
content = content.slice(3);
|
|
87
|
+
needTranslate = true;
|
|
88
|
+
}
|
|
89
|
+
if (useI18n || needTranslate) {
|
|
90
|
+
// 需要翻译时,使用t方法并默认关闭动态内容的警告
|
|
91
|
+
return i18nT(content, interpolations, options);
|
|
92
|
+
}
|
|
93
|
+
// 不需要翻译时,直接返回原始内容
|
|
94
|
+
return content;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default i18n;
|
package/app/view/entry.tpl
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tushi11/elpis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"@babel/core": "^7.24.0",
|
|
18
18
|
"@babel/plugin-transform-runtime": "^7.1.0",
|
|
19
19
|
"@babel/preset-env": "^7.4.5",
|
|
20
|
-
"@babel/runtime": "^7.28.4",
|
|
21
20
|
"@element-plus/icons-vue": "^2.3.1",
|
|
22
21
|
"@iconify-json/ep": "^1.2.3",
|
|
23
22
|
"@iconify-json/mdi": "^1.2.3",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
"koa": "2.7.0",
|
|
50
49
|
"koa-bodyparser": "^4.2.1",
|
|
51
50
|
"koa-nunjucks-2": "^3.0.2",
|
|
52
|
-
"koa-proxy": "^1.0.0-alpha.3",
|
|
53
51
|
"koa-router": "^7.4.0",
|
|
54
52
|
"koa-static": "^5.0.0",
|
|
55
53
|
"koa-useragent": "2.0.0",
|
|
@@ -67,8 +65,6 @@
|
|
|
67
65
|
"nprogress": "^0.2.0",
|
|
68
66
|
"path": "^0.12.7",
|
|
69
67
|
"pinia": "^2.1.6",
|
|
70
|
-
"postcss": "^8.4.41",
|
|
71
|
-
"postcss-loader": "^8.1.1",
|
|
72
68
|
"postcss-pxtorem": "^6.1.0",
|
|
73
69
|
"sass": "^1.77.8",
|
|
74
70
|
"sass-loader": "^16.0.5",
|
|
@@ -103,7 +99,10 @@
|
|
|
103
99
|
"eslint-plugin-import": "^2.28.1",
|
|
104
100
|
"eslint-plugin-vue": "^9.17.0",
|
|
105
101
|
"ghooks": "~1.0.3",
|
|
102
|
+
"koa-proxy": "^1.0.0-alpha.3",
|
|
106
103
|
"mocha": "^6.1.4",
|
|
104
|
+
"postcss": "^8.4.41",
|
|
105
|
+
"postcss-loader": "^8.1.1",
|
|
107
106
|
"supertest": "^4.0.2",
|
|
108
107
|
"tailwindcss": "^3.4.10",
|
|
109
108
|
"validate-commit-msg": "~2.14.0"
|