vite-uni-dev-tool 0.0.11 → 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.
- package/README.md +55 -1
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
- package/dev/components/ConsoleList/RunJSInput.vue +0 -235
- package/dev/components/ConsoleList/index.vue +0 -130
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -182
- package/dev/components/DevToolButton/index.vue +0 -213
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1037
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -474
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -197
- package/dev/components/NetworkList/NetworkItem.vue +0 -106
- package/dev/components/NetworkList/index.vue +0 -115
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -110
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -225
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -124
- package/dev/components/UniEvent/index.vue +0 -94
- package/dev/components/UploadList/UploadDetail.vue +0 -208
- package/dev/components/UploadList/UploadItem.vue +0 -111
- package/dev/components/UploadList/index.vue +0 -104
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -175
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -98
- package/dev/components/WebSocket/WebSocketList.vue +0 -176
- package/dev/components/WebSocket/index.vue +0 -111
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -166
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -806
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -718
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -264
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -46
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -72
- package/dev/utils/object.ts +0 -298
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="device-info-content">
|
|
3
|
-
<JsonPretty :data="deviceInfo" v-if="showJson" />
|
|
4
|
-
<Empty v-else />
|
|
5
|
-
</view>
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
import Empty from '../Empty/index.vue';
|
|
10
|
-
import JsonPretty from '../JsonPretty/index.vue';
|
|
11
|
-
const props = defineProps<{
|
|
12
|
-
deviceInfo: Record<string, any>;
|
|
13
|
-
}>();
|
|
14
|
-
|
|
15
|
-
const showJson = computed(() => {
|
|
16
|
-
try {
|
|
17
|
-
const str = JSON.stringify(props.deviceInfo);
|
|
18
|
-
if (typeof props.deviceInfo === 'object' && (str === '' || str === '{}')) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
</script>
|
|
27
|
-
<style>
|
|
28
|
-
.device-info-content {
|
|
29
|
-
padding: 16px;
|
|
30
|
-
font-size: var(--dev-tool-base-font-size);
|
|
31
|
-
}
|
|
32
|
-
</style>
|
|
Binary file
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="dev-tool-empty">
|
|
3
|
-
<image :src="empty" class="dev-tool-empty-image" />
|
|
4
|
-
<text class="dev-tool-empty-text">{{ text ?? '暂无调试信息' }}</text>
|
|
5
|
-
</view>
|
|
6
|
-
</template>
|
|
7
|
-
<script lang="ts" setup>
|
|
8
|
-
import empty from './empty.png';
|
|
9
|
-
defineProps<{ text?: string }>();
|
|
10
|
-
</script>
|
|
11
|
-
<style scoped>
|
|
12
|
-
.dev-tool-empty {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
align-items: center;
|
|
17
|
-
margin: 0 auto;
|
|
18
|
-
}
|
|
19
|
-
.dev-tool-empty-image {
|
|
20
|
-
margin-top: 50px;
|
|
21
|
-
width: 50px;
|
|
22
|
-
height: 50px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.dev-tool-empty-text {
|
|
26
|
-
color: #888;
|
|
27
|
-
}
|
|
28
|
-
</style>
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="filter-input-wrapper">
|
|
3
|
-
<input
|
|
4
|
-
:class="`filter-input`"
|
|
5
|
-
:value="modelValue"
|
|
6
|
-
:placeholder="placeholder || '请输入'"
|
|
7
|
-
@confirm="debounceInput"
|
|
8
|
-
/>
|
|
9
|
-
<view class="filter-input-clear" @click="onClear"> × </view>
|
|
10
|
-
</view>
|
|
11
|
-
</template>
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import { debounce } from '../../utils';
|
|
14
|
-
import { ref, onMounted } from 'vue';
|
|
15
|
-
const props = defineProps<{
|
|
16
|
-
placeholder?: string;
|
|
17
|
-
modelValue?: string;
|
|
18
|
-
}>();
|
|
19
|
-
const emit = defineEmits<{
|
|
20
|
-
(e: 'update:modelValue', value: string): void;
|
|
21
|
-
(e: 'search', value: string): void;
|
|
22
|
-
(e: 'openSearch', value: boolean): void;
|
|
23
|
-
}>();
|
|
24
|
-
|
|
25
|
-
const isActive = ref(false);
|
|
26
|
-
|
|
27
|
-
function onInput(e: any) {
|
|
28
|
-
const value = e.detail.value;
|
|
29
|
-
emit('update:modelValue', value);
|
|
30
|
-
emit('search', value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function onClear() {
|
|
34
|
-
emit('update:modelValue', '');
|
|
35
|
-
emit('search', '');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function openSearch(open: boolean) {
|
|
39
|
-
isActive.value = open;
|
|
40
|
-
emit('openSearch', open);
|
|
41
|
-
if (!open && props.modelValue) {
|
|
42
|
-
emit('update:modelValue', '');
|
|
43
|
-
emit('search', '');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const debounceInput = debounce(onInput, 500);
|
|
48
|
-
</script>
|
|
49
|
-
<style scoped>
|
|
50
|
-
.filter-input-wrapper {
|
|
51
|
-
flex: 1;
|
|
52
|
-
display: flex;
|
|
53
|
-
align-items: center;
|
|
54
|
-
padding: 0 8px;
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 24px;
|
|
57
|
-
|
|
58
|
-
border-radius: 4px;
|
|
59
|
-
border: 1px solid #eee;
|
|
60
|
-
|
|
61
|
-
background-color: #fff;
|
|
62
|
-
transition: max-width 0.3s;
|
|
63
|
-
box-sizing: border-box;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.filter-input {
|
|
67
|
-
flex: 1;
|
|
68
|
-
box-shadow: none;
|
|
69
|
-
box-sizing: border-box;
|
|
70
|
-
border-radius: 5;
|
|
71
|
-
font-family: inherit;
|
|
72
|
-
color: #000;
|
|
73
|
-
font-weight: 400;
|
|
74
|
-
font: unset;
|
|
75
|
-
height: 24px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.filter-input-clear {
|
|
79
|
-
padding-left: 8px;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.filter-input-icon {
|
|
83
|
-
width: 24px;
|
|
84
|
-
height: 24px;
|
|
85
|
-
}
|
|
86
|
-
</style>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="json-pretty-tree-brackets" @click="onClick">
|
|
3
|
-
{{ data }}
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
<script lang="ts" setup>
|
|
7
|
-
defineProps<{ data: string }>();
|
|
8
|
-
const emit = defineEmits<{
|
|
9
|
-
(e: 'click', event: MouseEvent): void;
|
|
10
|
-
}>();
|
|
11
|
-
|
|
12
|
-
function onClick(e: MouseEvent) {
|
|
13
|
-
emit('click', e);
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
<style>
|
|
17
|
-
.json-pretty-tree-brackets {
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
}
|
|
20
|
-
.json-pretty-tree-brackets:hover {
|
|
21
|
-
color: var(--json-pretty-primary-color);
|
|
22
|
-
}
|
|
23
|
-
</style>
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
v-if="isOpen || isClose"
|
|
4
|
-
:class="`json-pretty-carets json-pretty-carets-${
|
|
5
|
-
isOpen ? 'open' : 'close'
|
|
6
|
-
}`"
|
|
7
|
-
@click="onClick"
|
|
8
|
-
>
|
|
9
|
-
<view class="json-pretty-caret-down"></view>
|
|
10
|
-
</view>
|
|
11
|
-
</template>
|
|
12
|
-
<script lang="ts" setup>
|
|
13
|
-
import { computed } from 'vue';
|
|
14
|
-
// import "./styles.less";
|
|
15
|
-
const props = defineProps<{ nodeType: string }>();
|
|
16
|
-
const emit = defineEmits<{
|
|
17
|
-
(e: 'click', event: MouseEvent): void;
|
|
18
|
-
}>();
|
|
19
|
-
|
|
20
|
-
const isOpen = computed(() => {
|
|
21
|
-
return props.nodeType === 'objectStart' || props.nodeType === 'arrayStart';
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const isClose = computed(() => {
|
|
25
|
-
return (
|
|
26
|
-
props.nodeType === 'objectCollapsed' || props.nodeType === 'arrayCollapsed'
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
function onClick(e: MouseEvent) {
|
|
31
|
-
emit('click', e);
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
34
|
-
<style>
|
|
35
|
-
.json-pretty-carets {
|
|
36
|
-
position: absolute;
|
|
37
|
-
right: 0;
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
40
|
-
.json-pretty-carets svg {
|
|
41
|
-
transition: transform 0.3s;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.json-pretty-carets::hover {
|
|
45
|
-
color: var(--json-pretty-primary-color);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.json-pretty-carets-close {
|
|
49
|
-
transform: rotate(-90deg);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.json-pretty-caret-down {
|
|
53
|
-
margin: 7px 4px;
|
|
54
|
-
border: 3px solid #000;
|
|
55
|
-
border-top-color: transparent;
|
|
56
|
-
border-left-color: transparent;
|
|
57
|
-
transform: rotate(45deg);
|
|
58
|
-
}
|
|
59
|
-
</style>
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
:class="`json-pretty-check-controller ${model ? 'is-checked' : ''}`"
|
|
4
|
-
@click="onClick"
|
|
5
|
-
>
|
|
6
|
-
<!-- <view
|
|
7
|
-
:class="`json-pretty-check-controller-inner is-${uiType}`"
|
|
8
|
-
@click="onChange"
|
|
9
|
-
>
|
|
10
|
-
</view>
|
|
11
|
-
<input
|
|
12
|
-
:checked="model"
|
|
13
|
-
:class="`json-pretty-check-controller-original is-${uiType}`"
|
|
14
|
-
:type="uiType"
|
|
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"
|
|
29
|
-
/>
|
|
30
|
-
</view>
|
|
31
|
-
</template>
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
import { computed } from 'vue';
|
|
34
|
-
const props = defineProps<{ checked: boolean; isMultiple: boolean }>();
|
|
35
|
-
const emit = defineEmits<{
|
|
36
|
-
(e: 'change', value: boolean): void;
|
|
37
|
-
(e: 'update:modelValue', value: boolean): void;
|
|
38
|
-
}>();
|
|
39
|
-
|
|
40
|
-
const uiType = computed(() => (props.isMultiple ? 'checkbox' : 'radio'));
|
|
41
|
-
const model = computed({
|
|
42
|
-
get: (): boolean => props.checked,
|
|
43
|
-
set: (val) => emit('update:modelValue', val),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
function onChange() {
|
|
47
|
-
emit('change', !model.value);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function onClick(e: MouseEvent) {
|
|
51
|
-
e.stopPropagation();
|
|
52
|
-
}
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<style>
|
|
56
|
-
.json-pretty-check-controller {
|
|
57
|
-
position: absolute;
|
|
58
|
-
left: 0;
|
|
59
|
-
}
|
|
60
|
-
.json-pretty-check-controller.is-checked .json-pretty-check-controller-inner {
|
|
61
|
-
background-color: var(--json-pretty-color-primary);
|
|
62
|
-
border-color: var(--json-pretty-color-primary);
|
|
63
|
-
}
|
|
64
|
-
.json-pretty-check-controller.is-checked
|
|
65
|
-
.json-pretty-check-controller-inner.is-checkbox:after {
|
|
66
|
-
transform: rotate(45deg) scaleY(1);
|
|
67
|
-
}
|
|
68
|
-
.json-pretty-check-controller.is-checked
|
|
69
|
-
.json-pretty-check-controller-inner.is-radio:after {
|
|
70
|
-
transform: translate(-50%, -50%) scale(1);
|
|
71
|
-
}
|
|
72
|
-
.json-pretty-check-controller .json-pretty-check-controller-inner {
|
|
73
|
-
display: inline-block;
|
|
74
|
-
position: relative;
|
|
75
|
-
border: 1px solid var(--json-pretty-border-color);
|
|
76
|
-
border-radius: 2px;
|
|
77
|
-
vertical-align: middle;
|
|
78
|
-
box-sizing: border-box;
|
|
79
|
-
width: 16px;
|
|
80
|
-
height: 16px;
|
|
81
|
-
background-color: #fff;
|
|
82
|
-
z-index: 1;
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
transition:
|
|
85
|
-
border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),
|
|
86
|
-
background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46);
|
|
87
|
-
}
|
|
88
|
-
.json-pretty-check-controller .json-pretty-check-controller-inner:after {
|
|
89
|
-
box-sizing: content-box;
|
|
90
|
-
content: '';
|
|
91
|
-
border: 2px solid #fff;
|
|
92
|
-
border-left: 0;
|
|
93
|
-
border-top: 0;
|
|
94
|
-
height: 8px;
|
|
95
|
-
left: 4px;
|
|
96
|
-
position: absolute;
|
|
97
|
-
top: 1px;
|
|
98
|
-
transform: rotate(45deg) scaleY(0);
|
|
99
|
-
width: 4px;
|
|
100
|
-
transition: transform 0.15s cubic-bezier(0.71, -0.46, 0.88, 0.6) 0.05s;
|
|
101
|
-
transform-origin: center;
|
|
102
|
-
}
|
|
103
|
-
.json-pretty-check-controller .json-pretty-check-controller-inner.is-radio {
|
|
104
|
-
border-radius: 100%;
|
|
105
|
-
}
|
|
106
|
-
.json-pretty-check-controller
|
|
107
|
-
.json-pretty-check-controller-inner.is-radio:after {
|
|
108
|
-
border-radius: 100%;
|
|
109
|
-
height: 4px;
|
|
110
|
-
background-color: #fff;
|
|
111
|
-
left: 50%;
|
|
112
|
-
top: 50%;
|
|
113
|
-
}
|
|
114
|
-
.json-pretty-check-controller .json-pretty-check-controller-original {
|
|
115
|
-
opacity: 0;
|
|
116
|
-
outline: none;
|
|
117
|
-
position: absolute;
|
|
118
|
-
z-index: -1;
|
|
119
|
-
top: 0;
|
|
120
|
-
left: 0;
|
|
121
|
-
right: 0;
|
|
122
|
-
bottom: 0;
|
|
123
|
-
margin: 0;
|
|
124
|
-
}
|
|
125
|
-
</style>
|
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
:class="{
|
|
4
|
-
'json-pretty-tree-node': true,
|
|
5
|
-
'has-selector': showSelectController,
|
|
6
|
-
'has-carets': showIcon,
|
|
7
|
-
'is-highlight': highlightSelectedNode && checked,
|
|
8
|
-
'json-pretty-tree-node-active': state.editing,
|
|
9
|
-
dark: theme === 'dark',
|
|
10
|
-
}"
|
|
11
|
-
@click="handleNodeClick"
|
|
12
|
-
@mouseover="handleNodeMouseover"
|
|
13
|
-
:style="style"
|
|
14
|
-
>
|
|
15
|
-
<view v-if="showLineNumber" class="json-pretty-node-index">
|
|
16
|
-
{{ node.id + 1 }}
|
|
17
|
-
</view>
|
|
18
|
-
|
|
19
|
-
<CheckController
|
|
20
|
-
v-if="
|
|
21
|
-
showSelectController &&
|
|
22
|
-
selectable &&
|
|
23
|
-
node.type !== 'objectEnd' &&
|
|
24
|
-
node.type !== 'arrayEnd'
|
|
25
|
-
"
|
|
26
|
-
:isMultiple="isMultiple"
|
|
27
|
-
:checked="checked"
|
|
28
|
-
@change="handleSelectedChange"
|
|
29
|
-
/>
|
|
30
|
-
|
|
31
|
-
<view class="json-pretty-indent">
|
|
32
|
-
<view
|
|
33
|
-
v-for="(item, index) in Array(node.level)"
|
|
34
|
-
:key="index"
|
|
35
|
-
:class="{
|
|
36
|
-
'json-pretty-indent-unit': true,
|
|
37
|
-
'has-line': showLine,
|
|
38
|
-
}"
|
|
39
|
-
>
|
|
40
|
-
<view v-for="() in Array(indent)" :key="Math.random()"> </view>
|
|
41
|
-
</view>
|
|
42
|
-
<Carets v-if="showIcon" :nodeType="node.type" @click="handleIconClick" />
|
|
43
|
-
</view>
|
|
44
|
-
|
|
45
|
-
<view v-if="node.key" class="json-pretty-key">
|
|
46
|
-
<slot name="render-node-key" :node="props.node" :default-key="prettyKey">
|
|
47
|
-
{{ prettyKey }}
|
|
48
|
-
</slot>
|
|
49
|
-
<view class="json-pretty-colon">
|
|
50
|
-
{{ `:${showKeyValueSpace ? ' ' : ''}` }}
|
|
51
|
-
</view>
|
|
52
|
-
</view>
|
|
53
|
-
|
|
54
|
-
<view class="json-pretty-value-wrapper">
|
|
55
|
-
<Brackets
|
|
56
|
-
v-if="node.type !== 'content' && node.content"
|
|
57
|
-
:data="node.content.toString()"
|
|
58
|
-
@click="handleBracketsClick"
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
<view v-else :class="valueClass" @click="handleValueEdit">
|
|
62
|
-
<input
|
|
63
|
-
v-if="editable && state.editing"
|
|
64
|
-
class="json-pretty-edit-input"
|
|
65
|
-
:value="defaultValue"
|
|
66
|
-
:focus="state.editing"
|
|
67
|
-
@blur="handleInputBlur"
|
|
68
|
-
/>
|
|
69
|
-
<view v-else>
|
|
70
|
-
<slot
|
|
71
|
-
name="render-node-value"
|
|
72
|
-
:node="props.node"
|
|
73
|
-
:default-value="defaultValue"
|
|
74
|
-
>
|
|
75
|
-
{{ defaultValue }}
|
|
76
|
-
</slot>
|
|
77
|
-
<text v-if="node.showComma">,</text>
|
|
78
|
-
</view>
|
|
79
|
-
</view>
|
|
80
|
-
|
|
81
|
-
<view v-if="showLength && collapsed" class="json-pretty-comment">
|
|
82
|
-
// {{ node.length }} items
|
|
83
|
-
</view>
|
|
84
|
-
</view>
|
|
85
|
-
<view class="json-pretty-tree-node-actions" v-if="showNodeActions">
|
|
86
|
-
<slot name="render-node-actions" :copy="handleCopy">
|
|
87
|
-
<view @click="handleCopy" class="json-pretty-tree-node-actions-item">
|
|
88
|
-
copy
|
|
89
|
-
</view>
|
|
90
|
-
</slot>
|
|
91
|
-
</view>
|
|
92
|
-
</view>
|
|
93
|
-
</template>
|
|
94
|
-
|
|
95
|
-
<script lang="ts" setup>
|
|
96
|
-
import { reactive, computed } from 'vue';
|
|
97
|
-
import Brackets from '../Brackets/index.vue';
|
|
98
|
-
import CheckController from '../CheckController/index.vue';
|
|
99
|
-
import Carets from '../Carets/index.vue';
|
|
100
|
-
import { getDataType, isFunction, stringToAutoType } from '../../utils';
|
|
101
|
-
|
|
102
|
-
import type { NodeDataType, TreeNodeProps } from '../../type';
|
|
103
|
-
import { getValueByPath } from '../../../../utils';
|
|
104
|
-
|
|
105
|
-
const props = withDefaults(defineProps<TreeNodeProps>(), {
|
|
106
|
-
rootPath: 'root',
|
|
107
|
-
indent: 2,
|
|
108
|
-
showDoubleQuotes: true,
|
|
109
|
-
showLine: true,
|
|
110
|
-
selectOnClickNode: true,
|
|
111
|
-
highlightSelectedNode: true,
|
|
112
|
-
theme: 'light',
|
|
113
|
-
showKeyValueSpace: true,
|
|
114
|
-
editableTrigger: 'click',
|
|
115
|
-
checked: false,
|
|
116
|
-
nodeSelectable: () => false,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const emit = defineEmits<{
|
|
120
|
-
(e: 'nodeClick', node: NodeDataType): void;
|
|
121
|
-
(e: 'nodeMouseover', node: NodeDataType): void;
|
|
122
|
-
(e: 'bracketsClick', collapsed: boolean, node: NodeDataType): void;
|
|
123
|
-
(e: 'iconClick', collapsed: boolean, node: NodeDataType): void;
|
|
124
|
-
(e: 'selectedChange', node: NodeDataType): void;
|
|
125
|
-
(e: 'valueChange', value: any, path: string): void;
|
|
126
|
-
}>();
|
|
127
|
-
|
|
128
|
-
const dataType = computed<string>(() => getDataType(props.node.content));
|
|
129
|
-
|
|
130
|
-
const valueClass = computed(
|
|
131
|
-
() => `json-pretty-value json-pretty-value-${dataType.value}`,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const prettyKey = computed(() =>
|
|
135
|
-
props.showDoubleQuotes ? `"${props.node.key}"` : props.node.key,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const isMultiple = computed(() => props.selectableType === 'multiple');
|
|
139
|
-
|
|
140
|
-
const isSingle = computed(() => props.selectableType === 'single');
|
|
141
|
-
|
|
142
|
-
const selectable = computed(
|
|
143
|
-
() =>
|
|
144
|
-
isFunction(props?.nodeSelectable) &&
|
|
145
|
-
props?.nodeSelectable?.(props.node) &&
|
|
146
|
-
(isMultiple.value || isSingle.value),
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const state = reactive({
|
|
150
|
-
editing: false,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const handleInputBlur = (e: FocusEvent) => {
|
|
154
|
-
const source = (e.detail as any).value;
|
|
155
|
-
const value = stringToAutoType(source);
|
|
156
|
-
emit('valueChange', value, props.node.path);
|
|
157
|
-
state.editing = false;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const defaultValue = computed(() => {
|
|
161
|
-
let value = props.node?.content;
|
|
162
|
-
if (value === null) {
|
|
163
|
-
value = 'null';
|
|
164
|
-
} else if (value === undefined) {
|
|
165
|
-
value = 'undefined';
|
|
166
|
-
}
|
|
167
|
-
return dataType.value === 'string' ? `"${value}"` : value?.toString();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const handleBracketsClick = () => {
|
|
171
|
-
emit('bracketsClick', !props.collapsed, props.node);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const handleIconClick = () => {
|
|
175
|
-
emit('iconClick', !props.collapsed, props.node);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const handleSelectedChange = () => {
|
|
179
|
-
emit('selectedChange', props.node);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const handleNodeClick = () => {
|
|
183
|
-
emit('nodeClick', props.node);
|
|
184
|
-
if (selectable.value && props.selectOnClickNode) {
|
|
185
|
-
emit('selectedChange', props.node);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const handleNodeMouseover = () => {
|
|
190
|
-
emit('nodeMouseover', props.node);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const handleValueEdit = (e: MouseEvent) => {
|
|
194
|
-
if (!props.editable) return;
|
|
195
|
-
|
|
196
|
-
if (!state.editing) {
|
|
197
|
-
state.editing = true;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const handleCopy = () => {
|
|
202
|
-
const { key, path } = props.node;
|
|
203
|
-
const rootPath = props.rootPath;
|
|
204
|
-
|
|
205
|
-
const content = getValueByPath(props.data, path.slice(rootPath.length));
|
|
206
|
-
|
|
207
|
-
const copiedData = JSON.stringify(
|
|
208
|
-
key ? { [key]: content } : content,
|
|
209
|
-
null,
|
|
210
|
-
2,
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
uni.setClipboardData({
|
|
214
|
-
data: copiedData,
|
|
215
|
-
success() {
|
|
216
|
-
uni.showToast({
|
|
217
|
-
title: '复制成功',
|
|
218
|
-
icon: 'none',
|
|
219
|
-
});
|
|
220
|
-
},
|
|
221
|
-
fail() {
|
|
222
|
-
uni.showToast({
|
|
223
|
-
title: '复制失败',
|
|
224
|
-
icon: 'none',
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
</script>
|
|
230
|
-
<style scoped>
|
|
231
|
-
.json-pretty-tree-node {
|
|
232
|
-
display: flex;
|
|
233
|
-
/* align-items: center; */
|
|
234
|
-
position: relative;
|
|
235
|
-
line-height: 20px;
|
|
236
|
-
}
|
|
237
|
-
.json-pretty-tree-node.has-carets {
|
|
238
|
-
padding-left: 15px;
|
|
239
|
-
}
|
|
240
|
-
.json-pretty-tree-node.has-selector,
|
|
241
|
-
.json-pretty-tree-node.has-carets.has-selector {
|
|
242
|
-
padding-left: 30px;
|
|
243
|
-
}
|
|
244
|
-
.json-pretty-tree-node.is-highlight,
|
|
245
|
-
.json-pretty-tree-node:hover {
|
|
246
|
-
background-color: var(--json-pretty-highlight-bg-color);
|
|
247
|
-
border-radius: 4px;
|
|
248
|
-
}
|
|
249
|
-
.json-pretty-tree-node.is-highlight .json-pretty-tree-node-actions,
|
|
250
|
-
.json-pretty-tree-node:hover .json-pretty-tree-node-actions {
|
|
251
|
-
display: block;
|
|
252
|
-
}
|
|
253
|
-
.json-pretty-tree-node .json-pretty-indent {
|
|
254
|
-
display: flex;
|
|
255
|
-
position: relative;
|
|
256
|
-
}
|
|
257
|
-
.json-pretty-tree-node .json-pretty-indent-unit {
|
|
258
|
-
display: flex;
|
|
259
|
-
}
|
|
260
|
-
.json-pretty-tree-node .json-pretty-indent-unit.has-line {
|
|
261
|
-
border-left: 1px dashed var(--json-pretty-border-color);
|
|
262
|
-
}
|
|
263
|
-
.json-pretty-tree-node .json-pretty-tree-node-actions {
|
|
264
|
-
display: none;
|
|
265
|
-
position: absolute;
|
|
266
|
-
right: 0;
|
|
267
|
-
top: 0;
|
|
268
|
-
padding: 0 4px;
|
|
269
|
-
background-color: var(--json-pretty-highlight-bg-color);
|
|
270
|
-
border-radius: 4px;
|
|
271
|
-
}
|
|
272
|
-
.json-pretty-tree-node
|
|
273
|
-
.json-pretty-tree-node-actions
|
|
274
|
-
.json-pretty-tree-node-actions-item {
|
|
275
|
-
cursor: pointer;
|
|
276
|
-
}
|
|
277
|
-
.json-pretty-tree-node
|
|
278
|
-
.json-pretty-tree-node-actions
|
|
279
|
-
.json-pretty-tree-node-actions-item:hover {
|
|
280
|
-
color: var(--json-pretty-color-primary);
|
|
281
|
-
}
|
|
282
|
-
.json-pretty-tree-node.dark.is-highlight,
|
|
283
|
-
.json-pretty-tree-node.dark:hover {
|
|
284
|
-
background-color: var(--json-pretty-highlight-bg-color-dark);
|
|
285
|
-
}
|
|
286
|
-
.json-pretty-tree-node.dark .json-pretty-tree-node-actions {
|
|
287
|
-
background-color: var(--json-pretty-highlight-bg-color-dark);
|
|
288
|
-
}
|
|
289
|
-
.json-pretty-tree-node-active {
|
|
290
|
-
background-color: var(--json-pretty-highlight-bg-color);
|
|
291
|
-
border-radius: 4px;
|
|
292
|
-
}
|
|
293
|
-
.json-pretty-tree-node-active .json-pretty-tree-node-actions {
|
|
294
|
-
display: block;
|
|
295
|
-
}
|
|
296
|
-
.json-pretty-node-index {
|
|
297
|
-
position: absolute;
|
|
298
|
-
right: 100%;
|
|
299
|
-
margin-right: 4px;
|
|
300
|
-
user-select: none;
|
|
301
|
-
}
|
|
302
|
-
.json-pretty-colon {
|
|
303
|
-
white-space: pre;
|
|
304
|
-
}
|
|
305
|
-
.json-pretty-comment {
|
|
306
|
-
color: var(--json-pretty-color-primary);
|
|
307
|
-
}
|
|
308
|
-
.json-pretty-key {
|
|
309
|
-
display: flex;
|
|
310
|
-
}
|
|
311
|
-
.json-pretty-value-wrapper {
|
|
312
|
-
display: flex;
|
|
313
|
-
align-items: center;
|
|
314
|
-
}
|
|
315
|
-
.json-pretty-value {
|
|
316
|
-
word-break: break-all;
|
|
317
|
-
white-space: normal;
|
|
318
|
-
/* white-space: pre-line; */
|
|
319
|
-
/* white-space: nowrap; */
|
|
320
|
-
}
|
|
321
|
-
.json-pretty-value-null {
|
|
322
|
-
color: var(--json-pretty-color-null);
|
|
323
|
-
}
|
|
324
|
-
.json-pretty-value-undefined {
|
|
325
|
-
color: var(--json-pretty-color-undefined);
|
|
326
|
-
}
|
|
327
|
-
.json-pretty-value-number {
|
|
328
|
-
color: var(--json-pretty-color-number);
|
|
329
|
-
}
|
|
330
|
-
.json-pretty-value-boolean {
|
|
331
|
-
color: var(--json-pretty-color-boolean);
|
|
332
|
-
}
|
|
333
|
-
.json-pretty-value-string {
|
|
334
|
-
color: var(--json-pretty-color-string);
|
|
335
|
-
}
|
|
336
|
-
.json-pretty-edit-input {
|
|
337
|
-
padding: 0px 8px;
|
|
338
|
-
border: 1px solid #eee;
|
|
339
|
-
box-shadow: none;
|
|
340
|
-
box-sizing: border-box;
|
|
341
|
-
border-radius: 5;
|
|
342
|
-
font-family: inherit;
|
|
343
|
-
color: #000;
|
|
344
|
-
font-weight: 400;
|
|
345
|
-
background-color: #fff;
|
|
346
|
-
font: unset;
|
|
347
|
-
height: 16px;
|
|
348
|
-
}
|
|
349
|
-
</style>
|