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.
- 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 +7 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- 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 -207
- package/dev/components/ConsoleList/RunJSInput.vue +0 -237
- package/dev/components/ConsoleList/index.vue +0 -139
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -188
- package/dev/components/DevToolButton/index.vue +0 -210
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1053
- 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 -476
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -194
- package/dev/components/NetworkList/NetworkItem.vue +0 -119
- package/dev/components/NetworkList/index.vue +0 -128
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -121
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -222
- package/dev/components/SourceCode/index.vue +0 -231
- 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 -126
- package/dev/components/UniEvent/index.vue +0 -98
- package/dev/components/UploadList/UploadDetail.vue +0 -204
- package/dev/components/UploadList/UploadItem.vue +0 -117
- package/dev/components/UploadList/index.vue +0 -117
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -238
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -103
- package/dev/components/WebSocket/WebSocketList.vue +0 -173
- package/dev/components/WebSocket/index.vue +0 -124
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -164
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -810
- 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 -732
- package/dev/devToolInfo/index.ts +0 -26
- 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 -291
- 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 -51
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -77
- package/dev/utils/object.ts +0 -306
- 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
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
JSONDataType,
|
|
3
|
-
JSONFlattenOptions,
|
|
4
|
-
JSONFlattenReturnType
|
|
5
|
-
} from "../type";
|
|
6
|
-
|
|
7
|
-
export function emitError(message: string): void {
|
|
8
|
-
throw new Error(`[JsonPretty] ${message}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getDataType(value: unknown): string {
|
|
12
|
-
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function jsonFlatten(
|
|
16
|
-
data: JSONDataType,
|
|
17
|
-
path = "root",
|
|
18
|
-
level = 0,
|
|
19
|
-
options?: JSONFlattenOptions
|
|
20
|
-
): JSONFlattenReturnType[] {
|
|
21
|
-
const {
|
|
22
|
-
key,
|
|
23
|
-
index,
|
|
24
|
-
type = "content",
|
|
25
|
-
showComma = false,
|
|
26
|
-
length = 1
|
|
27
|
-
} = options || ({} as JSONFlattenOptions);
|
|
28
|
-
const dataType = getDataType(data);
|
|
29
|
-
|
|
30
|
-
if (dataType === "array") {
|
|
31
|
-
const inner = arrFlat(
|
|
32
|
-
(data as JSONDataType[]).map((item, idx, arr) =>
|
|
33
|
-
jsonFlatten(item, `${path}[${idx}]`, level + 1, {
|
|
34
|
-
index: idx,
|
|
35
|
-
showComma: idx !== arr.length - 1,
|
|
36
|
-
length,
|
|
37
|
-
type
|
|
38
|
-
})
|
|
39
|
-
)
|
|
40
|
-
) as JSONFlattenReturnType[];
|
|
41
|
-
return [
|
|
42
|
-
jsonFlatten("[", path, level, {
|
|
43
|
-
showComma: false,
|
|
44
|
-
key,
|
|
45
|
-
length: (data as unknown[]).length,
|
|
46
|
-
type: "arrayStart"
|
|
47
|
-
})[0]
|
|
48
|
-
].concat(
|
|
49
|
-
inner,
|
|
50
|
-
jsonFlatten("]", path, level, {
|
|
51
|
-
showComma,
|
|
52
|
-
length: (data as unknown[]).length,
|
|
53
|
-
type: "arrayEnd"
|
|
54
|
-
})[0]
|
|
55
|
-
);
|
|
56
|
-
} else if (dataType === "object") {
|
|
57
|
-
const keys = Object.keys(data as Record<string, JSONDataType>);
|
|
58
|
-
const inner = arrFlat(
|
|
59
|
-
keys.map((objKey, idx, arr) =>
|
|
60
|
-
jsonFlatten(
|
|
61
|
-
(data as Record<string, JSONDataType>)[objKey],
|
|
62
|
-
/^[a-zA-Z_]\w*$/.test(objKey)
|
|
63
|
-
? `${path}.${objKey}`
|
|
64
|
-
: `${path}["${objKey}"]`,
|
|
65
|
-
level + 1,
|
|
66
|
-
{
|
|
67
|
-
key: objKey,
|
|
68
|
-
showComma: idx !== arr.length - 1,
|
|
69
|
-
length,
|
|
70
|
-
type
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
)
|
|
74
|
-
) as JSONFlattenReturnType[];
|
|
75
|
-
return [
|
|
76
|
-
jsonFlatten("{", path, level, {
|
|
77
|
-
showComma: false,
|
|
78
|
-
key,
|
|
79
|
-
index,
|
|
80
|
-
length: keys.length,
|
|
81
|
-
type: "objectStart"
|
|
82
|
-
})[0]
|
|
83
|
-
].concat(
|
|
84
|
-
inner,
|
|
85
|
-
jsonFlatten("}", path, level, {
|
|
86
|
-
showComma,
|
|
87
|
-
length: keys.length,
|
|
88
|
-
type: "objectEnd"
|
|
89
|
-
})[0]
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return [
|
|
94
|
-
{
|
|
95
|
-
content: data as JSONFlattenReturnType["content"],
|
|
96
|
-
level,
|
|
97
|
-
key,
|
|
98
|
-
index,
|
|
99
|
-
path,
|
|
100
|
-
showComma,
|
|
101
|
-
length,
|
|
102
|
-
type
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function arrFlat<T extends unknown[]>(arr: T): unknown[] {
|
|
108
|
-
if (typeof Array.prototype.flat === "function") {
|
|
109
|
-
return arr.flat();
|
|
110
|
-
}
|
|
111
|
-
const stack = [...arr];
|
|
112
|
-
const result = [];
|
|
113
|
-
while (stack.length) {
|
|
114
|
-
const first = stack.shift();
|
|
115
|
-
if (Array.isArray(first)) {
|
|
116
|
-
stack.unshift(...first);
|
|
117
|
-
} else {
|
|
118
|
-
result.push(first);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function cloneDeep<T extends unknown>(
|
|
125
|
-
source: T,
|
|
126
|
-
hash = new WeakMap()
|
|
127
|
-
): T {
|
|
128
|
-
if (source === null || source === undefined) return source;
|
|
129
|
-
if (source instanceof Date) return new Date(source) as T;
|
|
130
|
-
if (source instanceof RegExp) return new RegExp(source) as T;
|
|
131
|
-
if (typeof source !== "object") return source;
|
|
132
|
-
if (hash.get(source as Record<string, unknown>))
|
|
133
|
-
return hash.get(source as Record<string, unknown>);
|
|
134
|
-
|
|
135
|
-
if (Array.isArray(source)) {
|
|
136
|
-
const output = source.map((item) => cloneDeep(item, hash));
|
|
137
|
-
hash.set(source, output);
|
|
138
|
-
return output as T;
|
|
139
|
-
}
|
|
140
|
-
const output = {} as T;
|
|
141
|
-
for (const key in source) {
|
|
142
|
-
output[key] = cloneDeep(source[key], hash);
|
|
143
|
-
}
|
|
144
|
-
hash.set(source as Record<string, unknown>, output);
|
|
145
|
-
return output as T;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function stringToAutoType(source: string): unknown {
|
|
149
|
-
let value;
|
|
150
|
-
if (source === "null") value = null;
|
|
151
|
-
else if (source === "undefined") value = undefined;
|
|
152
|
-
else if (source === "true") value = true;
|
|
153
|
-
else if (source === "false") value = false;
|
|
154
|
-
else if (
|
|
155
|
-
source[0] + source[source.length - 1] === '""' ||
|
|
156
|
-
source[0] + source[source.length - 1] === "''"
|
|
157
|
-
) {
|
|
158
|
-
value = source.slice(1, -1);
|
|
159
|
-
} else if (
|
|
160
|
-
(typeof Number(source) === "number" && !isNaN(Number(source))) ||
|
|
161
|
-
source === "NaN"
|
|
162
|
-
) {
|
|
163
|
-
value = Number(source);
|
|
164
|
-
} else {
|
|
165
|
-
value = source;
|
|
166
|
-
}
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function isFunction(value: unknown): value is Function {
|
|
171
|
-
return typeof value === "function";
|
|
172
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="network-detail" :style="{ zIndex: zIndex }">
|
|
3
|
-
<view class="network-detail-control">
|
|
4
|
-
<Tag
|
|
5
|
-
mode="info"
|
|
6
|
-
v-for="item in selectItems"
|
|
7
|
-
:active="item.value === currentSelect"
|
|
8
|
-
:key="item.value"
|
|
9
|
-
@click="onSelect(item)"
|
|
10
|
-
>
|
|
11
|
-
{{ item.label }}
|
|
12
|
-
</Tag>
|
|
13
|
-
<CloseButton style="margin-left: auto" @click="onClose" />
|
|
14
|
-
</view>
|
|
15
|
-
|
|
16
|
-
<view class="network-detail-header" v-if="currentSelect === 'header'">
|
|
17
|
-
<view class="network-detail-title">常规</view>
|
|
18
|
-
<view class="net-detail-item">
|
|
19
|
-
<view>请求url:</view>
|
|
20
|
-
<view>{{ network.url }}</view>
|
|
21
|
-
</view>
|
|
22
|
-
<view class="net-detail-item">
|
|
23
|
-
<view>请求方法:</view>
|
|
24
|
-
<Tag mode="info">{{ network.method }}</Tag>
|
|
25
|
-
</view>
|
|
26
|
-
<view class="net-detail-item">
|
|
27
|
-
<view>状态代码:</view>
|
|
28
|
-
{{ network.status }}
|
|
29
|
-
</view>
|
|
30
|
-
<view class="network-detail-title">请求头</view>
|
|
31
|
-
<view
|
|
32
|
-
class="net-detail-item"
|
|
33
|
-
v-for="item in network.headers.requestHeader"
|
|
34
|
-
:key="item.key"
|
|
35
|
-
>
|
|
36
|
-
<view>{{ item.key }}:</view>
|
|
37
|
-
{{ item.value }}
|
|
38
|
-
</view>
|
|
39
|
-
<view class="network-detail-title">响应头</view>
|
|
40
|
-
<view
|
|
41
|
-
class="net-detail-item"
|
|
42
|
-
v-for="item in network.headers.responseHeader"
|
|
43
|
-
:key="item.key"
|
|
44
|
-
>
|
|
45
|
-
<view>{{ item.key }}:</view>
|
|
46
|
-
{{ item.value }}
|
|
47
|
-
</view>
|
|
48
|
-
</view>
|
|
49
|
-
|
|
50
|
-
<template v-if="currentSelect === 'payload'">
|
|
51
|
-
<template v-if="payload?.type === 'object'">
|
|
52
|
-
<JsonPretty :data="payload.value" />
|
|
53
|
-
</template>
|
|
54
|
-
<view
|
|
55
|
-
v-else-if="payload?.type === 'string'"
|
|
56
|
-
class="network-detail-payload"
|
|
57
|
-
>
|
|
58
|
-
{{ payload.value }}
|
|
59
|
-
</view>
|
|
60
|
-
<Empty v-else />
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
|
-
<template v-if="currentSelect === 'response'">
|
|
64
|
-
<template v-if="response?.type === 'object'">
|
|
65
|
-
<JsonPretty :data="response.value" virtual />
|
|
66
|
-
</template>
|
|
67
|
-
<view
|
|
68
|
-
v-else-if="response?.type === 'string'"
|
|
69
|
-
class="network-detail-payload"
|
|
70
|
-
>
|
|
71
|
-
{{ response.value }}
|
|
72
|
-
</view>
|
|
73
|
-
<Empty v-else />
|
|
74
|
-
</template>
|
|
75
|
-
</view>
|
|
76
|
-
</template>
|
|
77
|
-
<script lang="ts" setup>
|
|
78
|
-
import { ref, computed } from 'vue';
|
|
79
|
-
import JsonPretty from '../JsonPretty/index.vue';
|
|
80
|
-
import Tag from '../Tag/index.vue';
|
|
81
|
-
import Empty from '../Empty/index.vue';
|
|
82
|
-
import CloseButton from '../CloseButton/index.vue';
|
|
83
|
-
import type { DevTool } from '../../type';
|
|
84
|
-
const props = defineProps<{ network: DevTool.NetworkItem; zIndex?: number }>();
|
|
85
|
-
const emit = defineEmits<{ (e: 'close'): void }>();
|
|
86
|
-
const selectItems = [
|
|
87
|
-
{
|
|
88
|
-
label: 'header',
|
|
89
|
-
value: 'header',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
label: 'payload',
|
|
93
|
-
value: 'payload',
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
label: 'response',
|
|
97
|
-
value: 'response',
|
|
98
|
-
},
|
|
99
|
-
];
|
|
100
|
-
const currentSelect = ref('header');
|
|
101
|
-
|
|
102
|
-
const payload = computed(() => {
|
|
103
|
-
try {
|
|
104
|
-
if (props.network.payload) {
|
|
105
|
-
return {
|
|
106
|
-
value: JSON.parse(props.network.payload),
|
|
107
|
-
type: 'object',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
value: {},
|
|
112
|
-
type: 'empty',
|
|
113
|
-
};
|
|
114
|
-
} catch (error) {
|
|
115
|
-
return {
|
|
116
|
-
value: props.network.payload,
|
|
117
|
-
type: props.network.payload ? 'string' : 'empty',
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const response = computed(() => {
|
|
123
|
-
try {
|
|
124
|
-
if (props.network.response) {
|
|
125
|
-
return {
|
|
126
|
-
value: JSON.parse(JSON.stringify(props.network.response)),
|
|
127
|
-
type: 'object',
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
value: {},
|
|
132
|
-
type: 'empty',
|
|
133
|
-
};
|
|
134
|
-
} catch (error) {
|
|
135
|
-
return {
|
|
136
|
-
value: props.network.response,
|
|
137
|
-
type: props.network.response ? 'string' : 'empty',
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
function onSelect(item: { label: string; value: string }) {
|
|
143
|
-
currentSelect.value = item.value;
|
|
144
|
-
}
|
|
145
|
-
function onClose() {
|
|
146
|
-
emit('close');
|
|
147
|
-
}
|
|
148
|
-
</script>
|
|
149
|
-
<style scoped>
|
|
150
|
-
.network-detail {
|
|
151
|
-
position: fixed;
|
|
152
|
-
width: 100vw;
|
|
153
|
-
height: 100vh;
|
|
154
|
-
z-index: 1001;
|
|
155
|
-
top: 0;
|
|
156
|
-
left: 0;
|
|
157
|
-
padding: 0 16px;
|
|
158
|
-
|
|
159
|
-
background-color: rgba(255, 255, 255, 0.95);
|
|
160
|
-
box-sizing: border-box;
|
|
161
|
-
}
|
|
162
|
-
.network-detail .network-detail-control {
|
|
163
|
-
display: flex;
|
|
164
|
-
align-items: center;
|
|
165
|
-
margin-bottom: 4px;
|
|
166
|
-
gap: 12px;
|
|
167
|
-
height: 32px;
|
|
168
|
-
border-bottom: 1px solid transparent;
|
|
169
|
-
box-sizing: border-box;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.network-detail .network-detail-control :deep(.tag) {
|
|
173
|
-
margin-right: 16px;
|
|
174
|
-
}
|
|
175
|
-
.network-detail .network-detail-control :deep(.tag):last-child {
|
|
176
|
-
margin-right: 0;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.network-detail .network-detail-header .net-detail-item {
|
|
180
|
-
display: flex;
|
|
181
|
-
align-items: center;
|
|
182
|
-
min-height: 28px;
|
|
183
|
-
word-break: break-all;
|
|
184
|
-
}
|
|
185
|
-
.network-detail .network-detail-header .net-detail-item > view:first-child {
|
|
186
|
-
white-space: nowrap;
|
|
187
|
-
margin-right: 8px;
|
|
188
|
-
color: #616161;
|
|
189
|
-
}
|
|
190
|
-
.network-detail .network-detail-payload {
|
|
191
|
-
word-break: break-all;
|
|
192
|
-
max-width: 100%;
|
|
193
|
-
}
|
|
194
|
-
</style>
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="network-item">
|
|
3
|
-
<view class="network-url-row">
|
|
4
|
-
<Tag mode="info">{{ network.method }}</Tag>
|
|
5
|
-
|
|
6
|
-
<view class="network-url" v-html="lastUrl"> </view>
|
|
7
|
-
|
|
8
|
-
<Tag
|
|
9
|
-
mode="main"
|
|
10
|
-
class="network-detail-icon"
|
|
11
|
-
@click="showDetail = !showDetail"
|
|
12
|
-
>详情</Tag
|
|
13
|
-
>
|
|
14
|
-
</view>
|
|
15
|
-
<view class="network-info">
|
|
16
|
-
<view>
|
|
17
|
-
<Tag
|
|
18
|
-
:mode="
|
|
19
|
-
network.status === 'pending'
|
|
20
|
-
? 'info'
|
|
21
|
-
: /[4,5]\d{2,}/.test(network.status + '') ||
|
|
22
|
-
network.status === 'error'
|
|
23
|
-
? 'error'
|
|
24
|
-
: 'success'
|
|
25
|
-
"
|
|
26
|
-
>{{ network.status }}</Tag
|
|
27
|
-
>
|
|
28
|
-
</view>
|
|
29
|
-
<!-- <view>{{ network.status }}</view> -->
|
|
30
|
-
<view>{{ network.time }}</view>
|
|
31
|
-
<view>{{ network.size }}</view>
|
|
32
|
-
<view
|
|
33
|
-
>开始:
|
|
34
|
-
{{
|
|
35
|
-
network.startTime
|
|
36
|
-
? formatDate(network.startTime, 'HH:mm:ss')
|
|
37
|
-
: '--:--:--'
|
|
38
|
-
}}</view
|
|
39
|
-
>
|
|
40
|
-
<view>
|
|
41
|
-
结束:
|
|
42
|
-
{{
|
|
43
|
-
network.endTime ? formatDate(network.endTime, 'HH:mm:ss') : '--:--:--'
|
|
44
|
-
}}
|
|
45
|
-
</view>
|
|
46
|
-
</view>
|
|
47
|
-
</view>
|
|
48
|
-
<!-- <Transition name="slide-fade"> -->
|
|
49
|
-
<NetworkDetail
|
|
50
|
-
v-if="showDetail"
|
|
51
|
-
:network="network"
|
|
52
|
-
:zIndex="zIndex"
|
|
53
|
-
@close="onClose"
|
|
54
|
-
/>
|
|
55
|
-
<!-- </Transition> -->
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<script lang="ts" setup>
|
|
59
|
-
import { computed, ref } from 'vue';
|
|
60
|
-
import Tag from '../Tag/index.vue';
|
|
61
|
-
import NetworkDetail from './NetworkDetail.vue';
|
|
62
|
-
import { formatDate } from '../../utils';
|
|
63
|
-
import type { DevTool } from '../../type';
|
|
64
|
-
const props = defineProps<{
|
|
65
|
-
network: DevTool.NetworkItem;
|
|
66
|
-
zIndex?: number;
|
|
67
|
-
}>();
|
|
68
|
-
const showDetail = ref(false);
|
|
69
|
-
|
|
70
|
-
const lastUrl = computed(() => {
|
|
71
|
-
const start = props.network.url.lastIndexOf('/');
|
|
72
|
-
return props.network.url.slice(start + 1);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
function onClose() {
|
|
76
|
-
showDetail.value = false;
|
|
77
|
-
}
|
|
78
|
-
</script>
|
|
79
|
-
<style scoped>
|
|
80
|
-
.network-item {
|
|
81
|
-
padding: 16px;
|
|
82
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
83
|
-
font-size: var(--dev-tool-base-font-size);
|
|
84
|
-
}
|
|
85
|
-
.network-url-row {
|
|
86
|
-
display: flex;
|
|
87
|
-
align-items: center;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.network-url {
|
|
91
|
-
margin-left: 4px;
|
|
92
|
-
flex: 1;
|
|
93
|
-
white-space: nowrap;
|
|
94
|
-
overflow: hidden;
|
|
95
|
-
text-overflow: ellipsis;
|
|
96
|
-
}
|
|
97
|
-
.network-detail-icon {
|
|
98
|
-
margin-left: auto;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.network-info {
|
|
102
|
-
display: flex;
|
|
103
|
-
align-items: center;
|
|
104
|
-
justify-content: space-between;
|
|
105
|
-
margin-top: 4px;
|
|
106
|
-
color: #616161;
|
|
107
|
-
}
|
|
108
|
-
.slide-fade-enter-active {
|
|
109
|
-
transition: all 0.8s ease-out;
|
|
110
|
-
}
|
|
111
|
-
.slide-fade-leave-active {
|
|
112
|
-
transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
|
|
113
|
-
}
|
|
114
|
-
.slide-fade-enter-from,
|
|
115
|
-
.slide-fade-leave-to {
|
|
116
|
-
transform: translateY(20px);
|
|
117
|
-
opacity: 0;
|
|
118
|
-
}
|
|
119
|
-
</style>
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="network-content">
|
|
3
|
-
<view class="network-control">
|
|
4
|
-
<FilterInput
|
|
5
|
-
:modelValue="modelValue"
|
|
6
|
-
placeholder="查询url"
|
|
7
|
-
@search="emit('search', $event)"
|
|
8
|
-
@update:modelValue="emit('update:modelValue', $event)"
|
|
9
|
-
/>
|
|
10
|
-
<Tag
|
|
11
|
-
v-for="item in networkFilterItems"
|
|
12
|
-
:mode="item.mode"
|
|
13
|
-
:key="item.value"
|
|
14
|
-
:active="item.value === currentNetworkType"
|
|
15
|
-
@click="onChoose(item.value)"
|
|
16
|
-
>
|
|
17
|
-
{{ item.label }}
|
|
18
|
-
</Tag>
|
|
19
|
-
</view>
|
|
20
|
-
|
|
21
|
-
<VirtualListPro
|
|
22
|
-
:data="networkList"
|
|
23
|
-
:pageSize="15"
|
|
24
|
-
:height="height"
|
|
25
|
-
className="network-list"
|
|
26
|
-
>
|
|
27
|
-
<template v-slot="{ list, start }">
|
|
28
|
-
<AutoSize
|
|
29
|
-
v-for="(item, index) in list"
|
|
30
|
-
:index="start + index"
|
|
31
|
-
:key="start + index"
|
|
32
|
-
>
|
|
33
|
-
<NetworkItem :network="item" :zIndex="zIndex" />
|
|
34
|
-
</AutoSize>
|
|
35
|
-
<Empty v-if="!networkList || networkList.length === 0" />
|
|
36
|
-
</template>
|
|
37
|
-
</VirtualListPro>
|
|
38
|
-
</view>
|
|
39
|
-
</template>
|
|
40
|
-
<script lang="ts" setup>
|
|
41
|
-
import Tag from '../Tag/index.vue';
|
|
42
|
-
import NetworkItem from './NetworkItem.vue';
|
|
43
|
-
import Empty from '../Empty/index.vue';
|
|
44
|
-
import FilterInput from '../FilterInput/index.vue';
|
|
45
|
-
import type { DevTool } from '../../type';
|
|
46
|
-
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
47
|
-
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
48
|
-
import { onMounted, ref } from 'vue';
|
|
49
|
-
|
|
50
|
-
defineProps<{
|
|
51
|
-
currentNetworkType: string;
|
|
52
|
-
networkList: DevTool.NetworkItem[];
|
|
53
|
-
modelValue: string;
|
|
54
|
-
zIndex?: number;
|
|
55
|
-
}>();
|
|
56
|
-
|
|
57
|
-
const emit = defineEmits<{
|
|
58
|
-
(e: 'choose', type: string): void;
|
|
59
|
-
(e: 'update:modelValue', value: string): void;
|
|
60
|
-
(e: 'search', value: string): void;
|
|
61
|
-
}>();
|
|
62
|
-
const networkFilterItems = [
|
|
63
|
-
{
|
|
64
|
-
label: '全部',
|
|
65
|
-
value: 'all',
|
|
66
|
-
mode: 'all',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: 'get',
|
|
70
|
-
value: 'GET',
|
|
71
|
-
mode: 'info',
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
label: 'post',
|
|
75
|
-
value: 'POST',
|
|
76
|
-
mode: 'info',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
label: 'put',
|
|
80
|
-
value: 'PUT',
|
|
81
|
-
mode: 'info',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
label: 'del',
|
|
85
|
-
value: 'DELETE',
|
|
86
|
-
mode: 'info',
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: 'error',
|
|
90
|
-
value: 'error',
|
|
91
|
-
mode: 'error',
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
label: '清除',
|
|
95
|
-
value: 'clear',
|
|
96
|
-
mode: 'clear',
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
function onChoose(type: string) {
|
|
101
|
-
emit('choose', type);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const height = ref(0);
|
|
105
|
-
onMounted(() => {
|
|
106
|
-
const { windowHeight } = uni.getWindowInfo();
|
|
107
|
-
height.value = windowHeight - 32 - 32;
|
|
108
|
-
});
|
|
109
|
-
</script>
|
|
110
|
-
<style scoped>
|
|
111
|
-
.network-content {
|
|
112
|
-
height: 100%;
|
|
113
|
-
font-size: var(--dev-tool-base-font-size);
|
|
114
|
-
}
|
|
115
|
-
.network-list {
|
|
116
|
-
height: calc(100% - 32px);
|
|
117
|
-
}
|
|
118
|
-
.network-control {
|
|
119
|
-
display: flex;
|
|
120
|
-
align-items: center;
|
|
121
|
-
justify-content: space-between;
|
|
122
|
-
gap: 8px;
|
|
123
|
-
padding: 0 16px;
|
|
124
|
-
height: 32px;
|
|
125
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
126
|
-
box-sizing: border-box;
|
|
127
|
-
}
|
|
128
|
-
</style>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="pinia-content">
|
|
3
|
-
<JsonPretty
|
|
4
|
-
:data="piniaList"
|
|
5
|
-
showLength
|
|
6
|
-
editable
|
|
7
|
-
v-if="showJson"
|
|
8
|
-
@update:data="onUpdateData"
|
|
9
|
-
@nodeClick="onNodeClick"
|
|
10
|
-
/>
|
|
11
|
-
<Empty v-else />
|
|
12
|
-
</view>
|
|
13
|
-
</template>
|
|
14
|
-
<script lang="ts" setup>
|
|
15
|
-
import { computed } from 'vue';
|
|
16
|
-
import JsonPretty from '../JsonPretty/index.vue';
|
|
17
|
-
import Empty from '../Empty/index.vue';
|
|
18
|
-
import { getValueByPath } from '../../utils';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const props = defineProps<{
|
|
22
|
-
piniaList: Record<string, any>;
|
|
23
|
-
}>();
|
|
24
|
-
const emit = defineEmits<{
|
|
25
|
-
(e: 'update:piniaList', data: Record<string, any>): void;
|
|
26
|
-
(e: 'diffValue', value: any): void;
|
|
27
|
-
}>();
|
|
28
|
-
const showJson = computed(() => {
|
|
29
|
-
try {
|
|
30
|
-
const str = JSON.stringify(props.piniaList);
|
|
31
|
-
if (typeof props.piniaList === 'object' && (str === '' || str === '{}')) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
let currentSelect: any;
|
|
41
|
-
function onUpdateData(data: Record<string, any>) {
|
|
42
|
-
try {
|
|
43
|
-
const keys = currentSelect?.path?.slice(5);
|
|
44
|
-
if (!keys) return;
|
|
45
|
-
const newData = getValueByPath(data, keys);
|
|
46
|
-
|
|
47
|
-
emit('update:piniaList', data);
|
|
48
|
-
emit('diffValue', {
|
|
49
|
-
[keys]: newData
|
|
50
|
-
});
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.log('error: ', error);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function onNodeClick(node: any) {
|
|
56
|
-
currentSelect = node;
|
|
57
|
-
}
|
|
58
|
-
</script>
|
|
59
|
-
<style scoped>
|
|
60
|
-
.pinia-content {
|
|
61
|
-
padding: 16px;
|
|
62
|
-
font-size: var(--dev-tool-base-font-size);
|
|
63
|
-
}
|
|
64
|
-
</style>
|