vite-uni-dev-tool 0.0.12 → 0.0.13

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 (181) hide show
  1. package/dist/const.d.ts +133 -0
  2. package/dist/const.d.ts.map +1 -0
  3. package/dist/const.js +36 -0
  4. package/dist/core.d.ts +52 -0
  5. package/dist/core.d.ts.map +1 -0
  6. package/dist/core.js +80 -0
  7. package/dist/devConsole/index.d.ts +169 -0
  8. package/dist/devConsole/index.d.ts.map +1 -0
  9. package/dist/devConsole/index.js +270 -0
  10. package/dist/devEvent/index.d.ts +286 -0
  11. package/dist/devEvent/index.d.ts.map +1 -0
  12. package/dist/devEvent/index.js +435 -0
  13. package/dist/devEventBus/index.d.ts +42 -0
  14. package/dist/devEventBus/index.d.ts.map +1 -0
  15. package/dist/devEventBus/index.js +70 -0
  16. package/dist/devIntercept/index.d.ts +119 -0
  17. package/dist/devIntercept/index.d.ts.map +1 -0
  18. package/dist/devIntercept/index.js +582 -0
  19. package/dist/devRunJS/index.d.ts +67 -0
  20. package/dist/devRunJS/index.d.ts.map +1 -0
  21. package/dist/devStore/index.d.ts +178 -0
  22. package/dist/devStore/index.d.ts.map +1 -0
  23. package/dist/devStore/index.js +395 -0
  24. package/dist/devToolInfo/index.d.ts +17 -0
  25. package/dist/devToolInfo/index.d.ts.map +1 -0
  26. package/dist/devToolInfo/index.js +15 -0
  27. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
  28. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  29. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  30. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  31. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  32. package/dist/plugins/utils/index.js +1 -0
  33. package/dist/type.d.ts +264 -0
  34. package/dist/type.d.ts.map +1 -0
  35. package/dist/utils/array.d.ts +2 -0
  36. package/dist/utils/array.d.ts.map +1 -0
  37. package/dist/utils/array.js +12 -0
  38. package/dist/utils/date.d.ts +19 -0
  39. package/dist/utils/date.d.ts.map +1 -0
  40. package/dist/utils/date.js +40 -0
  41. package/dist/utils/file.d.ts +11 -0
  42. package/dist/utils/file.d.ts.map +1 -0
  43. package/dist/utils/file.js +87 -0
  44. package/dist/utils/function.d.ts +28 -0
  45. package/dist/utils/function.d.ts.map +1 -0
  46. package/dist/utils/function.js +46 -0
  47. package/dist/utils/index.d.ts +11 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/index.js +55 -0
  50. package/dist/utils/ip.d.ts +5 -0
  51. package/dist/utils/ip.d.ts.map +1 -0
  52. package/dist/utils/ip.js +21 -0
  53. package/dist/utils/language.d.ts +29 -0
  54. package/dist/utils/language.d.ts.map +1 -0
  55. package/dist/utils/language.js +50 -0
  56. package/dist/utils/object.d.ts +49 -0
  57. package/dist/utils/object.d.ts.map +1 -0
  58. package/dist/utils/object.js +118 -0
  59. package/dist/utils/page.d.ts +7 -0
  60. package/dist/utils/page.d.ts.map +1 -0
  61. package/dist/utils/page.js +7 -0
  62. package/dist/utils/platform.d.ts +4 -0
  63. package/dist/utils/platform.d.ts.map +1 -0
  64. package/dist/utils/platform.js +14 -0
  65. package/dist/utils/string.d.ts +45 -0
  66. package/dist/utils/string.d.ts.map +1 -0
  67. package/dist/utils/string.js +88 -0
  68. package/dist/utils/utils.d.ts +16 -0
  69. package/dist/utils/utils.d.ts.map +1 -0
  70. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  71. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  72. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  73. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  74. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  75. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  76. package/dist/v2/JsonPretty/type.d.ts +93 -0
  77. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  78. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  79. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  80. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  81. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  82. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  83. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  84. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  85. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  86. package/dist/v3/JsonPretty/type.d.ts +93 -0
  87. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  88. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  89. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  90. package/package.json +5 -5
  91. package/dev/components/AppInfo/index.vue +0 -36
  92. package/dev/components/AutoSizer/index.vue +0 -193
  93. package/dev/components/AutoSizer/index1.vue +0 -186
  94. package/dev/components/AutoSizer/utils.ts +0 -49
  95. package/dev/components/Button/index.vue +0 -34
  96. package/dev/components/CaptureScreen/index.vue +0 -62
  97. package/dev/components/Checkbox/index.vue +0 -40
  98. package/dev/components/CloseButton/index.vue +0 -26
  99. package/dev/components/Code/index.vue +0 -230
  100. package/dev/components/Connection/index.vue +0 -88
  101. package/dev/components/ConsoleList/Code.vue +0 -227
  102. package/dev/components/ConsoleList/ConsoleItem.vue +0 -207
  103. package/dev/components/ConsoleList/RunJSInput.vue +0 -237
  104. package/dev/components/ConsoleList/index.vue +0 -139
  105. package/dev/components/ConsoleList/staticTips.ts +0 -1145
  106. package/dev/components/DevTool/index.vue +0 -188
  107. package/dev/components/DevToolButton/index.vue +0 -210
  108. package/dev/components/DevToolTitle/index.vue +0 -21
  109. package/dev/components/DevToolWindow/index.vue +0 -1053
  110. package/dev/components/DeviceInfo/index.vue +0 -32
  111. package/dev/components/Empty/empty.png +0 -0
  112. package/dev/components/Empty/index.vue +0 -28
  113. package/dev/components/FilterInput/index.vue +0 -86
  114. package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
  115. package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
  116. package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
  117. package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
  118. package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
  119. package/dev/components/JsonPretty/hooks/useError.ts +0 -21
  120. package/dev/components/JsonPretty/index.vue +0 -476
  121. package/dev/components/JsonPretty/type.ts +0 -125
  122. package/dev/components/JsonPretty/utils/index.ts +0 -172
  123. package/dev/components/NetworkList/NetworkDetail.vue +0 -194
  124. package/dev/components/NetworkList/NetworkItem.vue +0 -119
  125. package/dev/components/NetworkList/index.vue +0 -128
  126. package/dev/components/PiniaList/index.vue +0 -64
  127. package/dev/components/RouteList/index.vue +0 -121
  128. package/dev/components/RunJS/index.vue +0 -128
  129. package/dev/components/SettingList/index.vue +0 -222
  130. package/dev/components/SourceCode/index.vue +0 -231
  131. package/dev/components/StorageList/index.vue +0 -170
  132. package/dev/components/SystemInfo/index.vue +0 -34
  133. package/dev/components/Tabs/index.vue +0 -123
  134. package/dev/components/Tag/index.vue +0 -89
  135. package/dev/components/UniEvent/UniEventItem.vue +0 -126
  136. package/dev/components/UniEvent/index.vue +0 -98
  137. package/dev/components/UploadList/UploadDetail.vue +0 -204
  138. package/dev/components/UploadList/UploadItem.vue +0 -117
  139. package/dev/components/UploadList/index.vue +0 -117
  140. package/dev/components/VirtualList/index.vue +0 -112
  141. package/dev/components/VirtualListPro/AutoSize.vue +0 -43
  142. package/dev/components/VirtualListPro/index.vue +0 -238
  143. package/dev/components/VirtualListPro/readme.md +0 -40
  144. package/dev/components/VuexList/index.vue +0 -54
  145. package/dev/components/WebSocket/WebSocketItem.vue +0 -103
  146. package/dev/components/WebSocket/WebSocketList.vue +0 -173
  147. package/dev/components/WebSocket/index.vue +0 -124
  148. package/dev/components/WindowInfo/index.vue +0 -33
  149. package/dev/const.ts +0 -164
  150. package/dev/core.ts +0 -118
  151. package/dev/devConsole/index.ts +0 -350
  152. package/dev/devEvent/index.ts +0 -810
  153. package/dev/devEventBus/index.ts +0 -94
  154. package/dev/devIntercept/index.ts +0 -745
  155. package/dev/devRunJS/index.ts +0 -170
  156. package/dev/devStore/index.ts +0 -732
  157. package/dev/devToolInfo/index.ts +0 -26
  158. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  159. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  160. package/dev/plugins/utils/index.js +0 -1
  161. package/dev/shims-uni.d.ts +0 -43
  162. package/dev/type.ts +0 -291
  163. package/dev/utils/array.ts +0 -15
  164. package/dev/utils/date.ts +0 -75
  165. package/dev/utils/file.ts +0 -121
  166. package/dev/utils/function.ts +0 -192
  167. package/dev/utils/index.d.ts +0 -6
  168. package/dev/utils/index.ts +0 -51
  169. package/dev/utils/ip.ts +0 -79
  170. package/dev/utils/language.ts +0 -77
  171. package/dev/utils/object.ts +0 -306
  172. package/dev/utils/page.ts +0 -13
  173. package/dev/utils/platform.ts +0 -14
  174. package/dev/utils/string.ts +0 -133
  175. package/dev/utils/utils.ts +0 -198
  176. /package/{dev → dist}/index.d.ts +0 -0
  177. /package/{dev → dist}/index.d.ts.map +0 -0
  178. /package/{dev → dist}/index.js +0 -0
  179. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  180. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
  181. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
@@ -1,207 +0,0 @@
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
- <!-- <view class="console-copy">C</view> -->
49
- <SourceCode
50
- v-if="openCode && consoleItem.stack"
51
- :url="consoleItem.stack"
52
- :sourceFileServers="sourceFileServers"
53
- :mode="mode"
54
- :zIndex="zIndex"
55
- @close="onCloseCode"
56
- />
57
- </view>
58
- </template>
59
-
60
- <script setup lang="ts">
61
- import { ref, computed } from 'vue';
62
- import Tag from '../Tag/index.vue';
63
- import SourceCode from '../SourceCode/index.vue';
64
- import type { DevTool } from '../../type';
65
- import { isAndroid, isMockWX } from '../../utils';
66
- import JsonPretty from '../JsonPretty/index.vue';
67
- const props = defineProps<{
68
- consoleItem: DevTool.ConsoleItem;
69
- sourceFileServers?: string[];
70
- mode?: string;
71
- useDevSource?: boolean;
72
- zIndex?: number;
73
- id: string;
74
- }>();
75
-
76
- const openCode = ref(false);
77
-
78
- const isUseDevSource = computed(() => {
79
- return (
80
- !isMockWX(props?.consoleItem?.stack ?? '') &&
81
- props.mode === 'development' &&
82
- props.useDevSource
83
- );
84
- });
85
-
86
- const isWXLink = computed(() => {
87
- return (
88
- isMockWX(props?.consoleItem?.stack ?? '') || props.mode !== 'development'
89
- );
90
- });
91
-
92
- function onStackClick() {
93
- if (isWXLink.value) {
94
- uni.showToast({
95
- icon: 'none',
96
- title: '[DevTool] 请在小程序真机调试模式下查看源码',
97
- });
98
- return;
99
- }
100
-
101
- if (!isUseDevSource.value) {
102
- return;
103
- }
104
-
105
- if (isAndroid()) {
106
- if (props.sourceFileServers && props.sourceFileServers.length > 0) {
107
- openCode.value = true;
108
- } else {
109
- uni.showToast({
110
- icon: 'none',
111
- title: '[DevTool] sourceFileServers 配置异常',
112
- });
113
- uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
114
- }
115
- } else {
116
- openCode.value = true;
117
- }
118
- }
119
-
120
- function onCloseCode() {
121
- openCode.value = false;
122
- }
123
- </script>
124
- <style scoped>
125
- .console-item {
126
- display: flex;
127
- padding: 16px;
128
- border-bottom: 1px solid var(--dev-tool-border-color);
129
- font-size: var(--dev-tool-base-font-size);
130
- }
131
- .console-info {
132
- flex: 1;
133
- }
134
- .console-args {
135
- display: flex;
136
- flex-wrap: wrap;
137
- color: #000;
138
- }
139
- .console-arg {
140
- margin-right: 4px;
141
- white-space: pre-line;
142
- word-break: break-all;
143
- }
144
- .console-position {
145
- display: flex;
146
- align-items: flex-start;
147
- justify-content: space-between;
148
- margin-top: 4px;
149
- color: #616161;
150
- text-align: right;
151
- }
152
-
153
- .console-tags {
154
- display: flex;
155
- align-items: center;
156
- }
157
- .console-time {
158
- margin-right: auto;
159
- word-break: break-all;
160
- }
161
- .console-other {
162
- word-break: break-all;
163
- }
164
-
165
- .console-stack {
166
- text-decoration: underline;
167
- cursor: pointer;
168
- }
169
-
170
- .console-copy {
171
- flex-shrink: 0;
172
- margin-left: 16px;
173
- display: flex;
174
- align-items: center;
175
- justify-content: center;
176
- width: 24px;
177
- height: 24px;
178
- color: #fff;
179
- border-radius: 50%;
180
- background-color: var(--dev-tool-success-color);
181
- }
182
- .console-item-info {
183
- color: #9c9c9c;
184
- }
185
- .console-item-log {
186
- color: #f9f9f9;
187
- }
188
-
189
- .console-arg-null {
190
- color: #020201;
191
- }
192
- .console-arg-undefined {
193
- color: #020201;
194
- }
195
- .console-arg-string {
196
- color: #888888;
197
- }
198
- .console-arg-number {
199
- color: #1d8ce0;
200
- }
201
- .console-arg-boolean {
202
- color: #1d8ce0;
203
- }
204
- .console-arg-symbol {
205
- color: bisque;
206
- }
207
- </style>
@@ -1,237 +0,0 @@
1
- <template>
2
- <view class="run-js-input-wrapper">
3
- <view class="run-js-input-icon"></view>
4
- <input
5
- v-model="code"
6
- class="run-js-input"
7
- placeholder="run..."
8
- @confirm="onConfirm"
9
- @input="onChange"
10
- />
11
- <view class="run-js-tips">
12
- <view
13
- class="run-js-tips-item"
14
- v-for="(item, index) in tips"
15
- @click="onChoose(item.name)"
16
- >
17
- {{ item.name }}{{ item.description ? ': ' : ' ' }}{{ item.description }}
18
- </view>
19
- </view>
20
- </view>
21
- </template>
22
- <script lang="ts" setup>
23
- import { ref } from 'vue';
24
- import {
25
- staticTips,
26
- singleTips,
27
- flatStaticTips,
28
- baseSymbols,
29
- type Tip,
30
- } from './staticTips';
31
-
32
- const emit = defineEmits<{
33
- (e: 'run', value: string): void;
34
- }>();
35
-
36
- const code = ref('');
37
-
38
- const tips = ref<Tip[]>([]);
39
-
40
- function onConfirm() {
41
- tips.value = [];
42
- const value = code.value;
43
- if (!value) return;
44
- code.value = '';
45
- setTimeout(() => {
46
- emit('run', value);
47
- }, 100);
48
- }
49
-
50
- /**
51
- * 1.对象,方法,变量 在 ; ( , =,==,=== , + , - , * , / , && , || ?? 之后 开始提示
52
- *
53
- * Math
54
- * console
55
- *
56
- * 2.在 . 之后 提示
57
- *
58
- * Math.a
59
- * console.a
60
- *
61
- *
62
- * 3.对方法,属性返回值进行提示
63
- *
64
- * Math.abc().
65
- *
66
- *
67
- * any, void 不进行提示
68
- *
69
- * 4. [] 数组提示
70
- *
71
- * [1,2].concat([2,3].map(parseInt))
72
- *
73
- * 5. (值) 推断提示
74
- * ({}).valueOf()
75
- *
76
- *
77
- * @param e 输入框内容
78
- */
79
- function onChange(e: any) {
80
- const { value, cursor } = e.detail as { value: string; cursor: number };
81
- // 光标之前的内容
82
- const content = value.slice(0, cursor);
83
-
84
- // 获取符号之后的内容
85
- const lastIndex = getBaseSymbolLastIndex(content);
86
-
87
- const con = lastIndex > -1 ? value.substring(lastIndex + 1) : value;
88
-
89
- if (!con) {
90
- // 不存在内容
91
- tips.value = [];
92
- } else {
93
- // 存在内容
94
-
95
- // 一级点之后的内容
96
- const [main, sub] = con.split('.');
97
-
98
- if (singleTips.includes(main) && con.includes('.')) {
99
- const list = [
100
- ...(staticTips[main]?.attr ?? []),
101
- ...(staticTips[main]?.fun ?? []),
102
- ];
103
-
104
- if (sub) {
105
- tips.value = list.filter((item) => item.name.startsWith(sub));
106
- } else {
107
- tips.value = list;
108
- }
109
- } else {
110
- if (main.includes(')') && con.includes('.')) {
111
- // 方法调用之后的提示
112
-
113
- // 获取方法名称 倒数第二个 . 到最后一个 ( 之间为方法名称
114
- const s = getSecondLastDotPosition(content);
115
- const e = content.lastIndexOf('(');
116
- const methodName = content.substring(s + 1, e);
117
-
118
- const fn = findFunction(methodName);
119
- // 获取方法返回值
120
- const result = fn?.[0]?.result?.[0];
121
- if (result && result !== 'any' && result !== 'void') {
122
- tips.value = Object.values(staticTips?.[result] ?? {}).flat(2);
123
- } else {
124
- tips.value = [];
125
- }
126
- } else {
127
- // 基础提示
128
- tips.value = singleTips
129
- .filter((item) => item.startsWith(con))
130
- .map((item) => ({
131
- name: item,
132
- description: '',
133
- result: ['any'],
134
- }));
135
- }
136
- }
137
- }
138
- }
139
- function onChoose(name: string) {
140
- // TODO 选择提示
141
- // const lastIndex = code.value.lastIndexOf(';');
142
- // const con =
143
- // lastIndex > -1 ? code.value?.substring(lastIndex + 1) : code.value;
144
- // const lastCon = con.lastIndexOf('.');
145
- // if (lastCon > -1) {
146
- // code.value = con.substring(0, lastCon + 1) + name;
147
- // } else {
148
- // code.value = name;
149
- // }
150
- // tips.value = [];
151
- }
152
-
153
- function getBaseSymbolLastIndex(code: string) {
154
- for (let i = code.length - 1; i >= 0; i--) {
155
- if (baseSymbols.includes(code[i])) {
156
- return i; // 找到最后一个符号的位置
157
- }
158
- }
159
- return -1; // 未找到任何符号
160
- }
161
-
162
- function getSecondLastDotPosition(str: string) {
163
- let dotCount = 0;
164
- for (let i = str.length - 1; i >= 0; i--) {
165
- if (str[i] === '.') {
166
- dotCount++;
167
- if (dotCount === 2) {
168
- return i;
169
- }
170
- }
171
- }
172
- return -1; // 未找到足够的点号
173
- }
174
-
175
- function findFunction(fn: string) {
176
- return flatStaticTips.filter((item) => item.name.startsWith(fn));
177
- }
178
- </script>
179
- <style scoped>
180
- .run-js-input-wrapper {
181
- position: relative;
182
- display: flex;
183
- align-items: center;
184
- padding: 0 16px;
185
- height: 32px;
186
- border-top: 1px solid var(--dev-tool-border-color);
187
- border-bottom: 1px solid var(--dev-tool-border-color);
188
- box-sizing: border-box;
189
- }
190
-
191
- .run-js-input-icon {
192
- margin: 10px 0 10px -4px;
193
- width: 8px;
194
- height: 8px;
195
- border: 1px solid #000;
196
- border-bottom-color: transparent;
197
- border-left-color: transparent;
198
- overflow: hidden;
199
- transform: rotate(45deg);
200
- }
201
-
202
- .run-js-input {
203
- margin: 1px 0 1px 16px;
204
- min-height: 26px;
205
- width: 100%;
206
- border: 1px solid transparent;
207
- font-size: var(--dev-tool-base-font-size);
208
- }
209
-
210
- .run-js-tips {
211
- position: absolute;
212
- bottom: 31px;
213
- left: 0;
214
- background-color: #fff;
215
- width: 100%;
216
- max-height: 200px;
217
- padding: 0 16px 0 36px;
218
- box-sizing: border-box;
219
- overflow-y: auto;
220
- overflow-x: hidden;
221
- box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
222
- }
223
- .run-js-tips-item {
224
- display: flex;
225
- align-items: center;
226
- height: 28px;
227
- width: 100%;
228
- white-space: nowrap;
229
- border: 1px solid transparent;
230
- border-bottom: 1px solid var(--dev-tool-border-color);
231
- overflow: hidden;
232
- text-overflow: ellipsis;
233
- }
234
- .run-js-tips-item-active {
235
- border: 1px solid var(--dev-tool-main-color);
236
- }
237
- </style>
@@ -1,139 +0,0 @@
1
- <template>
2
- <view class="console-content">
3
- <view class="console-control">
4
- <FilterInput
5
- :modelValue="modelValue"
6
- @search="emit('search', $event)"
7
- @update:modelValue="emit('update:modelValue', $event)"
8
- />
9
- <Tag
10
- v-for="item in consoleFilterItems"
11
- :mode="item.value"
12
- :key="item.value"
13
- :active="currentConsoleType === item.value"
14
- @click="emit('choose', item.value)"
15
- >
16
- {{ item.label }}
17
- </Tag>
18
- </view>
19
-
20
- <VirtualListPro
21
- :data="consoleList"
22
- :pageSize="15"
23
- :scrollIntoView="scrollIntoView"
24
- :scrollWithAnimation="true"
25
- :height="height"
26
- className="console-list"
27
- >
28
- <template v-slot="{ list, start }">
29
- <AutoSize
30
- v-for="(item, index) in list"
31
- :index="start + index"
32
- :key="start + index"
33
- >
34
- <ConsoleItem
35
- :consoleItem="item"
36
- :sourceFileServers="sourceFileServers"
37
- :mode="mode"
38
- :useDevSource="useDevSource"
39
- :id="`dev-console-${index}`"
40
- :zIndex="zIndex"
41
- />
42
- </AutoSize>
43
- <Empty v-if="!consoleList || consoleList.length === 0" />
44
- </template>
45
- </VirtualListPro>
46
- <RunJSInput @run="emit('run', $event)" />
47
- </view>
48
- </template>
49
- <script setup lang="ts">
50
- import ConsoleItem from './ConsoleItem.vue';
51
- import Tag from '../Tag/index.vue';
52
- import Empty from '../Empty/index.vue';
53
- import FilterInput from '../FilterInput/index.vue';
54
- import RunJSInput from './RunJSInput.vue';
55
- import type { DevTool } from '../../type';
56
- import { onMounted, ref, watch } from 'vue';
57
- import { debounce } from '../../utils';
58
- import VirtualListPro from '../VirtualListPro/index.vue';
59
- import AutoSize from '../VirtualListPro/AutoSize.vue';
60
-
61
- type ConsoleType = 'all' | 'log' | 'info' | 'warn' | 'error' | 'clear';
62
- const props = defineProps<{
63
- consoleList: DevTool.ConsoleItem[];
64
- currentConsoleType: string;
65
- modelValue: string;
66
- sourceFileServers?: string[];
67
- mode?: string;
68
- useDevSource?: boolean;
69
- zIndex?: number;
70
- }>();
71
- const emit = defineEmits<{
72
- (e: 'choose', type: ConsoleType): void;
73
- (e: 'search', value: string): void;
74
- (e: 'update:modelValue', value: string): void;
75
- (e: 'run', value: string): void;
76
- }>();
77
- const consoleFilterItems: {
78
- label: string;
79
- value: ConsoleType;
80
- }[] = [
81
- {
82
- label: '全部',
83
- value: 'all',
84
- },
85
- {
86
- label: 'info',
87
- value: 'info',
88
- },
89
- {
90
- label: 'log',
91
- value: 'log',
92
- },
93
- {
94
- label: 'warn',
95
- value: 'warn',
96
- },
97
- {
98
- label: 'error',
99
- value: 'error',
100
- },
101
- {
102
- label: '清除',
103
- value: 'clear',
104
- },
105
- ];
106
-
107
- const scrollIntoView = ref('');
108
-
109
- const debounceWatch = debounce(() => {
110
- scrollIntoView.value = `dev-console-${props.consoleList.length - 1}`;
111
- }, 200);
112
-
113
- watch(() => props.consoleList, debounceWatch);
114
-
115
- const height = ref(0);
116
- onMounted(() => {
117
- const { windowHeight } = uni.getWindowInfo();
118
- height.value = windowHeight - 32 - 32 - 32;
119
- });
120
- </script>
121
- <style scoped>
122
- .console-content {
123
- height: 100%;
124
- font-size: var(--dev-tool-base-font-size);
125
- }
126
- .console-list {
127
- height: calc(100% - 32px - 32px);
128
- }
129
- .console-control {
130
- display: flex;
131
- align-items: center;
132
- justify-content: space-between;
133
- gap: 8px;
134
- padding: 0 16px;
135
- height: 32px;
136
- border-bottom: 1px solid var(--dev-tool-border-color);
137
- box-sizing: border-box;
138
- }
139
- </style>