vite-uni-dev-tool 0.0.13 → 0.0.15
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/core.js +1 -1
- package/dist/devIntercept/index.d.ts +3 -3
- package/dist/devIntercept/index.d.ts.map +1 -1
- package/dist/devIntercept/index.js +117 -114
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts +32 -0
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/transform/transformApp.js +32 -0
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts +26 -0
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -0
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +41 -0
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/transform/transformVue.js +9 -0
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +7 -3
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -33
- package/dist/plugins/utils/index.d.ts +32 -0
- package/dist/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -1
- package/dist/type.d.ts +2 -2
- package/dist/type.d.ts.map +1 -1
- package/dist/v2/AppInfo/index.vue +41 -0
- package/dist/v2/AutoSizer/index.vue +189 -0
- package/dist/v2/AutoSizer/index1.vue +193 -0
- package/dist/v2/AutoSizer/utils.ts +49 -0
- package/dist/v2/CaptureScreen/index.vue +78 -0
- package/dist/v2/CloseButton/index.vue +32 -0
- package/dist/v2/Connection/index.vue +94 -0
- package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
- package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
- package/dist/v2/ConsoleList/index.vue +164 -0
- package/dist/v2/ConsoleList/staticTips.js +1144 -0
- package/dist/v2/DevTool/index.vue +162 -0
- package/dist/v2/DevToolButton/index.vue +228 -0
- package/dist/v2/DevToolTitle/index.vue +28 -0
- package/dist/v2/DevToolWindow/index.vue +1051 -0
- package/dist/v2/DeviceInfo/index.vue +48 -0
- package/dist/v2/Empty/empty.png +0 -0
- package/dist/v2/Empty/index.vue +40 -0
- package/dist/v2/FilterInput/index.vue +100 -0
- package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
- package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
- package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
- package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
- package/dist/v2/JsonPretty/index.vue +531 -0
- package/dist/v2/JsonPretty/type.ts +125 -0
- package/dist/v2/JsonPretty/utils/index.js +211 -0
- package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
- package/dist/v2/NetworkList/NetworkItem.vue +135 -0
- package/dist/v2/NetworkList/index.vue +148 -0
- package/dist/v2/PiniaList/index.vue +79 -0
- package/dist/v2/RouteList/index.vue +137 -0
- package/dist/v2/RunJS/index.vue +128 -0
- package/dist/v2/SettingList/index.vue +318 -0
- package/dist/v2/SourceCode/index.vue +237 -0
- package/dist/v2/StorageList/index.vue +165 -0
- package/dist/v2/SystemInfo/index.vue +49 -0
- package/dist/v2/Tabs/index.vue +127 -0
- package/dist/v2/Tag/index.vue +91 -0
- package/dist/v2/UniEvent/UniEventItem.vue +157 -0
- package/dist/v2/UniEvent/index.vue +127 -0
- package/dist/v2/UploadList/UploadDetail.vue +204 -0
- package/dist/v2/UploadList/UploadItem.vue +134 -0
- package/dist/v2/UploadList/index.vue +143 -0
- package/dist/v2/VirtualList/index.vue +140 -0
- package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
- package/dist/v2/VirtualListPro/index.vue +255 -0
- package/dist/v2/VirtualListPro/readme.md +40 -0
- package/dist/v2/VuexList/index.vue +80 -0
- package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
- package/dist/v2/WebSocket/WebSocketList.vue +183 -0
- package/dist/v2/WebSocket/index.vue +155 -0
- package/dist/v2/WindowInfo/index.vue +49 -0
- package/dist/v3/AppInfo/index.vue +35 -0
- package/dist/v3/AutoSizer/index.vue +193 -0
- package/dist/v3/AutoSizer/index1.vue +186 -0
- package/dist/v3/AutoSizer/utils.ts +49 -0
- package/dist/v3/CaptureScreen/index.vue +62 -0
- package/dist/v3/CloseButton/index.vue +29 -0
- package/dist/v3/Connection/index.vue +88 -0
- package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
- package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
- package/dist/v3/ConsoleList/index.vue +139 -0
- package/dist/v3/ConsoleList/staticTips.ts +1145 -0
- package/dist/v3/DevTool/index.vue +217 -0
- package/dist/v3/DevToolButton/index.vue +210 -0
- package/dist/v3/DevToolTitle/index.vue +21 -0
- package/dist/v3/DevToolWindow/index.vue +1116 -0
- package/dist/v3/DeviceInfo/index.vue +32 -0
- package/dist/v3/Empty/empty.png +0 -0
- package/dist/v3/Empty/index.vue +28 -0
- package/dist/v3/FilterInput/index.vue +87 -0
- package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
- package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
- package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
- package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
- package/dist/v3/JsonPretty/index.vue +476 -0
- package/dist/v3/JsonPretty/type.ts +125 -0
- package/dist/v3/JsonPretty/utils/index.ts +172 -0
- package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
- package/dist/v3/NetworkList/NetworkItem.vue +120 -0
- package/dist/v3/NetworkList/index.vue +128 -0
- package/dist/v3/PiniaList/index.vue +64 -0
- package/dist/v3/RouteList/index.vue +121 -0
- package/dist/v3/RunJS/index.vue +128 -0
- package/dist/v3/SettingList/index.vue +313 -0
- package/dist/v3/SourceCode/index.vue +231 -0
- package/dist/v3/StorageList/index.vue +170 -0
- package/dist/v3/SystemInfo/index.vue +34 -0
- package/dist/v3/Tabs/index.vue +123 -0
- package/dist/v3/Tag/index.vue +89 -0
- package/dist/v3/UniEvent/UniEventItem.vue +126 -0
- package/dist/v3/UniEvent/index.vue +98 -0
- package/dist/v3/UploadList/UploadDetail.vue +192 -0
- package/dist/v3/UploadList/UploadItem.vue +117 -0
- package/dist/v3/UploadList/index.vue +117 -0
- package/dist/v3/VirtualList/index.vue +112 -0
- package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
- package/dist/v3/VirtualListPro/index.vue +238 -0
- package/dist/v3/VirtualListPro/readme.md +40 -0
- package/dist/v3/VuexList/index.vue +54 -0
- package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
- package/dist/v3/WebSocket/WebSocketList.vue +161 -0
- package/dist/v3/WebSocket/index.vue +124 -0
- package/dist/v3/WindowInfo/index.vue +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
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: var(--dev-tool-bg-color);
|
|
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: var(--dev-tool-info-color);
|
|
189
|
+
}
|
|
190
|
+
.network-detail .network-detail-payload {
|
|
191
|
+
word-break: break-all;
|
|
192
|
+
max-width: 100%;
|
|
193
|
+
}
|
|
194
|
+
</style>
|
|
@@ -0,0 +1,120 @@
|
|
|
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: var(--dev-tool-text-color);
|
|
107
|
+
transition: color 0.3s;
|
|
108
|
+
}
|
|
109
|
+
.slide-fade-enter-active {
|
|
110
|
+
transition: all 0.8s ease-out;
|
|
111
|
+
}
|
|
112
|
+
.slide-fade-leave-active {
|
|
113
|
+
transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
|
|
114
|
+
}
|
|
115
|
+
.slide-fade-enter-from,
|
|
116
|
+
.slide-fade-leave-to {
|
|
117
|
+
transform: translateY(20px);
|
|
118
|
+
opacity: 0;
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,128 @@
|
|
|
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>
|
|
@@ -0,0 +1,64 @@
|
|
|
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>
|