vite-uni-dev-tool 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dev/components/Code/index.vue +227 -0
- package/dev/components/ConsoleList/Code.vue +1 -1
- package/dev/components/ConsoleList/ConsoleItem.vue +38 -12
- package/dev/components/ConsoleList/RunJSInput.vue +59 -0
- package/dev/components/ConsoleList/index.vue +24 -8
- package/dev/components/DevTool/index.vue +1 -1
- package/dev/components/DevToolButton/index.vue +10 -10
- package/dev/components/DevToolWindow/index.vue +21 -2
- package/dev/components/FilterInput/index.vue +1 -1
- package/dev/components/JsonPretty/components/CheckController/index.vue +22 -5
- package/dev/components/JsonPretty/components/TreeNode/index.vue +16 -15
- package/dev/components/JsonPretty/index.vue +77 -75
- package/dev/components/JsonPretty/type.ts +2 -0
- package/dev/components/NetworkList/NetworkDetail.vue +1 -1
- package/dev/components/RunJS/index.vue +128 -0
- package/dev/components/SettingList/index.vue +1 -1
- package/dev/components/UniEvent/UniEventItem.vue +72 -3
- package/dev/components/UniEvent/index.vue +10 -1
- package/dev/components/UploadList/UploadDetail.vue +1 -1
- package/dev/components/VirtualList/index.vue +112 -0
- package/dev/components/WebSocket/WebSocketList.vue +1 -1
- package/dev/const.ts +97 -26
- package/dev/core.ts +0 -2
- package/dev/devConsole/index.ts +21 -4
- package/dev/devEvent/index.ts +85 -1
- package/dev/devIntercept/index.ts +27 -21
- package/dev/devRunJS/index.ts +170 -0
- package/dev/devStore/index.ts +13 -3
- package/dev/index.d.ts +3 -2
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +2 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -38
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +2 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -9
- package/dev/plugins/utils/index.d.ts +10 -2
- package/dev/plugins/utils/index.d.ts.map +1 -1
- package/dev/plugins/utils/index.js +1 -1
- package/dev/type.ts +38 -2
- package/dev/utils/index.ts +10 -1
- package/dev/utils/language.ts +53 -0
- package/dev/utils/object.ts +64 -1
- package/dev/utils/string.ts +5 -5
- package/package.json +2 -2
|
@@ -3,18 +3,34 @@
|
|
|
3
3
|
:class="`json-pretty-check-controller ${model ? 'is-checked' : ''}`"
|
|
4
4
|
@click="onClick"
|
|
5
5
|
>
|
|
6
|
-
<view
|
|
6
|
+
<!-- <view
|
|
7
|
+
:class="`json-pretty-check-controller-inner is-${uiType}`"
|
|
8
|
+
@click="onChange"
|
|
9
|
+
>
|
|
10
|
+
</view>
|
|
7
11
|
<input
|
|
8
12
|
:checked="model"
|
|
9
13
|
:class="`json-pretty-check-controller-original is-${uiType}`"
|
|
10
14
|
:type="uiType"
|
|
11
15
|
@change="onChange"
|
|
16
|
+
/> -->
|
|
17
|
+
|
|
18
|
+
<checkbox
|
|
19
|
+
v-if="uiType === 'checkbox'"
|
|
20
|
+
:checked="model"
|
|
21
|
+
style="transform: scale(0.6)"
|
|
22
|
+
@change="onChange"
|
|
23
|
+
/>
|
|
24
|
+
<radio
|
|
25
|
+
v-if="uiType === 'radio'"
|
|
26
|
+
:checked="model"
|
|
27
|
+
style="transform: scale(0.6)"
|
|
28
|
+
@change="onChange"
|
|
12
29
|
/>
|
|
13
30
|
</view>
|
|
14
31
|
</template>
|
|
15
32
|
<script lang="ts" setup>
|
|
16
33
|
import { computed } from 'vue';
|
|
17
|
-
// import "./style.less";
|
|
18
34
|
const props = defineProps<{ checked: boolean; isMultiple: boolean }>();
|
|
19
35
|
const emit = defineEmits<{
|
|
20
36
|
(e: 'change', value: boolean): void;
|
|
@@ -24,11 +40,11 @@ const emit = defineEmits<{
|
|
|
24
40
|
const uiType = computed(() => (props.isMultiple ? 'checkbox' : 'radio'));
|
|
25
41
|
const model = computed({
|
|
26
42
|
get: (): boolean => props.checked,
|
|
27
|
-
set: (val) => emit('update:modelValue', val)
|
|
43
|
+
set: (val) => emit('update:modelValue', val),
|
|
28
44
|
});
|
|
29
45
|
|
|
30
46
|
function onChange() {
|
|
31
|
-
emit('change', model.value);
|
|
47
|
+
emit('change', !model.value);
|
|
32
48
|
}
|
|
33
49
|
|
|
34
50
|
function onClick(e: MouseEvent) {
|
|
@@ -65,7 +81,8 @@ function onClick(e: MouseEvent) {
|
|
|
65
81
|
background-color: #fff;
|
|
66
82
|
z-index: 1;
|
|
67
83
|
cursor: pointer;
|
|
68
|
-
transition:
|
|
84
|
+
transition:
|
|
85
|
+
border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),
|
|
69
86
|
background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46);
|
|
70
87
|
}
|
|
71
88
|
.json-pretty-check-controller .json-pretty-check-controller-inner:after {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
@mouseover="handleNodeMouseover"
|
|
13
13
|
:style="style"
|
|
14
14
|
>
|
|
15
|
-
<view v-if="showLineNumber" class="json-pretty-node-index">
|
|
16
|
-
node.id + 1
|
|
17
|
-
|
|
15
|
+
<view v-if="showLineNumber" class="json-pretty-node-index">
|
|
16
|
+
{{ node.id + 1 }}
|
|
17
|
+
</view>
|
|
18
18
|
|
|
19
19
|
<CheckController
|
|
20
20
|
v-if="
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
<slot name="render-node-key" :node="props.node" :default-key="prettyKey">
|
|
47
47
|
{{ prettyKey }}
|
|
48
48
|
</slot>
|
|
49
|
-
<view class="json-pretty-colon">
|
|
50
|
-
`:${showKeyValueSpace ? ' ' : ''}`
|
|
51
|
-
|
|
49
|
+
<view class="json-pretty-colon">
|
|
50
|
+
{{ `:${showKeyValueSpace ? ' ' : ''}` }}
|
|
51
|
+
</view>
|
|
52
52
|
</view>
|
|
53
53
|
|
|
54
54
|
<view class="json-pretty-value-wrapper">
|
|
@@ -74,20 +74,19 @@
|
|
|
74
74
|
>
|
|
75
75
|
{{ defaultValue }}
|
|
76
76
|
</slot>
|
|
77
|
+
<text v-if="node.showComma">,</text>
|
|
77
78
|
</view>
|
|
78
79
|
</view>
|
|
79
80
|
|
|
80
|
-
<view v-if="node.showComma">,</view>
|
|
81
|
-
|
|
82
81
|
<view v-if="showLength && collapsed" class="json-pretty-comment">
|
|
83
82
|
// {{ node.length }} items
|
|
84
83
|
</view>
|
|
85
84
|
</view>
|
|
86
85
|
<view class="json-pretty-tree-node-actions" v-if="showNodeActions">
|
|
87
86
|
<slot name="render-node-actions" :copy="handleCopy">
|
|
88
|
-
<view @click="handleCopy" class="json-pretty-tree-node-actions-item"
|
|
89
|
-
|
|
90
|
-
>
|
|
87
|
+
<view @click="handleCopy" class="json-pretty-tree-node-actions-item">
|
|
88
|
+
copy
|
|
89
|
+
</view>
|
|
91
90
|
</slot>
|
|
92
91
|
</view>
|
|
93
92
|
</view>
|
|
@@ -165,7 +164,7 @@ const defaultValue = computed(() => {
|
|
|
165
164
|
} else if (value === undefined) {
|
|
166
165
|
value = 'undefined';
|
|
167
166
|
}
|
|
168
|
-
return dataType.value === 'string' ? `"${value}"` : value
|
|
167
|
+
return dataType.value === 'string' ? `"${value}"` : value?.toString();
|
|
169
168
|
});
|
|
170
169
|
|
|
171
170
|
const handleBracketsClick = () => {
|
|
@@ -231,7 +230,7 @@ const handleCopy = () => {
|
|
|
231
230
|
<style scoped>
|
|
232
231
|
.json-pretty-tree-node {
|
|
233
232
|
display: flex;
|
|
234
|
-
align-items: center;
|
|
233
|
+
/* align-items: center; */
|
|
235
234
|
position: relative;
|
|
236
235
|
line-height: 20px;
|
|
237
236
|
}
|
|
@@ -314,8 +313,10 @@ const handleCopy = () => {
|
|
|
314
313
|
align-items: center;
|
|
315
314
|
}
|
|
316
315
|
.json-pretty-value {
|
|
317
|
-
|
|
318
|
-
white-space:
|
|
316
|
+
word-break: break-all;
|
|
317
|
+
white-space: normal;
|
|
318
|
+
/* white-space: pre-line; */
|
|
319
|
+
/* white-space: nowrap; */
|
|
319
320
|
}
|
|
320
321
|
.json-pretty-value-null {
|
|
321
322
|
color: var(--json-pretty-color-null);
|
|
@@ -16,62 +16,51 @@
|
|
|
16
16
|
: style
|
|
17
17
|
"
|
|
18
18
|
>
|
|
19
|
-
<
|
|
20
|
-
v-if="
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
:style="{ height: `${height}px` }"
|
|
25
|
-
@scroll="handleTreeScroll"
|
|
26
|
-
ref="treeRef"
|
|
19
|
+
<VirtualList
|
|
20
|
+
v-if="autoVirtual"
|
|
21
|
+
:height="state.height"
|
|
22
|
+
:itemHeight="itemHeight"
|
|
23
|
+
:data="flatData"
|
|
27
24
|
>
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
itemHeight && itemHeight !== 20
|
|
68
|
-
? { lineHeight: `${itemHeight}px` }
|
|
69
|
-
: {}
|
|
70
|
-
"
|
|
71
|
-
/>
|
|
72
|
-
</view>
|
|
73
|
-
</view>
|
|
74
|
-
</scroll-view>
|
|
25
|
+
<template v-slot="{ list }">
|
|
26
|
+
<TreeNode
|
|
27
|
+
v-for="item in list"
|
|
28
|
+
:key="item.id"
|
|
29
|
+
:data="data"
|
|
30
|
+
:rootPath="rootPath"
|
|
31
|
+
:indent="indent"
|
|
32
|
+
:node="item"
|
|
33
|
+
:collapsed="!!state.hiddenPaths[item.path]"
|
|
34
|
+
:theme="theme"
|
|
35
|
+
:showDoubleQuotes="showDoubleQuotes"
|
|
36
|
+
:showLength="showLength"
|
|
37
|
+
:checked="selectedPaths.includes(item.path)"
|
|
38
|
+
:selectableType="selectableType"
|
|
39
|
+
:showLine="showLine"
|
|
40
|
+
:showLineNumber="showLineNumber"
|
|
41
|
+
:showSelectController="showSelectController"
|
|
42
|
+
:selectOnClickNode="selectOnClickNode"
|
|
43
|
+
:nodeSelectable="nodeSelectable"
|
|
44
|
+
:highlightSelectedNode="highlightSelectedNode"
|
|
45
|
+
:editable="editable"
|
|
46
|
+
:editableTrigger="editableTrigger"
|
|
47
|
+
:showIcon="showIcon"
|
|
48
|
+
:showKeyValueSpace="showKeyValueSpace"
|
|
49
|
+
:showNodeActions="showNodeActions"
|
|
50
|
+
@nodeClick="handleNodeClick"
|
|
51
|
+
@nodeMouseover="handleNodeMouseover"
|
|
52
|
+
@bracketsClick="handleBracketsClick"
|
|
53
|
+
@iconClick="handleIconClick"
|
|
54
|
+
@selectedChange="handleSelectedChange"
|
|
55
|
+
@valueChange="handleValueChange"
|
|
56
|
+
:style="
|
|
57
|
+
itemHeight && itemHeight !== 20
|
|
58
|
+
? { lineHeight: `${itemHeight}px` }
|
|
59
|
+
: {}
|
|
60
|
+
"
|
|
61
|
+
/>
|
|
62
|
+
</template>
|
|
63
|
+
</VirtualList>
|
|
75
64
|
<template v-else>
|
|
76
65
|
<TreeNode
|
|
77
66
|
v-for="item in state?.visibleData"
|
|
@@ -115,7 +104,6 @@
|
|
|
115
104
|
|
|
116
105
|
<script setup lang="ts">
|
|
117
106
|
import {
|
|
118
|
-
ref,
|
|
119
107
|
reactive,
|
|
120
108
|
computed,
|
|
121
109
|
watchEffect,
|
|
@@ -127,6 +115,8 @@ import {
|
|
|
127
115
|
} from 'vue';
|
|
128
116
|
import TreeNode from './components/TreeNode/index.vue';
|
|
129
117
|
|
|
118
|
+
import VirtualList from '../VirtualList/index.vue';
|
|
119
|
+
|
|
130
120
|
import { emitError, jsonFlatten, cloneDeep, isFunction } from './utils';
|
|
131
121
|
|
|
132
122
|
import type { NodeDataType, ScrollEvent, Tree } from './type';
|
|
@@ -170,9 +160,6 @@ const props = withDefaults(defineProps<Tree>(), {
|
|
|
170
160
|
});
|
|
171
161
|
const emits = defineEmits<Emits>();
|
|
172
162
|
|
|
173
|
-
// 初始化数据
|
|
174
|
-
const treeRef = ref<HTMLElement | null>(null);
|
|
175
|
-
|
|
176
163
|
const originFlatData = computed(() => jsonFlatten(props.data, props.rootPath));
|
|
177
164
|
|
|
178
165
|
// 初始化折叠路径
|
|
@@ -203,12 +190,14 @@ interface State {
|
|
|
203
190
|
translateY: number;
|
|
204
191
|
visibleData: NodeDataType[] | null;
|
|
205
192
|
hiddenPaths: Record<string, 1>;
|
|
193
|
+
height: number;
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
const state = reactive<State>({
|
|
209
197
|
translateY: 0,
|
|
210
198
|
visibleData: [],
|
|
211
199
|
hiddenPaths: initHiddenPaths(props.deep, props.collapsedNodeLength),
|
|
200
|
+
height: props.height ?? 400,
|
|
212
201
|
});
|
|
213
202
|
|
|
214
203
|
// 计算属性
|
|
@@ -263,12 +252,22 @@ const propsErrorMessage = computed(() => {
|
|
|
263
252
|
: '';
|
|
264
253
|
});
|
|
265
254
|
|
|
255
|
+
const autoVirtual = computed(() => {
|
|
256
|
+
if (props.virtual) return true;
|
|
257
|
+
if (typeof props.autoVirtualRow === 'number') {
|
|
258
|
+
if (flatData.value.length > props.autoVirtualRow) {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
});
|
|
264
|
+
|
|
266
265
|
// 更新可见数据
|
|
266
|
+
// 优化 虚拟列表,每项高度自适应
|
|
267
267
|
const updateVisibleData = (scrollTop: number = 0) => {
|
|
268
268
|
const flatDataValue = flatData.value ?? [];
|
|
269
|
-
if (
|
|
269
|
+
if (autoVirtual.value) {
|
|
270
270
|
const visibleCount = props.height / props.itemHeight;
|
|
271
|
-
// const scrollTop = treeRef.value?.scrollTop || 0;
|
|
272
271
|
const scrollCount = Math.floor(scrollTop / props.itemHeight);
|
|
273
272
|
let start =
|
|
274
273
|
scrollCount < 0
|
|
@@ -336,6 +335,10 @@ const updateCollapsedPaths = (collapsed: boolean, path: string) => {
|
|
|
336
335
|
delete newPaths[path];
|
|
337
336
|
state.hiddenPaths = newPaths;
|
|
338
337
|
}
|
|
338
|
+
|
|
339
|
+
if (path === props.rootPath) {
|
|
340
|
+
state.height = collapsed ? props.itemHeight : props.height;
|
|
341
|
+
}
|
|
339
342
|
};
|
|
340
343
|
|
|
341
344
|
const handleBracketsClick = (collapsed: boolean, node: NodeDataType) => {
|
|
@@ -386,6 +389,19 @@ watch(
|
|
|
386
389
|
},
|
|
387
390
|
);
|
|
388
391
|
|
|
392
|
+
// 监听是否折叠,默认不折叠
|
|
393
|
+
watch(
|
|
394
|
+
() => props.collapsed,
|
|
395
|
+
(val) => {
|
|
396
|
+
if (val) {
|
|
397
|
+
updateCollapsedPaths(true, props.rootPath);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
immediate: true,
|
|
402
|
+
},
|
|
403
|
+
);
|
|
404
|
+
|
|
389
405
|
// 生命周期钩子
|
|
390
406
|
onMounted(() => {
|
|
391
407
|
updateVisibleData();
|
|
@@ -443,20 +459,6 @@ onUnmounted(() => {
|
|
|
443
459
|
white-space: nowrap;
|
|
444
460
|
}
|
|
445
461
|
|
|
446
|
-
.json-pretty-tree-list {
|
|
447
|
-
overflow: auto;
|
|
448
|
-
position: relative;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
.json-pretty-tree-list-holder {
|
|
452
|
-
position: relative;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
.json-pretty-tree-list-holder-inner {
|
|
456
|
-
position: absolute;
|
|
457
|
-
width: 100%;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
462
|
.dark {
|
|
461
463
|
/* 深色主题样式 */
|
|
462
464
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="run-js">
|
|
3
|
+
<view class="run-js-control">
|
|
4
|
+
<FilterInput
|
|
5
|
+
:modelValue="modelValue"
|
|
6
|
+
placeholder="查询"
|
|
7
|
+
@search="emit('search', $event)"
|
|
8
|
+
@update:modelValue="emit('update:modelValue', $event)"
|
|
9
|
+
/>
|
|
10
|
+
<Tag mode="clear" @click="emit('clear')">清空</Tag>
|
|
11
|
+
</view>
|
|
12
|
+
<view class="run-js-list">
|
|
13
|
+
<view class="run-js-item" v-for="item in runJSList">
|
|
14
|
+
<view :class="`run-js-item-icon run-js-item-${item.mode}`"></view>
|
|
15
|
+
<view class="run-js-item-duration" v-if="item.mode === 'output'">
|
|
16
|
+
{{ item.duration }}ms
|
|
17
|
+
</view>
|
|
18
|
+
<view
|
|
19
|
+
class="run-js-item-content"
|
|
20
|
+
v-html="item.mode === 'input' ? item.code : item.result"
|
|
21
|
+
>
|
|
22
|
+
</view>
|
|
23
|
+
</view>
|
|
24
|
+
<view class="run-js-item">
|
|
25
|
+
<view class="run-js-item-icon run-js-item-input"> </view>
|
|
26
|
+
|
|
27
|
+
<input v-model="code" class="run-js-input" @confirm="onConfirm" />
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</template>
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import { ref } from 'vue';
|
|
34
|
+
import type { DevTool } from '../../type';
|
|
35
|
+
import FilterInput from '../FilterInput/index.vue';
|
|
36
|
+
import Tag from '../Tag/index.vue';
|
|
37
|
+
|
|
38
|
+
defineProps<{ runJSList: DevTool.RunJSItem[]; modelValue: string }>();
|
|
39
|
+
|
|
40
|
+
const emit = defineEmits<{
|
|
41
|
+
(e: 'search', value: string): void;
|
|
42
|
+
(e: 'update:modelValue', value: string): void;
|
|
43
|
+
(e: 'clear'): void;
|
|
44
|
+
(e: 'run', value: string): void;
|
|
45
|
+
}>();
|
|
46
|
+
const code = ref('');
|
|
47
|
+
function onConfirm() {
|
|
48
|
+
const value = code.value;
|
|
49
|
+
if (!value) return;
|
|
50
|
+
code.value = '';
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
emit('run', value);
|
|
53
|
+
}, 100);
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
<style scoped>
|
|
57
|
+
.run-js {
|
|
58
|
+
height: 100%;
|
|
59
|
+
font-size: var(--dev-tool-base-font-size);
|
|
60
|
+
}
|
|
61
|
+
.run-js-control {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
padding: 0 16px;
|
|
67
|
+
height: 32px;
|
|
68
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.run-js-list {
|
|
73
|
+
height: calc(100% - 32px);
|
|
74
|
+
overflow: auto;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.run-js-item {
|
|
78
|
+
position: relative;
|
|
79
|
+
display: flex;
|
|
80
|
+
padding: 0 16px;
|
|
81
|
+
min-height: 28px;
|
|
82
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.run-js-item-icon {
|
|
87
|
+
width: 8px;
|
|
88
|
+
height: 8px;
|
|
89
|
+
border: 1px solid #000;
|
|
90
|
+
border-bottom-color: transparent;
|
|
91
|
+
border-left-color: transparent;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.run-js-item-input {
|
|
96
|
+
margin: 10px 0 10px -4px;
|
|
97
|
+
transform: rotate(45deg);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.run-js-item-output {
|
|
101
|
+
margin: 10px -4px 10px 0px;
|
|
102
|
+
transform: rotate(-135deg);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.run-js-item-content {
|
|
106
|
+
margin-left: 16px;
|
|
107
|
+
min-height: 28px;
|
|
108
|
+
line-height: 28px;
|
|
109
|
+
white-space: pre-line;
|
|
110
|
+
word-break: break-all;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.run-js-input {
|
|
114
|
+
margin: 1px 0 1px 16px;
|
|
115
|
+
min-height: 26px;
|
|
116
|
+
width: 100%;
|
|
117
|
+
border: 1px solid transparent;
|
|
118
|
+
font-size: var(--dev-tool-base-font-size);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.run-js-item-duration {
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: 2px;
|
|
124
|
+
right: 16px;
|
|
125
|
+
height: 24px;
|
|
126
|
+
line-height: 24px;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -17,16 +17,85 @@
|
|
|
17
17
|
<view class="uni-event-item-right"> {{ eventItem.timer }}</view>
|
|
18
18
|
</view>
|
|
19
19
|
|
|
20
|
-
<view
|
|
21
|
-
{
|
|
20
|
+
<view
|
|
21
|
+
:class="`uni-event-item-right ${isUseDevSource ? 'link' : ''}`"
|
|
22
|
+
@click="onStackClick"
|
|
23
|
+
>
|
|
24
|
+
{{ eventItem.stack }}
|
|
22
25
|
</view>
|
|
26
|
+
|
|
27
|
+
<Code
|
|
28
|
+
v-if="openCode && eventItem.stack"
|
|
29
|
+
:url="eventItem.stack"
|
|
30
|
+
:sourceFileServers="sourceFileServers"
|
|
31
|
+
:mode="mode"
|
|
32
|
+
@close="onCloseCode"
|
|
33
|
+
/>
|
|
23
34
|
</view>
|
|
24
35
|
</template>
|
|
25
36
|
<script lang="ts" setup>
|
|
26
37
|
import Tag from '../Tag/index.vue';
|
|
38
|
+
import Code from '../Code/index.vue';
|
|
27
39
|
import type { DevTool } from '../../type';
|
|
40
|
+
import { computed, ref } from 'vue';
|
|
41
|
+
import { isAndroid, isMockWX } from '../../utils';
|
|
42
|
+
|
|
43
|
+
const props = defineProps<{
|
|
44
|
+
eventItem: DevTool.EventItem;
|
|
45
|
+
mode?: string;
|
|
46
|
+
useDevSource?: boolean;
|
|
47
|
+
sourceFileServers?: string[];
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const openCode = ref(false);
|
|
51
|
+
|
|
52
|
+
const isUseDevSource = computed(() => {
|
|
53
|
+
return (
|
|
54
|
+
!isMockWX(props?.eventItem?.stack ?? '') &&
|
|
55
|
+
props.mode === 'development' &&
|
|
56
|
+
props.useDevSource
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const isWXLink = computed(() => {
|
|
61
|
+
console.log('props?.eventItem: ', props?.eventItem);
|
|
62
|
+
console.log('props.mode: ', props.mode);
|
|
63
|
+
return (
|
|
64
|
+
isMockWX(props?.eventItem?.stack ?? '') || props.mode !== 'development'
|
|
65
|
+
);
|
|
66
|
+
});
|
|
28
67
|
|
|
29
|
-
|
|
68
|
+
function onStackClick() {
|
|
69
|
+
if (isWXLink.value) {
|
|
70
|
+
uni.showToast({
|
|
71
|
+
icon: 'none',
|
|
72
|
+
title: '[DevTool] 请在小程序真机调试模式下查看源码',
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!isUseDevSource.value) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (isAndroid()) {
|
|
82
|
+
if (props.sourceFileServers && props.sourceFileServers.length > 0) {
|
|
83
|
+
openCode.value = true;
|
|
84
|
+
} else {
|
|
85
|
+
uni.showToast({
|
|
86
|
+
icon: 'none',
|
|
87
|
+
title: '[DevTool] sourceFileServers 配置异常',
|
|
88
|
+
});
|
|
89
|
+
uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
openCode.value = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function onCloseCode() {
|
|
97
|
+
openCode.value = false;
|
|
98
|
+
}
|
|
30
99
|
</script>
|
|
31
100
|
|
|
32
101
|
<style scoped>
|
|
@@ -35,7 +35,13 @@
|
|
|
35
35
|
</Tag>
|
|
36
36
|
</DevToolTitle>
|
|
37
37
|
<view class="uni-event-list">
|
|
38
|
-
<UniEventItem
|
|
38
|
+
<UniEventItem
|
|
39
|
+
v-for="item in eventList"
|
|
40
|
+
:eventItem="item"
|
|
41
|
+
:mode="mode"
|
|
42
|
+
:useDevSource="useDevSource"
|
|
43
|
+
:sourceFileServers="sourceFileServers"
|
|
44
|
+
/>
|
|
39
45
|
</view>
|
|
40
46
|
</view>
|
|
41
47
|
</template>
|
|
@@ -48,6 +54,9 @@ import type { DevTool } from '@/dev/type';
|
|
|
48
54
|
defineProps<{
|
|
49
55
|
eventList?: DevTool.EventItem[];
|
|
50
56
|
eventCount?: DevTool.EventCount;
|
|
57
|
+
useDevSource?: boolean;
|
|
58
|
+
mode?: string;
|
|
59
|
+
sourceFileServers?: string[];
|
|
51
60
|
}>();
|
|
52
61
|
|
|
53
62
|
const emit = defineEmits<{
|