verce-vue-test 0.0.43 → 0.0.45

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 (77) hide show
  1. package/package.json +1 -1
  2. package/src/utils/homeBalance.ts +5 -92
  3. package/src/views/HomeView.vue +27 -25
  4. package/888/1 +0 -121
  5. package/888/mini2.0-main/.editorconfig +0 -8
  6. package/888/mini2.0-main/.env.development +0 -3
  7. package/888/mini2.0-main/.env.production +0 -3
  8. package/888/mini2.0-main/.env.test +0 -3
  9. package/888/mini2.0-main/.gitattributes +0 -1
  10. package/888/mini2.0-main/.oxlintrc.json +0 -10
  11. package/888/mini2.0-main/.prettierrc.json +0 -6
  12. package/888/mini2.0-main/.vscode/extensions.json +0 -9
  13. package/888/mini2.0-main/README.md +0 -179
  14. package/888/mini2.0-main/auto-imports.d.ts +0 -629
  15. package/888/mini2.0-main/components.d.ts +0 -21
  16. package/888/mini2.0-main/design-qa.md +0 -36
  17. package/888/mini2.0-main/docs/MX_API.md +0 -244
  18. package/888/mini2.0-main/docs/REQUEST.md +0 -217
  19. package/888/mini2.0-main/docs/jsapi.js +0 -515
  20. package/888/mini2.0-main/docs/package-json-guide.md +0 -132
  21. package/888/mini2.0-main/env.d.ts +0 -15
  22. package/888/mini2.0-main/eslint.config.ts +0 -26
  23. package/888/mini2.0-main/index.html +0 -16
  24. package/888/mini2.0-main/output/playwright/rmb-position/design-comparison.png +0 -0
  25. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-back-top.png +0 -0
  26. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-page.png +0 -0
  27. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-sticky-check.png +0 -0
  28. package/888/mini2.0-main/output/playwright/rmb-position/rmb-position-sticky-scrolled.png +0 -0
  29. package/888/mini2.0-main/package-lock.json +0 -6442
  30. package/888/mini2.0-main/package.json +0 -66
  31. package/888/mini2.0-main/plugins/bump-version.ts +0 -61
  32. package/888/mini2.0-main/postcss.config.ts +0 -15
  33. package/888/mini2.0-main/public/favicon.ico +0 -0
  34. package/888/mini2.0-main/public/images/12a73787-86a9-4891-a65f-66104746f6a8.png +0 -0
  35. package/888/mini2.0-main/public/images/5798d7aa-ba8b-4605-8079-58b35495ac55.png +0 -0
  36. package/888/mini2.0-main/public/images/73fef1e4-0fd0-4a1a-9b8b-a70a5b6acbbc.png +0 -0
  37. package/888/mini2.0-main/public/images/bc685b4c-0cca-4a79-924c-a8ee10e6f8eb.png +0 -0
  38. package/888/mini2.0-main/public/images/c3dbbd9d-be56-490e-b9f4-6ee17ebefffc.png +0 -0
  39. package/888/mini2.0-main/public/images/ea745a10-42aa-4f44-8d7f-3ab02cc0adcd.png +0 -0
  40. package/888/mini2.0-main/public/images/f5876785-b927-4347-ba19-999114240649.png +0 -0
  41. package/888/mini2.0-main/public/images/img.png +0 -0
  42. package/888/mini2.0-main/src/App.vue +0 -59
  43. package/888/mini2.0-main/src/api/health.ts +0 -13
  44. package/888/mini2.0-main/src/api/rmb-position.ts +0 -287
  45. package/888/mini2.0-main/src/api/user.ts +0 -54
  46. package/888/mini2.0-main/src/auto-imports.d.ts +0 -639
  47. package/888/mini2.0-main/src/components.d.ts +0 -30
  48. package/888/mini2.0-main/src/config/config.properties +0 -3
  49. package/888/mini2.0-main/src/config/env.ts +0 -6
  50. package/888/mini2.0-main/src/config/plugin.properties.pro +0 -6
  51. package/888/mini2.0-main/src/config/plugin.properties.test +0 -6
  52. package/888/mini2.0-main/src/core/mxApi/index.ts +0 -344
  53. package/888/mini2.0-main/src/core/request/index.ts +0 -135
  54. package/888/mini2.0-main/src/main.ts +0 -39
  55. package/888/mini2.0-main/src/router/index.ts +0 -77
  56. package/888/mini2.0-main/src/stores/app.ts +0 -24
  57. package/888/mini2.0-main/src/stores/counter.ts +0 -12
  58. package/888/mini2.0-main/src/stores/user.ts +0 -85
  59. package/888/mini2.0-main/src/types/api.d.ts +0 -14
  60. package/888/mini2.0-main/src/types/nprogress.d.ts +0 -8
  61. package/888/mini2.0-main/src/utils/auth-token.ts +0 -197
  62. package/888/mini2.0-main/src/utils/query.ts +0 -27
  63. package/888/mini2.0-main/src/utils/request.ts +0 -233
  64. package/888/mini2.0-main/src/views/clearing-detail/index.vue +0 -49
  65. package/888/mini2.0-main/src/views/foreign-position/index.vue +0 -49
  66. package/888/mini2.0-main/src/views/home/index.vue +0 -213
  67. package/888/mini2.0-main/src/views/login/index.vue +0 -202
  68. package/888/mini2.0-main/src/views/mine/index.vue +0 -143
  69. package/888/mini2.0-main/src/views/net-debit/index.vue +0 -49
  70. package/888/mini2.0-main/src/views/pbc-position/index.vue +0 -49
  71. package/888/mini2.0-main/src/views/position-estimate/index.vue +0 -49
  72. package/888/mini2.0-main/src/views/rmb-position/index.vue +0 -1042
  73. package/888/mini2.0-main/src/views/warning/index.vue +0 -49
  74. package/888/mini2.0-main/tsconfig.app.json +0 -18
  75. package/888/mini2.0-main/tsconfig.json +0 -11
  76. package/888/mini2.0-main/tsconfig.node.json +0 -28
  77. package/888/mini2.0-main/vite.config.ts +0 -98
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -3,89 +3,14 @@ export type HomeBalanceAmount = {
3
3
  decimal: string
4
4
  }
5
5
 
6
- export type HomeBalanceData = Partial<Record<string, HomeBalanceAmount>>
7
-
8
- type PlainObject = Record<string, unknown>
9
-
10
- const DIRECT_FIELDS: Record<string, string[]> = {
11
- rmb: ['balanceAmt', 'balanceAmount', 'availableBalance', 'rmbAmount', 'cnyAmount'],
12
- clearing: ['settleAccount', 'settleAmount', 'clearingAmount'],
13
- 'cross-border-rmb': ['crossBorderRmbAmount', 'crossBorderAmount'],
14
- 'digital-currency': ['dccyAvailableAmt', 'dccyAvailableAmount', 'digitalCurrencyAmount'],
15
- }
16
-
17
- const FOREIGN_CARD_ID: Record<string, string> = {
18
- USD: 'usd',
19
- EUR: 'eur',
20
- HKD: 'hkd',
21
- JPY: 'jpy',
22
- }
23
-
24
6
  /**
25
- * 把首页余额接口原始数据转换成页面需要的金额展示数据。
7
+ * 把单个金额值转换成首页卡片展示需要的金额结构。
26
8
  *
27
- * 当前只处理两类返回:
28
- * - 人民币类字段在 body 上,例如 balanceAmt / settleAccount
29
- * - 外币字段在 body.resultInfos 数组里,例如 { ccy: 'USD', mainAcctAmt: '47631' }
9
+ * 示例:
10
+ * formatHomeBalanceAmount('316789101.25')
11
+ * => { amount: '316,789,101', decimal: '.25' }
30
12
  */
31
- export function transformHomeBalanceData(payload: unknown): HomeBalanceData {
32
- const body = getBody(payload)
33
- const result: HomeBalanceData = {}
34
-
35
- Object.entries(DIRECT_FIELDS).forEach(([cardId, fields]) => {
36
- const value = pickValue(body, fields)
37
-
38
- if (value !== undefined) {
39
- result[cardId] = formatAmount(value)
40
- }
41
- })
42
-
43
- Object.entries(collectForeignAmounts(body)).forEach(([cardId, amount]) => {
44
- result[cardId] = formatAmount(amount)
45
- })
46
-
47
- return result
48
- }
49
-
50
- function getBody(payload: unknown) {
51
- const root = toObject(payload)
52
-
53
- return toObject(root?.body) ?? root ?? {}
54
- }
55
-
56
- function collectForeignAmounts(body: PlainObject) {
57
- const rows = Array.isArray(body.resultInfos) ? body.resultInfos : []
58
- const totals: Record<string, number> = {}
59
-
60
- rows.forEach((row) => {
61
- const item = toObject(row)
62
- const currency = String(item?.ccy ?? '').toUpperCase()
63
- const cardId = FOREIGN_CARD_ID[currency]
64
- const amount = toNumber(item?.mainAcctAmt)
65
-
66
- if (!cardId || !Number.isFinite(amount)) {
67
- return
68
- }
69
-
70
- totals[cardId] = (totals[cardId] ?? 0) + amount
71
- })
72
-
73
- return totals
74
- }
75
-
76
- function pickValue(source: PlainObject, fields: string[]) {
77
- for (const field of fields) {
78
- const value = source[field]
79
-
80
- if (value !== null && value !== undefined && value !== '') {
81
- return value
82
- }
83
- }
84
-
85
- return undefined
86
- }
87
-
88
- function formatAmount(value: unknown): HomeBalanceAmount {
13
+ export function formatHomeBalanceAmount(value: unknown): HomeBalanceAmount {
89
14
  const text = normalizeNumberText(value)
90
15
 
91
16
  if (!text) {
@@ -103,12 +28,6 @@ function formatAmount(value: unknown): HomeBalanceAmount {
103
28
  }
104
29
  }
105
30
 
106
- function toNumber(value: unknown) {
107
- const text = normalizeNumberText(value)
108
-
109
- return text ? Number(text) : Number.NaN
110
- }
111
-
112
31
  function normalizeNumberText(value: unknown) {
113
32
  const raw = String(value ?? '').trim()
114
33
 
@@ -125,9 +44,3 @@ function normalizeNumberText(value: unknown) {
125
44
  function addThousands(value: string) {
126
45
  return value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
127
46
  }
128
-
129
- function toObject(value: unknown): PlainObject | undefined {
130
- return Object.prototype.toString.call(value) === '[object Object]'
131
- ? value as PlainObject
132
- : undefined
133
- }
@@ -23,13 +23,13 @@ import cardCrossBorderBg from '@/assets/home/card-cross-border-map.png'
23
23
  import cardHkdBg from '@/assets/home/card-hkd-skyline.png'
24
24
  import cardDigitalBg from '@/assets/home/card-digital-currency.png'
25
25
  import cardJpyBg from '@/assets/home/card-jpy-fuji.png'
26
- import { transformHomeBalanceData } from '@/utils/homeBalance'
26
+ import { formatHomeBalanceAmount } from '@/utils/homeBalance'
27
27
 
28
28
  /**
29
29
  * 首页余额卡片的渲染模型。
30
30
  *
31
31
  * 注意:
32
- * - id 会和 src/utils/homeBalance.ts 转换出的字段对应,接口转换后按 id 回填金额。
32
+ * - id 用于按卡片更新金额;接口字段由调用方自己取值。
33
33
  * - amount / decimal 分开存放,是为了让整数位和小数位在视觉上使用不同字号。
34
34
  * - background / accent 系列字段只负责视觉,不参与接口转换。
35
35
  */
@@ -65,8 +65,8 @@ const router = useRouter()
65
65
  /**
66
66
  * 首页余额卡片的默认展示数据。
67
67
  *
68
- * 后续对接接口时不用直接改这个数组结构,只需要把接口结果传给
69
- * updateBalanceCardsFromApi(payload),转换工具只会按 id 返回 amount / decimal。
68
+ * 后续对接接口时不用直接改这个数组结构,调用方取到具体金额值后,
69
+ * 通过 updateBalanceCardAmount(cardId, value) 更新指定卡片。
70
70
  */
71
71
  const balanceCards = ref<BalanceCard[]>([
72
72
  {
@@ -207,28 +207,25 @@ function isLongAmount(card: BalanceCard) {
207
207
  }
208
208
 
209
209
  /**
210
- * 首页接口接入点。
210
+ * 首页单个金额更新入口。
211
211
  *
212
212
  * 用法示例:
213
- * const res = await fetchHomeBalance()
214
- * updateBalanceCardsFromApi(res)
213
+ * updateBalanceCardAmount('rmb', res.body.balanceAmt)
214
+ * updateBalanceCardAmount('usd', usdItem.mainAcctAmt)
215
215
  *
216
- * 该方法只负责把转换后的金额更新到静态卡片;
217
- * 请求、错误提示、loading 状态可以在调用方自行处理。
216
+ * 这里不读取后端返回结构,只负责把单个金额值格式化后更新到指定卡片。
218
217
  */
219
- function updateBalanceCardsFromApi(payload: unknown) {
220
- const nextBalance = transformHomeBalanceData(payload)
218
+ function updateBalanceCardAmount(cardId: string, value: unknown) {
219
+ const amount = formatHomeBalanceAmount(value)
221
220
 
222
221
  balanceCards.value = balanceCards.value.map((card) => {
223
- const amount = nextBalance[card.id]
224
-
225
- return amount ? { ...card, ...amount } : card
222
+ return card.id === cardId ? { ...card, ...amount } : card
226
223
  })
227
224
  updatedAt.value = formatDateTime(new Date())
228
225
  }
229
226
 
230
227
  defineExpose({
231
- updateBalanceCardsFromApi,
228
+ updateBalanceCardAmount,
232
229
  })
233
230
 
234
231
  function formatDateTime(date: Date) {
@@ -368,7 +365,7 @@ function formatDateTime(date: Date) {
368
365
  min-height: 0;
369
366
  }
370
367
 
371
- /* 外层主面板只保留一层外边框;内部余额项不再额外套描边,避免“卡片套卡片”。 */
368
+ /* 外层主面板保留一层外边框;每个币种项单独使用轻量彩色边框表达分组。 */
372
369
  .balance-panel {
373
370
  position: relative;
374
371
  display: grid;
@@ -497,34 +494,39 @@ function formatDateTime(date: Date) {
497
494
  min-height: 0;
498
495
  overflow: hidden;
499
496
  padding: 0 clamp(0.55rem, 1vw, 1.05rem) 0 clamp(0.5rem, 0.9vw, 0.95rem);
500
- border: none;
497
+ border: 1px solid var(--card-border);
501
498
  border-radius: var(--card-radius);
502
499
  background:
503
500
  linear-gradient(90deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
504
501
  #ffffff;
505
502
  box-shadow:
503
+ 0 0 0 1px color-mix(in srgb, var(--accent-soft) 42%, rgba(255, 255, 255, 0.72)) inset,
506
504
  0 0.12rem clamp(0.28rem, 0.5vw, 0.55rem) color-mix(in srgb, var(--card-glow) 55%, transparent),
507
505
  0 0 clamp(0.4rem, 0.75vw, 0.85rem) rgba(255, 255, 255, 0.76) inset,
508
- -0.16rem 0 0 var(--accent) inset;
506
+ 0.24rem 0 0 var(--accent) inset;
509
507
  }
510
508
 
511
- /* 左侧色条保留币种识别,但不使用完整边框,降低内部卡片感。 */
509
+ /* 左侧色条拉满高度并提升层级,避免被卡片底图或柔光覆盖。 */
512
510
  .balance-card::before {
513
511
  position: absolute;
514
- top: 11%;
515
- bottom: 11%;
512
+ top: 0;
513
+ bottom: 0;
516
514
  left: 0;
517
- width: clamp(0.15rem, 0.22vw, 0.24rem);
515
+ z-index: 2;
516
+ width: clamp(0.24rem, 0.34vw, 0.38rem);
518
517
  content: "";
519
- border-radius: 0 99px 99px 0;
518
+ border-radius: var(--card-radius) 0 0 var(--card-radius);
520
519
  background: linear-gradient(180deg, var(--accent-soft), var(--accent-deep));
521
- box-shadow: 0 0 clamp(0.45rem, 0.85vw, 1rem) var(--card-glow);
520
+ box-shadow:
521
+ 0.08rem 0 0 color-mix(in srgb, var(--accent-soft) 62%, rgba(255, 255, 255, 0.82)),
522
+ 0 0 clamp(0.45rem, 0.85vw, 1rem) var(--card-glow);
522
523
  }
523
524
 
524
525
  /* 柔光覆盖层让底图和金额文字有层次;不参与交互。 */
525
526
  .balance-card::after {
526
527
  position: absolute;
527
528
  inset: 0;
529
+ z-index: 1;
528
530
  content: "";
529
531
  pointer-events: none;
530
532
  background:
@@ -548,7 +550,7 @@ function formatDateTime(date: Date) {
548
550
  .balance-card h2,
549
551
  .amount-block {
550
552
  position: relative;
551
- z-index: 1;
553
+ z-index: 3;
552
554
  }
553
555
 
554
556
  .badge-shell {
package/888/1 DELETED
@@ -1,121 +0,0 @@
1
- <template>
2
- <el-dialog
3
- v-model="dialogVisible"
4
- :title="isEdit ? '编辑用户' : '新增用户'"
5
- width="520px"
6
- destroy-on-close
7
- @closed="resetForm"
8
- >
9
- <el-form ref="formRef" :model="form" :rules="rules" label-width="90px">
10
- <el-form-item label="用户名" prop="username">
11
- <el-input v-model="form.username" />
12
- </el-form-item>
13
-
14
- <el-form-item label="手机号" prop="phone">
15
- <el-input v-model="form.phone" />
16
- </el-form-item>
17
-
18
- <el-form-item label="状态" prop="status">
19
- <el-radio-group v-model="form.status">
20
- <el-radio :value="1">启用</el-radio>
21
- <el-radio :value="0">禁用</el-radio>
22
- </el-radio-group>
23
- </el-form-item>
24
- </el-form>
25
-
26
- <template #footer>
27
- <el-button @click="dialogVisible = false">取消</el-button>
28
- <el-button type="primary" :loading="loading" @click="handleSubmit">
29
- 保存
30
- </el-button>
31
- </template>
32
- </el-dialog>
33
- </template>
34
-
35
- <script setup>
36
- import { computed, reactive, ref, watch } from 'vue'
37
- import { ElMessage } from 'element-plus'
38
-
39
- const props = defineProps({
40
- modelValue: {
41
- type: Boolean,
42
- default: false
43
- },
44
- mode: {
45
- type: String,
46
- default: 'create'
47
- },
48
- rowData: {
49
- type: Object,
50
- default: () => null
51
- }
52
- })
53
-
54
- const emit = defineEmits(['update:modelValue', 'success'])
55
-
56
- const dialogVisible = computed({
57
- get: () => props.modelValue,
58
- set: value => emit('update:modelValue', value)
59
- })
60
-
61
- const isEdit = computed(() => props.mode === 'edit')
62
-
63
- const formRef = ref()
64
- const loading = ref(false)
65
-
66
- const defaultForm = {
67
- id: null,
68
- username: '',
69
- phone: '',
70
- status: 1
71
- }
72
-
73
- const form = reactive({ ...defaultForm })
74
-
75
- const rules = {
76
- username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
77
- phone: [{ required: true, message: '请输入手机号', trigger: 'blur' }]
78
- }
79
-
80
- watch(
81
- () => props.modelValue,
82
- visible => {
83
- if (!visible) return
84
-
85
- Object.assign(form, defaultForm)
86
-
87
- if (props.mode === 'edit' && props.rowData) {
88
- Object.assign(form, props.rowData)
89
- }
90
-
91
- formRef.value?.clearValidate()
92
- }
93
- )
94
-
95
- const resetForm = () => {
96
- Object.assign(form, defaultForm)
97
- formRef.value?.clearValidate()
98
- }
99
-
100
- const handleSubmit = async () => {
101
- await formRef.value.validate()
102
-
103
- loading.value = true
104
- try {
105
- if (isEdit.value) {
106
- // await updateUserApi(form.id, form)
107
- console.log('编辑:', form)
108
- ElMessage.success('修改成功')
109
- } else {
110
- // await createUserApi(form)
111
- console.log('新增:', form)
112
- ElMessage.success('新增成功')
113
- }
114
-
115
- dialogVisible.value = false
116
- emit('success')
117
- } finally {
118
- loading.value = false
119
- }
120
- }
121
- </script>
@@ -1,8 +0,0 @@
1
- [*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}]
2
- charset = utf-8
3
- indent_size = 2
4
- indent_style = space
5
- insert_final_newline = true
6
- trim_trailing_whitespace = true
7
- end_of_line = lf
8
- max_line_length = 100
@@ -1,3 +0,0 @@
1
- VITE_APP_ENV=development
2
- VITE_API_BASE_URL=/oms
3
- VITE_API_TIMEOUT=10000
@@ -1,3 +0,0 @@
1
- VITE_APP_ENV=production
2
- VITE_API_BASE_URL=https://api.example.com
3
- VITE_API_TIMEOUT=10000
@@ -1,3 +0,0 @@
1
- VITE_APP_ENV=test
2
- VITE_API_BASE_URL=http://10.56.183.8090/oms
3
- VITE_API_TIMEOUT=10000
@@ -1 +0,0 @@
1
- * text=auto eol=lf
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "./node_modules/oxlint/configuration_schema.json",
3
- "plugins": ["eslint", "typescript", "unicorn", "oxc", "vue"],
4
- "env": {
5
- "browser": true
6
- },
7
- "categories": {
8
- "correctness": "error"
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/prettierrc",
3
- "semi": false,
4
- "singleQuote": true,
5
- "printWidth": 100
6
- }
@@ -1,9 +0,0 @@
1
- {
2
- "recommendations": [
3
- "Vue.volar",
4
- "dbaeumer.vscode-eslint",
5
- "EditorConfig.EditorConfig",
6
- "oxc.oxc-vscode",
7
- "esbenp.prettier-vscode"
8
- ]
9
- }
@@ -1,179 +0,0 @@
1
- # mini2.0 项目说明
2
-
3
- ## 项目概述
4
-
5
- 基于 Vue 3 + TypeScript + Vant 的移动端混合应用模板,已集成敏行原生桥接 API。
6
-
7
- ## 技术栈
8
-
9
- | 技术 | 版本 | 用途 |
10
- |------|------|------|
11
- | Vue 3 | ^3.5 | 前端框架 |
12
- | TypeScript | ^6.0 | 类型检查 |
13
- | Vite | ^8.0 | 构建工具 |
14
- | Vant | ^4.9 | 移动端 UI 组件库 |
15
- | Pinia | ^3.0 | 状态管理 |
16
- | Vue Router | ^5.0 | 路由管理 |
17
- | Axios | ^1.16 | HTTP 客户端 |
18
-
19
- ## 目录结构
20
-
21
- ```
22
- mini2.0/
23
- ├── src/
24
- │ ├── core/
25
- │ │ └── mxApi/
26
- │ │ └── index.ts # 原生桥接 API
27
- │ ├── api/ # API 接口定义
28
- │ ├── config/
29
- │ │ └── env.ts # 环境配置
30
- │ ├── router/ # 路由配置
31
- │ ├── stores/ # Pinia 状态管理
32
- │ ├── types/ # TypeScript 类型定义
33
- │ ├── utils/
34
- │ │ └── request.ts # axios 封装
35
- │ ├── views/ # 页面视图
36
- │ ├── App.vue # 根组件
37
- │ └── main.ts # 入口文件
38
- ├── docs/
39
- │ └── MX_API.md # 原生 API 文档
40
- ├── vite.config.ts # Vite 配置
41
- └── package.json
42
- ```
43
-
44
- ## 两种 HTTP 请求方案
45
-
46
- ### 1. axios(默认,浏览器环境)
47
-
48
- ```typescript
49
- import { request } from '@/utils/request'
50
-
51
- const res = await request({
52
- url: '/api/users',
53
- method: 'GET',
54
- params: { page: 1 }
55
- })
56
- ```
57
-
58
- ### 2. 原生 AJAX(绕过跨域)
59
-
60
- ```typescript
61
- import { ajaxGet } from '@/core/mxApi'
62
-
63
- const { data } = await ajaxGet('/api/users', { page: 1 })
64
- ```
65
-
66
- ## 智能切换示例
67
-
68
- ```typescript
69
- import { isNativeApp, ajaxGet as nativeGet } from '@/core/mxApi'
70
- import { request } from '@/utils/request'
71
-
72
- export async function fetchUsers(page: number) {
73
- if (isNativeApp()) {
74
- return (await nativeGet('/api/users', { page })).data
75
- } else {
76
- return (await request({ url: '/api/users', params: { page } })).data
77
- }
78
- }
79
- ```
80
-
81
- ## 开发命令
82
-
83
- ```bash
84
- # 开发环境
85
- npm run dev
86
-
87
- # 测试环境
88
- npm run dev:test
89
-
90
- # 生产构建
91
- npm run build:prod
92
-
93
- # 类型检查
94
- npm run type-check
95
-
96
- # 代码检查
97
- npm run lint
98
- ```
99
-
100
- ## 环境变量配置
101
-
102
- 创建 `.env` 文件:
103
-
104
- ```bash
105
- # API 基础地址
106
- VITE_API_BASE_URL=/api
107
-
108
- # API 超时时间(毫秒)
109
- VITE_API_TIMEOUT=10000
110
-
111
- # 代理目标(开发环境)
112
- VITE_PROXY_TARGET=http://localhost:3030
113
-
114
- # 应用环境
115
- VITE_APP_ENV=development
116
- ```
117
-
118
- ## 原生 API 使用
119
-
120
- 详见 [MX_API.md](./MX_API.md)
121
-
122
- ```typescript
123
- import {
124
- hideWebViewTitle,
125
- getCurrentUser,
126
- MXSelectUsers,
127
- isNativeApp
128
- } from '@/core/mxApi'
129
-
130
- // 检测环境
131
- if (isNativeApp()) {
132
- // 获取用户
133
- const user = await getCurrentUser()
134
-
135
- // 选人
136
- const users = await MXSelectUsers()
137
- }
138
- ```
139
-
140
- ## Vant 组件使用
141
-
142
- 自动导入,无需手动引入:
143
-
144
- ```vue
145
- <template>
146
- <van-button type="primary" @click="handleClick">按钮</van-button>
147
- <van-cell title="标题" value="内容" />
148
- </template>
149
-
150
- <script setup lang="ts">
151
- // showToast 已自动导入
152
- const handleClick = () => {
153
- showToast('Hello')
154
- }
155
- </script>
156
- ```
157
-
158
- ## 构建产物
159
-
160
- ```bash
161
- npm run build:prod
162
-
163
- # 输出到 dist/ 目录
164
- # 部署到敏行 App 的资源目录即可
165
- ```
166
-
167
- ## 注意事项
168
-
169
- 1. **原生 API 集成**:`src/core/mxApi/index.ts` 是核心,已适配 TypeScript
170
- 2. **自动导入**:Vant 组件和 Vue API 已配置自动导入
171
- 3. **移动端适配**:使用 postcss-px-to-viewport 插件
172
- 4. **环境变量**:所有配置通过 `.env` 文件管理
173
-
174
- ## 下一步
175
-
176
- 1. 根据业务需求创建页面(`src/views/`)
177
- 2. 定义 API 接口(`src/api/`)
178
- 3. 配置路由(`src/router/`)
179
- 4. 创建状态管理(`src/stores/`)