@tushi11/elpis 1.0.33 → 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.
@@ -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
  // 处理请求头
@@ -76,11 +76,7 @@ const axiosHooks = {
76
76
  async responseInterceptorsHook(response) {
77
77
  NProgress.done();
78
78
  // 从请求配置的自定义选项中获取响应处理开关
79
- const {
80
- responseType = 'dtoResponse',
81
- showLoading,
82
- showMsgError,
83
- } = response?.config?.requestOptions;
79
+ const { responseType = 'dtoResponse', showLoading } = response?.config?.requestOptions;
84
80
 
85
81
  // 关闭全局加载中
86
82
  if (showLoading) {
@@ -145,9 +141,7 @@ const axiosHooks = {
145
141
  };
146
142
 
147
143
  const errorMsg = errorMessages[code] || errorMessages.default;
148
- if (showMsgError) {
149
- feedback.msgError(errorMsg);
150
- }
144
+ feedback.msgError(errorMsg);
151
145
  return Promise.resolve({ success: false, code, message: errorMsg });
152
146
  }
153
147
  // async 函数会自动将 “非 Promise 返回值” 用 Promise.resolve() 包装,因此 return 普通对象 等价于 return Promise.resolve(普通对象) // return 普通对象 更简洁(少写冗余代码),且语义清晰
@@ -181,7 +175,7 @@ const axiosHooks = {
181
175
  * 可通过请求时的自定义配置覆盖默认值
182
176
  */
183
177
  const {
184
- requestSetting: { timeout, proxyIndex, proxyOption = [], showMsgError = true } = {},
178
+ requestSetting: { timeout, proxyIndex, proxyOption = [] } = {},
185
179
  sysSetting: { version } = {},
186
180
  } = pageConfigs;
187
181
  const proxyConfig = proxyOption[proxyIndex] || {};
@@ -206,7 +200,6 @@ const defaultOptions = {
206
200
  retryCount: 2, // 最大重试次数(默认2次)
207
201
  showLoading: false, // 是否显示全局的加载中(默认不显示)
208
202
  loadingText: 'Loading...', // 加载中的提示文字
209
- showMsgError, // 是否显示错误消息(默认显示)
210
203
  },
211
204
  };
212
205
 
@@ -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;
@@ -24,5 +24,4 @@
24
24
  console.log(e);
25
25
  }
26
26
  </script>
27
- <script src="https://www.sandbox.paypal.com/sdk/js?client-id=AWhwIJEyFRpQH2igaNQjVpFEefY6Zw3ozpuesHryZu8pDqsoSYjd8hjoXT0zvZ--7Lx_9RoxymY2EOlB&currency=USD"></script>
28
27
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tushi11/elpis",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -65,10 +65,7 @@
65
65
  "nprogress": "^0.2.0",
66
66
  "path": "^0.12.7",
67
67
  "pinia": "^2.1.6",
68
- "postcss": "^8.4.41",
69
- "postcss-loader": "^8.1.1",
70
68
  "postcss-pxtorem": "^6.1.0",
71
- "koa-proxy": "^1.0.0-alpha.3",
72
69
  "sass": "^1.77.8",
73
70
  "sass-loader": "^16.0.5",
74
71
  "style-loader": "^0.14.1",
@@ -102,7 +99,10 @@
102
99
  "eslint-plugin-import": "^2.28.1",
103
100
  "eslint-plugin-vue": "^9.17.0",
104
101
  "ghooks": "~1.0.3",
102
+ "koa-proxy": "^1.0.0-alpha.3",
105
103
  "mocha": "^6.1.4",
104
+ "postcss": "^8.4.41",
105
+ "postcss-loader": "^8.1.1",
106
106
  "supertest": "^4.0.2",
107
107
  "tailwindcss": "^3.4.10",
108
108
  "validate-commit-msg": "~2.14.0"