verce-vue-test 0.0.59 → 0.0.60

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.
@@ -0,0 +1,61 @@
1
+ - generic [active] [ref=e1]:
2
+ - generic [ref=e3]:
3
+ - banner [ref=e4]:
4
+ - generic [ref=e5]:
5
+ - heading "头寸管理平台" [level=1]
6
+ - group "页面操作" [ref=e9]:
7
+ - button "更多" [ref=e10] [cursor=pointer]
8
+ - button "关闭" [ref=e16] [cursor=pointer]
9
+ - main [ref=e82]:
10
+ - region "欢迎登录头寸管理系统" [ref=e83]:
11
+ - img "欢迎登录头寸管理系统" [ref=e84]
12
+ - generic [ref=e85]:
13
+ - heading "常用功能" [level=2] [ref=e88]
14
+ - generic [ref=e89]:
15
+ - button "人民币头寸 预报及查询 人民币头寸预报及查询" [ref=e90]:
16
+ - generic [ref=e91]:
17
+ - generic [ref=e92]: 人民币头寸
18
+ - generic [ref=e93]: 预报及查询
19
+ - generic [ref=e95]: 
20
+ - img "人民币头寸预报及查询"
21
+ - button "外币头寸 预报及查询 外币头寸预报及查询" [ref=e96]:
22
+ - generic [ref=e97]:
23
+ - generic [ref=e98]: 外币头寸
24
+ - generic [ref=e99]: 预报及查询
25
+ - generic [ref=e101]: 
26
+ - img "外币头寸预报及查询"
27
+ - button "人行头寸 余额查询 人行头寸余额查询" [ref=e102]:
28
+ - generic [ref=e103]:
29
+ - generic [ref=e104]: 人行头寸
30
+ - generic [ref=e105]: 余额查询
31
+ - generic [ref=e107]: 
32
+ - img "人行头寸余额查询"
33
+ - button "头寸匡算 头寸匡算" [ref=e108]:
34
+ - generic [ref=e110]: 头寸匡算
35
+ - generic [ref=e112]: 
36
+ - img "头寸匡算"
37
+ - button "人民币净借记 可用额度管理 人民币净借记可用额度管理" [ref=e113]:
38
+ - generic [ref=e114]:
39
+ - generic [ref=e115]: 人民币净借记
40
+ - generic [ref=e116]: 可用额度管理
41
+ - generic [ref=e118]: 
42
+ - img "人民币净借记可用额度管理"
43
+ - button "人民币小额网银 清算场次明细 人民币小额网银清算场次明细" [ref=e119]:
44
+ - generic [ref=e120]:
45
+ - generic [ref=e121]: 人民币小额网银
46
+ - generic [ref=e122]: 清算场次明细
47
+ - generic [ref=e124]: 
48
+ - img "人民币小额网银清算场次明细"
49
+ - button "预警信息 预警信息" [ref=e125]:
50
+ - generic [ref=e127]: 预警信息
51
+ - generic [ref=e129]: 
52
+ - img "预警信息"
53
+ - tablist [ref=e131]:
54
+ - tab " 首页" [selected] [ref=e132] [cursor=pointer]:
55
+ - generic [ref=e134]: 
56
+ - generic [ref=e135]: 首页
57
+ - tab " 我的" [ref=e136] [cursor=pointer]:
58
+ - generic [ref=e138]: 
59
+ - generic [ref=e139]: 我的
60
+ - dialog [ref=e76]:
61
+ - generic [ref=e77]: 连接错误 502
@@ -0,0 +1,66 @@
1
+ - generic [ref=e3]:
2
+ - banner [ref=e4]:
3
+ - generic [ref=e5]:
4
+ - heading "头寸管理平台" [level=1]
5
+ - generic [ref=e6]:
6
+ - group "页面操作" [ref=e7]:
7
+ - button "更多" [expanded] [active] [ref=e8] [cursor=pointer]
8
+ - button "关闭" [ref=e14] [cursor=pointer]
9
+ - menu "更多菜单" [ref=e76]:
10
+ - menuitem " 回到首页" [ref=e77] [cursor=pointer]:
11
+ - generic [ref=e78]: 
12
+ - generic [ref=e79]: 回到首页
13
+ - menuitem " 设置" [ref=e80] [cursor=pointer]:
14
+ - generic [ref=e81]: 
15
+ - generic [ref=e82]: 设置
16
+ - main [ref=e16]:
17
+ - region "欢迎登录头寸管理系统" [ref=e17]:
18
+ - img "欢迎登录头寸管理系统" [ref=e18]
19
+ - generic [ref=e19]:
20
+ - heading "常用功能" [level=2] [ref=e22]
21
+ - generic [ref=e23]:
22
+ - button "人民币头寸 预报及查询 人民币头寸预报及查询" [ref=e24]:
23
+ - generic [ref=e25]:
24
+ - generic [ref=e26]: 人民币头寸
25
+ - generic [ref=e27]: 预报及查询
26
+ - generic [ref=e29]: 
27
+ - img "人民币头寸预报及查询"
28
+ - button "外币头寸 预报及查询 外币头寸预报及查询" [ref=e30]:
29
+ - generic [ref=e31]:
30
+ - generic [ref=e32]: 外币头寸
31
+ - generic [ref=e33]: 预报及查询
32
+ - generic [ref=e35]: 
33
+ - img "外币头寸预报及查询"
34
+ - button "人行头寸 余额查询 人行头寸余额查询" [ref=e36]:
35
+ - generic [ref=e37]:
36
+ - generic [ref=e38]: 人行头寸
37
+ - generic [ref=e39]: 余额查询
38
+ - generic [ref=e41]: 
39
+ - img "人行头寸余额查询"
40
+ - button "头寸匡算 头寸匡算" [ref=e42]:
41
+ - generic [ref=e44]: 头寸匡算
42
+ - generic [ref=e46]: 
43
+ - img "头寸匡算"
44
+ - button "人民币净借记 可用额度管理 人民币净借记可用额度管理" [ref=e47]:
45
+ - generic [ref=e48]:
46
+ - generic [ref=e49]: 人民币净借记
47
+ - generic [ref=e50]: 可用额度管理
48
+ - generic [ref=e52]: 
49
+ - img "人民币净借记可用额度管理"
50
+ - button "人民币小额网银 清算场次明细 人民币小额网银清算场次明细" [ref=e53]:
51
+ - generic [ref=e54]:
52
+ - generic [ref=e55]: 人民币小额网银
53
+ - generic [ref=e56]: 清算场次明细
54
+ - generic [ref=e58]: 
55
+ - img "人民币小额网银清算场次明细"
56
+ - button "预警信息 预警信息" [ref=e59]:
57
+ - generic [ref=e61]: 预警信息
58
+ - generic [ref=e63]: 
59
+ - img "预警信息"
60
+ - tablist [ref=e65]:
61
+ - tab " 首页" [selected] [ref=e66] [cursor=pointer]:
62
+ - generic [ref=e68]: 
63
+ - generic [ref=e69]: 首页
64
+ - tab " 我的" [ref=e70] [cursor=pointer]:
65
+ - generic [ref=e72]: 
66
+ - generic [ref=e73]: 我的
@@ -29,11 +29,29 @@ const activeTab = computed({
29
29
  }
30
30
  },
31
31
  })
32
+
33
+ function goHomeFromCapsuleMenu() {
34
+ if (route.name !== 'Home') {
35
+ router.replace({ name: 'Home' })
36
+ }
37
+ }
38
+
39
+ function goSettingsFromCapsuleMenu() {
40
+ if (route.name !== 'Settings') {
41
+ router.push({ name: 'Settings' })
42
+ }
43
+ }
32
44
  </script>
33
45
 
34
46
  <template>
35
47
  <div class="app-shell">
36
- <AppTitleBar :title="headerTitle" :show-back="showHeaderBack" @back="router.back()" />
48
+ <AppTitleBar
49
+ :title="headerTitle"
50
+ :show-back="showHeaderBack"
51
+ @back="router.back()"
52
+ @menu-home="goHomeFromCapsuleMenu"
53
+ @menu-settings="goSettingsFromCapsuleMenu"
54
+ />
37
55
 
38
56
  <router-view v-slot="{ Component }">
39
57
  <keep-alive include="HomePage">
@@ -80,9 +80,11 @@ type PbcPositionSendBody = {
80
80
  refNo?: string
81
81
  }
82
82
 
83
- type PbcPositionQueryBody = {
84
- resultList?: PbcPositionRecord[]
85
- }
83
+ type PbcPositionQueryBody =
84
+ | PbcPositionRecord[]
85
+ | {
86
+ resultList?: PbcPositionRecord[]
87
+ }
86
88
 
87
89
  type PbcPositionDetailRequestBody = {
88
90
  refNo: string
@@ -142,7 +144,7 @@ export async function queryPbcPositionBalance(requestRefNo: string): Promise<Pbc
142
144
  console.log('[人行头寸余额查询1入参]', queryPayload)
143
145
 
144
146
  const queryResponse = await queryPbcPositionList(queryPayload)
145
- const records = queryResponse.body.resultList || []
147
+ const records = getPbcPositionRecords(queryResponse.body)
146
148
 
147
149
  if (records.length === 0) {
148
150
  throw new Error('人行头寸余额查询结果为空')
@@ -168,3 +170,9 @@ export async function queryPbcPositionBalance(requestRefNo: string): Promise<Pbc
168
170
 
169
171
  throw new Error(`未查询到编号 ${requestRefNo} 对应的余额结果`)
170
172
  }
173
+
174
+ function getPbcPositionRecords(body: PbcPositionQueryBody) {
175
+ if (Array.isArray(body)) return body
176
+
177
+ return body.resultList || []
178
+ }
@@ -10,7 +10,6 @@ declare global {
10
10
  const acceptHMRUpdate: typeof import('pinia').acceptHMRUpdate
11
11
  const asyncComputed: typeof import('@vueuse/core').asyncComputed
12
12
  const autoResetRef: typeof import('@vueuse/core').autoResetRef
13
- const closeToast: typeof import('vant').closeToast
14
13
  const computed: typeof import('vue').computed
15
14
  const computedAsync: typeof import('@vueuse/core').computedAsync
16
15
  const computedEager: typeof import('@vueuse/core').computedEager
@@ -107,8 +106,6 @@ declare global {
107
106
  const shallowRef: typeof import('vue').shallowRef
108
107
  const showConfirmDialog: typeof import('vant').showConfirmDialog
109
108
  const showDialog: typeof import('vant').showDialog
110
- const showLoadingToast: typeof import('vant').showLoadingToast
111
- const showToast: typeof import('vant').showToast
112
109
  const storeToRefs: typeof import('pinia').storeToRefs
113
110
  const syncRef: typeof import('@vueuse/core').syncRef
114
111
  const syncRefs: typeof import('@vueuse/core').syncRefs
@@ -331,7 +328,6 @@ declare module 'vue' {
331
328
  readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
332
329
  readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
333
330
  readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
334
- readonly closeToast: UnwrapRef<typeof import('vant')['closeToast']>
335
331
  readonly computed: UnwrapRef<typeof import('vue')['computed']>
336
332
  readonly computedAsync: UnwrapRef<typeof import('@vueuse/core')['computedAsync']>
337
333
  readonly computedEager: UnwrapRef<typeof import('@vueuse/core')['computedEager']>
@@ -428,8 +424,6 @@ declare module 'vue' {
428
424
  readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
429
425
  readonly showConfirmDialog: UnwrapRef<typeof import('vant')['showConfirmDialog']>
430
426
  readonly showDialog: UnwrapRef<typeof import('vant')['showDialog']>
431
- readonly showLoadingToast: UnwrapRef<typeof import('vant')['showLoadingToast']>
432
- readonly showToast: UnwrapRef<typeof import('vant')['showToast']>
433
427
  readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
434
428
  readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>
435
429
  readonly syncRefs: UnwrapRef<typeof import('@vueuse/core')['syncRefs']>
@@ -20,16 +20,64 @@ const emit = defineEmits<{
20
20
  back: []
21
21
  capsuleMore: []
22
22
  capsuleClose: []
23
+ menuHome: []
24
+ menuSettings: []
23
25
  }>()
24
26
 
27
+ const capsuleMenuOpen = ref(false)
28
+ const capsuleMenuRef = ref<HTMLElement | null>(null)
29
+
25
30
  onMounted(() => {
26
31
  hideWebViewTitle()
32
+ document.addEventListener('pointerdown', handleDocumentPointerDown)
33
+ document.addEventListener('keydown', handleDocumentKeydown)
34
+ })
35
+
36
+ onBeforeUnmount(() => {
37
+ document.removeEventListener('pointerdown', handleDocumentPointerDown)
38
+ document.removeEventListener('keydown', handleDocumentKeydown)
27
39
  })
28
40
 
29
41
  function handleCapsuleClose() {
42
+ closeCapsuleMenu()
30
43
  emit('capsuleClose')
31
44
  closeWindow()
32
45
  }
46
+
47
+ function toggleCapsuleMenu() {
48
+ capsuleMenuOpen.value = !capsuleMenuOpen.value
49
+ emit('capsuleMore')
50
+ }
51
+
52
+ function closeCapsuleMenu() {
53
+ capsuleMenuOpen.value = false
54
+ }
55
+
56
+ function handleMenuHome() {
57
+ closeCapsuleMenu()
58
+ emit('menuHome')
59
+ }
60
+
61
+ function handleMenuSettings() {
62
+ closeCapsuleMenu()
63
+ emit('menuSettings')
64
+ }
65
+
66
+ function handleDocumentPointerDown(event: PointerEvent) {
67
+ const target = event.target
68
+
69
+ if (!(target instanceof Node) || capsuleMenuRef.value?.contains(target)) {
70
+ return
71
+ }
72
+
73
+ closeCapsuleMenu()
74
+ }
75
+
76
+ function handleDocumentKeydown(event: KeyboardEvent) {
77
+ if (event.key === 'Escape') {
78
+ closeCapsuleMenu()
79
+ }
80
+ }
33
81
  </script>
34
82
 
35
83
  <template>
@@ -47,28 +95,55 @@ function handleCapsuleClose() {
47
95
 
48
96
  <h1 class="app-title-bar__title">{{ title }}</h1>
49
97
 
50
- <div class="app-title-bar__capsule" role="group" aria-label="页面操作">
51
- <button
52
- class="app-title-bar__capsule-btn"
53
- type="button"
54
- aria-label="更多"
55
- @click="emit('capsuleMore')"
56
- >
57
- <span class="app-title-bar__dots" aria-hidden="true">
58
- <i></i>
59
- <i></i>
60
- <i></i>
61
- </span>
62
- </button>
63
- <span class="app-title-bar__divider" aria-hidden="true"></span>
64
- <button
65
- class="app-title-bar__capsule-btn"
66
- type="button"
67
- aria-label="关闭"
68
- @click="handleCapsuleClose"
69
- >
70
- <span class="app-title-bar__circle" aria-hidden="true"></span>
71
- </button>
98
+ <div ref="capsuleMenuRef" class="app-title-bar__capsule-area">
99
+ <div class="app-title-bar__capsule" role="group" aria-label="页面操作">
100
+ <button
101
+ class="app-title-bar__capsule-btn"
102
+ type="button"
103
+ aria-label="更多"
104
+ aria-haspopup="menu"
105
+ :aria-expanded="capsuleMenuOpen"
106
+ @click="toggleCapsuleMenu"
107
+ >
108
+ <span class="app-title-bar__dots" aria-hidden="true">
109
+ <i></i>
110
+ <i></i>
111
+ <i></i>
112
+ </span>
113
+ </button>
114
+ <span class="app-title-bar__divider" aria-hidden="true"></span>
115
+ <button
116
+ class="app-title-bar__capsule-btn"
117
+ type="button"
118
+ aria-label="关闭"
119
+ @click="handleCapsuleClose"
120
+ >
121
+ <span class="app-title-bar__circle" aria-hidden="true"></span>
122
+ </button>
123
+ </div>
124
+
125
+ <transition name="app-title-bar-menu">
126
+ <div v-if="capsuleMenuOpen" class="app-title-bar__menu" role="menu" aria-label="更多菜单">
127
+ <button
128
+ class="app-title-bar__menu-item"
129
+ type="button"
130
+ role="menuitem"
131
+ @click="handleMenuHome"
132
+ >
133
+ <van-icon name="wap-home-o" />
134
+ <span>回到首页</span>
135
+ </button>
136
+ <button
137
+ class="app-title-bar__menu-item"
138
+ type="button"
139
+ role="menuitem"
140
+ @click="handleMenuSettings"
141
+ >
142
+ <van-icon name="setting-o" />
143
+ <span>设置</span>
144
+ </button>
145
+ </div>
146
+ </transition>
72
147
  </div>
73
148
  </div>
74
149
  </header>
@@ -146,10 +221,16 @@ function handleCapsuleClose() {
146
221
  pointer-events: none;
147
222
  }
148
223
 
149
- .app-title-bar__capsule {
224
+ .app-title-bar__capsule-area {
150
225
  position: absolute;
151
226
  right: 10px;
152
227
  top: 50%;
228
+ z-index: 2;
229
+ width: 88px;
230
+ transform: translateY(-50%);
231
+ }
232
+
233
+ .app-title-bar__capsule {
153
234
  display: flex;
154
235
  align-items: center;
155
236
  width: 88px;
@@ -162,7 +243,6 @@ function handleCapsuleClose() {
162
243
  0 6px 18px rgba(23, 27, 32, 0.08),
163
244
  inset 0 0 0 0.5px rgba(255, 255, 255, 0.82);
164
245
  backdrop-filter: blur(10px);
165
- transform: translateY(-50%);
166
246
  }
167
247
 
168
248
  .app-title-bar__capsule-btn {
@@ -218,6 +298,75 @@ function handleCapsuleClose() {
218
298
  transform: translate(-50%, -50%);
219
299
  }
220
300
 
301
+ .app-title-bar__menu {
302
+ position: absolute;
303
+ top: 40px;
304
+ right: 0;
305
+ width: 126px;
306
+ padding: 6px;
307
+ border: 1px solid rgba(23, 27, 32, 0.08);
308
+ border-radius: 8px;
309
+ background: #ffffff;
310
+ box-shadow: 0 12px 28px rgba(23, 27, 32, 0.14);
311
+ box-sizing: border-box;
312
+ transform-origin: 78px 0;
313
+ }
314
+
315
+ .app-title-bar__menu::before {
316
+ position: absolute;
317
+ top: -5px;
318
+ right: 58px;
319
+ width: 10px;
320
+ height: 10px;
321
+ border-top: 1px solid rgba(23, 27, 32, 0.08);
322
+ border-left: 1px solid rgba(23, 27, 32, 0.08);
323
+ background: #ffffff;
324
+ content: '';
325
+ transform: rotate(45deg);
326
+ }
327
+
328
+ .app-title-bar__menu-item {
329
+ position: relative;
330
+ z-index: 1;
331
+ display: flex;
332
+ align-items: center;
333
+ gap: 8px;
334
+ width: 100%;
335
+ min-height: 40px;
336
+ border: 0;
337
+ border-radius: 6px;
338
+ padding: 0 10px;
339
+ color: #171b20;
340
+ font: inherit;
341
+ font-size: 14px;
342
+ line-height: 1;
343
+ white-space: nowrap;
344
+ background: transparent;
345
+ appearance: none;
346
+ cursor: pointer;
347
+ }
348
+
349
+ .app-title-bar__menu-item:active {
350
+ background: rgba(242, 47, 61, 0.08);
351
+ }
352
+
353
+ .app-title-bar__menu-item + .app-title-bar__menu-item {
354
+ margin-top: 2px;
355
+ }
356
+
357
+ .app-title-bar-menu-enter-active,
358
+ .app-title-bar-menu-leave-active {
359
+ transition:
360
+ opacity 0.14s ease,
361
+ transform 0.14s ease;
362
+ }
363
+
364
+ .app-title-bar-menu-enter-from,
365
+ .app-title-bar-menu-leave-to {
366
+ opacity: 0;
367
+ transform: translateY(-4px) scale(0.98);
368
+ }
369
+
221
370
  @media (max-width: 360px) {
222
371
  .app-title-bar__title {
223
372
  left: 58px;
@@ -2,6 +2,7 @@ import { createApp } from 'vue'
2
2
  import { createPinia } from 'pinia'
3
3
  import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
4
4
  import 'vant/lib/index.css'
5
+ import './styles/vant-overrides.css'
5
6
 
6
7
  import App from './App.vue'
7
8
  import router from './router'
@@ -0,0 +1,42 @@
1
+ :root {
2
+ --van-toast-max-width: min(78vw, 360px);
3
+ --van-toast-font-size: 14px;
4
+ --van-toast-line-height: 1.45;
5
+ --van-toast-text-color: #fff;
6
+ --van-toast-radius: 8px;
7
+ --van-toast-text-min-width: 96px;
8
+ --van-toast-text-padding: 9px 14px;
9
+ --van-toast-default-padding: 14px 16px;
10
+ --van-toast-default-width: auto;
11
+ --van-toast-default-min-height: 0;
12
+ --van-toast-background: rgba(17, 24, 39, 0.82);
13
+ --van-toast-loading-icon-color: #fff;
14
+ }
15
+
16
+ .van-toast {
17
+ color: #fff !important;
18
+ background: rgba(17, 24, 39, 0.82) !important;
19
+ box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
20
+ backdrop-filter: blur(8px);
21
+ -webkit-backdrop-filter: blur(8px);
22
+ }
23
+
24
+ .van-toast--text {
25
+ width: fit-content;
26
+ min-width: 96px;
27
+ max-width: min(78vw, 360px);
28
+ min-height: 0 !important;
29
+ padding: 9px 14px !important;
30
+ border-radius: 8px !important;
31
+ }
32
+
33
+ .van-toast__text {
34
+ color: #fff !important;
35
+ font-size: 14px;
36
+ line-height: 1.45;
37
+ word-break: break-word;
38
+ }
39
+
40
+ .van-toast__loading {
41
+ color: #fff !important;
42
+ }
@@ -6,7 +6,6 @@ import type {
6
6
  AxiosResponse,
7
7
  InternalAxiosRequestConfig,
8
8
  } from 'axios'
9
- import { showToast } from 'vant'
10
9
  import NProgress from 'nprogress'
11
10
  import 'nprogress/nprogress.css'
12
11
  import { apiConfig } from '@/config/env'
@@ -20,6 +19,7 @@ import {
20
19
  refreshAccessToken,
21
20
  type AuthTokenResponse,
22
21
  } from '@/utils/auth-token'
22
+ import { showAppToast } from '@/utils/toast'
23
23
 
24
24
  // 关闭 NProgress 右侧旋转小圆圈,保持进度条简洁
25
25
  NProgress.configure({ showSpinner: false })
@@ -84,7 +84,7 @@ service.interceptors.response.use(
84
84
 
85
85
  // 只有响应体明确包含 code 字段时,才按统一业务格式判断,兼容 0 和 "0000" 两种成功码。
86
86
  if (typeof res.code !== 'undefined' && !isSuccessCode(res.code)) {
87
- showToast(res.message || '请求失败')
87
+ showAppToast(res.message || '请求失败')
88
88
 
89
89
  // 将业务错误抛出,调用方可通过 catch 捕获
90
90
  return Promise.reject(new Error(res.message || '请求失败'))
@@ -114,7 +114,7 @@ service.interceptors.response.use(
114
114
  } catch (refreshError) {
115
115
  clearAuthTokens()
116
116
  router.push('/login')
117
- showToast('登录已过期,请重新登录')
117
+ showAppToast('登录已过期,请重新登录')
118
118
  return Promise.reject(refreshError)
119
119
  }
120
120
  }
@@ -132,7 +132,7 @@ service.interceptors.response.use(
132
132
  const status = error.response?.status as number
133
133
  const message = error.response ? statusCodeMap[status] || `连接错误 ${status}` : '网络连接异常'
134
134
 
135
- showToast(message)
135
+ showAppToast(message)
136
136
 
137
137
  // 401 未授权:清除 token 并跳转登录页
138
138
  if (error.response?.status === 401) {
@@ -0,0 +1,61 @@
1
+ import {
2
+ closeToast,
3
+ setToastDefaultOptions,
4
+ showLoadingToast,
5
+ showToast,
6
+ type ToastOptions,
7
+ type ToastWrapperInstance,
8
+ } from 'vant'
9
+
10
+ const DEFAULT_TOAST_OPTIONS: ToastOptions = {
11
+ duration: 2200,
12
+ position: 'middle',
13
+ wordBreak: 'break-word',
14
+ teleport: 'body',
15
+ zIndex: 9999,
16
+ }
17
+
18
+ setToastDefaultOptions(DEFAULT_TOAST_OPTIONS)
19
+ setToastDefaultOptions('loading', {
20
+ ...DEFAULT_TOAST_OPTIONS,
21
+ duration: 0,
22
+ forbidClick: true,
23
+ })
24
+
25
+ export type AppToastOptions = string | ToastOptions
26
+
27
+ export function showAppToast(options: AppToastOptions): ToastWrapperInstance {
28
+ if (typeof options === 'string') {
29
+ return showToast({
30
+ ...DEFAULT_TOAST_OPTIONS,
31
+ message: options,
32
+ })
33
+ }
34
+
35
+ return showToast({
36
+ ...DEFAULT_TOAST_OPTIONS,
37
+ ...options,
38
+ })
39
+ }
40
+
41
+ export function showAppLoadingToast(options: AppToastOptions = '加载中...'): ToastWrapperInstance {
42
+ if (typeof options === 'string') {
43
+ return showLoadingToast({
44
+ ...DEFAULT_TOAST_OPTIONS,
45
+ message: options,
46
+ duration: 0,
47
+ forbidClick: true,
48
+ })
49
+ }
50
+
51
+ return showLoadingToast({
52
+ ...DEFAULT_TOAST_OPTIONS,
53
+ duration: 0,
54
+ forbidClick: true,
55
+ ...options,
56
+ })
57
+ }
58
+
59
+ export function closeAppToast(all?: boolean) {
60
+ closeToast(all)
61
+ }
@@ -2,6 +2,7 @@
2
2
  import { highlightArticleHtml } from '@/utils/code-highlight'
3
3
  import { copyText } from '@/utils/copy'
4
4
  import { formatArticleDate, getArticleDetail, type Article } from '@/api/announcement'
5
+ import { showAppToast } from '@/utils/toast'
5
6
 
6
7
  defineOptions({ name: 'ArticleDetailPage' })
7
8
 
@@ -53,16 +54,16 @@ async function copyArticleContent() {
53
54
  const text = articleContentToText(article.value.content)
54
55
 
55
56
  if (!text) {
56
- showToast('暂无可复制内容')
57
+ showAppToast('暂无可复制内容')
57
58
  return
58
59
  }
59
60
 
60
61
  try {
61
62
  await copyText(text)
62
- showToast('已复制内容')
63
+ showAppToast('已复制内容')
63
64
  } catch (error) {
64
65
  console.error('[公告] 内容复制失败', error)
65
- showToast('复制失败')
66
+ showAppToast('复制失败')
66
67
  }
67
68
  }
68
69
 
@@ -5,6 +5,7 @@ import {
5
5
  getArticleDetail,
6
6
  updateArticle,
7
7
  } from '@/api/announcement'
8
+ import { showAppToast } from '@/utils/toast'
8
9
 
9
10
  defineOptions({ name: 'ArticleEditPage' })
10
11
 
@@ -46,7 +47,7 @@ onMounted(async () => {
46
47
  setEditorHtml(article.content)
47
48
  } catch (error) {
48
49
  console.error('[公告] 编辑详情加载失败', error)
49
- showToast('公告加载失败')
50
+ showAppToast('公告加载失败')
50
51
  router.replace('/articles')
51
52
  } finally {
52
53
  detailLoading.value = false
@@ -127,7 +128,7 @@ function insertLink() {
127
128
  const url = normalizeUrl(linkForm.url)
128
129
 
129
130
  if (!url) {
130
- showToast('请输入链接地址')
131
+ showAppToast('请输入链接地址')
131
132
  return
132
133
  }
133
134
 
@@ -154,7 +155,7 @@ function insertCodeBlock() {
154
155
  const code = codeForm.code.trimEnd()
155
156
 
156
157
  if (!code.trim()) {
157
- showToast('请输入代码内容')
158
+ showAppToast('请输入代码内容')
158
159
  return
159
160
  }
160
161
 
@@ -188,12 +189,12 @@ async function handleSave() {
188
189
  const text = extractTextFromHtml(contentHtml.value)
189
190
 
190
191
  if (!title.value.trim()) {
191
- showToast('请输入公告标题')
192
+ showAppToast('请输入公告标题')
192
193
  return
193
194
  }
194
195
 
195
196
  if (!text) {
196
- showToast('请输入公告正文')
197
+ showAppToast('请输入公告正文')
197
198
  return
198
199
  }
199
200
 
@@ -209,7 +210,7 @@ async function handleSave() {
209
210
  ? await updateArticle(articleId.value, payload)
210
211
  : await createArticle(payload)
211
212
 
212
- showToast(isEditing.value ? '已保存' : '已发布')
213
+ showAppToast(isEditing.value ? '已保存' : '已发布')
213
214
  router.replace(article.id ? `/articles/${article.id}` : '/articles')
214
215
  } catch (error) {
215
216
  console.error('[公告] 保存失败', error)
@@ -1,12 +1,12 @@
1
1
  <script setup lang="ts">
2
2
  import { useRouter } from 'vue-router'
3
3
  import { getLastLoginTimeApi, getOrgByUserNameApi, loginApi, loginByAppTokenApi } from '@/api/user'
4
- import { showToast } from 'vant'
5
4
  import { useAppStore } from '@/stores/app'
6
5
  import { useUserStore } from '@/stores/user'
7
6
  import { getAppToken } from '@/core/mxApi'
8
7
  import { appEnv } from '@/config/env'
9
8
  import { saveAuthTokens, type AuthTokenResponse } from '@/utils/auth-token'
9
+ import { showAppToast } from '@/utils/toast'
10
10
 
11
11
  const router = useRouter()
12
12
  const appStore = useAppStore()
@@ -37,7 +37,7 @@ async function loginWithAppToken() {
37
37
  } catch (error) {
38
38
  console.error('[登录页] APP token 自动登录失败', error)
39
39
  if (!isLoginUnavailableError(error)) {
40
- showToast({ message: 'APP 自动登录失败,请手动登录', duration: 3000 })
40
+ showAppToast({ message: 'APP 自动登录失败,请手动登录', duration: 3000 })
41
41
  }
42
42
  appStore.isNative = false
43
43
  } finally {
@@ -82,14 +82,14 @@ async function onSubmit() {
82
82
  async function loginByAppToken(appToken: string) {
83
83
  const res = await loginByAppTokenApi(appToken)
84
84
  await saveBusinessTokenAndOrg(res)
85
- showToast('登录成功')
85
+ showAppToast('登录成功')
86
86
  router.push('/')
87
87
  }
88
88
 
89
89
  async function loginByPassword() {
90
90
  const res = await loginApi(form.value)
91
91
  await saveBusinessTokenAndOrg(res)
92
- showToast('登录成功')
92
+ showAppToast('登录成功')
93
93
  router.push('/')
94
94
  }
95
95
 
@@ -135,7 +135,7 @@ async function saveSystemWorkDate() {
135
135
  }
136
136
 
137
137
  function rejectLoginWithoutOrg(): never {
138
- showToast(LOGIN_UNAVAILABLE_MESSAGE)
138
+ showAppToast(LOGIN_UNAVAILABLE_MESSAGE)
139
139
  throw new Error(LOGIN_UNAVAILABLE_MESSAGE)
140
140
  }
141
141
 
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { useUserStore } from '@/stores/user'
3
+ import { showAppToast } from '@/utils/toast'
3
4
 
4
5
  defineOptions({ name: 'MinePage' })
5
6
 
@@ -24,7 +25,7 @@ async function handleLogout() {
24
25
  confirmButtonColor: '#f22f3d',
25
26
  })
26
27
  userStore.clearToken()
27
- showToast('已退出登录')
28
+ showAppToast('已退出登录')
28
29
  router.replace('/login')
29
30
  } catch {
30
31
  // 用户取消时不需要处理
@@ -66,9 +67,7 @@ async function handleLogout() {
66
67
  margin: 0 auto;
67
68
  padding: 22px 11px 24px;
68
69
  color: #171b20;
69
- background:
70
- radial-gradient(circle at 16% 4%, rgba(242, 47, 61, 0.1), transparent 112px),
71
- #f7f8fa;
70
+ background: radial-gradient(circle at 16% 4%, rgba(242, 47, 61, 0.1), transparent 112px), #f7f8fa;
72
71
  box-sizing: border-box;
73
72
  }
74
73
 
@@ -5,6 +5,7 @@ import {
5
5
  sendPbcPositionRequest,
6
6
  type PbcPositionBalance,
7
7
  } from '@/api/pbc-position'
8
+ import { showAppToast } from '@/utils/toast'
8
9
 
9
10
  defineOptions({ name: 'PbcPositionPage' })
10
11
 
@@ -93,10 +94,10 @@ async function handleSend() {
93
94
  requestRefNo: refNo,
94
95
  refNo,
95
96
  }
96
- showToast(refNo ? `发送成功:${refNo}` : '发送成功')
97
+ showAppToast(refNo ? `发送成功:${refNo}` : '发送成功')
97
98
  } catch (error) {
98
99
  console.error('[人行头寸余额发送失败]', error)
99
- showToast(getErrorMessage(error, '发送失败,请重试'))
100
+ showAppToast(getErrorMessage(error, '发送失败,请重试'))
100
101
  } finally {
101
102
  sending.value = false
102
103
  }
@@ -118,10 +119,10 @@ async function handleQuery() {
118
119
 
119
120
  try {
120
121
  balanceDetail.value = await queryPbcPositionBalance(requestRefNo.value)
121
- showToast('查询完成')
122
+ showAppToast('查询完成')
122
123
  } catch (error) {
123
124
  console.error('[人行头寸余额查询失败]', error)
124
- showToast(getErrorMessage(error, '查询失败,请重试'))
125
+ showAppToast(getErrorMessage(error, '查询失败,请重试'))
125
126
  } finally {
126
127
  querying.value = false
127
128
  }
@@ -198,9 +199,6 @@ function getErrorMessage(error: unknown, fallback: string) {
198
199
  margin: 0 auto;
199
200
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 82px);
200
201
  color: #181d28;
201
- background:
202
- linear-gradient(180deg, rgba(255, 255, 255, 0) 0 68px, #ffffff 68px),
203
- radial-gradient(circle at 50% 28%, rgba(255, 237, 238, 0.95), transparent 118px), #ffffff;
204
202
  box-sizing: border-box;
205
203
  }
206
204
 
@@ -15,6 +15,7 @@ import {
15
15
  resolveForecastStatus,
16
16
  toBillionYuan,
17
17
  } from '@/utils/rmb-forecast'
18
+ import { showAppToast } from '@/utils/toast'
18
19
 
19
20
  defineOptions({ name: 'RmbPositionPage' })
20
21
 
@@ -139,19 +140,19 @@ async function handleSearch() {
139
140
  (queryForm.minAmount && minAmount === undefined) ||
140
141
  (queryForm.maxAmount && maxAmount === undefined)
141
142
  ) {
142
- showToast('请输入正确的金额')
143
+ showAppToast('请输入正确的金额')
143
144
  return
144
145
  }
145
146
 
146
147
  if (minAmount !== undefined && maxAmount !== undefined && minAmount > maxAmount) {
147
- showToast('下限金额不能大于上限金额')
148
+ showAppToast('下限金额不能大于上限金额')
148
149
  return
149
150
  }
150
151
 
151
152
  await resetAndLoad()
152
153
 
153
154
  if (!listError.value) {
154
- showToast(`查询到 ${forecastTotal.value} 笔预报`)
155
+ showAppToast(`查询到 ${forecastTotal.value} 笔预报`)
155
156
  }
156
157
  }
157
158
 
@@ -197,7 +198,7 @@ async function loadNextPage() {
197
198
  } catch (error) {
198
199
  console.error('[人民币预报查询失败]', error)
199
200
  listError.value = true
200
- showToast('数据加载失败,请重试')
201
+ showAppToast('数据加载失败,请重试')
201
202
  } finally {
202
203
  requesting.value = false
203
204
  listLoading.value = false
@@ -211,7 +212,7 @@ function confirmDate() {
211
212
 
212
213
  function openDetail(item: Forecast) {
213
214
  if (!item.predRefNo) {
214
- showToast('暂无预报流水号')
215
+ showAppToast('暂无预报流水号')
215
216
  return
216
217
  }
217
218
 
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { useAppStore } from '@/stores/app'
3
+ import { showAppToast } from '@/utils/toast'
3
4
 
4
5
  defineOptions({ name: 'RmbPositionCreatePage' })
5
6
 
@@ -49,17 +50,17 @@ function submitCreate() {
49
50
  const amount = parseAmount(form.amount)
50
51
 
51
52
  if (!form.tranDate) {
52
- showToast('请选择交易日期')
53
+ showAppToast('请选择交易日期')
53
54
  return
54
55
  }
55
56
 
56
57
  if (!form.institution.trim() || !form.business.trim()) {
57
- showToast('请补充落地机构和业务类型')
58
+ showAppToast('请补充落地机构和业务类型')
58
59
  return
59
60
  }
60
61
 
61
62
  if (form.amount && amount === undefined) {
62
- showToast('请输入正确的预报金额')
63
+ showAppToast('请输入正确的预报金额')
63
64
  return
64
65
  }
65
66
 
@@ -74,7 +75,7 @@ function submitCreate() {
74
75
  }
75
76
 
76
77
  sessionStorage.setItem(pendingForecastKey, JSON.stringify(pendingForecast))
77
- showToast('新增预报成功')
78
+ showAppToast('新增预报成功')
78
79
  router.replace({ name: 'RmbPosition' })
79
80
  }
80
81
  </script>
@@ -11,6 +11,7 @@ import {
11
11
  resolveClientType,
12
12
  resolveForecastStatus,
13
13
  } from '@/utils/rmb-forecast'
14
+ import { showAppToast } from '@/utils/toast'
14
15
 
15
16
  defineOptions({ name: 'RmbPositionDetailPage' })
16
17
 
@@ -119,7 +120,7 @@ async function loadDetail() {
119
120
  } catch (error) {
120
121
  console.error('[人民币预报详情加载失败]', error)
121
122
  loadError.value = true
122
- showToast('详情加载失败,请重试')
123
+ showAppToast('详情加载失败,请重试')
123
124
  } finally {
124
125
  loading.value = false
125
126
  }
@@ -32,13 +32,7 @@ export default defineConfig(({ command, mode }) => {
32
32
  'pinia',
33
33
  '@vueuse/core',
34
34
  {
35
- vant: [
36
- 'showToast',
37
- 'showDialog',
38
- 'showConfirmDialog',
39
- 'showLoadingToast',
40
- 'closeToast',
41
- ],
35
+ vant: ['showDialog', 'showConfirmDialog'],
42
36
  },
43
37
  ],
44
38
  dts: 'src/auto-imports.d.ts',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {