af-mobile-client-vue3 1.5.92 → 1.5.94

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.5.92",
4
+ "version": "1.5.94",
5
5
  "packageManager": "pnpm@10.13.1",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -0,0 +1,38 @@
1
+ /**
2
+ * 统一的返回函数 - 解决 micro-app 栈不同步导致 404 的问题
3
+ *
4
+ * 问题背景:
5
+ * 1. 在 micro-app 环境中,Vue Router 的 router.back() 和浏览器的 history.back() 是独立的
6
+ * 2. micro-app 维护了一个虚拟栈来跟踪子应用的路由历史
7
+ * 3. 直接使用 router.back() 可能导致虚拟栈和浏览器 History 栈不同步
8
+ * 4. 栈不同步会导致返回后 URL 跳转到不存在的页面(404)
9
+ *
10
+ * 解决方案:
11
+ * - 在 micro-app 环境中使用 microApp.router.back()(由框架维护栈一致性)
12
+ * - 在独立运行环境中使用 Vue Router 的 router.back()
13
+ */
14
+
15
+ import router from '@af-mobile-client-vue3/router'
16
+
17
+ /**
18
+ * 统一的返回函数
19
+ * - micro-app 环境使用 microApp.router.back()
20
+ * - 独立环境使用 router.back()
21
+ * - 无浏览器历史时跳转到首页
22
+ */
23
+ export function goBack(): void {
24
+ if (window.history.length <= 1) {
25
+ console.log('[goBack] 无浏览器历史,跳转首页')
26
+ router.push('/')
27
+ return
28
+ }
29
+
30
+ if ((window as any).__MICRO_APP_ENVIRONMENT__) {
31
+ console.log('[goBack] micro-app 环境,使用 microApp.router.back()')
32
+ ;(window as any).microApp?.router?.back()
33
+ }
34
+ else {
35
+ console.log('[goBack] 独立环境,使用 router.back()')
36
+ router.back()
37
+ }
38
+ }
@@ -1,7 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { FormInstance } from 'vant'
3
3
  import { formatDate } from '@af-mobile-client-vue3/hooks/useCommon'
4
-
5
4
  import { getConfigByName, getConfigByNameAsync, runLogic } from '@af-mobile-client-vue3/services/api/common'
6
5
  import useSafecheckStore from '@af-mobile-client-vue3/stores/modules/safecheckStore'
7
6
  import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
@@ -9,6 +8,7 @@ import { setAppBackIntercept } from '@af-mobile-client-vue3/utils/appBackManager
9
8
  import { mobileUtil } from '@af-mobile-client-vue3/utils/mobileUtil'
10
9
  import { getPhotosFromAny } from '@af-mobile-client-vue3/utils/PhotoClean'
11
10
  import { executeStrFunctionByContext } from '@af-mobile-client-vue3/utils/runEvalFunction'
11
+ import { goBack } from '@af-mobile-client-vue3/utils/safeBack'
12
12
  import { formatNow } from '@af-mobile-client-vue3/utils/timeUtil'
13
13
  import hiddenDangers from '@af-mobile-client-vue3/views/SafeInspection/SecurityCertificate/OverallHiddenDangers/index.vue'
14
14
  import photoAiRecognition from '@af-mobile-client-vue3/views/SafeInspection/SecurityCertificate/photoAiRecognition/index.vue'
@@ -487,9 +487,9 @@ function initParseData(res) {
487
487
  }
488
488
  else {
489
489
  showFailToast('未查询到相应安检结果,请刷新后重试!')
490
- // 提交成功后返回
491
- router.back()
492
490
  clear()
491
+ // 提交成功后返回
492
+ goBack()
493
493
  }
494
494
  config.data = templateJson
495
495
  processFormItemDefaults()
@@ -643,8 +643,8 @@ async function continuePageInit() {
643
643
  }
644
644
  else {
645
645
  showFailToast('未查询到相应安检单配置,请联系管理员!')
646
- router.back()
647
646
  clear()
647
+ goBack()
648
648
  }
649
649
  })
650
650
  }).catch(() => {
@@ -671,7 +671,7 @@ async function continuePageInit() {
671
671
  }
672
672
  else {
673
673
  showFailToast('未查询到相应安检单配置,请联系管理员!')
674
- router.back()
674
+ goBack()
675
675
  clear()
676
676
  }
677
677
  })
@@ -700,7 +700,7 @@ async function continuePageInit() {
700
700
  }
701
701
  else {
702
702
  showFailToast('未查询到相应安检单配置,请联系管理员!')
703
- router.back()
703
+ goBack()
704
704
  clear()
705
705
  }
706
706
  })
@@ -844,7 +844,7 @@ async function reloadNewForm() {
844
844
  }
845
845
  else {
846
846
  showFailToast('未查询到相应安检单配置,请联系管理员!')
847
- router.back()
847
+ goBack()
848
848
  clear()
849
849
  }
850
850
  }
@@ -1490,7 +1490,7 @@ async function saveDraftData() {
1490
1490
  }
1491
1491
  await runLogic('saveDraft', param, 'af-safecheck')
1492
1492
  showSuccessToast('临时数据保存成功!')
1493
- router.back()
1493
+ goBack()
1494
1494
  clear()
1495
1495
  }
1496
1496
  catch (error) {
@@ -1644,7 +1644,7 @@ function submitSecurityCheckData(submitData: any) {
1644
1644
  if (res.data && res.data.enqueued) {
1645
1645
  showSuccessToast('提交成功')
1646
1646
  // 提交成功后返回
1647
- router.back()
1647
+ goBack()
1648
1648
  clear()
1649
1649
  }
1650
1650
  else {
@@ -2063,7 +2063,7 @@ function onFloatingBubble() {
2063
2063
  async function floatingBubbleSwitch(action) {
2064
2064
  // 返回首页固定为路由回退
2065
2065
  if (action.title === '返回上级') {
2066
- router.back()
2066
+ goBack()
2067
2067
  clear()
2068
2068
  }
2069
2069
  else if (action.title === '清空保存数据') {