@4399ywkf/cli 1.0.6 → 1.0.8

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.
Files changed (177) hide show
  1. package/dist/templates/HarmonyOS_Sans_Bold.woff2 +0 -0
  2. package/dist/templates/HarmonyOS_Sans_Medium.woff2 +0 -0
  3. package/dist/templates/HarmonyOS_Sans_Regular.woff2 +0 -0
  4. package/dist/templates/Locale.tsx +14 -18
  5. package/dist/templates/MainContentWrap.tsx +11 -15
  6. package/dist/templates/ThemeContext.tsx +27 -24
  7. package/dist/templates/actions.ts +14 -11
  8. package/dist/templates/app/config/env/.env.public.tpl +2 -19
  9. package/dist/templates/app/config/jwt/index.ts +4 -4
  10. package/dist/templates/app/config/request/error-handler.ts +67 -0
  11. package/dist/templates/app/config/request/index.ts +127 -129
  12. package/dist/templates/app/config/request/interceptors.ts +118 -0
  13. package/dist/templates/app/config/request/token-manager.ts +23 -0
  14. package/dist/templates/app/config/request/types.ts +63 -0
  15. package/dist/templates/app/config/rspack/rspack.config.mjs +62 -61
  16. package/dist/templates/app/config/rspack/rspack.prod.mjs +41 -62
  17. package/dist/templates/app/locales/zh-CN/common.json +3 -0
  18. package/dist/templates/app/package.json.tpl +1 -10
  19. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  20. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  21. package/dist/templates/app/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  22. package/dist/templates/app/react-app-env.d.ts +13 -8
  23. package/dist/templates/app/src/bootstrap/index.ts +34 -0
  24. package/dist/templates/app/src/config/env.ts +84 -0
  25. package/dist/templates/app/src/index.tsx +17 -54
  26. package/dist/templates/app/src/layout/Locale.tsx +14 -18
  27. package/dist/templates/app/src/layout/MainContentWrap.tsx +11 -15
  28. package/dist/templates/app/src/layout/ThemeContext.tsx +27 -24
  29. package/dist/templates/app/src/locales/default/common.ts +3 -1
  30. package/dist/templates/app/src/micro/garfish.ts +53 -0
  31. package/dist/templates/app/src/pages/base/index.tsx +189 -25
  32. package/dist/templates/app/src/routes.tsx +21 -12
  33. package/dist/templates/app/src/types/global.d.ts +19 -0
  34. package/dist/templates/app/src/utils/index.ts +3 -1
  35. package/dist/templates/app/store/middleware/createDevtools.ts +7 -7
  36. package/dist/templates/base/index.tsx +189 -25
  37. package/dist/templates/bootstrap/index.ts +34 -0
  38. package/dist/templates/common.json +3 -0
  39. package/dist/templates/common.ts +3 -1
  40. package/dist/templates/config/env/.env.public.tpl +2 -19
  41. package/dist/templates/config/env.ts +84 -0
  42. package/dist/templates/config/jwt/index.ts +4 -4
  43. package/dist/templates/config/request/error-handler.ts +67 -0
  44. package/dist/templates/config/request/index.ts +127 -129
  45. package/dist/templates/config/request/interceptors.ts +118 -0
  46. package/dist/templates/config/request/token-manager.ts +23 -0
  47. package/dist/templates/config/request/types.ts +63 -0
  48. package/dist/templates/config/rspack/rspack.config.mjs +62 -61
  49. package/dist/templates/config/rspack/rspack.prod.mjs +41 -62
  50. package/dist/templates/createDevtools.ts +7 -7
  51. package/dist/templates/default/common.ts +3 -1
  52. package/dist/templates/env/.env.public.tpl +2 -19
  53. package/dist/templates/env.ts +83 -2
  54. package/dist/templates/error-handler.ts +67 -0
  55. package/dist/templates/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  56. package/dist/templates/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  57. package/dist/templates/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  58. package/dist/templates/garfish.ts +53 -0
  59. package/dist/templates/global.d.ts +19 -0
  60. package/dist/templates/index.tsx +189 -25
  61. package/dist/templates/initialState.ts +28 -10
  62. package/dist/templates/interceptors.ts +118 -0
  63. package/dist/templates/jwt/index.ts +4 -4
  64. package/dist/templates/layout/Locale.tsx +14 -18
  65. package/dist/templates/layout/MainContentWrap.tsx +11 -15
  66. package/dist/templates/layout/ThemeContext.tsx +27 -24
  67. package/dist/templates/locales/default/common.ts +3 -1
  68. package/dist/templates/locales/zh-CN/common.json +3 -0
  69. package/dist/templates/micro/garfish.ts +53 -0
  70. package/dist/templates/middleware/createDevtools.ts +7 -7
  71. package/dist/templates/package.json.tpl +1 -10
  72. package/dist/templates/page.tsx +21 -19
  73. package/dist/templates/pages/base/index.tsx +189 -25
  74. package/dist/templates/public/fonts/HarmonyOS_Sans_Bold.woff2 +0 -0
  75. package/dist/templates/public/fonts/HarmonyOS_Sans_Medium.woff2 +0 -0
  76. package/dist/templates/public/fonts/HarmonyOS_Sans_Regular.woff2 +0 -0
  77. package/dist/templates/react-app-env.d.ts +13 -8
  78. package/dist/templates/request/error-handler.ts +67 -0
  79. package/dist/templates/request/index.ts +127 -129
  80. package/dist/templates/request/interceptors.ts +118 -0
  81. package/dist/templates/request/token-manager.ts +23 -0
  82. package/dist/templates/request/types.ts +63 -0
  83. package/dist/templates/routes.tsx +21 -12
  84. package/dist/templates/rspack/rspack.config.mjs +62 -61
  85. package/dist/templates/rspack/rspack.prod.mjs +41 -62
  86. package/dist/templates/rspack.config.mjs +62 -61
  87. package/dist/templates/rspack.prod.mjs +41 -62
  88. package/dist/templates/src/bootstrap/index.ts +34 -0
  89. package/dist/templates/src/config/env.ts +84 -0
  90. package/dist/templates/src/index.tsx +17 -54
  91. package/dist/templates/src/layout/Locale.tsx +14 -18
  92. package/dist/templates/src/layout/MainContentWrap.tsx +11 -15
  93. package/dist/templates/src/layout/ThemeContext.tsx +27 -24
  94. package/dist/templates/src/locales/default/common.ts +3 -1
  95. package/dist/templates/src/micro/garfish.ts +53 -0
  96. package/dist/templates/src/pages/base/index.tsx +189 -25
  97. package/dist/templates/src/routes.tsx +21 -12
  98. package/dist/templates/src/types/global.d.ts +19 -0
  99. package/dist/templates/src/utils/index.ts +3 -1
  100. package/dist/templates/store/middleware/createDevtools.ts +7 -7
  101. package/dist/templates/token-manager.ts +23 -0
  102. package/dist/templates/types/global.d.ts +19 -0
  103. package/dist/templates/utils/index.ts +3 -1
  104. package/dist/templates/zh-CN/common.json +3 -0
  105. package/package.json +1 -1
  106. package/dist/templates/app/config/sentry/sentry.config.ts +0 -188
  107. package/dist/templates/app/src/hooks/useRouteTitle.tsx +0 -36
  108. package/dist/templates/app/src/hooks/useSentry.ts +0 -92
  109. package/dist/templates/app/src/pages/base/layout.tsx +0 -6
  110. package/dist/templates/app/src/pages/base/page.tsx +0 -25
  111. package/dist/templates/app/src/utils/env.ts +0 -3
  112. package/dist/templates/app/src/utils/format.ts +0 -21
  113. package/dist/templates/app/src/utils/getMicroApp.ts +0 -39
  114. package/dist/templates/app/src/utils/sentry.ts +0 -187
  115. package/dist/templates/app/src/utils/sentryDecorators.ts +0 -34
  116. package/dist/templates/app/src/utils/updateVersion.ts +0 -186
  117. package/dist/templates/base/layout.tsx +0 -6
  118. package/dist/templates/base/page.tsx +0 -25
  119. package/dist/templates/config/public/404.png +0 -0
  120. package/dist/templates/config/public/favicon.ico +0 -0
  121. package/dist/templates/config/public/images/banner_market_modal.webp +0 -0
  122. package/dist/templates/config/public/images/chatmode_chat_dark.webp +0 -0
  123. package/dist/templates/config/public/images/chatmode_chat_light.webp +0 -0
  124. package/dist/templates/config/public/images/chatmode_docs_dark.webp +0 -0
  125. package/dist/templates/config/public/images/chatmode_docs_light.webp +0 -0
  126. package/dist/templates/config/public/images/empty_topic_dark.webp +0 -0
  127. package/dist/templates/config/public/images/empty_topic_light.webp +0 -0
  128. package/dist/templates/config/public/images/screenshot_background.webp +0 -0
  129. package/dist/templates/config/public/images/theme_auto.webp +0 -0
  130. package/dist/templates/config/public/images/theme_dark.webp +0 -0
  131. package/dist/templates/config/public/images/theme_light.webp +0 -0
  132. package/dist/templates/config/public/index.html +0 -29
  133. package/dist/templates/config/sentry/sentry.config.ts +0 -188
  134. package/dist/templates/format.ts +0 -21
  135. package/dist/templates/getMicroApp.ts +0 -39
  136. package/dist/templates/hooks/useRouteTitle.tsx +0 -36
  137. package/dist/templates/hooks/useSentry.ts +0 -92
  138. package/dist/templates/layout.tsx +0 -6
  139. package/dist/templates/pages/base/layout.tsx +0 -6
  140. package/dist/templates/pages/base/page.tsx +0 -25
  141. package/dist/templates/sentry/sentry.config.ts +0 -188
  142. package/dist/templates/sentry.config.ts +0 -188
  143. package/dist/templates/sentry.ts +0 -187
  144. package/dist/templates/sentryDecorators.ts +0 -34
  145. package/dist/templates/src/hooks/useRouteTitle.tsx +0 -36
  146. package/dist/templates/src/hooks/useSentry.ts +0 -92
  147. package/dist/templates/src/pages/base/layout.tsx +0 -6
  148. package/dist/templates/src/pages/base/page.tsx +0 -25
  149. package/dist/templates/src/utils/env.ts +0 -3
  150. package/dist/templates/src/utils/format.ts +0 -21
  151. package/dist/templates/src/utils/getMicroApp.ts +0 -39
  152. package/dist/templates/src/utils/sentry.ts +0 -187
  153. package/dist/templates/src/utils/sentryDecorators.ts +0 -34
  154. package/dist/templates/src/utils/updateVersion.ts +0 -186
  155. package/dist/templates/updateVersion.ts +0 -186
  156. package/dist/templates/useRouteTitle.tsx +0 -36
  157. package/dist/templates/useSentry.ts +0 -92
  158. package/dist/templates/utils/env.ts +0 -3
  159. package/dist/templates/utils/format.ts +0 -21
  160. package/dist/templates/utils/getMicroApp.ts +0 -39
  161. package/dist/templates/utils/sentry.ts +0 -187
  162. package/dist/templates/utils/sentryDecorators.ts +0 -34
  163. package/dist/templates/utils/updateVersion.ts +0 -186
  164. /package/dist/templates/app/{config/public → public}/404.png +0 -0
  165. /package/dist/templates/app/{config/public → public}/favicon.ico +0 -0
  166. /package/dist/templates/app/{config/public → public}/images/banner_market_modal.webp +0 -0
  167. /package/dist/templates/app/{config/public → public}/images/chatmode_chat_dark.webp +0 -0
  168. /package/dist/templates/app/{config/public → public}/images/chatmode_chat_light.webp +0 -0
  169. /package/dist/templates/app/{config/public → public}/images/chatmode_docs_dark.webp +0 -0
  170. /package/dist/templates/app/{config/public → public}/images/chatmode_docs_light.webp +0 -0
  171. /package/dist/templates/app/{config/public → public}/images/empty_topic_dark.webp +0 -0
  172. /package/dist/templates/app/{config/public → public}/images/empty_topic_light.webp +0 -0
  173. /package/dist/templates/app/{config/public → public}/images/screenshot_background.webp +0 -0
  174. /package/dist/templates/app/{config/public → public}/images/theme_auto.webp +0 -0
  175. /package/dist/templates/app/{config/public → public}/images/theme_dark.webp +0 -0
  176. /package/dist/templates/app/{config/public → public}/images/theme_light.webp +0 -0
  177. /package/dist/templates/app/{config/public → public}/index.html +0 -0
@@ -1,186 +0,0 @@
1
- import { message, notification } from 'antd';
2
- import React from 'react';
3
-
4
- const APP_NAME = process.env.APP_NAME;
5
- interface IVersionRecord {
6
- action: '' | 'refreshedByClick';
7
- stack: string[];
8
- }
9
- // 对应的数组的key
10
- const RECORD_KEY = `${APP_NAME}_version_record`;
11
-
12
- // 当前版本号
13
- let CUR_VERSION = '';
14
- // 页面是否有通知
15
- let CUR_STATE = false;
16
- // 是否通过点击通知触发刷新
17
- let REFRESHED_BY_CLICK = false;
18
-
19
- window.addEventListener('beforeunload', () => {
20
- if (!REFRESHED_BY_CLICK) {
21
- const recordStr = localStorage.getItem(RECORD_KEY);
22
- if (recordStr === null) return;
23
- const record: IVersionRecord = JSON.parse(recordStr);
24
- if (record.action !== '') {
25
- record.action = '';
26
- localStorage.setItem(RECORD_KEY, JSON.stringify(record));
27
- }
28
- }
29
- });
30
-
31
- const Interval = {
32
- clearInterval: function () {
33
- cancelAnimationFrame(this.timer);
34
- },
35
- setInterval: function (callback: any, interval: any) {
36
- let startTime = new Date().valueOf();
37
- let endTime = new Date().valueOf();
38
- const self: any = this; // eslint-disable-line
39
- const loop = () => {
40
- self.timer = requestAnimationFrame(loop);
41
- endTime = new Date().valueOf();
42
- if (endTime - startTime >= interval) {
43
- endTime = startTime = new Date().valueOf();
44
- callback?.(); // eslint-disable-line
45
- }
46
- };
47
- this.timer = requestAnimationFrame(loop);
48
- return this.timer;
49
- },
50
- timer: 0,
51
- };
52
-
53
- /**
54
- * 读取到更新的json文件版本内容
55
- */
56
- const fetchUpdateVersionFile = () => {
57
- return new Promise((resolve, reject) => {
58
- fetch('/update_version.json')
59
- .then(res => {
60
- return res.body;
61
- })
62
- .then(body => {
63
- const reader = body?.getReader();
64
- if (reader) {
65
- reader
66
- .read()
67
- .then(val => {
68
- let str = '';
69
- if (val.value) {
70
- for (let i = 0; i < val.value.length; i++) {
71
- str += String.fromCharCode(val.value[i]);
72
- }
73
- }
74
- return JSON.parse(str);
75
- })
76
- .then(json => {
77
- resolve(json);
78
- })
79
- .catch(err => {
80
- reject(err);
81
- });
82
- }
83
- })
84
- .catch(err => {
85
- reject(err);
86
- });
87
- });
88
- };
89
-
90
- const ENV = process.env.NODE_ENV;
91
-
92
- const notifyUserUpdate = () => {
93
- const handleClick = () => {
94
- REFRESHED_BY_CLICK = true;
95
- const recordStr = localStorage.getItem(RECORD_KEY);
96
- if (recordStr === null) return;
97
- const record: IVersionRecord = JSON.parse(recordStr);
98
- record.action = 'refreshedByClick';
99
- localStorage.setItem(RECORD_KEY, JSON.stringify(record));
100
- window.location.reload();
101
- };
102
- const handleClose = () => {
103
- Interval.clearInterval();
104
- message.open({
105
- content: '页面将不会提示更新',
106
- type: 'warning',
107
- });
108
- };
109
- const openNotification = () => {
110
- const element = React.createElement(
111
- 'div', // 类型
112
- {
113
- onClick: handleClick,
114
- style: { color: '#1677ff', cursor: 'pointer' },
115
- }, // 属性
116
- '页面已更新,请点击此处刷新页面!', // 子元素
117
- );
118
- notification.warning({
119
- description: element,
120
- duration: null,
121
- message: '温馨提示',
122
- onClose: handleClose,
123
- placement: 'bottomRight',
124
- });
125
- };
126
- openNotification();
127
- CUR_STATE = true;
128
- };
129
-
130
- const handleMain = (version: string, handleCb: any, fetchDelay: number) => {
131
- // 记录当前版本号
132
- CUR_VERSION = version;
133
- // 从本地获取历史记录
134
- const oldVersionRecordStr = localStorage.getItem(RECORD_KEY);
135
- // 继承历史记录中的action、stack
136
- let oldAction: IVersionRecord['action'] = '';
137
- const oldStack: IVersionRecord['stack'] = [version];
138
- if (oldVersionRecordStr !== null) {
139
- const record: IVersionRecord = JSON.parse(oldVersionRecordStr);
140
- oldAction = record.action;
141
- }
142
- // 创建变量记录版本、操作
143
- const curVersionRecord: IVersionRecord = {
144
- action: oldAction,
145
- stack: oldStack,
146
- };
147
-
148
- localStorage.setItem(RECORD_KEY, JSON.stringify(curVersionRecord));
149
-
150
- Interval.setInterval(() => {
151
- fetchUpdateVersionFile().then((res: any) => {
152
- // 读取版本记录
153
- const versionRecordStr = localStorage.getItem(RECORD_KEY);
154
- if (typeof versionRecordStr === 'string') {
155
- const versionRecord: IVersionRecord = JSON.parse(versionRecordStr);
156
- // 读取对应栈
157
- const lastVersion = versionRecord.stack[0];
158
- localStorage.setItem(RECORD_KEY, JSON.stringify(versionRecord));
159
- // 在服务器的版本与当前版本不一致
160
- if (res.version !== CUR_VERSION) {
161
- if (CUR_STATE === false) {
162
- // 发起通知
163
- handleCb();
164
- } else if (
165
- versionRecord.action === 'refreshedByClick' &&
166
- lastVersion !== CUR_VERSION
167
- ) {
168
- // 上一个标签页更新过,且当前标签页未更新
169
- REFRESHED_BY_CLICK = true;
170
- window.location.reload();
171
- }
172
- }
173
- }
174
- });
175
- }, fetchDelay);
176
- };
177
-
178
- export const openUpdateVersionNotify = (fetchDelay: number) => {
179
- // 开发环境没有必要开启版本检测功能
180
- if (ENV === 'development') {
181
- return;
182
- }
183
- fetchUpdateVersionFile().then((res: any) => {
184
- handleMain(res.version, notifyUserUpdate, fetchDelay);
185
- });
186
- };