verce-vue-test 0.0.37 → 0.0.39

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 (153) hide show
  1. package/888/mini2.0-main/.editorconfig +8 -0
  2. package/888/mini2.0-main/.env.development +3 -0
  3. package/888/mini2.0-main/.env.production +3 -0
  4. package/888/mini2.0-main/.env.test +3 -0
  5. package/888/mini2.0-main/.gitattributes +1 -0
  6. package/888/mini2.0-main/.oxlintrc.json +10 -0
  7. package/888/mini2.0-main/.prettierrc.json +6 -0
  8. package/888/mini2.0-main/.vscode/extensions.json +9 -0
  9. package/888/mini2.0-main/README.md +179 -0
  10. package/888/mini2.0-main/auto-imports.d.ts +629 -0
  11. package/888/mini2.0-main/components.d.ts +21 -0
  12. package/888/mini2.0-main/design-qa.md +36 -0
  13. package/888/mini2.0-main/docs/MX_API.md +244 -0
  14. package/888/mini2.0-main/docs/REQUEST.md +217 -0
  15. package/888/mini2.0-main/docs/jsapi.js +515 -0
  16. package/888/mini2.0-main/docs/package-json-guide.md +132 -0
  17. package/888/mini2.0-main/env.d.ts +15 -0
  18. package/888/mini2.0-main/eslint.config.ts +26 -0
  19. package/888/mini2.0-main/index.html +16 -0
  20. package/888/mini2.0-main/output/playwright/rmb-position/design-comparison.png +0 -0
  21. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-back-top.png +0 -0
  22. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-page.png +0 -0
  23. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-sticky-check.png +0 -0
  24. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-sticky-scrolled.png +0 -0
  25. package/888/mini2.0-main/package-lock.json +6442 -0
  26. package/888/mini2.0-main/package.json +66 -0
  27. package/888/mini2.0-main/plugins/bump-version.ts +61 -0
  28. package/888/mini2.0-main/postcss.config.ts +15 -0
  29. package/888/mini2.0-main/public/favicon.ico +0 -0
  30. package/888/mini2.0-main/public/images/12a73787-86a9-4891-a65f-66104746f6a8.png +0 -0
  31. package/888/mini2.0-main/public/images/5798d7aa-ba8b-4605-8079-58b35495ac55.png +0 -0
  32. package/888/mini2.0-main/public/images/73fef1e4-0fd0-4a1a-9b8b-a70a5b6acbbc.png +0 -0
  33. package/888/mini2.0-main/public/images/bc685b4c-0cca-4a79-924c-a8ee10e6f8eb.png +0 -0
  34. package/888/mini2.0-main/public/images/c3dbbd9d-be56-490e-b9f4-6ee17ebefffc.png +0 -0
  35. package/888/mini2.0-main/public/images/ea745a10-42aa-4f44-8d7f-3ab02cc0adcd.png +0 -0
  36. package/888/mini2.0-main/public/images/f5876785-b927-4347-ba19-999114240649.png +0 -0
  37. package/888/mini2.0-main/public/images/img.png +0 -0
  38. package/888/mini2.0-main/src/App.vue +59 -0
  39. package/888/mini2.0-main/src/api/health.ts +13 -0
  40. package/888/mini2.0-main/src/api/rmb-position.ts +287 -0
  41. package/888/mini2.0-main/src/api/user.ts +54 -0
  42. package/888/mini2.0-main/src/auto-imports.d.ts +639 -0
  43. package/888/mini2.0-main/src/components.d.ts +30 -0
  44. package/888/mini2.0-main/src/config/config.properties +3 -0
  45. package/888/mini2.0-main/src/config/env.ts +6 -0
  46. package/888/mini2.0-main/src/config/plugin.properties.pro +6 -0
  47. package/888/mini2.0-main/src/config/plugin.properties.test +6 -0
  48. package/888/mini2.0-main/src/core/mxApi/index.ts +344 -0
  49. package/888/mini2.0-main/src/core/request/index.ts +135 -0
  50. package/888/mini2.0-main/src/main.ts +39 -0
  51. package/888/mini2.0-main/src/router/index.ts +77 -0
  52. package/888/mini2.0-main/src/stores/app.ts +24 -0
  53. package/888/mini2.0-main/src/stores/counter.ts +12 -0
  54. package/888/mini2.0-main/src/stores/user.ts +85 -0
  55. package/888/mini2.0-main/src/types/api.d.ts +14 -0
  56. package/888/mini2.0-main/src/types/nprogress.d.ts +8 -0
  57. package/888/mini2.0-main/src/utils/auth-token.ts +197 -0
  58. package/888/mini2.0-main/src/utils/query.ts +27 -0
  59. package/888/mini2.0-main/src/utils/request.ts +233 -0
  60. package/888/mini2.0-main/src/views/clearing-detail/index.vue +49 -0
  61. package/888/mini2.0-main/src/views/foreign-position/index.vue +49 -0
  62. package/888/mini2.0-main/src/views/home/index.vue +213 -0
  63. package/888/mini2.0-main/src/views/login/index.vue +202 -0
  64. package/888/mini2.0-main/src/views/mine/index.vue +143 -0
  65. package/888/mini2.0-main/src/views/net-debit/index.vue +49 -0
  66. package/888/mini2.0-main/src/views/pbc-position/index.vue +49 -0
  67. package/888/mini2.0-main/src/views/position-estimate/index.vue +49 -0
  68. package/888/mini2.0-main/src/views/rmb-position/index.vue +1042 -0
  69. package/888/mini2.0-main/src/views/warning/index.vue +49 -0
  70. package/888/mini2.0-main/tsconfig.app.json +18 -0
  71. package/888/mini2.0-main/tsconfig.json +11 -0
  72. package/888/mini2.0-main/tsconfig.node.json +28 -0
  73. package/888/mini2.0-main/vite.config.ts +98 -0
  74. package/design-qa.md +39 -0
  75. package/mini2.0-main 2/.editorconfig +8 -0
  76. package/mini2.0-main 2/.env.development +3 -0
  77. package/mini2.0-main 2/.env.production +3 -0
  78. package/mini2.0-main 2/.env.test +3 -0
  79. package/mini2.0-main 2/.gitattributes +1 -0
  80. package/mini2.0-main 2/.oxlintrc.json +10 -0
  81. package/mini2.0-main 2/.prettierrc.json +6 -0
  82. package/mini2.0-main 2/.vscode/extensions.json +9 -0
  83. package/mini2.0-main 2/README.md +179 -0
  84. package/mini2.0-main 2/auto-imports.d.ts +629 -0
  85. package/mini2.0-main 2/components.d.ts +21 -0
  86. package/mini2.0-main 2/docs/MX_API.md +244 -0
  87. package/mini2.0-main 2/docs/REQUEST.md +217 -0
  88. package/mini2.0-main 2/docs/jsapi.js +515 -0
  89. package/mini2.0-main 2/docs/package-json-guide.md +132 -0
  90. package/mini2.0-main 2/env.d.ts +13 -0
  91. package/mini2.0-main 2/eslint.config.ts +26 -0
  92. package/mini2.0-main 2/index.html +16 -0
  93. package/mini2.0-main 2/package-lock.json +6442 -0
  94. package/mini2.0-main 2/package.json +66 -0
  95. package/mini2.0-main 2/plugins/bump-version.ts +61 -0
  96. package/mini2.0-main 2/postcss.config.ts +15 -0
  97. package/mini2.0-main 2/public/favicon.ico +0 -0
  98. package/mini2.0-main 2/public/images/12a73787-86a9-4891-a65f-66104746f6a8.png +0 -0
  99. package/mini2.0-main 2/public/images/5798d7aa-ba8b-4605-8079-58b35495ac55.png +0 -0
  100. package/mini2.0-main 2/public/images/73fef1e4-0fd0-4a1a-9b8b-a70a5b6acbbc.png +0 -0
  101. package/mini2.0-main 2/public/images/bc685b4c-0cca-4a79-924c-a8ee10e6f8eb.png +0 -0
  102. package/mini2.0-main 2/public/images/c3dbbd9d-be56-490e-b9f4-6ee17ebefffc.png +0 -0
  103. package/mini2.0-main 2/public/images/ea745a10-42aa-4f44-8d7f-3ab02cc0adcd.png +0 -0
  104. package/mini2.0-main 2/public/images/f5876785-b927-4347-ba19-999114240649.png +0 -0
  105. package/mini2.0-main 2/public/images/img.png +0 -0
  106. package/mini2.0-main 2/src/App.vue +11 -0
  107. package/mini2.0-main 2/src/api/user.ts +33 -0
  108. package/mini2.0-main 2/src/auto-imports.d.ts +639 -0
  109. package/mini2.0-main 2/src/components.d.ts +23 -0
  110. package/mini2.0-main 2/src/config/config.properties +3 -0
  111. package/mini2.0-main 2/src/config/env.ts +6 -0
  112. package/mini2.0-main 2/src/config/plugin.properties.pro +6 -0
  113. package/mini2.0-main 2/src/config/plugin.properties.test +6 -0
  114. package/mini2.0-main 2/src/core/mxApi/index.ts +217 -0
  115. package/mini2.0-main 2/src/core/request/index.ts +42 -0
  116. package/mini2.0-main 2/src/main.ts +28 -0
  117. package/mini2.0-main 2/src/router/index.ts +70 -0
  118. package/mini2.0-main 2/src/stores/app.ts +24 -0
  119. package/mini2.0-main 2/src/stores/counter.ts +12 -0
  120. package/mini2.0-main 2/src/stores/user.ts +52 -0
  121. package/mini2.0-main 2/src/types/api.d.ts +14 -0
  122. package/mini2.0-main 2/src/types/nprogress.d.ts +8 -0
  123. package/mini2.0-main 2/src/utils/query.ts +27 -0
  124. package/mini2.0-main 2/src/utils/request.ts +159 -0
  125. package/mini2.0-main 2/src/views/clearing-detail/index.vue +49 -0
  126. package/mini2.0-main 2/src/views/foreign-position/index.vue +49 -0
  127. package/mini2.0-main 2/src/views/home/index.vue +201 -0
  128. package/mini2.0-main 2/src/views/login/index.vue +196 -0
  129. package/mini2.0-main 2/src/views/net-debit/index.vue +49 -0
  130. package/mini2.0-main 2/src/views/pbc-position/index.vue +49 -0
  131. package/mini2.0-main 2/src/views/position-estimate/index.vue +49 -0
  132. package/mini2.0-main 2/src/views/rmb-position/index.vue +49 -0
  133. package/mini2.0-main 2/src/views/warning/index.vue +49 -0
  134. package/mini2.0-main 2/tsconfig.app.json +18 -0
  135. package/mini2.0-main 2/tsconfig.json +11 -0
  136. package/mini2.0-main 2/tsconfig.node.json +28 -0
  137. package/mini2.0-main 2/vite.config.ts +69 -0
  138. package/output/playwright/home-1672x941.png +0 -0
  139. package/output/playwright/home-preview-1672x941.png +0 -0
  140. package/output/playwright/home-reference-vs-preview.png +0 -0
  141. package/package.json +1 -1
  142. package/src/assets/home/card-clearing-city.png +0 -0
  143. package/src/assets/home/card-cross-border-map.png +0 -0
  144. package/src/assets/home/card-digital-currency.png +0 -0
  145. package/src/assets/home/card-eur-church.png +0 -0
  146. package/src/assets/home/card-hkd-skyline.png +0 -0
  147. package/src/assets/home/card-jpy-fuji.png +0 -0
  148. package/src/assets/home/card-rmb-great-wall.png +0 -0
  149. package/src/assets/home/card-usd-liberty.png +0 -0
  150. package/src/assets/home/home-page-bg.png +0 -0
  151. package/src/router/index.ts +1 -0
  152. package/src/views/FundCockpitView.vue +17 -23
  153. package/src/views/HomeView.vue +619 -33
@@ -0,0 +1,23 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ // biome-ignore lint: disable
4
+ // oxlint-disable
5
+ // ------
6
+ // Generated by unplugin-vue-components
7
+ // Read more: https://github.com/vuejs/core/pull/3399
8
+
9
+ export {}
10
+
11
+ /* prettier-ignore */
12
+ declare module 'vue' {
13
+ export interface GlobalComponents {
14
+ RouterLink: typeof import('vue-router')['RouterLink']
15
+ RouterView: typeof import('vue-router')['RouterView']
16
+ VanButton: typeof import('vant/es')['Button']
17
+ VanCellGroup: typeof import('vant/es')['CellGroup']
18
+ VanField: typeof import('vant/es')['Field']
19
+ VanForm: typeof import('vant/es')['Form']
20
+ VanIcon: typeof import('vant/es')['Icon']
21
+ VanLoading: typeof import('vant/es')['Loading']
22
+ }
23
+ }
@@ -0,0 +1,3 @@
1
+ hideWebViewTitle=false;
2
+ hideOptionMenu=true;
3
+ hideToolbar=true;
@@ -0,0 +1,6 @@
1
+ export const appEnv = import.meta.env.VITE_APP_ENV
2
+
3
+ export const apiConfig = {
4
+ baseURL: import.meta.env.VITE_API_BASE_URL,
5
+ timeout: Number(import.meta.env.VITE_API_TIMEOUT) || 10000,
6
+ }
@@ -0,0 +1,6 @@
1
+ app_id=vue_demo;
2
+ version_code=10000;
3
+ version_name=1.0.0.00;
4
+ type=html5;
5
+ frame=vue;
6
+ platform=[mac,win,ios,android];
@@ -0,0 +1,6 @@
1
+ app_id=vue_demo;
2
+ version_code=10001;
3
+ version_name=1.0.0.01;
4
+ type=html5;
5
+ frame=vue;
6
+ platform=[mac,win,ios,android];
@@ -0,0 +1,217 @@
1
+ /**
2
+ * 敏行 AJAX 支持的 HTTP 请求类型。
3
+ *
4
+ * 该枚举范围来自 MXCommon.ajax 文档;未包含 PATCH,
5
+ * 调用方如需 PATCH 应在业务请求中提前处理。
6
+ */
7
+ export type MXAjaxType = 'GET' | 'POST' | 'PUT' | 'DELETE'
8
+
9
+ /**
10
+ * MXCommon.ajax 入参。
11
+ *
12
+ * 这里只保留敏行 AJAX 文档中明确支持的公共字段:
13
+ * - type: 请求方式,默认 GET
14
+ * - url: 请求地址
15
+ * - dataType: 返回数据格式
16
+ * - async: 是否异步请求,默认 true
17
+ * - data: 请求数据,兼容实际宿主能力透传
18
+ * - success/error/complete: 宿主回调
19
+ */
20
+ export interface MXAjaxParams {
21
+ /** 请求方式,未传时按敏行文档默认 GET。 */
22
+ type?: MXAjaxType
23
+ /** 请求地址,可以是完整 URL,也可以由调用方传入业务接口路径。 */
24
+ url: string
25
+ /** 返回数据格式,例如 text/json,具体支持范围以敏行宿主为准。 */
26
+ dataType?: string
27
+ /** 是否异步请求,未传时默认 true。 */
28
+ async?: boolean
29
+ /** 请求数据,原样透传给敏行宿主。 */
30
+ data?: unknown
31
+ /** 请求成功回调,收到的是宿主原始返回值。 */
32
+ success?: (data: unknown) => void
33
+ /** 请求失败回调,收到的是宿主原始错误值。 */
34
+ error?: (data: unknown) => void
35
+ /** 请求完成回调,无论成功或失败都由宿主触发。 */
36
+ complete?: () => void
37
+ }
38
+
39
+ /**
40
+ * Promise 化后的 AJAX 返回结构。
41
+ *
42
+ * 敏行宿主以回调返回原始数据;封装层会尝试 JSON.parse,
43
+ * 成功则返回解析后的对象,失败则保留原始数据。
44
+ */
45
+ export interface MXAjaxResponse<T = unknown> {
46
+ data: T
47
+ }
48
+
49
+ /**
50
+ * 获取 APP token 成功回调。
51
+ */
52
+ export type MXAppTokenSuccess = (token: string) => void
53
+
54
+ /**
55
+ * 获取 APP token 失败回调。
56
+ */
57
+ export type MXAppTokenError = (error: unknown) => void
58
+
59
+ /**
60
+ * 当前项目使用的敏行公共宿主能力。
61
+ */
62
+ interface MXCommonHost {
63
+ ajax?: (options: MXAjaxParams) => void
64
+ getEncryptString?: (success: MXAppTokenSuccess, error?: MXAppTokenError) => void
65
+ }
66
+
67
+ declare global {
68
+ interface Window {
69
+ /** 敏行旧宿主命名空间。 */
70
+ MXCommon?: MXCommonHost
71
+ /** 敏行新宿主命名空间,部分客户端使用 NXCommon。 */
72
+ NXCommon?: MXCommonHost
73
+ }
74
+ }
75
+
76
+ /**
77
+ * 获取当前可用的敏行公共宿主对象。
78
+ *
79
+ * 优先使用 MXCommon;如果客户端只注入 NXCommon,则回退到 NXCommon。
80
+ * 增加 window 判断是为了避免在类型检查、SSR 或非浏览器上下文导入时报错。
81
+ */
82
+ const getHostCommon = () => {
83
+ if (typeof window === 'undefined') return undefined
84
+
85
+ return window.MXCommon || window.NXCommon
86
+ }
87
+
88
+ /**
89
+ * 安全解析宿主返回的数据。
90
+ *
91
+ * 敏行 AJAX 示例中 dataType 常使用 text,业务响应可能是 JSON 字符串。
92
+ * 这里仅在字符串非空且 JSON.parse 成功时转换;否则保持原值,避免吞掉
93
+ * 文本响应或宿主返回的非 JSON 数据。
94
+ */
95
+ const safeJsonParse = (data: unknown) => {
96
+ if (typeof data !== 'string') return data
97
+
98
+ const text = data.trim()
99
+ if (!text) return data
100
+
101
+ try {
102
+ return JSON.parse(text)
103
+ } catch {
104
+ return data
105
+ }
106
+ }
107
+
108
+ /**
109
+ * 发起敏行 AJAX 请求。
110
+ *
111
+ * 该方法做三件事:
112
+ * 1. 判断当前环境是否存在 MXCommon.ajax / NXCommon.ajax。
113
+ * 2. 补齐敏行文档默认值,例如 type=GET、async=true。
114
+ * 3. 将宿主回调包装成 Promise,同时保留调用方传入的回调。
115
+ *
116
+ * @param options 敏行 AJAX 请求参数
117
+ * @returns Promise 化后的请求结果
118
+ */
119
+ export function ajax<T = unknown>(options: MXAjaxParams): Promise<MXAjaxResponse<T>> {
120
+ return new Promise((resolve, reject) => {
121
+ const hostCommon = getHostCommon()
122
+
123
+ // 非敏行宿主环境无法调用 MXCommon.ajax,直接进入失败链路。
124
+ if (!hostCommon?.ajax) {
125
+ const error = new Error('当前环境不支持 MXCommon.ajax')
126
+ options.error?.(error)
127
+ options.complete?.()
128
+ reject(error)
129
+ return
130
+ }
131
+
132
+ // 透传调用方参数,并补齐敏行文档中的默认请求配置。
133
+ const requestOptions: MXAjaxParams = {
134
+ ...options,
135
+ type: options.type || 'GET',
136
+ async: options.async ?? true,
137
+ success(data) {
138
+ // 先保留原始回调行为,再 resolve Promise,避免破坏旧调用方。
139
+ options.success?.(data)
140
+ resolve({ data: safeJsonParse(data) as T })
141
+ },
142
+ error(data) {
143
+ const errorData = safeJsonParse(data)
144
+ // error 同样保留调用方回调,再 reject 给 await/catch 使用。
145
+ options.error?.(errorData)
146
+ reject(errorData)
147
+ },
148
+ complete() {
149
+ options.complete?.()
150
+ },
151
+ }
152
+
153
+ // 每次调用敏行 AJAX 前打印完整关键参数,方便原生联调定位问题。
154
+ console.log('[MXCommon.ajax] request params', {
155
+ type: requestOptions.type,
156
+ url: requestOptions.url,
157
+ dataType: requestOptions.dataType,
158
+ async: requestOptions.async,
159
+ data: requestOptions.data,
160
+ hasSuccessCallback: Boolean(options.success),
161
+ hasErrorCallback: Boolean(options.error),
162
+ hasCompleteCallback: Boolean(options.complete),
163
+ })
164
+
165
+ hostCommon.ajax(requestOptions)
166
+ })
167
+ }
168
+
169
+ /**
170
+ * 获取敏行宿主提供的 APP token。
171
+ *
172
+ * 宿主文档方法名为 MXCommon.getEncryptString(),这里只封装该方法。
173
+ *
174
+ * @returns Promise 化后的 APP token 字符串
175
+ */
176
+ export function getAppToken(): Promise<string> {
177
+ return new Promise((resolve, reject) => {
178
+ const hostCommon = getHostCommon()
179
+ const getToken = hostCommon?.getEncryptString
180
+
181
+ if (!getToken) {
182
+ const error = new Error('当前环境不支持 MXCommon.getEncryptString')
183
+ reject(error)
184
+ return
185
+ }
186
+
187
+ console.log('[MXCommon.getEncryptString] request params', {
188
+ hasSuccessCallback: true,
189
+ hasErrorCallback: true,
190
+ actualMethod: 'getEncryptString',
191
+ })
192
+
193
+ getToken(
194
+ (token) => {
195
+ resolve(token)
196
+ },
197
+ (error) => {
198
+ reject(error)
199
+ },
200
+ )
201
+ })
202
+ }
203
+
204
+ /**
205
+ * MXCommon.getEncryptString 的同名封装。
206
+ *
207
+ * 保留宿主方法名,方便调用方按敏行文档搜索和使用。
208
+ */
209
+ export const getEncryptString = getAppToken
210
+
211
+ /**
212
+ * 判断当前页面是否运行在敏行宿主环境中。
213
+ *
214
+ * 只要宿主注入了 MXCommon 或 NXCommon,就认为是原生环境。
215
+ */
216
+ export const isNativeApp = (): boolean =>
217
+ typeof window.MXCommon !== 'undefined' || typeof window.NXCommon !== 'undefined'
@@ -0,0 +1,42 @@
1
+ import { ajax, isNativeApp } from '@/core/mxApi'
2
+ import type { MXAjaxType } from '@/core/mxApi'
3
+ import { request as axiosRequest } from '@/utils/request'
4
+ import type { RequestConfig } from '@/utils/request'
5
+ import { appendQuery } from '@/utils/query'
6
+ import type { ApiResponse } from '@/types/api'
7
+
8
+ export type { RequestConfig } from '@/utils/request'
9
+
10
+ export function request<R = unknown, T = unknown>(
11
+ config: RequestConfig<T>,
12
+ ): Promise<ApiResponse<R>> {
13
+ if (isNativeApp()) {
14
+ return nativeRequest<R, T>(config)
15
+ }
16
+
17
+ return axiosRequest<R, T>(config)
18
+ }
19
+
20
+ async function nativeRequest<R = unknown, T = unknown>(
21
+ config: RequestConfig<T>,
22
+ ): Promise<ApiResponse<R>> {
23
+ const method = (config.method || 'GET').toUpperCase()
24
+
25
+ if (!isMXAjaxType(method)) {
26
+ throw new Error(`敏行 AJAX 不支持 ${method} 请求`)
27
+ }
28
+
29
+ const response = await ajax<ApiResponse<R>>({
30
+ type: method,
31
+ url: appendQuery(config.url, config.params),
32
+ data: config.data,
33
+ dataType: 'text',
34
+ async: true,
35
+ })
36
+
37
+ return response.data
38
+ }
39
+
40
+ function isMXAjaxType(method: string): method is MXAjaxType {
41
+ return method === 'GET' || method === 'POST' || method === 'PUT' || method === 'DELETE'
42
+ }
@@ -0,0 +1,28 @@
1
+ import { createApp } from 'vue'
2
+ import { createPinia } from 'pinia'
3
+ import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
4
+ import 'vant/lib/index.css'
5
+
6
+ import App from './App.vue'
7
+ import router from './router'
8
+ import { useAppStore } from '@/stores/app'
9
+
10
+ const app = createApp(App)
11
+ const pinia = createPinia()
12
+
13
+ pinia.use(piniaPluginPersistedstate)
14
+
15
+ app.use(pinia)
16
+ app.use(router)
17
+
18
+ // 等待原生环境检测完成后再挂载,确保所有组件读到的 isNative 都是正确值
19
+ const appStore = useAppStore()
20
+ appStore.initNativeDetection()
21
+
22
+ // 测试环境 + 原生设备:加载 vConsole 调试面板
23
+ if (import.meta.env.VITE_APP_ENV === 'test' && appStore.isNative) {
24
+ const { default: VConsole } = await import('vconsole')
25
+ new VConsole()
26
+ }
27
+
28
+ app.mount('#app')
@@ -0,0 +1,70 @@
1
+ import { createRouter, createWebHashHistory } from 'vue-router'
2
+ import { useUserStore } from '@/stores/user'
3
+
4
+ const router = createRouter({
5
+ history: createWebHashHistory(),
6
+ routes: [
7
+ {
8
+ path: '/',
9
+ name: 'Home',
10
+ component: () => import('@/views/home/index.vue'),
11
+ meta: { requiresAuth: true },
12
+ },
13
+ {
14
+ path: '/login',
15
+ name: 'Login',
16
+ component: () => import('@/views/login/index.vue'),
17
+ },
18
+ {
19
+ path: '/rmb-position',
20
+ name: 'RmbPosition',
21
+ component: () => import('@/views/rmb-position/index.vue'),
22
+ meta: { requiresAuth: true },
23
+ },
24
+ {
25
+ path: '/foreign-position',
26
+ name: 'ForeignPosition',
27
+ component: () => import('@/views/foreign-position/index.vue'),
28
+ meta: { requiresAuth: true },
29
+ },
30
+ {
31
+ path: '/pbc-position',
32
+ name: 'PbcPosition',
33
+ component: () => import('@/views/pbc-position/index.vue'),
34
+ meta: { requiresAuth: true },
35
+ },
36
+ {
37
+ path: '/position-estimate',
38
+ name: 'PositionEstimate',
39
+ component: () => import('@/views/position-estimate/index.vue'),
40
+ meta: { requiresAuth: true },
41
+ },
42
+ {
43
+ path: '/net-debit',
44
+ name: 'NetDebit',
45
+ component: () => import('@/views/net-debit/index.vue'),
46
+ meta: { requiresAuth: true },
47
+ },
48
+ {
49
+ path: '/clearing-detail',
50
+ name: 'ClearingDetail',
51
+ component: () => import('@/views/clearing-detail/index.vue'),
52
+ meta: { requiresAuth: true },
53
+ },
54
+ {
55
+ path: '/warning',
56
+ name: 'Warning',
57
+ component: () => import('@/views/warning/index.vue'),
58
+ meta: { requiresAuth: true },
59
+ },
60
+ ],
61
+ })
62
+
63
+ router.beforeEach((to) => {
64
+ const userStore = useUserStore()
65
+ if (to.meta.requiresAuth && !userStore.token) {
66
+ return { name: 'Login' }
67
+ }
68
+ })
69
+
70
+ export default router
@@ -0,0 +1,24 @@
1
+ import { defineStore } from 'pinia'
2
+ import { isNativeApp } from '@/core/mxApi'
3
+
4
+ /**
5
+ * 应用级状态 Store
6
+ *
7
+ * 存放全局共享的运行时状态,不持久化。
8
+ * initNativeDetection 在 main.ts 挂载前调用,组件读取时值已就绪。
9
+ */
10
+ export const useAppStore = defineStore('app', () => {
11
+ /** 是否在原生 APP WebView 环境中 */
12
+ const isNative = ref(false)
13
+
14
+ /**
15
+ * 初始化原生环境检测
16
+ *
17
+ * 判断当前运行环境是否存在敏行宿主能力。
18
+ */
19
+ function initNativeDetection() {
20
+ isNative.value = isNativeApp()
21
+ }
22
+
23
+ return { isNative, initNativeDetection }
24
+ })
@@ -0,0 +1,12 @@
1
+ import { ref, computed } from 'vue'
2
+ import { defineStore } from 'pinia'
3
+
4
+ export const useCounterStore = defineStore('counter', () => {
5
+ const count = ref(0)
6
+ const doubleCount = computed(() => count.value * 2)
7
+ function increment() {
8
+ count.value++
9
+ }
10
+
11
+ return { count, doubleCount, increment }
12
+ })
@@ -0,0 +1,52 @@
1
+ import { defineStore } from 'pinia'
2
+
3
+ const TOKEN_KEY = 'token'
4
+
5
+ /**
6
+ * 用户状态 Store
7
+ *
8
+ * 使用 Composition API 风格(setup 语法)定义,通过 pinia-plugin-persistedstate
9
+ * 自动将 state 持久化到 localStorage,刷新页面后状态不会丢失。
10
+ */
11
+ export const useUserStore = defineStore(
12
+ 'user',
13
+
14
+ () => {
15
+ // -------------------------------- State --------------------------------
16
+
17
+ /** 登录凭证,登录成功后由后端返回,后续请求通过请求头携带 */
18
+ const token = ref('')
19
+
20
+ // ------------------------------ Actions --------------------------------
21
+
22
+ /**
23
+ * 设置 token
24
+ * 登录成功后调用,触发 persist 插件自动写入 localStorage
25
+ */
26
+ function setToken(value: string) {
27
+ token.value = value
28
+ localStorage.setItem(TOKEN_KEY, value)
29
+ }
30
+
31
+ /**
32
+ * 清空 token
33
+ * 退出登录时调用,触发 persist 插件自动清除 localStorage 对应条目
34
+ */
35
+ function clearToken() {
36
+ token.value = ''
37
+ localStorage.removeItem(TOKEN_KEY)
38
+ }
39
+
40
+ // ----------------------------- Return ----------------------------------
41
+
42
+ return { token, setToken, clearToken }
43
+ },
44
+
45
+ /**
46
+ * 持久化配置
47
+ * true = 全量持久化(state 中所有字段自动写入/恢复 localStorage)
48
+ * 如需精细控制,可替换为对象形式:
49
+ * persist: { key: 'user', storage: localStorage, paths: ['token'] }
50
+ */
51
+ { persist: true },
52
+ )
@@ -0,0 +1,14 @@
1
+ /** 后端统一响应格式 */
2
+ export interface ApiResponse<T = unknown> {
3
+ code: number
4
+ message: string
5
+ data: T
6
+ }
7
+
8
+ /** 分页响应 */
9
+ export interface PaginatedData<T> {
10
+ list: T[]
11
+ total: number
12
+ page: number
13
+ pageSize: number
14
+ }
@@ -0,0 +1,8 @@
1
+ declare module 'nprogress' {
2
+ const NProgress: {
3
+ configure(options: { showSpinner?: boolean }): void
4
+ start(): void
5
+ done(): void
6
+ }
7
+ export default NProgress
8
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 将 query 对象拼接到 URL 上
3
+ *
4
+ * 自动过滤 undefined/null 值,支持数组参数。
5
+ */
6
+ export function appendQuery(url: string, query?: Record<string, unknown>): string {
7
+ if (!query) return url
8
+
9
+ const searchParams = new URLSearchParams()
10
+ Object.entries(query).forEach(([key, value]) => {
11
+ if (value === undefined || value === null) return
12
+ if (Array.isArray(value)) {
13
+ value.forEach((item) => {
14
+ if (item !== undefined && item !== null) {
15
+ searchParams.append(key, String(item))
16
+ }
17
+ })
18
+ return
19
+ }
20
+ searchParams.append(key, String(value))
21
+ })
22
+
23
+ const queryString = searchParams.toString()
24
+ if (!queryString) return url
25
+
26
+ return `${url}${url.includes('?') ? '&' : '?'}${queryString}`
27
+ }