vite-uni-dev-tool 0.0.48 → 1.0.0
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 +20 -0
- package/dist/const.cjs +1 -0
- package/dist/const.d.ts +78 -161
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +1 -47
- package/dist/core-shared.d.ts +44 -0
- package/dist/core-shared.d.ts.map +1 -0
- package/dist/core-shared.js +1 -0
- package/dist/core.d.ts +2 -40
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +4 -159
- package/dist/i18n/index.cjs +1 -0
- package/dist/i18n/index.d.ts +9 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/instance.cjs +1 -0
- package/dist/i18n/instance.d.ts +15 -0
- package/dist/i18n/instance.d.ts.map +1 -0
- package/dist/i18n/instance.js +1 -0
- package/dist/i18n/locales/en.cjs +1 -0
- package/dist/i18n/locales/en.d.ts +470 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/en.js +1 -0
- package/dist/i18n/locales/zh-Hans.cjs +1 -0
- package/dist/i18n/locales/zh-Hans.d.ts +476 -0
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -0
- package/dist/i18n/locales/zh-Hans.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/devConsole/index.cjs +4 -0
- package/dist/{devConsole → modules/devConsole}/index.d.ts +1 -1
- package/dist/modules/devConsole/index.d.ts.map +1 -0
- package/dist/modules/devConsole/index.js +4 -0
- package/dist/modules/devEvent/index.cjs +5 -0
- package/dist/modules/devEvent/index.d.ts +115 -0
- package/dist/modules/devEvent/index.d.ts.map +1 -0
- package/dist/modules/devEvent/index.js +5 -0
- package/dist/modules/devIntercept/index.cjs +13 -0
- package/dist/modules/devIntercept/index.d.ts +71 -0
- package/dist/modules/devIntercept/index.d.ts.map +1 -0
- package/dist/modules/devIntercept/index.js +13 -0
- package/dist/modules/devStore/index.cjs +1 -0
- package/dist/modules/devStore/index.d.ts +159 -0
- package/dist/modules/devStore/index.d.ts.map +1 -0
- package/dist/modules/devStore/index.js +1 -0
- package/dist/modules/devToolInfo/index.cjs +1 -0
- package/dist/modules/devToolInfo/index.d.ts +27 -0
- package/dist/modules/devToolInfo/index.d.ts.map +1 -0
- package/dist/modules/devToolInfo/index.js +1 -0
- package/dist/plugins/uniDevTool/transform/transformApp.cjs +44 -0
- package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformApp.js +17 -17
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -0
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
- package/dist/plugins/uniDevTool/transform/transformVue.cjs +41 -0
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +1 -2
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformVue.js +32 -19
- package/dist/plugins/uniDevTool/uniDevTool.cjs +5 -0
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -11
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.cjs +19 -0
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dist/plugins/uniGlobalComponents/uniGlobalComponents.js +11 -19
- package/dist/plugins/uniParseStock/index.d.ts +10 -0
- package/dist/plugins/uniParseStock/index.d.ts.map +1 -0
- package/dist/plugins/utils/index.cjs +2 -0
- package/dist/plugins/utils/index.d.ts +1 -3
- package/dist/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +2 -2
- package/dist/shims-uni.d.ts +140 -0
- package/dist/type.d.ts +174 -16
- package/dist/type.d.ts.map +1 -1
- package/dist/utils/array.cjs +1 -0
- package/dist/utils/array.d.ts.map +1 -1
- package/dist/utils/array.js +1 -12
- package/dist/utils/date.cjs +1 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +1 -59
- package/dist/utils/file.cjs +1 -0
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +1 -85
- package/dist/utils/function.cjs +1 -0
- package/dist/utils/function.d.ts +13 -0
- package/dist/utils/function.d.ts.map +1 -1
- package/dist/utils/function.js +1 -68
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -63
- package/dist/utils/ip.cjs +1 -0
- package/dist/utils/ip.d.ts +1 -1
- package/dist/utils/ip.d.ts.map +1 -1
- package/dist/utils/ip.js +1 -45
- package/dist/utils/language.cjs +1 -0
- package/dist/utils/language.d.ts +2 -1
- package/dist/utils/language.d.ts.map +1 -1
- package/dist/utils/language.js +1 -63
- package/dist/utils/object.cjs +1 -0
- package/dist/utils/object.d.ts +4 -5
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/object.js +1 -136
- package/dist/utils/openLink.cjs +1 -0
- package/dist/utils/openLink.d.ts.map +1 -1
- package/dist/utils/openLink.js +1 -28
- package/dist/utils/page.cjs +1 -0
- package/dist/utils/page.d.ts.map +1 -1
- package/dist/utils/page.js +1 -7
- package/dist/utils/platform.cjs +1 -0
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/platform.js +1 -17
- package/dist/utils/string.cjs +1 -0
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js +1 -114
- package/dist/utils/utils.cjs +1 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +1 -126
- package/dist/v3/AppTransition/index.vue +170 -0
- package/dist/v3/AutoSizer/index.vue +4 -5
- package/dist/v3/AutoSizer/index1.vue +4 -6
- package/dist/v3/AutoSizer/utils.ts +1 -1
- package/dist/v3/CaptureScreen/index.vue +19 -8
- package/dist/v3/CircularButton/index.vue +64 -13
- package/dist/v3/ConsoleList/ConsoleItem.vue +56 -5
- package/dist/v3/ConsoleList/RunJSInput.vue +10 -6
- package/dist/v3/ConsoleList/index.vue +51 -35
- package/dist/v3/CustomSwiper/CustomSwiperItem.vue +49 -0
- package/dist/v3/CustomSwiper/index.vue +104 -0
- package/dist/v3/DevTool/fps-collector.render.ts +148 -0
- package/dist/v3/DevTool/index.vue +209 -102
- package/dist/v3/DevToolButton/index.vue +40 -59
- package/dist/v3/DevToolTitle/index.vue +4 -1
- package/dist/v3/DevToolWindow/DevToolOverlay.vue +182 -0
- package/dist/v3/DevToolWindow/const.ts +47 -69
- package/dist/v3/DevToolWindow/hooks/dataUtils.ts +48 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolData.ts +338 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolHandlers.ts +549 -0
- package/dist/v3/DevToolWindow/hooks/useDevToolOverlay.ts +184 -0
- package/dist/v3/DevToolWindow/index.css +89 -0
- package/dist/v3/DevToolWindow/index.vue +800 -1450
- package/dist/v3/DraggableContainer/index.vue +456 -0
- package/dist/v3/ElEvent/ElEventItem.vue +4 -3
- package/dist/v3/ElEvent/index.vue +26 -9
- package/dist/v3/Empty/index.vue +1 -0
- package/dist/v3/FilterInput/index.vue +8 -22
- package/dist/v3/FilterSelect/index.vue +37 -24
- package/dist/v3/Instance/components/InstanceTreeNode.vue +265 -0
- package/dist/v3/Instance/flatten.ts +226 -0
- package/dist/v3/Instance/index.vue +94 -0
- package/dist/v3/Instance/registry.ts +49 -0
- package/dist/v3/Instance/transformTree.ts +375 -0
- package/dist/v3/Instance/transformTreeCtx.ts +268 -0
- package/dist/v3/{InstanceTree → Instance}/typing.d.ts +15 -2
- package/dist/v3/InstanceDetail/index.vue +433 -44
- package/dist/v3/JsonDetail/index.vue +12 -8
- package/dist/v3/JsonPretty/components/Brackets/index.vue +1 -0
- package/dist/v3/JsonPretty/components/Carets/index.vue +2 -1
- package/dist/v3/JsonPretty/components/CheckController/index.vue +26 -15
- package/dist/v3/JsonPretty/components/TreeNode/index.vue +42 -20
- package/dist/v3/JsonPretty/index.vue +60 -37
- package/dist/v3/JsonPretty/utils/index.ts +41 -44
- package/dist/v3/MovableContainer/index.vue +89 -0
- package/dist/v3/NFCList/NFCItem.vue +14 -14
- package/dist/v3/NFCList/NFCTool.vue +99 -81
- package/dist/v3/NFCList/index.vue +14 -10
- package/dist/v3/NetworkList/InterceptConfig.vue +154 -364
- package/dist/v3/NetworkList/InterceptItem.vue +14 -6
- package/dist/v3/NetworkList/NetworkDetail.vue +34 -29
- package/dist/v3/NetworkList/NetworkIntercept.vue +11 -8
- package/dist/v3/NetworkList/NetworkItem.vue +27 -11
- package/dist/v3/NetworkList/NetworkSend.vue +132 -290
- package/dist/v3/NetworkList/hooks/useNetworkForm.ts +86 -0
- package/dist/v3/NetworkList/index.vue +32 -24
- package/dist/v3/NetworkList/utils.ts +101 -0
- package/dist/v3/Performance/index.vue +495 -0
- package/dist/v3/Performance/modules/PerformanceMetrics.vue +153 -0
- package/dist/v3/Performance/modules/PerformanceWidget.vue +249 -0
- package/dist/v3/Performance/modules/usePerformanceChart.ts +460 -0
- package/dist/v3/Performance/modules/usePerformanceData.ts +258 -0
- package/dist/v3/Pick/index.vue +322 -0
- package/dist/v3/PiniaList/index.vue +38 -17
- package/dist/v3/RouteList/index.vue +32 -15
- package/dist/v3/RunJS/index.vue +30 -10
- package/dist/v3/ScanCodeList/ScanCodeItem.vue +2 -9
- package/dist/v3/ScanCodeList/index.vue +12 -9
- package/dist/v3/SettingButton/index.vue +45 -0
- package/dist/v3/SettingList/index.css +120 -0
- package/dist/v3/SettingList/index.vue +96 -537
- package/dist/v3/SettingList/modules/SettingDevTool.vue +208 -0
- package/dist/v3/SettingList/modules/SettingInfo.vue +119 -0
- package/dist/v3/SettingList/modules/SettingLanguage.vue +74 -0
- package/dist/v3/SettingList/modules/SettingLog.vue +230 -0
- package/dist/v3/SettingList/modules/SettingNetwork.vue +120 -0
- package/dist/v3/SettingList/modules/SettingTheme.vue +312 -0
- package/dist/v3/SourceCode/Line.vue +15 -2
- package/dist/v3/SourceCode/index.vue +25 -24
- package/dist/v3/SourceCode/parseCode.ts +114 -56
- package/dist/v3/StorageList/index.vue +33 -33
- package/dist/v3/Tabs/index.vue +31 -28
- package/dist/v3/Tag/index.vue +39 -20
- package/dist/v3/TransferList/TransferDetail.vue +268 -0
- package/dist/v3/TransferList/TransferItem.vue +125 -0
- package/dist/v3/TransferList/index.vue +181 -0
- package/dist/v3/UniEvent/UniEventItem.vue +1 -0
- package/dist/v3/UniEvent/index.vue +28 -29
- package/dist/v3/{VirtualListPro → VirtualList}/AutoSize.vue +1 -1
- package/dist/v3/VirtualList/index.vue +382 -82
- package/dist/v3/VuexList/index.vue +38 -17
- package/dist/v3/WebSocket/WebSocketDetail.vue +142 -80
- package/dist/v3/WebSocket/WebSocketItem.vue +10 -4
- package/dist/v3/WebSocket/index.vue +44 -30
- package/dist/v3/hooks/useNFC/index.ts +6 -6
- package/dist/v3/hooks/useNFC/typing.d.ts +2 -2
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +215 -626
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +54 -85
- package/dist/v3/hooks/useNFC/utils.ts +3 -3
- package/dist/v3/hooks/useRequest/index.ts +2 -2
- package/dist/v3/hooks/useScanCode/index.ts +10 -8
- package/dist/v3/styles/theme.css +290 -0
- package/dist/v3/styles/theme.ts +12 -0
- package/package.json +25 -5
- package/dist/devConsole/index.d.ts.map +0 -1
- package/dist/devConsole/index.js +0 -273
- package/dist/devEvent/index.d.ts +0 -328
- package/dist/devEvent/index.d.ts.map +0 -1
- package/dist/devEvent/index.js +0 -697
- package/dist/devEventBus/index.d.ts +0 -42
- package/dist/devEventBus/index.d.ts.map +0 -1
- package/dist/devEventBus/index.js +0 -70
- package/dist/devIntercept/index.d.ts +0 -281
- package/dist/devIntercept/index.d.ts.map +0 -1
- package/dist/devIntercept/index.js +0 -949
- package/dist/devRunJS/index.d.ts +0 -67
- package/dist/devRunJS/index.d.ts.map +0 -1
- package/dist/devStore/index.d.ts +0 -199
- package/dist/devStore/index.d.ts.map +0 -1
- package/dist/devStore/index.js +0 -562
- package/dist/devToolInfo/index.d.ts +0 -17
- package/dist/devToolInfo/index.d.ts.map +0 -1
- package/dist/devToolInfo/index.js +0 -15
- package/dist/v3/AutoSizer/utils.d.ts +0 -5
- package/dist/v3/AutoSizer/utils.d.ts.map +0 -1
- package/dist/v3/ConsoleList/staticTips.d.ts +0 -13
- package/dist/v3/ConsoleList/staticTips.d.ts.map +0 -1
- package/dist/v3/DevToolWindow/const.d.ts +0 -46
- package/dist/v3/DevToolWindow/const.d.ts.map +0 -1
- package/dist/v3/InstanceTree/components/InstanceTreeNode.vue +0 -81
- package/dist/v3/InstanceTree/flatten.d.ts +0 -10
- package/dist/v3/InstanceTree/flatten.d.ts.map +0 -1
- package/dist/v3/InstanceTree/flatten.ts +0 -75
- package/dist/v3/InstanceTree/index.vue +0 -51
- package/dist/v3/InstanceTree/transformTree.d.ts +0 -17
- package/dist/v3/InstanceTree/transformTree.d.ts.map +0 -1
- package/dist/v3/InstanceTree/transformTree.ts +0 -237
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +0 -4
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +0 -1
- package/dist/v3/JsonPretty/hooks/useError.d.ts +0 -8
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +0 -1
- package/dist/v3/JsonPretty/type.d.ts +0 -94
- package/dist/v3/JsonPretty/type.d.ts.map +0 -1
- package/dist/v3/JsonPretty/utils/index.d.ts +0 -10
- package/dist/v3/JsonPretty/utils/index.d.ts.map +0 -1
- package/dist/v3/NFCList/const.d.ts +0 -13
- package/dist/v3/NFCList/const.d.ts.map +0 -1
- package/dist/v3/NetworkList/const.d.ts +0 -5
- package/dist/v3/NetworkList/const.d.ts.map +0 -1
- package/dist/v3/SourceCode/parseCode.d.ts +0 -27
- package/dist/v3/SourceCode/parseCode.d.ts.map +0 -1
- package/dist/v3/UploadList/UploadDetail.vue +0 -255
- package/dist/v3/UploadList/UploadItem.vue +0 -122
- package/dist/v3/UploadList/index.vue +0 -125
- package/dist/v3/VirtualListPro/index.vue +0 -229
- package/dist/v3/hooks/useContainerStyle.d.ts +0 -15
- package/dist/v3/hooks/useContainerStyle.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/index.d.ts +0 -5
- package/dist/v3/hooks/useNFC/index.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts +0 -2
- package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts +0 -2
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts.map +0 -1
- package/dist/v3/hooks/useNFC/utils.d.ts +0 -95
- package/dist/v3/hooks/useNFC/utils.d.ts.map +0 -1
- package/dist/v3/hooks/useRequest/index.d.ts +0 -126
- package/dist/v3/hooks/useRequest/index.d.ts.map +0 -1
- package/dist/v3/hooks/useRequest/utils.d.ts +0 -35
- package/dist/v3/hooks/useRequest/utils.d.ts.map +0 -1
- package/dist/v3/hooks/useScanCode/index.d.ts +0 -36
- package/dist/v3/hooks/useScanCode/index.d.ts.map +0 -1
- /package/dist/v3/{VirtualListPro → VirtualList}/readme.md +0 -0
|
@@ -1,266 +1,227 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="intercept-config" :style="customStyle">
|
|
3
3
|
<view class="intercept-config-control">
|
|
4
|
-
<DevToolTitle
|
|
4
|
+
<DevToolTitle>{{ t('network.interceptConfig') }}</DevToolTitle>
|
|
5
5
|
<CircularButton style="margin-left: auto" text="×" @click="onClose" />
|
|
6
6
|
</view>
|
|
7
7
|
|
|
8
8
|
<scroll-view scroll-y class="intercept-config-form">
|
|
9
9
|
<view class="intercept-config-tip">
|
|
10
|
-
|
|
11
|
-
拦截请求,发送请求之前将采用输入的请求头和请求参数,返回响应头和响应参数。会真实发起一次请求(真实请求可能失败),更改最后的响应结果。
|
|
10
|
+
{{ t('network.tipsIntercept') }}
|
|
12
11
|
</view>
|
|
13
12
|
<view class="intercept-config-control">
|
|
14
|
-
<DevToolTitle
|
|
13
|
+
<DevToolTitle>{{ t('network.timeout') }}</DevToolTitle>
|
|
15
14
|
</view>
|
|
16
15
|
<input
|
|
17
16
|
class="intercept-input"
|
|
18
17
|
:value="state.timeout"
|
|
19
|
-
@input="onChangeState($event, 'timeout')"
|
|
20
|
-
/>
|
|
18
|
+
@input="onChangeState($event, 'timeout')" />
|
|
21
19
|
<view class="intercept-config-tip">
|
|
22
|
-
|
|
20
|
+
{{ t('network.tipsTimeout') }}
|
|
23
21
|
</view>
|
|
24
22
|
<view class="intercept-config-control">
|
|
25
|
-
<DevToolTitle
|
|
23
|
+
<DevToolTitle>{{ t('network.responseStatus') }}</DevToolTitle>
|
|
26
24
|
</view>
|
|
27
25
|
<input
|
|
28
26
|
class="intercept-input"
|
|
29
27
|
:value="state.status"
|
|
30
|
-
@input="onChangeState($event, 'status')"
|
|
31
|
-
/>
|
|
28
|
+
@input="onChangeState($event, 'status')" />
|
|
32
29
|
<view class="intercept-config-control">
|
|
33
|
-
<DevToolTitle
|
|
30
|
+
<DevToolTitle>{{ t('network.requestMethod') }}</DevToolTitle>
|
|
34
31
|
</view>
|
|
35
32
|
<radio-group class="radio-group" @change="onChangeRequestMethod">
|
|
36
33
|
<label
|
|
37
34
|
class="radio-group-item"
|
|
38
35
|
v-for="item in requestMethods"
|
|
39
|
-
:key="item.value"
|
|
40
|
-
>
|
|
36
|
+
:key="item.value">
|
|
41
37
|
<radio
|
|
42
38
|
size
|
|
43
39
|
style="transform: scale(0.8)"
|
|
44
|
-
color="
|
|
40
|
+
:color="themeColor"
|
|
45
41
|
:value="item.value"
|
|
46
|
-
:checked="item.value === state.method"
|
|
47
|
-
/>
|
|
42
|
+
:checked="item.value === state.method" />
|
|
48
43
|
|
|
49
44
|
<view>{{ item.name }}</view>
|
|
50
45
|
</label>
|
|
51
46
|
</radio-group>
|
|
52
47
|
|
|
53
48
|
<view class="intercept-config-control">
|
|
54
|
-
<DevToolTitle
|
|
49
|
+
<DevToolTitle>{{ t('network.requestHeaders') }}</DevToolTitle>
|
|
55
50
|
<CircularButton
|
|
56
51
|
style="margin-left: auto"
|
|
57
52
|
text="+"
|
|
58
|
-
@click="onAddRequestHeader"
|
|
59
|
-
/>
|
|
53
|
+
@click="onAddRequestHeader" />
|
|
60
54
|
</view>
|
|
61
55
|
|
|
62
56
|
<view class="intercept-header-list">
|
|
63
57
|
<checkbox-group
|
|
64
58
|
v-if="requestHeaderList.length > 0"
|
|
65
59
|
key="requestHeaderList"
|
|
66
|
-
@change="onChangeRequestHeaderChecked"
|
|
67
|
-
>
|
|
60
|
+
@change="onChangeRequestHeaderChecked">
|
|
68
61
|
<view
|
|
69
62
|
class="intercept-header-item"
|
|
70
63
|
v-for="(item, index) in requestHeaderList"
|
|
71
|
-
:key="item.id"
|
|
72
|
-
>
|
|
64
|
+
:key="item.id">
|
|
73
65
|
<checkbox
|
|
74
|
-
color="
|
|
66
|
+
:color="themeColor"
|
|
75
67
|
:value="item.id"
|
|
76
|
-
:checked="item.checked"
|
|
77
|
-
/>
|
|
68
|
+
:checked="item.checked" />
|
|
78
69
|
<input
|
|
79
70
|
class="intercept-input"
|
|
80
|
-
placeholder="
|
|
81
|
-
placeholderStyle="font-size: 12px"
|
|
71
|
+
:placeholder="t('network.placeholderHeaderName')"
|
|
82
72
|
:value="item.key"
|
|
83
|
-
@input="onChangeRequestHeader($event, 'key', index)"
|
|
84
|
-
/>
|
|
73
|
+
@input="onChangeRequestHeader($event, 'key', index)" />
|
|
85
74
|
<input
|
|
86
75
|
class="intercept-input"
|
|
87
|
-
placeholder="
|
|
88
|
-
placeholderStyle="font-size: 12px"
|
|
76
|
+
:placeholder="t('network.placeholderHeaderValue')"
|
|
89
77
|
:value="item.value"
|
|
90
|
-
@input="onChangeRequestHeader($event, 'value', index)"
|
|
91
|
-
/>
|
|
78
|
+
@input="onChangeRequestHeader($event, 'value', index)" />
|
|
92
79
|
<CircularButton
|
|
93
80
|
style="margin-left: 6px"
|
|
94
81
|
text="一"
|
|
95
|
-
@click="onDeleteRequestHeader(item)"
|
|
96
|
-
/>
|
|
82
|
+
@click="onDeleteRequestHeader(item)" />
|
|
97
83
|
</view>
|
|
98
84
|
</checkbox-group>
|
|
99
85
|
|
|
100
|
-
<view class="intercept-empty" v-else>
|
|
86
|
+
<view class="intercept-empty" v-else>
|
|
87
|
+
{{ t('network.noRequestHeaders') }}
|
|
88
|
+
</view>
|
|
101
89
|
</view>
|
|
102
90
|
|
|
103
91
|
<view class="intercept-config-control">
|
|
104
|
-
<DevToolTitle
|
|
92
|
+
<DevToolTitle>{{ t('network.responseHeaders') }}</DevToolTitle>
|
|
105
93
|
<CircularButton
|
|
106
94
|
style="margin-left: auto"
|
|
107
95
|
text="+"
|
|
108
|
-
@click="onAddResponseHeader"
|
|
109
|
-
/>
|
|
96
|
+
@click="onAddResponseHeader" />
|
|
110
97
|
</view>
|
|
111
98
|
|
|
112
99
|
<view class="intercept-header-list">
|
|
113
100
|
<checkbox-group
|
|
114
101
|
v-if="responseHeaderList.length > 0"
|
|
115
102
|
key="responseHeaderList"
|
|
116
|
-
@change="onChangeResponseHeaderChecked"
|
|
117
|
-
>
|
|
103
|
+
@change="onChangeResponseHeaderChecked">
|
|
118
104
|
<view
|
|
119
105
|
class="intercept-header-item"
|
|
120
106
|
v-for="(item, index) in responseHeaderList"
|
|
121
|
-
:key="item.id"
|
|
122
|
-
>
|
|
107
|
+
:key="item.id">
|
|
123
108
|
<checkbox
|
|
124
|
-
color="
|
|
109
|
+
:color="themeColor"
|
|
125
110
|
:value="item.id"
|
|
126
|
-
:checked="item.checked"
|
|
127
|
-
/>
|
|
111
|
+
:checked="item.checked" />
|
|
128
112
|
<input
|
|
129
113
|
class="intercept-input"
|
|
130
|
-
placeholder="
|
|
131
|
-
placeholderStyle="font-size: 12px"
|
|
114
|
+
:placeholder="t('network.placeholderRespHeaderName')"
|
|
132
115
|
:value="item.key"
|
|
133
|
-
@input="onChangeResponseHeader($event, 'key', index)"
|
|
134
|
-
/>
|
|
116
|
+
@input="onChangeResponseHeader($event, 'key', index)" />
|
|
135
117
|
<input
|
|
136
118
|
class="intercept-input"
|
|
137
|
-
placeholder="
|
|
138
|
-
placeholderStyle="font-size: 12px"
|
|
119
|
+
:placeholder="t('network.placeholderRespHeaderValue')"
|
|
139
120
|
:value="item.value"
|
|
140
|
-
@input="onChangeResponseHeader($event, 'value', index)"
|
|
141
|
-
/>
|
|
121
|
+
@input="onChangeResponseHeader($event, 'value', index)" />
|
|
142
122
|
<CircularButton
|
|
143
123
|
style="margin-left: 6px"
|
|
144
124
|
text="一"
|
|
145
|
-
@click="onDeleteResponseHeader(item)"
|
|
146
|
-
/>
|
|
125
|
+
@click="onDeleteResponseHeader(item)" />
|
|
147
126
|
</view>
|
|
148
127
|
</checkbox-group>
|
|
149
128
|
|
|
150
|
-
<view class="intercept-empty" v-else>
|
|
129
|
+
<view class="intercept-empty" v-else>
|
|
130
|
+
{{ t('network.noResponseHeaders') }}
|
|
131
|
+
</view>
|
|
151
132
|
</view>
|
|
152
|
-
<DevToolTitle
|
|
133
|
+
<DevToolTitle>{{ t('network.requestUrl') }}</DevToolTitle>
|
|
153
134
|
<textarea
|
|
154
|
-
placeholder="
|
|
155
|
-
placeholderStyle="font-size: 12px"
|
|
135
|
+
:placeholder="t('network.placeholderUrl')"
|
|
156
136
|
class="intercept-textarea"
|
|
157
137
|
:value="state.url"
|
|
158
|
-
@input="onChangeUrl"
|
|
159
|
-
/>
|
|
138
|
+
@input="onChangeUrl" />
|
|
160
139
|
<view class="form-error-message">
|
|
161
|
-
{{ hasUrl ? '' : '
|
|
140
|
+
{{ hasUrl ? '' : t('network.toastEnterUrl') }}
|
|
162
141
|
</view>
|
|
163
142
|
|
|
164
143
|
<view class="intercept-config-control">
|
|
165
|
-
<DevToolTitle
|
|
144
|
+
<DevToolTitle>{{ t('network.requestParams') }}</DevToolTitle>
|
|
166
145
|
<CircularButton
|
|
167
146
|
style="margin-left: auto"
|
|
168
147
|
text="+"
|
|
169
|
-
@click="onAddQuery"
|
|
170
|
-
/>
|
|
148
|
+
@click="onAddQuery" />
|
|
171
149
|
</view>
|
|
172
150
|
<view class="intercept-param-list">
|
|
173
151
|
<checkbox-group
|
|
174
152
|
v-if="queryList.length > 0"
|
|
175
|
-
@change="
|
|
176
|
-
>
|
|
153
|
+
@change="handleQueryCheckedChange">
|
|
177
154
|
<view
|
|
178
155
|
class="intercept-param-item"
|
|
179
156
|
v-for="(item, index) in queryList"
|
|
180
|
-
:key="item.id"
|
|
181
|
-
>
|
|
157
|
+
:key="item.id">
|
|
182
158
|
<checkbox
|
|
183
|
-
color="
|
|
159
|
+
:color="themeColor"
|
|
184
160
|
:checked="item.checked"
|
|
185
|
-
:value="item.id"
|
|
186
|
-
/>
|
|
161
|
+
:value="item.id" />
|
|
187
162
|
<input
|
|
188
163
|
class="intercept-input"
|
|
189
|
-
placeholder="
|
|
190
|
-
placeholderStyle="font-size: 12px"
|
|
164
|
+
:placeholder="t('network.placeholderParamName')"
|
|
191
165
|
:value="item.key"
|
|
192
|
-
@input="onChangeQuery($event, 'key', index)"
|
|
193
|
-
/>
|
|
166
|
+
@input="onChangeQuery($event, 'key', index)" />
|
|
194
167
|
<input
|
|
195
168
|
class="intercept-input"
|
|
196
|
-
placeholder="
|
|
197
|
-
placeholderStyle="font-size: 12px"
|
|
169
|
+
:placeholder="t('network.placeholderParamValue')"
|
|
198
170
|
:value="item.value"
|
|
199
|
-
@input="onChangeQuery($event, 'value', index)"
|
|
200
|
-
/>
|
|
171
|
+
@input="onChangeQuery($event, 'value', index)" />
|
|
201
172
|
<CircularButton
|
|
202
173
|
text="一"
|
|
203
174
|
style="margin-left: 6px"
|
|
204
|
-
@click="onDeleteQuery(item)"
|
|
205
|
-
/>
|
|
175
|
+
@click="onDeleteQuery(item)" />
|
|
206
176
|
</view>
|
|
207
177
|
</checkbox-group>
|
|
208
178
|
|
|
209
|
-
<view class="intercept-empty" v-else>
|
|
179
|
+
<view class="intercept-empty" v-else>
|
|
180
|
+
{{ t('network.emptyParams') }}
|
|
181
|
+
</view>
|
|
210
182
|
</view>
|
|
211
183
|
|
|
212
184
|
<template v-if="!noBodyRequestMethods.includes(state.method)">
|
|
213
185
|
<view class="intercept-config-control">
|
|
214
|
-
<DevToolTitle
|
|
186
|
+
<DevToolTitle>{{ t('network.requestBody') }}</DevToolTitle>
|
|
215
187
|
</view>
|
|
216
188
|
|
|
217
189
|
<textarea
|
|
218
|
-
placeholder="
|
|
190
|
+
:placeholder="t('network.placeholderBody')"
|
|
219
191
|
class="intercept-textarea"
|
|
220
|
-
placeholderStyle="font-size: 12px"
|
|
221
192
|
:value="state.bodyText"
|
|
222
|
-
@input="onChangeState($event, 'bodyText')"
|
|
223
|
-
/>
|
|
193
|
+
@input="onChangeState($event, 'bodyText')" />
|
|
224
194
|
</template>
|
|
225
195
|
|
|
226
196
|
<view class="intercept-config-control">
|
|
227
|
-
<DevToolTitle
|
|
197
|
+
<DevToolTitle>{{ t('network.responseBody') }}</DevToolTitle>
|
|
228
198
|
</view>
|
|
229
199
|
<textarea
|
|
230
|
-
placeholder="
|
|
200
|
+
:placeholder="t('network.placeholderRespBody')"
|
|
231
201
|
class="intercept-textarea"
|
|
232
|
-
placeholderStyle="font-size: 12px"
|
|
233
202
|
:value="state.responseText"
|
|
234
|
-
@input="onChangeState($event, 'responseText')"
|
|
235
|
-
/>
|
|
203
|
+
@input="onChangeState($event, 'responseText')" />
|
|
236
204
|
</scroll-view>
|
|
237
205
|
<view class="intercept-config-buttons">
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
@click="emit('openDetail', network)"
|
|
242
|
-
>
|
|
243
|
-
详情
|
|
244
|
-
</button>
|
|
245
|
-
<button size="mini" @click="onReset">重置</button>
|
|
246
|
-
<button size="mini" @click="onSend">发送</button> -->
|
|
247
|
-
<button
|
|
248
|
-
size="mini"
|
|
249
|
-
style="width: 100%; background-color: #9254de; color: #fff"
|
|
250
|
-
@click="onConfirm"
|
|
251
|
-
>
|
|
252
|
-
保存配置
|
|
253
|
-
</button>
|
|
206
|
+
<SettingButton @click="onConfirm">
|
|
207
|
+
{{ t('network.saveConfig') }}
|
|
208
|
+
</SettingButton>
|
|
254
209
|
</view>
|
|
255
210
|
</view>
|
|
256
211
|
</template>
|
|
257
212
|
<script lang="ts" setup>
|
|
258
|
-
import {
|
|
213
|
+
import { computed, ref, onMounted } from 'vue';
|
|
259
214
|
import CircularButton from '../CircularButton/index.vue';
|
|
260
215
|
import DevToolTitle from '../DevToolTitle/index.vue';
|
|
261
216
|
import type { DevTool } from '../../type';
|
|
217
|
+
import SettingButton from '../SettingButton/index.vue';
|
|
218
|
+
import { useI18n } from '../../i18n';
|
|
219
|
+
import { getThemeMainColor } from '../styles/theme';
|
|
220
|
+
const { t } = useI18n();
|
|
221
|
+
const themeColor = computed(() => getThemeMainColor(props.theme));
|
|
262
222
|
|
|
263
223
|
const props = defineProps<{
|
|
224
|
+
theme?: string;
|
|
264
225
|
network: DevTool.NetworkItem;
|
|
265
226
|
zIndex?: number;
|
|
266
227
|
customStyle?: Record<string, any>;
|
|
@@ -272,73 +233,54 @@ const emit = defineEmits<{
|
|
|
272
233
|
(e: 'confirm', v: DevTool.NetworkItem): void;
|
|
273
234
|
}>();
|
|
274
235
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const state =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
url: 'http://mock.view-uni-dev-tool/a?a=123',
|
|
297
|
-
status: 200,
|
|
298
|
-
bodyText: '',
|
|
299
|
-
responseText: '',
|
|
300
|
-
timeout: 3 * 1000,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
const defaultHeader = [
|
|
304
|
-
{
|
|
305
|
-
id: '1',
|
|
306
|
-
key: 'Accept',
|
|
307
|
-
value: '*/*',
|
|
308
|
-
checked: false,
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
id: '2',
|
|
312
|
-
key: 'Accept-Language',
|
|
313
|
-
value: 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
314
|
-
checked: false,
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: '3',
|
|
318
|
-
key: 'Cache-Control',
|
|
319
|
-
value: 'no-cache',
|
|
320
|
-
checked: false,
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
id: '4',
|
|
324
|
-
key: 'Content-Type',
|
|
325
|
-
value: 'application/json; charset=utf-8',
|
|
326
|
-
checked: true,
|
|
327
|
-
},
|
|
328
|
-
];
|
|
329
|
-
|
|
330
|
-
type PB = {
|
|
331
|
-
id: string;
|
|
332
|
-
key: string;
|
|
333
|
-
value: string;
|
|
334
|
-
checked: boolean;
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const requestHeaderList = reactive([...defaultHeader]);
|
|
338
|
-
|
|
339
|
-
const responseHeaderList = reactive([...defaultHeader]);
|
|
236
|
+
import {
|
|
237
|
+
requestMethods,
|
|
238
|
+
noBodyRequestMethods,
|
|
239
|
+
defaultHeader,
|
|
240
|
+
arrayToObject,
|
|
241
|
+
objectToArray,
|
|
242
|
+
arrayToUrlParams,
|
|
243
|
+
urlParamsToObject,
|
|
244
|
+
unionArrayByKey,
|
|
245
|
+
} from './utils';
|
|
246
|
+
import { useKeyValueList, useNetworkState } from './hooks/useNetworkForm';
|
|
247
|
+
|
|
248
|
+
const { state, hasUrl, onChangeState, parseUrlToList, parseListToUrl } =
|
|
249
|
+
useNetworkState({
|
|
250
|
+
method: 'GET',
|
|
251
|
+
url: 'http://mock.view-uni-dev-tool/a?a=123',
|
|
252
|
+
status: 200,
|
|
253
|
+
bodyText: '',
|
|
254
|
+
responseText: '',
|
|
255
|
+
timeout: 3 * 1000,
|
|
256
|
+
});
|
|
340
257
|
|
|
341
|
-
const
|
|
258
|
+
const {
|
|
259
|
+
list: requestHeaderList,
|
|
260
|
+
onAdd: onAddRequestHeader,
|
|
261
|
+
onDelete: onDeleteRequestHeader,
|
|
262
|
+
onChangeChecked: onChangeRequestHeaderChecked,
|
|
263
|
+
onChangeValue: onChangeRequestHeaderItem,
|
|
264
|
+
setList: setRequestHeaderList,
|
|
265
|
+
} = useKeyValueList(defaultHeader);
|
|
266
|
+
|
|
267
|
+
const {
|
|
268
|
+
list: responseHeaderList,
|
|
269
|
+
onAdd: onAddResponseHeader,
|
|
270
|
+
onDelete: onDeleteResponseHeader,
|
|
271
|
+
onChangeChecked: onChangeResponseHeaderChecked,
|
|
272
|
+
onChangeValue: onChangeResponseHeaderItem,
|
|
273
|
+
setList: setResponseHeaderList,
|
|
274
|
+
} = useKeyValueList(defaultHeader);
|
|
275
|
+
|
|
276
|
+
const {
|
|
277
|
+
list: queryList,
|
|
278
|
+
onAdd: onAddQuery,
|
|
279
|
+
onDelete: onDeleteQuery,
|
|
280
|
+
onChangeChecked: onChangeQueryChecked,
|
|
281
|
+
onChangeValue: onChangeQueryItem,
|
|
282
|
+
setList: setQueryList,
|
|
283
|
+
} = useKeyValueList([
|
|
342
284
|
{
|
|
343
285
|
id: '1',
|
|
344
286
|
key: 'a',
|
|
@@ -349,39 +291,11 @@ const queryList = reactive<PB[]>([
|
|
|
349
291
|
|
|
350
292
|
const isFinished = ref(false);
|
|
351
293
|
|
|
352
|
-
const noBodyRequestMethods = ['GET', 'HEAD', 'PATCH', 'OPTIONS'];
|
|
353
|
-
|
|
354
|
-
function onChangeState(e: any, key: keyof typeof state) {
|
|
355
|
-
state[key] = e.detail.value as never;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function parseUrlToList(url: string) {
|
|
359
|
-
if (url.includes('?')) {
|
|
360
|
-
const query = url.split('?')[1];
|
|
361
|
-
const queryObject = urlParamsToObject(query);
|
|
362
|
-
const list = objectToArray(queryObject);
|
|
363
|
-
|
|
364
|
-
return list;
|
|
365
|
-
}
|
|
366
|
-
return [];
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function parseListToUrl(list: PB[]) {
|
|
370
|
-
const baseUrl = state.url.split('?')[0] || '';
|
|
371
|
-
if (list.length === 0) {
|
|
372
|
-
return baseUrl;
|
|
373
|
-
} else {
|
|
374
|
-
return (
|
|
375
|
-
baseUrl + '?' + arrayToUrlParams(queryList?.filter((q) => q.checked))
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
294
|
function onChangeUrl(e: any) {
|
|
381
295
|
const url = e.detail.value;
|
|
382
296
|
state.url = url;
|
|
383
297
|
const list = parseUrlToList(url);
|
|
384
|
-
|
|
298
|
+
setQueryList(list);
|
|
385
299
|
}
|
|
386
300
|
|
|
387
301
|
function onReset() {
|
|
@@ -390,8 +304,8 @@ function onReset() {
|
|
|
390
304
|
state.method = 'GET';
|
|
391
305
|
state.url = '';
|
|
392
306
|
state.bodyText = '';
|
|
393
|
-
|
|
394
|
-
|
|
307
|
+
setResponseHeaderList(defaultHeader);
|
|
308
|
+
setQueryList([]);
|
|
395
309
|
}
|
|
396
310
|
|
|
397
311
|
function onClose() {
|
|
@@ -403,7 +317,7 @@ function onConfirm() {
|
|
|
403
317
|
if (!state.url) {
|
|
404
318
|
hasUrl.value = false;
|
|
405
319
|
uni.showToast({
|
|
406
|
-
title: '
|
|
320
|
+
title: t('network.toastEnterUrl'),
|
|
407
321
|
icon: 'none',
|
|
408
322
|
});
|
|
409
323
|
return;
|
|
@@ -411,7 +325,7 @@ function onConfirm() {
|
|
|
411
325
|
hasUrl.value = true;
|
|
412
326
|
|
|
413
327
|
const responseHeader = arrayToObject(responseHeaderList);
|
|
414
|
-
const query = arrayToUrlParams(queryList);
|
|
328
|
+
const query = arrayToUrlParams(queryList.filter((q) => q.checked));
|
|
415
329
|
|
|
416
330
|
const baseUrl = state.url?.split('?')[0] || '';
|
|
417
331
|
const lastSlashIndex = baseUrl.lastIndexOf('/');
|
|
@@ -424,7 +338,7 @@ function onConfirm() {
|
|
|
424
338
|
url: state.url,
|
|
425
339
|
method: state.method,
|
|
426
340
|
timeout: state.timeout,
|
|
427
|
-
status: state.status,
|
|
341
|
+
status: state.status as string,
|
|
428
342
|
time: '',
|
|
429
343
|
startTime: 0,
|
|
430
344
|
endTime: 0,
|
|
@@ -435,7 +349,7 @@ function onConfirm() {
|
|
|
435
349
|
},
|
|
436
350
|
response: {
|
|
437
351
|
data: '',
|
|
438
|
-
statusCode: state.status,
|
|
352
|
+
statusCode: Number(state.status),
|
|
439
353
|
header: responseHeader,
|
|
440
354
|
cookies: [],
|
|
441
355
|
errMsg: 'request:ok',
|
|
@@ -461,9 +375,9 @@ function onConfirm() {
|
|
|
461
375
|
try {
|
|
462
376
|
const bodyJson = JSON.parse(state.bodyText);
|
|
463
377
|
interceptConfig.payload = bodyJson;
|
|
464
|
-
} catch (
|
|
378
|
+
} catch (_error) {
|
|
465
379
|
uni.showToast({
|
|
466
|
-
title: '
|
|
380
|
+
title: t('network.toastBodyJson'),
|
|
467
381
|
icon: 'none',
|
|
468
382
|
});
|
|
469
383
|
return;
|
|
@@ -475,9 +389,9 @@ function onConfirm() {
|
|
|
475
389
|
try {
|
|
476
390
|
const bodyJson = JSON.parse(state.responseText);
|
|
477
391
|
interceptConfig.response.data = bodyJson;
|
|
478
|
-
} catch (
|
|
392
|
+
} catch (_error) {
|
|
479
393
|
uni.showToast({
|
|
480
|
-
title: '
|
|
394
|
+
title: t('network.toastRespJson'),
|
|
481
395
|
icon: 'none',
|
|
482
396
|
});
|
|
483
397
|
return;
|
|
@@ -486,7 +400,7 @@ function onConfirm() {
|
|
|
486
400
|
|
|
487
401
|
uni.showToast({
|
|
488
402
|
icon: 'none',
|
|
489
|
-
title: '
|
|
403
|
+
title: t('network.toastSaveSuccess'),
|
|
490
404
|
});
|
|
491
405
|
|
|
492
406
|
emit('confirm', interceptConfig);
|
|
@@ -498,147 +412,22 @@ function onChangeRequestMethod(e: any) {
|
|
|
498
412
|
state.method = method;
|
|
499
413
|
}
|
|
500
414
|
|
|
501
|
-
function onDeleteResponseHeader(item: any) {
|
|
502
|
-
const index = responseHeaderList.findIndex((i) => i.id === item.id);
|
|
503
|
-
responseHeaderList.splice(index, 1);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function onDeleteRequestHeader(item: any) {
|
|
507
|
-
const index = requestHeaderList.findIndex((i) => i.id === item.id);
|
|
508
|
-
requestHeaderList.splice(index, 1);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function onAddRequestHeader() {
|
|
512
|
-
const id = Date.now()?.toString();
|
|
513
|
-
requestHeaderList.push({
|
|
514
|
-
id,
|
|
515
|
-
key: '',
|
|
516
|
-
value: '',
|
|
517
|
-
checked: false,
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
function onChangeRequestHeaderChecked(e: any) {
|
|
521
|
-
const list = e.detail?.value ?? [];
|
|
522
|
-
|
|
523
|
-
Object.assign(
|
|
524
|
-
requestHeaderList,
|
|
525
|
-
requestHeaderList.map((item) => {
|
|
526
|
-
return { ...item, checked: list?.includes(item.id) };
|
|
527
|
-
}),
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
415
|
function onChangeRequestHeader(e: any, key: 'key' | 'value', index: number) {
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
function onAddResponseHeader() {
|
|
536
|
-
const id = Date.now()?.toString();
|
|
537
|
-
responseHeaderList.push({
|
|
538
|
-
id,
|
|
539
|
-
key: '',
|
|
540
|
-
value: '',
|
|
541
|
-
checked: false,
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
function onChangeResponseHeaderChecked(e: any) {
|
|
546
|
-
const list = e.detail?.value ?? [];
|
|
547
|
-
|
|
548
|
-
Object.assign(
|
|
549
|
-
responseHeaderList,
|
|
550
|
-
responseHeaderList.map((item) => {
|
|
551
|
-
return { ...item, checked: list?.includes(item.id) };
|
|
552
|
-
}),
|
|
553
|
-
);
|
|
416
|
+
onChangeRequestHeaderItem(index, key, e.detail.value);
|
|
554
417
|
}
|
|
555
418
|
|
|
556
419
|
function onChangeResponseHeader(e: any, key: 'key' | 'value', index: number) {
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
function onDeleteQuery(item: any) {
|
|
561
|
-
const index = queryList.findIndex((i) => i.id === item.id);
|
|
562
|
-
queryList.splice(index, 1);
|
|
563
|
-
}
|
|
564
|
-
function onAddQuery() {
|
|
565
|
-
const id = Date.now()?.toString();
|
|
566
|
-
queryList.push({
|
|
567
|
-
id,
|
|
568
|
-
key: '',
|
|
569
|
-
value: '',
|
|
570
|
-
checked: false,
|
|
571
|
-
});
|
|
420
|
+
onChangeResponseHeaderItem(index, key, e.detail.value);
|
|
572
421
|
}
|
|
573
|
-
function onChangeQueryChecked(e: any) {
|
|
574
|
-
const list = e.detail?.value ?? [];
|
|
575
|
-
queryList.forEach((q) => {
|
|
576
|
-
q.checked = list?.includes(q.id);
|
|
577
|
-
});
|
|
578
422
|
|
|
579
|
-
|
|
423
|
+
function handleQueryCheckedChange(e: any) {
|
|
424
|
+
onChangeQueryChecked(e);
|
|
425
|
+
state.url = parseListToUrl(state.url, queryList);
|
|
580
426
|
}
|
|
581
427
|
|
|
582
428
|
function onChangeQuery(e: any, key: 'key' | 'value', index: number) {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
state.url = parseListToUrl(queryList);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
function arrayToObject(arr: any[]) {
|
|
589
|
-
return arr.reduce((acc, cur) => {
|
|
590
|
-
if (cur.checked) {
|
|
591
|
-
acc[cur.key] = cur.value;
|
|
592
|
-
}
|
|
593
|
-
return acc;
|
|
594
|
-
}, {});
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function objectToArray<T extends Record<string, any>>(obj: T) {
|
|
598
|
-
return Object.entries(obj).map(([key, value]) => ({
|
|
599
|
-
id: Date.now().toString(),
|
|
600
|
-
key,
|
|
601
|
-
value,
|
|
602
|
-
checked: true,
|
|
603
|
-
}));
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
function objectToUrlParams(obj: any) {
|
|
607
|
-
return Object.keys(obj)
|
|
608
|
-
.map((key) => `${key}=${encodeURIComponent(obj[key])}`)
|
|
609
|
-
.join('&');
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function arrayToUrlParams(arr: any[]) {
|
|
613
|
-
return arr
|
|
614
|
-
.map((item) => `${item.key}=${encodeURIComponent(item.value)}`)
|
|
615
|
-
?.join('&');
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function unionArrayByKey<T>(arr1: T[], arr2: T[], key: keyof T): T[] {
|
|
619
|
-
const map = new Map();
|
|
620
|
-
arr1.forEach((item) => {
|
|
621
|
-
map.set(item?.[key], item);
|
|
622
|
-
});
|
|
623
|
-
arr2.forEach((item) => {
|
|
624
|
-
if (map.has(item?.[key])) {
|
|
625
|
-
map.set(item?.[key], { ...map.get(item?.[key]), ...item });
|
|
626
|
-
} else {
|
|
627
|
-
map.set(item?.[key], item);
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
return Array.from(map.values());
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function urlParamsToObject(urlParams: string) {
|
|
634
|
-
return urlParams.split('&').reduce(
|
|
635
|
-
(acc, cur) => {
|
|
636
|
-
const [key, value] = cur.split('=');
|
|
637
|
-
acc[key] = value;
|
|
638
|
-
return acc;
|
|
639
|
-
},
|
|
640
|
-
{} as Record<string, any>,
|
|
641
|
-
);
|
|
429
|
+
onChangeQueryItem(index, key, e.detail.value);
|
|
430
|
+
state.url = parseListToUrl(state.url, queryList);
|
|
642
431
|
}
|
|
643
432
|
|
|
644
433
|
/**
|
|
@@ -651,7 +440,7 @@ function handleInterceptConfig() {
|
|
|
651
440
|
// 设置基础请求信息
|
|
652
441
|
state.url = props.network.url;
|
|
653
442
|
state.method = props.network.method?.toUpperCase() ?? 'GET';
|
|
654
|
-
state.status = props.network.status;
|
|
443
|
+
state.status = props.network.status as string;
|
|
655
444
|
|
|
656
445
|
// 初始化请求头
|
|
657
446
|
const requestHeaders =
|
|
@@ -663,7 +452,7 @@ function handleInterceptConfig() {
|
|
|
663
452
|
};
|
|
664
453
|
}) ?? [];
|
|
665
454
|
|
|
666
|
-
|
|
455
|
+
setRequestHeaderList(requestHeaders);
|
|
667
456
|
|
|
668
457
|
const responseHeaders =
|
|
669
458
|
props.network.headers?.responseHeader?.map((item, index) => {
|
|
@@ -674,9 +463,9 @@ function handleInterceptConfig() {
|
|
|
674
463
|
};
|
|
675
464
|
}) ?? [];
|
|
676
465
|
|
|
677
|
-
|
|
466
|
+
setResponseHeaderList(responseHeaders);
|
|
678
467
|
|
|
679
|
-
|
|
468
|
+
setQueryList([]);
|
|
680
469
|
|
|
681
470
|
// 解析参数
|
|
682
471
|
if (noBodyRequestMethods.includes(state.method)) {
|
|
@@ -689,7 +478,7 @@ function handleInterceptConfig() {
|
|
|
689
478
|
|
|
690
479
|
const list = unionArrayByKey(urlParams, payloadParams, 'key');
|
|
691
480
|
|
|
692
|
-
|
|
481
|
+
setQueryList(list);
|
|
693
482
|
}
|
|
694
483
|
} else {
|
|
695
484
|
// 参数在 query 中
|
|
@@ -697,7 +486,7 @@ function handleInterceptConfig() {
|
|
|
697
486
|
const urlParams = objectToArray(
|
|
698
487
|
urlParamsToObject(props.network.url.split('?')?.[1] ?? ''),
|
|
699
488
|
);
|
|
700
|
-
|
|
489
|
+
setQueryList(urlParams);
|
|
701
490
|
}
|
|
702
491
|
state.bodyText = JSON.stringify(props.network.payload);
|
|
703
492
|
}
|
|
@@ -705,8 +494,8 @@ function handleInterceptConfig() {
|
|
|
705
494
|
if (props.network.response?.data) {
|
|
706
495
|
try {
|
|
707
496
|
state.responseText = JSON.stringify(props.network.response.data);
|
|
708
|
-
} catch (
|
|
709
|
-
state.responseText = props.network.response.data;
|
|
497
|
+
} catch (_error) {
|
|
498
|
+
state.responseText = props.network.response.data as string;
|
|
710
499
|
}
|
|
711
500
|
}
|
|
712
501
|
}
|
|
@@ -725,19 +514,21 @@ onMounted(() => {
|
|
|
725
514
|
top: 0;
|
|
726
515
|
left: 0;
|
|
727
516
|
padding: 0 16px;
|
|
517
|
+
|
|
728
518
|
/* #ifdef H5 || APP-PLUS */
|
|
729
519
|
padding: 50px 16px;
|
|
520
|
+
|
|
730
521
|
/* #endif */
|
|
731
522
|
overflow: auto;
|
|
732
|
-
|
|
733
523
|
background-color: var(--dev-tool-bg3-color);
|
|
734
524
|
box-sizing: border-box;
|
|
735
525
|
}
|
|
736
526
|
|
|
737
527
|
.intercept-config-tip {
|
|
738
|
-
font-size:
|
|
528
|
+
font-size: var(--dev-tool-tips-font-size);
|
|
739
529
|
color: var(--dev-tool-info-color);
|
|
740
530
|
}
|
|
531
|
+
|
|
741
532
|
.intercept-config-form {
|
|
742
533
|
height: calc(100% - 32px - 42px);
|
|
743
534
|
overflow: auto;
|
|
@@ -762,23 +553,21 @@ onMounted(() => {
|
|
|
762
553
|
align-items: center;
|
|
763
554
|
width: 25%;
|
|
764
555
|
margin-bottom: 6px;
|
|
765
|
-
|
|
766
|
-
font-size: 12px;
|
|
767
556
|
}
|
|
768
557
|
|
|
769
558
|
.intercept-input {
|
|
770
559
|
padding: 0 6px;
|
|
771
560
|
height: 24px;
|
|
772
|
-
font-size: 12px;
|
|
773
561
|
border: 1px solid var(--dev-tool-border-color);
|
|
774
562
|
}
|
|
563
|
+
|
|
775
564
|
.intercept-textarea {
|
|
776
565
|
padding: 6px;
|
|
777
566
|
width: 100%;
|
|
778
567
|
box-sizing: border-box;
|
|
779
|
-
font-size: 12px;
|
|
780
568
|
border: 1px solid var(--dev-tool-border-color);
|
|
781
569
|
}
|
|
570
|
+
|
|
782
571
|
.form-error-message {
|
|
783
572
|
padding: 0 6px;
|
|
784
573
|
height: 24px;
|
|
@@ -810,6 +599,7 @@ onMounted(() => {
|
|
|
810
599
|
position: sticky;
|
|
811
600
|
display: flex;
|
|
812
601
|
justify-content: space-between;
|
|
602
|
+
|
|
813
603
|
/* gap: 6px; */
|
|
814
604
|
width: 100%;
|
|
815
605
|
margin-top: 12px;
|