af-mobile-client-vue3 1.5.93 → 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.93",
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'
@@ -86,8 +86,6 @@ const safeCheckPaperId = ref(null)
86
86
  const draftType = ref(null)
87
87
  // 调用时传入的额外数据 会存储在paper表的f_data字段中
88
88
  const extData = ref(null)
89
- // 小程序id
90
- const miniProgramId = ref(null)
91
89
 
92
90
  // 派单部门列表
93
91
  const dispatchDeptList = ref(null)
@@ -440,7 +438,6 @@ onBeforeMount(() => {
440
438
  safeCheckPaperId.value = route.query.paperId as string
441
439
  // 临时保存类型
442
440
  draftType.value = route.query.draftType as string
443
- miniProgramId.value = route.query.miniProgramId as string
444
441
  // 将路由中的extData参数存储到安检单的f_data中
445
442
  try {
446
443
  const ext = JSON.parse(route.query.extData as string)
@@ -490,9 +487,9 @@ function initParseData(res) {
490
487
  }
491
488
  else {
492
489
  showFailToast('未查询到相应安检结果,请刷新后重试!')
493
- // 提交成功后返回
494
- router.back()
495
490
  clear()
491
+ // 提交成功后返回
492
+ goBack()
496
493
  }
497
494
  config.data = templateJson
498
495
  processFormItemDefaults()
@@ -646,8 +643,8 @@ async function continuePageInit() {
646
643
  }
647
644
  else {
648
645
  showFailToast('未查询到相应安检单配置,请联系管理员!')
649
- router.back()
650
646
  clear()
647
+ goBack()
651
648
  }
652
649
  })
653
650
  }).catch(() => {
@@ -674,7 +671,7 @@ async function continuePageInit() {
674
671
  }
675
672
  else {
676
673
  showFailToast('未查询到相应安检单配置,请联系管理员!')
677
- router.back()
674
+ goBack()
678
675
  clear()
679
676
  }
680
677
  })
@@ -703,7 +700,7 @@ async function continuePageInit() {
703
700
  }
704
701
  else {
705
702
  showFailToast('未查询到相应安检单配置,请联系管理员!')
706
- router.back()
703
+ goBack()
707
704
  clear()
708
705
  }
709
706
  })
@@ -847,7 +844,7 @@ async function reloadNewForm() {
847
844
  }
848
845
  else {
849
846
  showFailToast('未查询到相应安检单配置,请联系管理员!')
850
- router.back()
847
+ goBack()
851
848
  clear()
852
849
  }
853
850
  }
@@ -1319,7 +1316,6 @@ function organizeSubmitData() {
1319
1316
  bonusData: route?.query?.bonusData ? JSON.parse(route.query.bonusData as any) : {},
1320
1317
  draftType: draftType.value,
1321
1318
  changeTableId: safecheckStore.getChangeTableId(),
1322
- miniProgramId: miniProgramId.value,
1323
1319
  }
1324
1320
  }
1325
1321
 
@@ -1494,7 +1490,7 @@ async function saveDraftData() {
1494
1490
  }
1495
1491
  await runLogic('saveDraft', param, 'af-safecheck')
1496
1492
  showSuccessToast('临时数据保存成功!')
1497
- router.back()
1493
+ goBack()
1498
1494
  clear()
1499
1495
  }
1500
1496
  catch (error) {
@@ -1648,7 +1644,7 @@ function submitSecurityCheckData(submitData: any) {
1648
1644
  if (res.data && res.data.enqueued) {
1649
1645
  showSuccessToast('提交成功')
1650
1646
  // 提交成功后返回
1651
- router.back()
1647
+ goBack()
1652
1648
  clear()
1653
1649
  }
1654
1650
  else {
@@ -2067,7 +2063,7 @@ function onFloatingBubble() {
2067
2063
  async function floatingBubbleSwitch(action) {
2068
2064
  // 返回首页固定为路由回退
2069
2065
  if (action.title === '返回上级') {
2070
- router.back()
2066
+ goBack()
2071
2067
  clear()
2072
2068
  }
2073
2069
  else if (action.title === '清空保存数据') {