vite-uni-dev-tool 0.0.13 → 0.0.15

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 (130) hide show
  1. package/dist/core.js +1 -1
  2. package/dist/devIntercept/index.d.ts +3 -3
  3. package/dist/devIntercept/index.d.ts.map +1 -1
  4. package/dist/devIntercept/index.js +117 -114
  5. package/dist/plugins/uniDevTool/transform/transformApp.d.ts +32 -0
  6. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -0
  7. package/dist/plugins/uniDevTool/transform/transformApp.js +32 -0
  8. package/dist/plugins/uniDevTool/transform/transformMain.d.ts +26 -0
  9. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -0
  10. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -0
  11. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +41 -0
  12. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -0
  13. package/dist/plugins/uniDevTool/transform/transformVue.js +9 -0
  14. package/dist/plugins/uniDevTool/uniDevTool.d.ts +7 -3
  15. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  16. package/dist/plugins/uniDevTool/uniDevTool.js +3 -33
  17. package/dist/plugins/utils/index.d.ts +32 -0
  18. package/dist/plugins/utils/index.d.ts.map +1 -1
  19. package/dist/plugins/utils/index.js +1 -1
  20. package/dist/type.d.ts +2 -2
  21. package/dist/type.d.ts.map +1 -1
  22. package/dist/v2/AppInfo/index.vue +41 -0
  23. package/dist/v2/AutoSizer/index.vue +189 -0
  24. package/dist/v2/AutoSizer/index1.vue +193 -0
  25. package/dist/v2/AutoSizer/utils.ts +49 -0
  26. package/dist/v2/CaptureScreen/index.vue +78 -0
  27. package/dist/v2/CloseButton/index.vue +32 -0
  28. package/dist/v2/Connection/index.vue +94 -0
  29. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  30. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  31. package/dist/v2/ConsoleList/index.vue +164 -0
  32. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  33. package/dist/v2/DevTool/index.vue +162 -0
  34. package/dist/v2/DevToolButton/index.vue +228 -0
  35. package/dist/v2/DevToolTitle/index.vue +28 -0
  36. package/dist/v2/DevToolWindow/index.vue +1051 -0
  37. package/dist/v2/DeviceInfo/index.vue +48 -0
  38. package/dist/v2/Empty/empty.png +0 -0
  39. package/dist/v2/Empty/index.vue +40 -0
  40. package/dist/v2/FilterInput/index.vue +100 -0
  41. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  42. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  43. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  44. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  45. package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
  46. package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
  47. package/dist/v2/JsonPretty/index.vue +531 -0
  48. package/dist/v2/JsonPretty/type.ts +125 -0
  49. package/dist/v2/JsonPretty/utils/index.js +211 -0
  50. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  51. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  52. package/dist/v2/NetworkList/index.vue +148 -0
  53. package/dist/v2/PiniaList/index.vue +79 -0
  54. package/dist/v2/RouteList/index.vue +137 -0
  55. package/dist/v2/RunJS/index.vue +128 -0
  56. package/dist/v2/SettingList/index.vue +318 -0
  57. package/dist/v2/SourceCode/index.vue +237 -0
  58. package/dist/v2/StorageList/index.vue +165 -0
  59. package/dist/v2/SystemInfo/index.vue +49 -0
  60. package/dist/v2/Tabs/index.vue +127 -0
  61. package/dist/v2/Tag/index.vue +91 -0
  62. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  63. package/dist/v2/UniEvent/index.vue +127 -0
  64. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  65. package/dist/v2/UploadList/UploadItem.vue +134 -0
  66. package/dist/v2/UploadList/index.vue +143 -0
  67. package/dist/v2/VirtualList/index.vue +140 -0
  68. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  69. package/dist/v2/VirtualListPro/index.vue +255 -0
  70. package/dist/v2/VirtualListPro/readme.md +40 -0
  71. package/dist/v2/VuexList/index.vue +80 -0
  72. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  73. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  74. package/dist/v2/WebSocket/index.vue +155 -0
  75. package/dist/v2/WindowInfo/index.vue +49 -0
  76. package/dist/v3/AppInfo/index.vue +35 -0
  77. package/dist/v3/AutoSizer/index.vue +193 -0
  78. package/dist/v3/AutoSizer/index1.vue +186 -0
  79. package/dist/v3/AutoSizer/utils.ts +49 -0
  80. package/dist/v3/CaptureScreen/index.vue +62 -0
  81. package/dist/v3/CloseButton/index.vue +29 -0
  82. package/dist/v3/Connection/index.vue +88 -0
  83. package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
  84. package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
  85. package/dist/v3/ConsoleList/index.vue +139 -0
  86. package/dist/v3/ConsoleList/staticTips.ts +1145 -0
  87. package/dist/v3/DevTool/index.vue +217 -0
  88. package/dist/v3/DevToolButton/index.vue +210 -0
  89. package/dist/v3/DevToolTitle/index.vue +21 -0
  90. package/dist/v3/DevToolWindow/index.vue +1116 -0
  91. package/dist/v3/DeviceInfo/index.vue +32 -0
  92. package/dist/v3/Empty/empty.png +0 -0
  93. package/dist/v3/Empty/index.vue +28 -0
  94. package/dist/v3/FilterInput/index.vue +87 -0
  95. package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
  96. package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
  97. package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
  98. package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
  99. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  100. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  101. package/dist/v3/JsonPretty/index.vue +476 -0
  102. package/dist/v3/JsonPretty/type.ts +125 -0
  103. package/dist/v3/JsonPretty/utils/index.ts +172 -0
  104. package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
  105. package/dist/v3/NetworkList/NetworkItem.vue +120 -0
  106. package/dist/v3/NetworkList/index.vue +128 -0
  107. package/dist/v3/PiniaList/index.vue +64 -0
  108. package/dist/v3/RouteList/index.vue +121 -0
  109. package/dist/v3/RunJS/index.vue +128 -0
  110. package/dist/v3/SettingList/index.vue +313 -0
  111. package/dist/v3/SourceCode/index.vue +231 -0
  112. package/dist/v3/StorageList/index.vue +170 -0
  113. package/dist/v3/SystemInfo/index.vue +34 -0
  114. package/dist/v3/Tabs/index.vue +123 -0
  115. package/dist/v3/Tag/index.vue +89 -0
  116. package/dist/v3/UniEvent/UniEventItem.vue +126 -0
  117. package/dist/v3/UniEvent/index.vue +98 -0
  118. package/dist/v3/UploadList/UploadDetail.vue +192 -0
  119. package/dist/v3/UploadList/UploadItem.vue +117 -0
  120. package/dist/v3/UploadList/index.vue +117 -0
  121. package/dist/v3/VirtualList/index.vue +112 -0
  122. package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
  123. package/dist/v3/VirtualListPro/index.vue +238 -0
  124. package/dist/v3/VirtualListPro/readme.md +40 -0
  125. package/dist/v3/VuexList/index.vue +54 -0
  126. package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
  127. package/dist/v3/WebSocket/WebSocketList.vue +161 -0
  128. package/dist/v3/WebSocket/index.vue +124 -0
  129. package/dist/v3/WindowInfo/index.vue +33 -0
  130. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <view
3
+ class="l-resize l-class"
4
+ :class="{ 'l-resize-target': hasNoDefaultSlot }"
5
+ :style="[styles, lStyle]"
6
+ >
7
+ <!-- 插槽需要脱离父容器文档流,防止父容器固宽固高导致插槽大小被限制 -->
8
+ <view
9
+ ref="lResizeContainer"
10
+ class="l-resize__container l-container-class"
11
+ :style="[lStyle]"
12
+ >
13
+ <!-- 被监听的插槽 -->
14
+ <slot></slot>
15
+ <!-- 监听插槽变大 -->
16
+ <scroll-view
17
+ class="l-resize__wrapper"
18
+ :scroll-y="true"
19
+ :scroll-x="true"
20
+ :scroll-top="expandScrollTop"
21
+ :scroll-left="expandScrollLeft"
22
+ @scroll="onScrollHandler"
23
+ >
24
+ <view
25
+ class="l-resize__wrapper--placeholder"
26
+ style="height: 100000px; width: 100000px"
27
+ ></view>
28
+ </scroll-view>
29
+ <!-- 监听插槽变小 -->
30
+ <scroll-view
31
+ class="l-resize__wrapper"
32
+ :scroll-y="true"
33
+ :scroll-x="true"
34
+ :scroll-top="shrinkScrollTop"
35
+ :scroll-left="shrinkScrollLeft"
36
+ @scroll="onScrollHandler"
37
+ >
38
+ <view
39
+ class="l-resize__wrapper--placeholder"
40
+ style="height: 250%; width: 250%"
41
+ ></view>
42
+ </scroll-view>
43
+ </view>
44
+ </view>
45
+ </template>
46
+
47
+ <script>
48
+ import { getRect, addUnit } from './utils';
49
+
50
+ export default {
51
+ props: {
52
+ lStyle: {
53
+ type: [String, Object],
54
+ default: () => ({}),
55
+ },
56
+ },
57
+
58
+ data() {
59
+ return {
60
+ width: 0,
61
+ height: 0,
62
+ hasNoDefaultSlot: false,
63
+ expandScrollTop: 0,
64
+ expandScrollLeft: 0,
65
+ shrinkScrollTop: 0,
66
+ shrinkScrollLeft: 0,
67
+ scrollEventCount: 0,
68
+ lastHeight: 0,
69
+ lastWidth: 0,
70
+ querySelector: '.l-resize__container',
71
+ };
72
+ },
73
+
74
+ computed: {
75
+ styles() {
76
+ // Vue2 中通过 this.$slots 访问插槽
77
+ if (this.$slots.default && (this.width || this.height)) {
78
+ return {
79
+ width: addUnit(this.width),
80
+ height: addUnit(this.height),
81
+ };
82
+ }
83
+ return {};
84
+ },
85
+ },
86
+
87
+ mounted() {
88
+ // 检查是否有默认插槽
89
+ this.hasNoDefaultSlot = !this.$slots.default;
90
+
91
+ // 初始获取尺寸
92
+ getRect(this.querySelector, this).then((res) => {
93
+ this.lastHeight = res.height || 0;
94
+ this.lastWidth = res.width || 0;
95
+ this.width = this.lastWidth;
96
+ this.height = this.lastHeight;
97
+ this.scrollToBottom({
98
+ width: this.lastWidth,
99
+ height: this.lastHeight,
100
+ });
101
+ });
102
+ },
103
+
104
+ methods: {
105
+ onScrollHandler() {
106
+ getRect(this.querySelector, this).then((res) => {
107
+ // 前两次滚动事件触发时通知尺寸变化
108
+ if (this.scrollEventCount++ === 0) {
109
+ this.resizeEvent(res);
110
+ }
111
+ // 屏蔽滚动条拉到底部的多余事件
112
+ if (this.scrollEventCount < 3) return;
113
+
114
+ const newHeight = res.height || 0;
115
+ const newWidth = res.width || 0;
116
+
117
+ // 更新容器尺寸
118
+ this.height = newHeight;
119
+ this.width = newWidth;
120
+
121
+ // 检查尺寸变化并触发事件
122
+ const emitStack = [];
123
+ if (newHeight !== this.lastHeight) {
124
+ this.lastHeight = newHeight;
125
+ emitStack.push(1);
126
+ }
127
+ if (newWidth !== this.lastWidth) {
128
+ this.lastWidth = newWidth;
129
+ emitStack.push(1);
130
+ }
131
+ if (emitStack.length > 0) {
132
+ this.resizeEvent(res);
133
+ }
134
+
135
+ // 滚动到底部
136
+ this.scrollToBottom({
137
+ width: this.lastWidth,
138
+ height: this.lastHeight,
139
+ });
140
+ });
141
+ },
142
+
143
+ scrollToBottom(res) {
144
+ this.expandScrollTop = 100000 + res.height;
145
+ this.shrinkScrollTop = 3 * this.height + res.height;
146
+ this.expandScrollLeft = 100000 + res.width;
147
+ this.shrinkScrollLeft = 3 * this.width + res.width;
148
+ },
149
+
150
+ resizeEvent(res) {
151
+ const result = {};
152
+ ['bottom', 'top', 'left', 'right', 'height', 'width'].forEach((prop) => {
153
+ result[prop] = res[prop];
154
+ });
155
+ this.$emit('resize', result);
156
+ },
157
+ },
158
+ };
159
+ </script>
160
+
161
+ <style lang="scss" scoped>
162
+ .l-resize {
163
+ &__container {
164
+ position: absolute;
165
+ min-width: 1px;
166
+ min-height: 1px;
167
+ }
168
+ &-target,
169
+ &__wrapper {
170
+ background-color: aqua;
171
+ position: absolute;
172
+ top: 0;
173
+ bottom: 0;
174
+ left: 0;
175
+ right: 0;
176
+ z-index: -9999;
177
+ overflow: hidden;
178
+ visibility: hidden;
179
+ }
180
+ &-target {
181
+ .l-resize__container {
182
+ width: 100%;
183
+ height: 100%;
184
+ }
185
+ }
186
+ &__wrapper {
187
+ &--placeholder {
188
+ transition: 0s;
189
+ animation: none;
190
+ }
191
+ }
192
+ }
193
+ </style>
@@ -0,0 +1,49 @@
1
+ import type { ComponentInternalInstance, ComponentPublicInstance } from 'vue';
2
+
3
+ export function getRect(
4
+ selector: string,
5
+ context: ComponentInternalInstance | null | any,
6
+ node: boolean = false,
7
+ ) {
8
+ // 之前是个对象,现在改成实例,防止旧版会报错
9
+ if (context == null) {
10
+ return Promise.reject('context is null');
11
+ }
12
+ if (context?.context) {
13
+ context = context.context;
14
+ }
15
+
16
+ return new Promise<UniNamespace.NodeInfo>((resolve, reject) => {
17
+ const dom = uni.createSelectorQuery().in(context).select(selector);
18
+ const result: any = (rect: UniNamespace.NodeInfo) => {
19
+ if (rect) {
20
+ resolve(rect);
21
+ } else {
22
+ reject('no rect');
23
+ }
24
+ };
25
+
26
+ if (!node) {
27
+ dom.boundingClientRect(result).exec();
28
+ } else {
29
+ dom
30
+ .fields(
31
+ {
32
+ node: true,
33
+ size: true,
34
+ rect: true,
35
+ },
36
+ result,
37
+ )
38
+ .exec();
39
+ }
40
+ });
41
+ }
42
+
43
+ export function addUnit(value?: string | number): string {
44
+ if (!value) {
45
+ return '0px';
46
+ }
47
+
48
+ return typeof value === 'number' ? `${value}px` : value;
49
+ }
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <view class="capture-screen-content">
3
+ <view class="capture-screen-control">
4
+ <Tag style="margin-left: auto" mode="clear" @click="handleClear">
5
+ 清空
6
+ </Tag>
7
+ </view>
8
+
9
+ <view class="capture-screen-list">
10
+ <view
11
+ class="capture-screen-item"
12
+ v-for="item in captureScreenList"
13
+ :key="item.timer + item.position"
14
+ >
15
+ <view class="info-row">时间:{{ item.timer }} </view>
16
+ <view class="info-row">页面:{{ item.position }}</view>
17
+ </view>
18
+
19
+ <Empty v-if="!captureScreenList || captureScreenList.length === 0" />
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import Empty from '../Empty/index.vue';
26
+ import Tag from '../Tag/index.vue';
27
+
28
+ export default {
29
+ components: {
30
+ Empty,
31
+ Tag,
32
+ },
33
+ props: {
34
+ /** @type {{position: string, time: string}[]} */
35
+ captureScreenList: {
36
+ type: Array,
37
+ default: () => [],
38
+ },
39
+ },
40
+ methods: {
41
+ handleClear() {
42
+ this.$emit('clear');
43
+ },
44
+ },
45
+ };
46
+ </script>
47
+
48
+ <style scoped>
49
+ .capture-screen-content {
50
+ height: 100%;
51
+ font-size: var(--dev-tool-base-font-size);
52
+ }
53
+
54
+ .capture-screen-list {
55
+ height: calc(100% - 32px);
56
+ overflow: auto;
57
+ }
58
+
59
+ .capture-screen-control {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: space-between;
63
+ gap: 8px;
64
+ padding: 0 16px;
65
+ height: 32px;
66
+ border-bottom: 1px solid var(--dev-tool-border-color);
67
+ box-sizing: border-box;
68
+ }
69
+
70
+ .capture-screen-item {
71
+ padding: 16px;
72
+ border-bottom: 1px solid var(--dev-tool-border-color);
73
+ }
74
+ .info-row {
75
+ height: 28px;
76
+ line-height: 28px;
77
+ }
78
+ </style>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <view class="close-button" @click="onClick"> × </view>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ methods: {
8
+ onClick() {
9
+ this.$emit('click');
10
+ },
11
+ },
12
+ };
13
+ </script>
14
+
15
+ <style scoped>
16
+ .close-button {
17
+ flex-shrink: 0;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ width: 24px;
22
+ height: 24px;
23
+ margin-left: auto;
24
+ border-radius: 50%;
25
+ border: 1px solid var(--dev-tool-text-color);
26
+ box-sizing: border-box;
27
+ color: var(--dev-tool-text-color);
28
+ transition:
29
+ border,
30
+ color 0.3s;
31
+ }
32
+ </style>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <view class="connection-content">
3
+ <view class="connection-item">
4
+ <DevToolTitle>网络连接</DevToolTitle>
5
+ <view class="connection-item-content">
6
+ <view class="connection-row">
7
+ <view>IP地址:</view>
8
+ <Tag
9
+ :mode="
10
+ netWorkStatus.isConnected === undefined || netWorkStatus.ip
11
+ ? 'info'
12
+ : netWorkStatus.isConnected && netWorkStatus.ip
13
+ ? 'success'
14
+ : 'error'
15
+ "
16
+ >
17
+ {{
18
+ netWorkStatus.isConnected === undefined
19
+ ? '未获取'
20
+ : netWorkStatus.ip || '未获取'
21
+ }}
22
+ </Tag>
23
+ </view>
24
+ <view class="connection-row">
25
+ <view>连接状态:</view>
26
+ <Tag
27
+ :mode="
28
+ netWorkStatus.isConnected === undefined
29
+ ? 'info'
30
+ : netWorkStatus.isConnected
31
+ ? 'success'
32
+ : 'error'
33
+ "
34
+ >
35
+ {{
36
+ netWorkStatus.isConnected === undefined
37
+ ? '未获取'
38
+ : netWorkStatus.isConnected
39
+ ? '已连接'
40
+ : '已断开'
41
+ }}
42
+ </Tag>
43
+ </view>
44
+ <view class="connection-row">
45
+ <view>网络类型:</view>
46
+ <Tag mode="info">{{ netWorkStatus.networkType || '未获取' }}</Tag>
47
+ </view>
48
+ </view>
49
+ </view>
50
+ </view>
51
+ </template>
52
+
53
+ <script>
54
+ import Tag from '../Tag/index.vue';
55
+ import DevToolTitle from '../DevToolTitle/index.vue';
56
+
57
+ export default {
58
+ components: {
59
+ Tag,
60
+ DevToolTitle,
61
+ },
62
+ props: {
63
+ netWorkStatus: {
64
+ type: Object,
65
+ default() {
66
+ return {
67
+ isConnected: undefined,
68
+ networkType: undefined,
69
+ ip: undefined,
70
+ };
71
+ },
72
+ },
73
+ },
74
+ };
75
+ </script>
76
+
77
+ <style scoped>
78
+ .connection-content {
79
+ height: 100%;
80
+ overflow: auto;
81
+ font-size: var(--dev-tool-base-font-size);
82
+ }
83
+ .connection-item {
84
+ padding: 16px 16px 0 16px;
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ .connection-row {
89
+ display: flex;
90
+ align-items: center;
91
+ justify-content: space-between;
92
+ margin: 8px 0;
93
+ }
94
+ </style>
@@ -0,0 +1,235 @@
1
+ <template>
2
+ <view :id="id" :class="`console-item console-item-${consoleItem.type}`">
3
+ <view class="console-info">
4
+ <view class="console-args">
5
+ <template v-for="(item, index) in consoleItem.args">
6
+ <view
7
+ v-if="item.type !== 'array' && item.type !== 'object'"
8
+ :class="`console-arg console-arg-${item.type}`"
9
+ :key="index"
10
+ v-html="item.value"
11
+ >
12
+ </view>
13
+ <JsonPretty
14
+ v-else
15
+ :data="item.value"
16
+ collapsed
17
+ showLength
18
+ :autoVirtualRow="100"
19
+ />
20
+ </template>
21
+ </view>
22
+ <view class="console-position">
23
+ <view class="console-tags">
24
+ <Tag
25
+ v-if="consoleItem.mode"
26
+ mode="log"
27
+ style="margin-right: 6px; justify-content: center"
28
+ >
29
+ {{ consoleItem.mode }}
30
+ </Tag>
31
+ <Tag :mode="consoleItem.type">
32
+ {{ consoleItem.type }}
33
+ </Tag>
34
+ </view>
35
+
36
+ <view>
37
+ <view class="console-time">{{ consoleItem.time }}</view>
38
+ <view class="console-other" v-html="consoleItem.position"></view>
39
+ <view
40
+ :class="`console-other ${isUseDevSource ? 'console-stack' : ''}`"
41
+ v-if="consoleItem.stack"
42
+ v-html="consoleItem.stack"
43
+ @click="onStackClick"
44
+ ></view>
45
+ </view>
46
+ </view>
47
+ </view>
48
+ <SourceCode
49
+ v-if="openCode && consoleItem.stack"
50
+ :url="consoleItem.stack"
51
+ :sourceFileServers="sourceFileServers"
52
+ :mode="mode"
53
+ :zIndex="zIndex"
54
+ @close="onCloseCode"
55
+ />
56
+ </view>
57
+ </template>
58
+
59
+ <script>
60
+ import Tag from '../Tag/index.vue';
61
+ import SourceCode from '../SourceCode/index.vue';
62
+ import JsonPretty from '../JsonPretty/index.vue';
63
+ import { isAndroid, isMockWX } from '../../utils';
64
+
65
+ export default {
66
+ components: {
67
+ Tag,
68
+ SourceCode,
69
+ JsonPretty,
70
+ },
71
+ props: {
72
+ consoleItem: {
73
+ type: Object,
74
+ required: true,
75
+ },
76
+ sourceFileServers: {
77
+ type: Array,
78
+ default: () => [],
79
+ },
80
+ mode: {
81
+ type: String,
82
+ default: '',
83
+ },
84
+ useDevSource: {
85
+ type: Boolean,
86
+ default: false,
87
+ },
88
+ zIndex: {
89
+ type: Number,
90
+ default: 0,
91
+ },
92
+ id: {
93
+ type: String,
94
+ required: true,
95
+ },
96
+ },
97
+ data() {
98
+ return {
99
+ openCode: false,
100
+ };
101
+ },
102
+ computed: {
103
+ isUseDevSource() {
104
+ return (
105
+ !isMockWX(this.consoleItem?.stack ?? '') &&
106
+ this.mode === 'development' &&
107
+ this.useDevSource
108
+ );
109
+ },
110
+ isWXLink() {
111
+ return (
112
+ isMockWX(this.consoleItem?.stack ?? '') || this.mode !== 'development'
113
+ );
114
+ },
115
+ },
116
+ methods: {
117
+ onStackClick() {
118
+ if (this.isWXLink) {
119
+ uni.showToast({
120
+ icon: 'none',
121
+ title: '[DevTool] 请在小程序真机调试模式下查看源码',
122
+ });
123
+ return;
124
+ }
125
+
126
+ if (!this.isUseDevSource) {
127
+ return;
128
+ }
129
+
130
+ if (isAndroid()) {
131
+ if (this.sourceFileServers && this.sourceFileServers.length > 0) {
132
+ this.openCode = true;
133
+ } else {
134
+ uni.showToast({
135
+ icon: 'none',
136
+ title: '[DevTool] sourceFileServers 配置异常',
137
+ });
138
+ uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
139
+ }
140
+ } else {
141
+ this.openCode = true;
142
+ }
143
+ },
144
+ onCloseCode() {
145
+ this.openCode = false;
146
+ },
147
+ },
148
+ };
149
+ </script>
150
+
151
+ <style scoped>
152
+ .console-item {
153
+ display: flex;
154
+ padding: 16px;
155
+ border-bottom: 1px solid var(--dev-tool-border-color);
156
+ font-size: var(--dev-tool-base-font-size);
157
+ }
158
+ .console-info {
159
+ flex: 1;
160
+ }
161
+ .console-args {
162
+ display: flex;
163
+ flex-wrap: wrap;
164
+ /* color: #000; */
165
+ /* color: var(--dev-tool-text-color); */
166
+ }
167
+ .console-arg {
168
+ margin-right: 4px;
169
+ white-space: pre-line;
170
+ word-break: break-all;
171
+ }
172
+ .console-position {
173
+ display: flex;
174
+ align-items: flex-start;
175
+ justify-content: space-between;
176
+ margin-top: 4px;
177
+ /* color: #616161; */
178
+ text-align: right;
179
+ }
180
+
181
+ .console-tags {
182
+ display: flex;
183
+ align-items: center;
184
+ }
185
+ .console-time {
186
+ margin-right: auto;
187
+ word-break: break-all;
188
+ }
189
+ .console-other {
190
+ word-break: break-all;
191
+ }
192
+
193
+ .console-stack {
194
+ text-decoration: underline;
195
+ cursor: pointer;
196
+ }
197
+
198
+ .console-copy {
199
+ flex-shrink: 0;
200
+ margin-left: 16px;
201
+ display: flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ width: 24px;
205
+ height: 24px;
206
+ color: #fff;
207
+ border-radius: 50%;
208
+ background-color: var(--dev-tool-success-color);
209
+ }
210
+ .console-item-info {
211
+ color: var(--dev-tool-log-color);
212
+ }
213
+ .console-item-log {
214
+ color: #f9f9f9;
215
+ }
216
+
217
+ .console-arg-null {
218
+ color: var(--dev-tool-nil-color);
219
+ }
220
+ .console-arg-undefined {
221
+ color: var(--dev-tool-nil-color);
222
+ }
223
+ .console-arg-string {
224
+ color: var(--dev-tool-string-color);
225
+ }
226
+ .console-arg-number {
227
+ color: var(--dev-tool-number-color);
228
+ }
229
+ .console-arg-boolean {
230
+ color: var(--dev-tool-boolean-color);
231
+ }
232
+ .console-arg-symbol {
233
+ color: var(--dev-tool-symbol-color);
234
+ }
235
+ </style>