vite-uni-dev-tool 0.0.13 → 0.0.14

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 (109) hide show
  1. package/dist/v2/AppInfo/index.vue +41 -0
  2. package/dist/v2/AutoSizer/index.vue +189 -0
  3. package/dist/v2/AutoSizer/index1.vue +193 -0
  4. package/dist/v2/AutoSizer/utils.ts +49 -0
  5. package/dist/v2/CaptureScreen/index.vue +78 -0
  6. package/dist/v2/CloseButton/index.vue +32 -0
  7. package/dist/v2/Connection/index.vue +94 -0
  8. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  9. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  10. package/dist/v2/ConsoleList/index.vue +164 -0
  11. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  12. package/dist/v2/DevTool/index.vue +162 -0
  13. package/dist/v2/DevToolButton/index.vue +228 -0
  14. package/dist/v2/DevToolTitle/index.vue +28 -0
  15. package/dist/v2/DevToolWindow/index.vue +1051 -0
  16. package/dist/v2/DeviceInfo/index.vue +48 -0
  17. package/dist/v2/Empty/empty.png +0 -0
  18. package/dist/v2/Empty/index.vue +40 -0
  19. package/dist/v2/FilterInput/index.vue +100 -0
  20. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  21. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  22. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  23. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  24. package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
  25. package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
  26. package/dist/v2/JsonPretty/index.vue +531 -0
  27. package/dist/v2/JsonPretty/type.ts +125 -0
  28. package/dist/v2/JsonPretty/utils/index.js +211 -0
  29. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  30. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  31. package/dist/v2/NetworkList/index.vue +148 -0
  32. package/dist/v2/PiniaList/index.vue +79 -0
  33. package/dist/v2/RouteList/index.vue +137 -0
  34. package/dist/v2/RunJS/index.vue +128 -0
  35. package/dist/v2/SettingList/index.vue +318 -0
  36. package/dist/v2/SourceCode/index.vue +237 -0
  37. package/dist/v2/StorageList/index.vue +165 -0
  38. package/dist/v2/SystemInfo/index.vue +49 -0
  39. package/dist/v2/Tabs/index.vue +127 -0
  40. package/dist/v2/Tag/index.vue +91 -0
  41. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  42. package/dist/v2/UniEvent/index.vue +127 -0
  43. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  44. package/dist/v2/UploadList/UploadItem.vue +134 -0
  45. package/dist/v2/UploadList/index.vue +143 -0
  46. package/dist/v2/VirtualList/index.vue +140 -0
  47. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  48. package/dist/v2/VirtualListPro/index.vue +255 -0
  49. package/dist/v2/VirtualListPro/readme.md +40 -0
  50. package/dist/v2/VuexList/index.vue +80 -0
  51. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  52. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  53. package/dist/v2/WebSocket/index.vue +155 -0
  54. package/dist/v2/WindowInfo/index.vue +49 -0
  55. package/dist/v3/AppInfo/index.vue +35 -0
  56. package/dist/v3/AutoSizer/index.vue +193 -0
  57. package/dist/v3/AutoSizer/index1.vue +186 -0
  58. package/dist/v3/AutoSizer/utils.ts +49 -0
  59. package/dist/v3/CaptureScreen/index.vue +62 -0
  60. package/dist/v3/CloseButton/index.vue +29 -0
  61. package/dist/v3/Connection/index.vue +88 -0
  62. package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
  63. package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
  64. package/dist/v3/ConsoleList/index.vue +139 -0
  65. package/dist/v3/ConsoleList/staticTips.ts +1145 -0
  66. package/dist/v3/DevTool/index.vue +217 -0
  67. package/dist/v3/DevToolButton/index.vue +210 -0
  68. package/dist/v3/DevToolTitle/index.vue +21 -0
  69. package/dist/v3/DevToolWindow/index.vue +1116 -0
  70. package/dist/v3/DeviceInfo/index.vue +32 -0
  71. package/dist/v3/Empty/empty.png +0 -0
  72. package/dist/v3/Empty/index.vue +28 -0
  73. package/dist/v3/FilterInput/index.vue +87 -0
  74. package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
  75. package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
  76. package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
  77. package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
  78. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  79. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  80. package/dist/v3/JsonPretty/index.vue +476 -0
  81. package/dist/v3/JsonPretty/type.ts +125 -0
  82. package/dist/v3/JsonPretty/utils/index.ts +172 -0
  83. package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
  84. package/dist/v3/NetworkList/NetworkItem.vue +120 -0
  85. package/dist/v3/NetworkList/index.vue +128 -0
  86. package/dist/v3/PiniaList/index.vue +64 -0
  87. package/dist/v3/RouteList/index.vue +121 -0
  88. package/dist/v3/RunJS/index.vue +128 -0
  89. package/dist/v3/SettingList/index.vue +313 -0
  90. package/dist/v3/SourceCode/index.vue +231 -0
  91. package/dist/v3/StorageList/index.vue +170 -0
  92. package/dist/v3/SystemInfo/index.vue +34 -0
  93. package/dist/v3/Tabs/index.vue +123 -0
  94. package/dist/v3/Tag/index.vue +89 -0
  95. package/dist/v3/UniEvent/UniEventItem.vue +126 -0
  96. package/dist/v3/UniEvent/index.vue +98 -0
  97. package/dist/v3/UploadList/UploadDetail.vue +192 -0
  98. package/dist/v3/UploadList/UploadItem.vue +117 -0
  99. package/dist/v3/UploadList/index.vue +117 -0
  100. package/dist/v3/VirtualList/index.vue +112 -0
  101. package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
  102. package/dist/v3/VirtualListPro/index.vue +238 -0
  103. package/dist/v3/VirtualListPro/readme.md +40 -0
  104. package/dist/v3/VuexList/index.vue +54 -0
  105. package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
  106. package/dist/v3/WebSocket/WebSocketList.vue +161 -0
  107. package/dist/v3/WebSocket/index.vue +124 -0
  108. package/dist/v3/WindowInfo/index.vue +33 -0
  109. package/package.json +1 -1
@@ -0,0 +1,208 @@
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
+ /* color: var(--dev-tool-text-color); */
139
+ }
140
+ .console-arg {
141
+ margin-right: 4px;
142
+ white-space: pre-line;
143
+ word-break: break-all;
144
+ }
145
+ .console-position {
146
+ display: flex;
147
+ align-items: flex-start;
148
+ justify-content: space-between;
149
+ margin-top: 4px;
150
+ /* color: #616161; */
151
+ text-align: right;
152
+ }
153
+
154
+ .console-tags {
155
+ display: flex;
156
+ align-items: center;
157
+ }
158
+ .console-time {
159
+ margin-right: auto;
160
+ word-break: break-all;
161
+ }
162
+ .console-other {
163
+ word-break: break-all;
164
+ }
165
+
166
+ .console-stack {
167
+ text-decoration: underline;
168
+ cursor: pointer;
169
+ }
170
+
171
+ .console-copy {
172
+ flex-shrink: 0;
173
+ margin-left: 16px;
174
+ display: flex;
175
+ align-items: center;
176
+ justify-content: center;
177
+ width: 24px;
178
+ height: 24px;
179
+ color: #fff;
180
+ border-radius: 50%;
181
+ background-color: var(--dev-tool-success-color);
182
+ }
183
+ .console-item-info {
184
+ color: var(--dev-tool-log-color);
185
+ }
186
+ .console-item-log {
187
+ color: #f9f9f9;
188
+ }
189
+
190
+ .console-arg-null {
191
+ color: var(--dev-tool-nil-color);
192
+ }
193
+ .console-arg-undefined {
194
+ color: var(--dev-tool-nil-color);
195
+ }
196
+ .console-arg-string {
197
+ color: var(--dev-tool-string-color);
198
+ }
199
+ .console-arg-number {
200
+ color: var(--dev-tool-number-color);
201
+ }
202
+ .console-arg-boolean {
203
+ color: var(--dev-tool-boolean-color);
204
+ }
205
+ .console-arg-symbol {
206
+ color: var(--dev-tool-symbol-color);
207
+ }
208
+ </style>
@@ -0,0 +1,240 @@
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 var(--dev-tool-text-color);
196
+ border-bottom-color: transparent;
197
+ border-left-color: transparent;
198
+ overflow: hidden;
199
+ transform: rotate(45deg);
200
+ transition: border 0.3s;
201
+ }
202
+
203
+ .run-js-input {
204
+ margin: 1px 0 1px 16px;
205
+ min-height: 26px;
206
+ width: 100%;
207
+ border: 1px solid transparent;
208
+ font-size: var(--dev-tool-base-font-size);
209
+ color: var(--dev-tool-text-color);
210
+ transition: color 0.3s;
211
+ }
212
+
213
+ .run-js-tips {
214
+ position: absolute;
215
+ bottom: 31px;
216
+ left: 0;
217
+ background-color: var(--dev-tool-bg-color);
218
+ width: 100%;
219
+ max-height: 200px;
220
+ padding: 0 16px 0 36px;
221
+ box-sizing: border-box;
222
+ overflow-y: auto;
223
+ overflow-x: hidden;
224
+ box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
225
+ }
226
+ .run-js-tips-item {
227
+ display: flex;
228
+ align-items: center;
229
+ height: 28px;
230
+ width: 100%;
231
+ white-space: nowrap;
232
+ border: 1px solid transparent;
233
+ border-bottom: 1px solid var(--dev-tool-border-color);
234
+ overflow: hidden;
235
+ text-overflow: ellipsis;
236
+ }
237
+ .run-js-tips-item-active {
238
+ border: 1px solid var(--dev-tool-main-color);
239
+ }
240
+ </style>
@@ -0,0 +1,139 @@
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>