vite-uni-dev-tool 1.1.0 → 1.2.1

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 (195) hide show
  1. package/README.md +21 -1
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +2 -1
  4. package/dist/const.js +1 -1
  5. package/dist/core-shared.d.ts +2 -3
  6. package/dist/core.d.ts +8 -8
  7. package/dist/core.js +2 -2
  8. package/dist/i18n/index.d.ts +0 -1
  9. package/dist/i18n/instance.d.ts +0 -1
  10. package/dist/i18n/locales/en.cjs +1 -1
  11. package/dist/i18n/locales/en.d.ts +6 -1
  12. package/dist/i18n/locales/en.js +1 -1
  13. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  14. package/dist/i18n/locales/zh-Hans.d.ts +6 -1
  15. package/dist/i18n/locales/zh-Hans.js +1 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/modules/devConsole/index.cjs +4 -4
  18. package/dist/modules/devConsole/index.d.ts +6 -107
  19. package/dist/modules/devConsole/index.js +4 -4
  20. package/dist/modules/devEvent/index.cjs +3 -3
  21. package/dist/modules/devEvent/index.d.ts +2 -3
  22. package/dist/modules/devEvent/index.js +3 -3
  23. package/dist/modules/devIntercept/index.cjs +14 -14
  24. package/dist/modules/devIntercept/index.d.ts +34 -6
  25. package/dist/modules/devIntercept/index.js +14 -14
  26. package/dist/modules/devStore/index.cjs +1 -1
  27. package/dist/modules/devStore/index.d.ts +48 -40
  28. package/dist/modules/devStore/index.js +1 -1
  29. package/dist/modules/devToolInfo/index.cjs +1 -1
  30. package/dist/modules/devToolInfo/index.d.ts +6 -25
  31. package/dist/modules/devToolInfo/index.js +1 -1
  32. package/dist/plugins/uniDevTool/transform/transformApp.d.ts +0 -1
  33. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
  34. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -2
  35. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  36. package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
  37. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -2
  38. package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
  39. package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
  40. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -2
  41. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  42. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -1
  43. package/dist/plugins/utils/index.d.ts +0 -1
  44. package/dist/shims-uni.d.ts +26 -22
  45. package/dist/type.d.ts +47 -43
  46. package/dist/utils/array.d.ts +0 -1
  47. package/dist/utils/date.d.ts +0 -1
  48. package/dist/utils/file.d.ts +0 -1
  49. package/dist/utils/function.d.ts +0 -1
  50. package/dist/utils/index.d.ts +0 -1
  51. package/dist/utils/ip.d.ts +0 -1
  52. package/dist/utils/language.d.ts +14 -15
  53. package/dist/utils/object.cjs +1 -1
  54. package/dist/utils/object.d.ts +7 -8
  55. package/dist/utils/object.js +1 -1
  56. package/dist/utils/openLink.d.ts +0 -1
  57. package/dist/utils/page.d.ts +0 -1
  58. package/dist/utils/platform.d.ts +0 -1
  59. package/dist/utils/string.d.ts +0 -1
  60. package/dist/utils/utils.d.ts +0 -1
  61. package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -199
  62. package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -730
  63. package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -167
  64. package/dist/v3/DevTool/components/CaptureScreen/index.vue +109 -109
  65. package/dist/v3/DevTool/components/ConsoleList/ConsoleItem.vue +230 -225
  66. package/dist/v3/DevTool/components/ConsoleList/RunJSInput.vue +247 -247
  67. package/dist/v3/DevTool/components/ConsoleList/index.vue +171 -171
  68. package/dist/v3/DevTool/components/ConsoleList/staticTips.ts +1145 -1145
  69. package/dist/v3/DevTool/components/DevToolButton/index.vue +42 -6
  70. package/dist/v3/DevTool/components/DevToolTitle/index.vue +24 -24
  71. package/dist/v3/DevTool/components/DevToolWindow/DevToolOverlay.vue +197 -197
  72. package/dist/v3/DevTool/components/DevToolWindow/hooks/dataUtils.ts +48 -48
  73. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +411 -387
  74. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +644 -629
  75. package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolOverlay.ts +201 -197
  76. package/dist/v3/DevTool/components/DevToolWindow/index.vue +27 -64
  77. package/dist/v3/DevTool/components/ElEvent/ElEventItem.vue +105 -105
  78. package/dist/v3/DevTool/components/ElEvent/index.vue +106 -106
  79. package/dist/v3/DevTool/components/Instance/components/InstanceTreeNode.vue +265 -265
  80. package/dist/v3/DevTool/components/Instance/flatten.ts +226 -226
  81. package/dist/v3/DevTool/components/Instance/index.vue +94 -94
  82. package/dist/v3/DevTool/components/Instance/registry.ts +49 -49
  83. package/dist/v3/DevTool/components/Instance/transformTree.ts +393 -375
  84. package/dist/v3/DevTool/components/Instance/transformTreeCtx.ts +268 -268
  85. package/dist/v3/DevTool/components/Instance/typing.d.ts +43 -43
  86. package/dist/v3/DevTool/components/InstanceDetail/index.vue +485 -485
  87. package/dist/v3/DevTool/components/JsonDetail/index.vue +70 -70
  88. package/dist/v3/DevTool/components/NFCList/NFCItem.vue +112 -112
  89. package/dist/v3/DevTool/components/NFCList/NFCTool.vue +454 -454
  90. package/dist/v3/DevTool/components/NFCList/const.ts +56 -56
  91. package/dist/v3/DevTool/components/NFCList/index.vue +94 -94
  92. package/dist/v3/DevTool/components/NetworkList/InterceptConfig.vue +624 -624
  93. package/dist/v3/DevTool/components/NetworkList/InterceptItem.vue +140 -140
  94. package/dist/v3/DevTool/components/NetworkList/NetworkDetail.vue +287 -287
  95. package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +88 -88
  96. package/dist/v3/DevTool/components/NetworkList/NetworkItem.vue +163 -163
  97. package/dist/v3/DevTool/components/NetworkList/NetworkSend.vue +589 -589
  98. package/dist/v3/DevTool/components/NetworkList/const.ts +4 -4
  99. package/dist/v3/DevTool/components/NetworkList/hooks/useNetworkForm.ts +86 -86
  100. package/dist/v3/DevTool/components/NetworkList/index.vue +160 -160
  101. package/dist/v3/DevTool/components/NetworkList/utils.ts +101 -101
  102. package/dist/v3/DevTool/components/Performance/index.vue +498 -498
  103. package/dist/v3/DevTool/components/Performance/modules/PerformanceMetrics.vue +153 -153
  104. package/dist/v3/DevTool/components/Performance/modules/usePerformanceChart.ts +460 -460
  105. package/dist/v3/DevTool/components/Performance/modules/usePerformanceData.ts +258 -258
  106. package/dist/v3/DevTool/components/PiniaList/index.vue +93 -93
  107. package/dist/v3/DevTool/components/RunJS/index.vue +148 -148
  108. package/dist/v3/DevTool/components/ScanCodeList/ScanCodeItem.vue +97 -97
  109. package/dist/v3/DevTool/components/ScanCodeList/index.vue +100 -100
  110. package/dist/v3/DevTool/components/SettingButton/index.vue +45 -45
  111. package/dist/v3/DevTool/components/SettingList/index.vue +226 -218
  112. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +320 -304
  113. package/dist/v3/DevTool/components/SettingList/modules/SettingDevTool.vue +212 -212
  114. package/dist/v3/DevTool/components/SettingList/modules/SettingInfo.vue +157 -157
  115. package/dist/v3/DevTool/components/SettingList/modules/SettingLanguage.vue +74 -74
  116. package/dist/v3/DevTool/components/SettingList/modules/SettingLog.vue +230 -230
  117. package/dist/v3/DevTool/components/SettingList/typing.d.ts +2 -2
  118. package/dist/v3/DevTool/components/SourceCode/Line.vue +127 -127
  119. package/dist/v3/DevTool/components/SourceCode/parseCode.ts +609 -609
  120. package/dist/v3/DevTool/components/StorageList/index.vue +174 -174
  121. package/dist/v3/DevTool/components/TransferList/TransferDetail.vue +268 -268
  122. package/dist/v3/DevTool/components/VuexList/index.vue +84 -84
  123. package/dist/v3/DevTool/index.vue +85 -138
  124. package/dist/v3/components/AppTransition/index.vue +156 -176
  125. package/dist/v3/components/AutoSizer/index.vue +192 -192
  126. package/dist/v3/components/AutoSizer/index1.vue +184 -184
  127. package/dist/v3/components/AutoSizer/utils.ts +49 -49
  128. package/dist/v3/components/Barrage/BarrageItem.vue +194 -137
  129. package/dist/v3/components/Barrage/index.vue +205 -202
  130. package/dist/v3/components/CircularButton/index.vue +84 -84
  131. package/dist/v3/components/CustomSwiper/CustomSwiperItem.vue +49 -49
  132. package/dist/v3/components/CustomSwiper/index.vue +104 -104
  133. package/dist/v3/components/DevErrorBoundary/index.vue +388 -0
  134. package/dist/v3/components/DraggableContainer/index.vue +186 -73
  135. package/dist/v3/components/Empty/index.vue +29 -29
  136. package/dist/v3/components/FilterSelect/index.vue +179 -179
  137. package/dist/v3/components/JsonPretty/components/Brackets/index.vue +27 -27
  138. package/dist/v3/components/JsonPretty/components/Carets/index.vue +59 -59
  139. package/dist/v3/components/JsonPretty/components/CheckController/index.vue +136 -136
  140. package/dist/v3/components/JsonPretty/components/TreeNode/index.vue +387 -387
  141. package/dist/v3/components/JsonPretty/hooks/useClipboard.ts +21 -21
  142. package/dist/v3/components/JsonPretty/hooks/useError.ts +21 -21
  143. package/dist/v3/components/JsonPretty/type.ts +127 -127
  144. package/dist/v3/components/JsonPretty/utils/index.ts +169 -169
  145. package/dist/v3/components/MovableContainer/index.vue +10 -4
  146. package/dist/v3/components/Pick/index.vue +321 -322
  147. package/dist/v3/components/Tag/index.vue +113 -113
  148. package/dist/v3/components/VirtualList/AutoSize.vue +40 -40
  149. package/dist/v3/components/VirtualList/index.vue +416 -416
  150. package/dist/v3/hooks/useBluetooth/index.ts +561 -561
  151. package/dist/v3/hooks/useContainerStyle.ts +95 -153
  152. package/dist/v3/hooks/useNFC/index.ts +107 -107
  153. package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
  154. package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
  155. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
  156. package/dist/v3/hooks/useNFC/utils.ts +754 -754
  157. package/dist/v3/hooks/useRequest/index.ts +586 -586
  158. package/dist/v3/hooks/useRequest/utils.ts +267 -267
  159. package/dist/v3/hooks/useScanCode/index.ts +206 -206
  160. package/dist/v3/hooks/useWebsocket/index.ts +253 -253
  161. package/dist/v3/styles/theme.ts +12 -12
  162. package/package.json +70 -59
  163. package/dist/const.d.ts.map +0 -1
  164. package/dist/core-shared.d.ts.map +0 -1
  165. package/dist/core.d.ts.map +0 -1
  166. package/dist/i18n/index.d.ts.map +0 -1
  167. package/dist/i18n/instance.d.ts.map +0 -1
  168. package/dist/i18n/locales/en.d.ts.map +0 -1
  169. package/dist/i18n/locales/zh-Hans.d.ts.map +0 -1
  170. package/dist/index.d.ts.map +0 -1
  171. package/dist/modules/devConsole/index.d.ts.map +0 -1
  172. package/dist/modules/devEvent/index.d.ts.map +0 -1
  173. package/dist/modules/devIntercept/index.d.ts.map +0 -1
  174. package/dist/modules/devStore/index.d.ts.map +0 -1
  175. package/dist/modules/devToolInfo/index.d.ts.map +0 -1
  176. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +0 -1
  177. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +0 -1
  178. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +0 -1
  179. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  180. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -1
  181. package/dist/plugins/utils/index.d.ts.map +0 -1
  182. package/dist/type.d.ts.map +0 -1
  183. package/dist/utils/array.d.ts.map +0 -1
  184. package/dist/utils/date.d.ts.map +0 -1
  185. package/dist/utils/file.d.ts.map +0 -1
  186. package/dist/utils/function.d.ts.map +0 -1
  187. package/dist/utils/index.d.ts.map +0 -1
  188. package/dist/utils/ip.d.ts.map +0 -1
  189. package/dist/utils/language.d.ts.map +0 -1
  190. package/dist/utils/object.d.ts.map +0 -1
  191. package/dist/utils/openLink.d.ts.map +0 -1
  192. package/dist/utils/page.d.ts.map +0 -1
  193. package/dist/utils/platform.d.ts.map +0 -1
  194. package/dist/utils/string.d.ts.map +0 -1
  195. package/dist/utils/utils.d.ts.map +0 -1
@@ -1,104 +1,104 @@
1
- <template>
2
- <view
3
- class="custom-swiper"
4
- @touchstart="onTouchStart"
5
- @touchend="onTouchEnd"
6
- @mousedown="onMouseDown"
7
- @mouseup="onMouseUp"
8
- @mouseleave="onMouseLeave">
9
- <view class="custom-swiper-wrapper" :style="wrapperStyle">
10
- <slot></slot>
11
- </view>
12
- </view>
13
- </template>
14
- <script lang="ts">
15
- export default {
16
- options: {
17
- virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
18
- },
19
- };
20
- </script>
21
- <script setup lang="ts">
22
- import { computed, ref } from 'vue';
23
-
24
- const props = defineProps<{
25
- modelValue: number;
26
- itemCount: number;
27
- }>();
28
-
29
- const emit = defineEmits<{
30
- (e: 'update:modelValue', value: number): void;
31
- (e: 'change', value: number): void;
32
- }>();
33
-
34
- const touchStart = ref({ x: 0, y: 0 });
35
-
36
- const isDragging = ref(false);
37
-
38
- const wrapperStyle = computed(() => ({
39
- transform: `translateX(-${props.modelValue * 100}%)`,
40
- }));
41
-
42
- // 统一处理滑动逻辑
43
- function handleSwipe(deltaX: number, deltaY: number) {
44
- if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
45
- if (deltaX > 0 && props.modelValue > 0) {
46
- const next = props.modelValue - 1;
47
- emit('update:modelValue', next);
48
- emit('change', next);
49
- } else if (deltaX < 0 && props.modelValue < props.itemCount - 1) {
50
- const next = props.modelValue + 1;
51
- emit('update:modelValue', next);
52
- emit('change', next);
53
- }
54
- }
55
- }
56
-
57
- // 触摸事件处理
58
- function onTouchStart(e: TouchEvent) {
59
- const touch = e.touches[0];
60
- touchStart.value = { x: touch.clientX, y: touch.clientY };
61
- }
62
-
63
- function onTouchEnd(e: TouchEvent) {
64
- const touch = e.changedTouches[0];
65
- const deltaX = touch.clientX - touchStart.value.x;
66
- const deltaY = touch.clientY - touchStart.value.y;
67
- handleSwipe(deltaX, deltaY);
68
- }
69
-
70
- // 鼠标事件处理
71
- function onMouseDown(e: MouseEvent) {
72
- isDragging.value = true;
73
- touchStart.value = { x: e.clientX, y: e.clientY };
74
- }
75
-
76
- function onMouseUp(e: MouseEvent) {
77
- if (!isDragging.value) return;
78
- isDragging.value = false;
79
- const deltaX = e.clientX - touchStart.value.x;
80
- const deltaY = e.clientY - touchStart.value.y;
81
- handleSwipe(deltaX, deltaY);
82
- }
83
-
84
- function onMouseLeave() {
85
- isDragging.value = false;
86
- }
87
- </script>
88
-
89
- <style scoped>
90
- .custom-swiper {
91
- width: 100%;
92
- height: 100%;
93
- overflow: hidden;
94
- position: relative;
95
- }
96
-
97
- .custom-swiper-wrapper {
98
- display: flex;
99
- width: 100%;
100
- height: 100%;
101
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
102
- will-change: transform;
103
- }
104
- </style>
1
+ <template>
2
+ <view
3
+ class="custom-swiper"
4
+ @touchstart="onTouchStart"
5
+ @touchend="onTouchEnd"
6
+ @mousedown="onMouseDown"
7
+ @mouseup="onMouseUp"
8
+ @mouseleave="onMouseLeave">
9
+ <view class="custom-swiper-wrapper" :style="wrapperStyle">
10
+ <slot></slot>
11
+ </view>
12
+ </view>
13
+ </template>
14
+ <script lang="ts">
15
+ export default {
16
+ options: {
17
+ virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
18
+ },
19
+ };
20
+ </script>
21
+ <script setup lang="ts">
22
+ import { computed, ref } from 'vue';
23
+
24
+ const props = defineProps<{
25
+ modelValue: number;
26
+ itemCount: number;
27
+ }>();
28
+
29
+ const emit = defineEmits<{
30
+ (e: 'update:modelValue', value: number): void;
31
+ (e: 'change', value: number): void;
32
+ }>();
33
+
34
+ const touchStart = ref({ x: 0, y: 0 });
35
+
36
+ const isDragging = ref(false);
37
+
38
+ const wrapperStyle = computed(() => ({
39
+ transform: `translateX(-${props.modelValue * 100}%)`,
40
+ }));
41
+
42
+ // 统一处理滑动逻辑
43
+ function handleSwipe(deltaX: number, deltaY: number) {
44
+ if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
45
+ if (deltaX > 0 && props.modelValue > 0) {
46
+ const next = props.modelValue - 1;
47
+ emit('update:modelValue', next);
48
+ emit('change', next);
49
+ } else if (deltaX < 0 && props.modelValue < props.itemCount - 1) {
50
+ const next = props.modelValue + 1;
51
+ emit('update:modelValue', next);
52
+ emit('change', next);
53
+ }
54
+ }
55
+ }
56
+
57
+ // 触摸事件处理
58
+ function onTouchStart(e: TouchEvent) {
59
+ const touch = e.touches[0];
60
+ touchStart.value = { x: touch.clientX, y: touch.clientY };
61
+ }
62
+
63
+ function onTouchEnd(e: TouchEvent) {
64
+ const touch = e.changedTouches[0];
65
+ const deltaX = touch.clientX - touchStart.value.x;
66
+ const deltaY = touch.clientY - touchStart.value.y;
67
+ handleSwipe(deltaX, deltaY);
68
+ }
69
+
70
+ // 鼠标事件处理
71
+ function onMouseDown(e: MouseEvent) {
72
+ isDragging.value = true;
73
+ touchStart.value = { x: e.clientX, y: e.clientY };
74
+ }
75
+
76
+ function onMouseUp(e: MouseEvent) {
77
+ if (!isDragging.value) return;
78
+ isDragging.value = false;
79
+ const deltaX = e.clientX - touchStart.value.x;
80
+ const deltaY = e.clientY - touchStart.value.y;
81
+ handleSwipe(deltaX, deltaY);
82
+ }
83
+
84
+ function onMouseLeave() {
85
+ isDragging.value = false;
86
+ }
87
+ </script>
88
+
89
+ <style scoped>
90
+ .custom-swiper {
91
+ width: 100%;
92
+ height: 100%;
93
+ overflow: hidden;
94
+ position: relative;
95
+ }
96
+
97
+ .custom-swiper-wrapper {
98
+ display: flex;
99
+ width: 100%;
100
+ height: 100%;
101
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
102
+ will-change: transform;
103
+ }
104
+ </style>
@@ -0,0 +1,388 @@
1
+ <template>
2
+ <slot v-if="!hasError"></slot>
3
+ <view v-else class="dev-error-boundary">
4
+ <view class="dev-error-card">
5
+ <view class="dev-error-header">
6
+ <view class="dev-error-icon-wrapper">
7
+ <view class="dev-error-icon">!</view>
8
+ <view class="dev-error-icon-pulse"></view>
9
+ </view>
10
+ <view class="dev-error-title-box">
11
+ <text class="dev-error-title">{{ t('errorBoundary.title') }}</text>
12
+ <text class="dev-error-subtitle">Runtime Exception Isolated</text>
13
+ </view>
14
+ </view>
15
+
16
+ <view class="dev-error-body">
17
+ <view class="dev-error-msg-container">
18
+ <view class="dev-error-msg-header">
19
+ <text class="dev-error-msg-label">StackTrace</text>
20
+ <view class="dev-error-copy" @tap="copyError">
21
+ <text class="dev-error-copy-text">Copy</text>
22
+ </view>
23
+ </view>
24
+ <scroll-view scroll-y class="dev-error-msg-box">
25
+ <text class="dev-error-msg">{{ errorMessage }}</text>
26
+ </scroll-view>
27
+ </view>
28
+ <view class="dev-error-tips-box">
29
+ <view class="dev-error-tips-dot"></view>
30
+ <text class="dev-error-tips">{{ t('errorBoundary.tips') }}</text>
31
+ </view>
32
+ </view>
33
+
34
+ <view class="dev-error-footer">
35
+ <view class="dev-error-btn-retry" @tap="retry">
36
+ <text class="dev-error-btn-text">{{ t('errorBoundary.retry') }}</text>
37
+ </view>
38
+ </view>
39
+ </view>
40
+
41
+ <!-- Subtle background decoration -->
42
+ <view class="dev-error-bg-circle-1"></view>
43
+ <view class="dev-error-bg-circle-2"></view>
44
+ </view>
45
+ </template>
46
+
47
+ <script setup lang="ts">
48
+ import { ref, onErrorCaptured, onMounted, onUnmounted, nextTick } from 'vue';
49
+ import { i18n } from '../../../i18n/instance';
50
+ import { DEV_ERROR_BOUNDARY_TRIGGER } from '../../../const';
51
+ import { getCurrentPagePath } from '../../../utils';
52
+
53
+ const t = (key: string) => i18n.t(key);
54
+
55
+ const hasError = ref(false);
56
+ const errorMessage = ref('');
57
+
58
+ /**
59
+ * 处理错误的核心逻辑
60
+ */
61
+ const handleError = (err: any, info?: string) => {
62
+ if (hasError.value) return; // 状态锁,防止重复处理
63
+
64
+ console.log('[DevTool] Boundary Handling Error:', err?.message || err);
65
+ hasError.value = true;
66
+ errorMessage.value =
67
+ err?.stack || err?.message || err?.toString() || 'Unknown Error';
68
+
69
+ // 手动打印到控制台
70
+ console.error('[ErrorBoundary]', err);
71
+ if (info) console.warn('[ErrorBoundary] Info: ' + info);
72
+
73
+ // 强制下一帧显示
74
+ nextTick(() => {
75
+ hasError.value = true;
76
+ });
77
+ };
78
+
79
+ onMounted(() => {
80
+ // 在非 H5 环境(小程序、APP),由于 onErrorCaptured 可能失效,启用全局监听作为核心捕获方案
81
+ // #ifndef H5
82
+ const mountedPath = getCurrentPagePath();
83
+ uni.$on(DEV_ERROR_BOUNDARY_TRIGGER, (data: any) => {
84
+ const currentPath = getCurrentPagePath();
85
+ if (currentPath === mountedPath && !hasError.value) {
86
+ handleError(data.err, data.info);
87
+ }
88
+ });
89
+ // #endif
90
+ });
91
+
92
+ onUnmounted(() => {
93
+ // #ifndef H5
94
+ uni.$off(DEV_ERROR_BOUNDARY_TRIGGER);
95
+ // #endif
96
+ });
97
+
98
+ onErrorCaptured((err: any, _instance: any, info: string) => {
99
+ // 在 H5 环境,onErrorCaptured 通常能可靠工作
100
+ // 在其它环境,它可能与全局拦截器同时生效,handleError 内部已有 hasError 锁定
101
+ handleError(err, info);
102
+ // 阻止错误继续向上冒泡,防止触发全局拦截器产生的二次 emit
103
+ return false;
104
+ });
105
+
106
+ const retry = () => {
107
+ hasError.value = false;
108
+ errorMessage.value = '';
109
+ };
110
+
111
+ const copyError = () => {
112
+ uni.setClipboardData({
113
+ data: errorMessage.value,
114
+ success: () => {
115
+ uni.showToast({
116
+ title: 'Copied to clipboard',
117
+ icon: 'none',
118
+ });
119
+ },
120
+ });
121
+ };
122
+
123
+ defineExpose({
124
+ retry,
125
+ });
126
+ </script>
127
+
128
+ <style scoped>
129
+ .dev-error-boundary {
130
+ position: fixed;
131
+ inset: 0;
132
+ z-index: 995;
133
+ width: 100vw;
134
+ height: 100vh;
135
+ display: flex;
136
+ flex-direction: column;
137
+ align-items: center;
138
+ justify-content: center;
139
+ padding: 80rpx 40rpx;
140
+ background-color: #f6f8fa;
141
+ box-sizing: border-box;
142
+ overflow: hidden;
143
+ }
144
+
145
+ /* Background elements for premium feel */
146
+ .dev-error-bg-circle-1 {
147
+ position: absolute;
148
+ width: 400rpx;
149
+ height: 400rpx;
150
+ border-radius: 50%;
151
+ background: radial-gradient(
152
+ circle,
153
+ rgb(255 77 79 / 5%) 0%,
154
+ transparent 70%
155
+ );
156
+ top: -100rpx;
157
+ right: -100rpx;
158
+ z-index: 1;
159
+ }
160
+
161
+ .dev-error-bg-circle-2 {
162
+ position: absolute;
163
+ width: 300rpx;
164
+ height: 300rpx;
165
+ border-radius: 50%;
166
+ background: radial-gradient(
167
+ circle,
168
+ rgb(24 144 255 / 5%) 0%,
169
+ transparent 70%
170
+ );
171
+ bottom: -50rpx;
172
+ left: -50rpx;
173
+ z-index: 1;
174
+ }
175
+
176
+ .dev-error-card {
177
+ background-color: rgb(255 255 255 / 95%);
178
+ backdrop-filter: blur(10px);
179
+ border-radius: 32rpx;
180
+ box-shadow:
181
+ 0 10rpx 30rpx rgb(0 0 0 / 4%),
182
+ 0 30rpx 100rpx rgb(0 0 0 / 8%);
183
+ width: 100%;
184
+ max-width: 680rpx;
185
+ overflow: hidden;
186
+ border: 1rpx solid rgb(255 255 255 / 80%);
187
+ animation: dev-premium-entrance 0.6s cubic-bezier(0.16, 1, 0.3, 1);
188
+ z-index: 2;
189
+ }
190
+
191
+ @keyframes dev-premium-entrance {
192
+ from {
193
+ opacity: 0;
194
+ transform: scale(0.95) translateY(40rpx);
195
+ }
196
+
197
+ to {
198
+ opacity: 1;
199
+ transform: scale(1) translateY(0);
200
+ }
201
+ }
202
+
203
+ .dev-error-header {
204
+ display: flex;
205
+ align-items: center;
206
+ padding: 40rpx;
207
+ background: linear-gradient(135deg, #fff7f6 0%, #fff 100%);
208
+ border-bottom: 2rpx solid #f0f0f0;
209
+ }
210
+
211
+ .dev-error-icon-wrapper {
212
+ position: relative;
213
+ width: 64rpx;
214
+ height: 64rpx;
215
+ background: linear-gradient(135deg, #ff7875 0%, #ff4d4f 100%);
216
+ border-radius: 20rpx;
217
+ display: flex;
218
+ align-items: center;
219
+ justify-content: center;
220
+ margin-right: 28rpx;
221
+ flex-shrink: 0;
222
+ box-shadow: 0 8rpx 20rpx rgb(255 77 79 / 25%);
223
+ }
224
+
225
+ .dev-error-icon {
226
+ color: #fff;
227
+ font-size: 36rpx;
228
+ font-weight: 900;
229
+ z-index: 3;
230
+ }
231
+
232
+ .dev-error-icon-pulse {
233
+ position: absolute;
234
+ width: 100%;
235
+ height: 100%;
236
+ background-color: #ff4d4f;
237
+ border-radius: 20rpx;
238
+ opacity: 0.4;
239
+ animation: dev-icon-pulse 2s infinite;
240
+ z-index: 2;
241
+ }
242
+
243
+ @keyframes dev-icon-pulse {
244
+ 0% {
245
+ transform: scale(1);
246
+ opacity: 0.4;
247
+ }
248
+
249
+ 70% {
250
+ transform: scale(1.4);
251
+ opacity: 0;
252
+ }
253
+
254
+ 100% {
255
+ transform: scale(1);
256
+ opacity: 0;
257
+ }
258
+ }
259
+
260
+ .dev-error-title-box {
261
+ display: flex;
262
+ flex-direction: column;
263
+ }
264
+
265
+ .dev-error-title {
266
+ font-size: 34rpx;
267
+ font-weight: 700;
268
+ color: #1a1a1a;
269
+ letter-spacing: -0.5rpx;
270
+ }
271
+
272
+ .dev-error-subtitle {
273
+ font-size: 20rpx;
274
+ color: #ff4d4f;
275
+ text-transform: uppercase;
276
+ font-weight: 600;
277
+ letter-spacing: 1rpx;
278
+ margin-top: 4rpx;
279
+ }
280
+
281
+ .dev-error-body {
282
+ padding: 40rpx;
283
+ }
284
+
285
+ .dev-error-msg-container {
286
+ border-radius: 20rpx;
287
+ background-color: #141414;
288
+ overflow: hidden;
289
+ margin-bottom: 30rpx;
290
+ box-shadow: inset 0 2rpx 10rpx rgb(0 0 0 / 20%);
291
+ }
292
+
293
+ .dev-error-msg-header {
294
+ display: flex;
295
+ justify-content: space-between;
296
+ align-items: center;
297
+ padding: 16rpx 24rpx;
298
+ background-color: #1a1a1a;
299
+ border-bottom: 1rpx solid #2a2a2a;
300
+ }
301
+
302
+ .dev-error-msg-label {
303
+ color: #8c8c8c;
304
+ font-size: 20rpx;
305
+ font-weight: 600;
306
+ text-transform: uppercase;
307
+ }
308
+
309
+ .dev-error-copy {
310
+ padding: 4rpx 16rpx;
311
+ background-color: #333;
312
+ border-radius: 8rpx;
313
+ }
314
+
315
+ .dev-error-copy:active {
316
+ background-color: #444;
317
+ }
318
+
319
+ .dev-error-copy-text {
320
+ color: #d9d9d9;
321
+ font-size: 20rpx;
322
+ }
323
+
324
+ .dev-error-msg-box {
325
+ padding: 24rpx;
326
+ max-height: 360rpx;
327
+ }
328
+
329
+ .dev-error-msg {
330
+ font-size: 22rpx;
331
+ color: #ff7875;
332
+ font-family:
333
+ 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
334
+ word-break: break-all;
335
+ line-height: 1.6;
336
+ }
337
+
338
+ .dev-error-tips-box {
339
+ display: flex;
340
+ align-items: center;
341
+ background-color: #fffaf0;
342
+ padding: 20rpx 24rpx;
343
+ border-radius: 12rpx;
344
+ border: 1rpx solid #ffe58f;
345
+ }
346
+
347
+ .dev-error-tips-dot {
348
+ width: 10rpx;
349
+ height: 10rpx;
350
+ background-color: #faad14;
351
+ border-radius: 50%;
352
+ margin-right: 16rpx;
353
+ flex-shrink: 0;
354
+ }
355
+
356
+ .dev-error-tips {
357
+ font-size: 24rpx;
358
+ color: #856404;
359
+ line-height: 1.4;
360
+ flex: 1;
361
+ }
362
+
363
+ .dev-error-footer {
364
+ padding: 0 40rpx 50rpx;
365
+ }
366
+
367
+ .dev-error-btn-retry {
368
+ background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%);
369
+ height: 88rpx;
370
+ border-radius: 44rpx;
371
+ display: flex;
372
+ align-items: center;
373
+ justify-content: center;
374
+ box-shadow: 0 8rpx 24rpx rgb(24 144 255 / 30%);
375
+ transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
376
+ }
377
+
378
+ .dev-error-btn-retry:active {
379
+ transform: scale(0.95);
380
+ box-shadow: 0 4rpx 12rpx rgb(24 144 255 / 20%);
381
+ }
382
+
383
+ .dev-error-btn-text {
384
+ color: #fff;
385
+ font-size: 30rpx;
386
+ font-weight: 600;
387
+ }
388
+ </style>