verce-vue-test 0.0.27 → 0.0.28
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.
- package/mini2.0-main/env.d.ts +1 -0
- package/mini2.0-main/plugins/bump-version.ts +8 -4
- package/mini2.0-main/src/App.vue +15 -2
- package/mini2.0-main/src/config/plugin.properties.pro +2 -2
- package/mini2.0-main/src/config/plugin.properties.test +2 -2
- package/mini2.0-main/src/core/mxApi/index.ts +28 -1
- package/mini2.0-main/src/main.ts +1 -6
- package/mini2.0-main/src/stores/app.ts +29 -0
- package/mini2.0-main/src/views/home/index.vue +8 -8
- package/mini2.0-main/src/views/login/index.vue +6 -5
- package/package.json +1 -1
package/mini2.0-main/env.d.ts
CHANGED
|
@@ -23,10 +23,14 @@ export function bumpVersion(mode: string): Plugin {
|
|
|
23
23
|
const oldCode = Number(match[1])
|
|
24
24
|
const newCode = oldCode + 1
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
26
|
+
// 版本号规则:5位 version_code → 4位版本名
|
|
27
|
+
// version_code: ABCDD A=major B=minor C=patch DD=hotfix
|
|
28
|
+
// version_name: A.B.C.DD 示例 66102 → 6.6.1.02
|
|
29
|
+
const major = Math.floor(newCode / 10000)
|
|
30
|
+
const minor = Math.floor((newCode / 1000) % 10)
|
|
31
|
+
const patch = Math.floor((newCode / 100) % 10)
|
|
32
|
+
const hotfix = String(newCode % 100).padStart(2, '0')
|
|
33
|
+
const versionName = `${major}.${minor}.${patch}.${hotfix}`
|
|
30
34
|
|
|
31
35
|
content = content
|
|
32
36
|
.replace(/version_code=\d+/, `version_code=${newCode}`)
|
package/mini2.0-main/src/App.vue
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
<script setup lang="ts"
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useAppStore } from '@/stores/app'
|
|
3
|
+
|
|
4
|
+
const appStore = useAppStore()
|
|
5
|
+
|
|
6
|
+
onMounted(async () => {
|
|
7
|
+
await appStore.initNativeDetection()
|
|
8
|
+
|
|
9
|
+
// 测试环境 + 原生设备:加载 vConsole 调试面板
|
|
10
|
+
if (import.meta.env.VITE_APP_ENV === 'test' && appStore.isNative) {
|
|
11
|
+
import('vconsole').then(({ default: VConsole }) => new VConsole())
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
2
15
|
|
|
3
16
|
<template>
|
|
4
|
-
<router-view v-slot="{ Component }">
|
|
17
|
+
<router-view v-if="appStore.ready" v-slot="{ Component }">
|
|
5
18
|
<keep-alive include="Home">
|
|
6
19
|
<component :is="Component" />
|
|
7
20
|
</keep-alive>
|
|
@@ -232,6 +232,33 @@ export const ajaxPut = <T = unknown>(url: string, data?: unknown): Promise<MXAja
|
|
|
232
232
|
export const ajaxDelete = <T = unknown>(url: string, id: string): Promise<MXAjaxResponse<T>> =>
|
|
233
233
|
ajax<T>({ type: 'DELETE', url: `${url}/${id}` })
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
let nativeReady = false
|
|
236
|
+
let resolveNativeReady: (() => void) | null = null
|
|
237
|
+
|
|
238
|
+
const nativeReadyPromise = new Promise<void>((resolve) => {
|
|
239
|
+
resolveNativeReady = resolve
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
document.addEventListener('deviceready', () => {
|
|
243
|
+
nativeReady = true
|
|
244
|
+
resolveNativeReady?.()
|
|
245
|
+
}, false)
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 等待原生设备就绪(deviceready 事件触发后 resolve)
|
|
249
|
+
*
|
|
250
|
+
* native 环境下 deviceready 触发后 window.MXCommon 才注入完成,
|
|
251
|
+
* 之后 isNativeApp() 才能拿到正确结果。
|
|
252
|
+
*/
|
|
253
|
+
export const whenNativeReady = (): Promise<boolean> => {
|
|
254
|
+
if (nativeReady) return Promise.resolve(isNativeApp())
|
|
255
|
+
|
|
256
|
+
return Promise.race([
|
|
257
|
+
nativeReadyPromise.then(() => isNativeApp()),
|
|
258
|
+
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), 3000)),
|
|
259
|
+
])
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** 检测是否在原生环境(需在 deviceready 之后调用才准确) */
|
|
236
263
|
export const isNativeApp = (): boolean =>
|
|
237
264
|
typeof window.MXCommon !== 'undefined'
|
package/mini2.0-main/src/main.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { createApp } from 'vue'
|
|
2
2
|
import { createPinia } from 'pinia'
|
|
3
3
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
4
|
-
import 'vant/lib/index.css'
|
|
4
|
+
import 'vant/lib/index.css'
|
|
5
5
|
|
|
6
6
|
import App from './App.vue'
|
|
7
7
|
import router from './router'
|
|
8
|
-
import { isNativeApp } from '@/core/mxApi'
|
|
9
|
-
|
|
10
|
-
if (import.meta.env.VITE_APP_ENV === 'test' && isNativeApp()) {
|
|
11
|
-
import('vconsole').then(({ default: VConsole }) => new VConsole())
|
|
12
|
-
}
|
|
13
8
|
|
|
14
9
|
const app = createApp(App)
|
|
15
10
|
const pinia = createPinia()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
import { whenNativeReady } from '@/core/mxApi'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 应用级状态 Store
|
|
6
|
+
*
|
|
7
|
+
* 存放全局共享的运行时状态,不持久化。
|
|
8
|
+
*/
|
|
9
|
+
export const useAppStore = defineStore('app', () => {
|
|
10
|
+
/** 原生环境检测是否已完成(App.vue onMounted 后变为 true) */
|
|
11
|
+
const ready = ref(false)
|
|
12
|
+
|
|
13
|
+
/** 是否在原生 APP WebView 环境中(由 App.vue 初始化时检测并写入) */
|
|
14
|
+
const isNative = ref(false)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 初始化原生环境检测
|
|
18
|
+
*
|
|
19
|
+
* 等待 deviceready 事件后判断 window.MXCommon 是否存在,
|
|
20
|
+
* 浏览器环境下 3 秒超时后返回 false。
|
|
21
|
+
* 应在 App.vue onMounted 中调用,全局只需一次。
|
|
22
|
+
*/
|
|
23
|
+
async function initNativeDetection() {
|
|
24
|
+
isNative.value = await whenNativeReady()
|
|
25
|
+
ready.value = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { ready, isNative, initNativeDetection }
|
|
29
|
+
})
|
|
@@ -7,44 +7,44 @@ type HomeFeature = {
|
|
|
7
7
|
|
|
8
8
|
defineOptions({ name: 'HomePage' })
|
|
9
9
|
|
|
10
|
-
const bannerImage =
|
|
10
|
+
const bannerImage = `${import.meta.env.BASE_URL}images/img.png`
|
|
11
11
|
|
|
12
12
|
const router = useRouter()
|
|
13
13
|
|
|
14
14
|
const features: HomeFeature[] = [
|
|
15
15
|
{
|
|
16
16
|
title: ['人民币头寸', '预报及查询'],
|
|
17
|
-
image:
|
|
17
|
+
image: `${import.meta.env.BASE_URL}images/f5876785-b927-4347-ba19-999114240649.png`,
|
|
18
18
|
route: '/rmb-position',
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
title: ['外币头寸', '预报及查询'],
|
|
22
|
-
image:
|
|
22
|
+
image: `${import.meta.env.BASE_URL}images/12a73787-86a9-4891-a65f-66104746f6a8.png`,
|
|
23
23
|
route: '/foreign-position',
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
title: ['人行头寸', '余额查询'],
|
|
27
|
-
image:
|
|
27
|
+
image: `${import.meta.env.BASE_URL}images/73fef1e4-0fd0-4a1a-9b8b-a70a5b6acbbc.png`,
|
|
28
28
|
route: '/pbc-position',
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
title: ['头寸匡算'],
|
|
32
|
-
image:
|
|
32
|
+
image: `${import.meta.env.BASE_URL}images/ea745a10-42aa-4f44-8d7f-3ab02cc0adcd.png`,
|
|
33
33
|
route: '/position-estimate',
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
title: ['人民币净借记', '可用额度管理'],
|
|
37
|
-
image:
|
|
37
|
+
image: `${import.meta.env.BASE_URL}images/5798d7aa-ba8b-4605-8079-58b35495ac55.png`,
|
|
38
38
|
route: '/net-debit',
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
title: ['人民币小额网银', '清算场次明细'],
|
|
42
|
-
image:
|
|
42
|
+
image: `${import.meta.env.BASE_URL}images/c3dbbd9d-be56-490e-b9f4-6ee17ebefffc.png`,
|
|
43
43
|
route: '/clearing-detail',
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
title: ['预警信息'],
|
|
47
|
-
image:
|
|
47
|
+
image: `${import.meta.env.BASE_URL}images/bc685b4c-0cca-4a79-924c-a8ee10e6f8eb.png`,
|
|
48
48
|
route: '/warning',
|
|
49
49
|
},
|
|
50
50
|
]
|
|
@@ -3,11 +3,12 @@ import { useRouter } from 'vue-router'
|
|
|
3
3
|
import { login } from '@/api/user'
|
|
4
4
|
import { showToast } from 'vant'
|
|
5
5
|
import { useUserStore } from '@/stores/user'
|
|
6
|
-
import {
|
|
6
|
+
import { useAppStore } from '@/stores/app'
|
|
7
|
+
import { getEncryptString } from '@/core/mxApi'
|
|
7
8
|
|
|
8
9
|
const router = useRouter()
|
|
9
10
|
const userStore = useUserStore()
|
|
10
|
-
const
|
|
11
|
+
const appStore = useAppStore()
|
|
11
12
|
|
|
12
13
|
const form = ref({
|
|
13
14
|
username: '',
|
|
@@ -18,12 +19,12 @@ const loading = ref(false)
|
|
|
18
19
|
|
|
19
20
|
// 原生环境:从客户端获取密钥,直接交换 token
|
|
20
21
|
onMounted(async () => {
|
|
21
|
-
if (!
|
|
22
|
+
if (!appStore.isNative) return
|
|
22
23
|
|
|
23
24
|
loading.value = true
|
|
24
25
|
try {
|
|
25
26
|
const secret = await getEncryptString()
|
|
26
|
-
|
|
27
|
+
console.log(secret)
|
|
27
28
|
} catch {
|
|
28
29
|
// 错误已由 request.ts 拦截器统一处理
|
|
29
30
|
} finally {
|
|
@@ -49,7 +50,7 @@ async function onSubmit() {
|
|
|
49
50
|
<template>
|
|
50
51
|
<div class="login-page">
|
|
51
52
|
<!-- 原生环境:自动登录,只显示加载状态 -->
|
|
52
|
-
<van-loading v-if="isNative" vertical class="native-loading">
|
|
53
|
+
<van-loading v-if="appStore.isNative" vertical class="native-loading">
|
|
53
54
|
正在登录...
|
|
54
55
|
</van-loading>
|
|
55
56
|
|