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
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
}"
|
|
11
11
|
@click="handleNodeClick"
|
|
12
12
|
@mouseover="handleNodeMouseover"
|
|
13
|
-
:style="customStyle"
|
|
14
|
-
>
|
|
13
|
+
:style="customStyle">
|
|
15
14
|
<view v-if="showLineNumber" class="json-pretty-node-index">
|
|
16
15
|
{{ node.id + 1 }}
|
|
17
16
|
</view>
|
|
@@ -24,9 +23,9 @@
|
|
|
24
23
|
node.type !== 'arrayEnd'
|
|
25
24
|
"
|
|
26
25
|
:isMultiple="isMultiple"
|
|
26
|
+
:theme="theme"
|
|
27
27
|
:checked="checked"
|
|
28
|
-
@change="handleSelectedChange"
|
|
29
|
-
/>
|
|
28
|
+
@change="handleSelectedChange" />
|
|
30
29
|
|
|
31
30
|
<view class="json-pretty-indent">
|
|
32
31
|
<view
|
|
@@ -35,13 +34,11 @@
|
|
|
35
34
|
:class="{
|
|
36
35
|
'json-pretty-indent-unit': true,
|
|
37
36
|
'has-line': showLine,
|
|
38
|
-
}"
|
|
39
|
-
>
|
|
37
|
+
}">
|
|
40
38
|
<view
|
|
41
|
-
v-for="() in
|
|
42
|
-
:key="
|
|
43
|
-
class="json-pretty-indent-space"
|
|
44
|
-
></view>
|
|
39
|
+
v-for="(_, i) in indent"
|
|
40
|
+
:key="i"
|
|
41
|
+
class="json-pretty-indent-space"></view>
|
|
45
42
|
</view>
|
|
46
43
|
<Carets v-if="showIcon" :nodeType="node.type" @click="handleIconClick" />
|
|
47
44
|
</view>
|
|
@@ -59,8 +56,7 @@
|
|
|
59
56
|
<Brackets
|
|
60
57
|
v-if="node.type !== 'content' && node.content"
|
|
61
58
|
:data="node.content.toString()"
|
|
62
|
-
@click="handleBracketsClick"
|
|
63
|
-
/>
|
|
59
|
+
@click="handleBracketsClick" />
|
|
64
60
|
|
|
65
61
|
<view v-else :class="valueClass" @click="handleValueEdit">
|
|
66
62
|
<input
|
|
@@ -68,14 +64,12 @@
|
|
|
68
64
|
class="json-pretty-edit-input"
|
|
69
65
|
:value="defaultValue"
|
|
70
66
|
:focus="state.editing"
|
|
71
|
-
@blur="handleInputBlur"
|
|
72
|
-
/>
|
|
67
|
+
@blur="handleInputBlur" />
|
|
73
68
|
<view v-else>
|
|
74
69
|
<slot
|
|
75
70
|
name="render-node-value"
|
|
76
71
|
:node="props.node"
|
|
77
|
-
:default-value="defaultValue"
|
|
78
|
-
>
|
|
72
|
+
:default-value="defaultValue">
|
|
79
73
|
{{ defaultValue }}
|
|
80
74
|
</slot>
|
|
81
75
|
<text v-if="node.showComma">,</text>
|
|
@@ -195,7 +189,7 @@ const handleNodeMouseover = () => {
|
|
|
195
189
|
emit('nodeMouseover', props.node);
|
|
196
190
|
};
|
|
197
191
|
|
|
198
|
-
const handleValueEdit = (
|
|
192
|
+
const handleValueEdit = (_e: MouseEvent) => {
|
|
199
193
|
if (!props.editable) return;
|
|
200
194
|
|
|
201
195
|
if (!state.editing) {
|
|
@@ -235,30 +229,37 @@ const handleCopy = () => {
|
|
|
235
229
|
<style scoped>
|
|
236
230
|
.json-pretty-tree-node {
|
|
237
231
|
display: flex;
|
|
232
|
+
|
|
238
233
|
/* align-items: center; */
|
|
239
234
|
position: relative;
|
|
240
235
|
line-height: 20px;
|
|
241
236
|
}
|
|
237
|
+
|
|
242
238
|
.json-pretty-tree-node.has-carets {
|
|
243
239
|
padding-left: 15px;
|
|
244
240
|
}
|
|
241
|
+
|
|
245
242
|
.json-pretty-tree-node.has-selector,
|
|
246
243
|
.json-pretty-tree-node.has-carets.has-selector {
|
|
247
244
|
padding-left: 30px;
|
|
248
245
|
}
|
|
246
|
+
|
|
249
247
|
.json-pretty-tree-node.is-highlight,
|
|
250
248
|
.json-pretty-tree-node:hover {
|
|
251
249
|
background-color: var(--json-pretty-highlight-bg-color);
|
|
252
250
|
border-radius: 4px;
|
|
253
251
|
}
|
|
252
|
+
|
|
254
253
|
.json-pretty-tree-node.is-highlight .json-pretty-tree-node-actions,
|
|
255
254
|
.json-pretty-tree-node:hover .json-pretty-tree-node-actions {
|
|
256
255
|
display: block;
|
|
257
256
|
}
|
|
257
|
+
|
|
258
258
|
.json-pretty-tree-node .json-pretty-indent {
|
|
259
259
|
display: flex;
|
|
260
260
|
position: relative;
|
|
261
261
|
}
|
|
262
|
+
|
|
262
263
|
.json-pretty-tree-node .json-pretty-indent-unit {
|
|
263
264
|
display: flex;
|
|
264
265
|
}
|
|
@@ -270,6 +271,7 @@ const handleCopy = () => {
|
|
|
270
271
|
.json-pretty-tree-node .json-pretty-indent-unit.has-line {
|
|
271
272
|
border-left: 1px dashed var(--json-pretty-border-color);
|
|
272
273
|
}
|
|
274
|
+
|
|
273
275
|
.json-pretty-tree-node .json-pretty-tree-node-actions {
|
|
274
276
|
display: none;
|
|
275
277
|
position: absolute;
|
|
@@ -279,81 +281,101 @@ const handleCopy = () => {
|
|
|
279
281
|
background-color: var(--json-pretty-highlight-bg-color);
|
|
280
282
|
border-radius: 4px;
|
|
281
283
|
}
|
|
284
|
+
|
|
282
285
|
.json-pretty-tree-node
|
|
283
286
|
.json-pretty-tree-node-actions
|
|
284
287
|
.json-pretty-tree-node-actions-item {
|
|
285
288
|
cursor: pointer;
|
|
286
289
|
}
|
|
290
|
+
|
|
287
291
|
.json-pretty-tree-node
|
|
288
292
|
.json-pretty-tree-node-actions
|
|
289
293
|
.json-pretty-tree-node-actions-item:hover {
|
|
290
294
|
color: var(--json-pretty-color-primary);
|
|
291
295
|
}
|
|
296
|
+
|
|
292
297
|
.json-pretty-tree-node.dark.is-highlight,
|
|
293
298
|
.json-pretty-tree-node.dark:hover {
|
|
294
299
|
background-color: var(--json-pretty-highlight-bg-color-dark);
|
|
295
300
|
}
|
|
301
|
+
|
|
296
302
|
.json-pretty-tree-node.dark .json-pretty-tree-node-actions {
|
|
297
303
|
background-color: var(--json-pretty-highlight-bg-color-dark);
|
|
298
304
|
}
|
|
305
|
+
|
|
299
306
|
.json-pretty-tree-node-active {
|
|
300
307
|
background-color: var(--json-pretty-highlight-bg-color);
|
|
301
308
|
border-radius: 4px;
|
|
302
309
|
}
|
|
310
|
+
|
|
303
311
|
.json-pretty-tree-node-active .json-pretty-tree-node-actions {
|
|
304
312
|
display: block;
|
|
305
313
|
}
|
|
314
|
+
|
|
306
315
|
.json-pretty-node-index {
|
|
307
316
|
position: absolute;
|
|
308
317
|
right: 100%;
|
|
309
318
|
margin-right: 4px;
|
|
310
319
|
user-select: none;
|
|
311
320
|
}
|
|
321
|
+
|
|
312
322
|
.json-pretty-colon {
|
|
313
323
|
white-space: pre;
|
|
314
324
|
}
|
|
325
|
+
|
|
315
326
|
.json-pretty-comment {
|
|
316
327
|
color: var(--json-pretty-color-primary);
|
|
317
328
|
}
|
|
329
|
+
|
|
318
330
|
.json-pretty-key {
|
|
319
331
|
display: flex;
|
|
320
332
|
}
|
|
333
|
+
|
|
321
334
|
.json-pretty-value-wrapper {
|
|
322
335
|
display: flex;
|
|
323
336
|
align-items: center;
|
|
324
337
|
}
|
|
338
|
+
|
|
325
339
|
.json-pretty-value {
|
|
326
340
|
/* word-break: break-all; */
|
|
341
|
+
|
|
327
342
|
/* white-space: normal; */
|
|
343
|
+
|
|
328
344
|
/* white-space: pre-line; */
|
|
329
345
|
white-space: nowrap;
|
|
330
346
|
}
|
|
347
|
+
|
|
331
348
|
.json-pretty-value-null {
|
|
332
349
|
color: var(--json-pretty-color-null);
|
|
333
350
|
}
|
|
351
|
+
|
|
334
352
|
.json-pretty-value-undefined {
|
|
335
353
|
color: var(--json-pretty-color-undefined);
|
|
336
354
|
}
|
|
355
|
+
|
|
337
356
|
.json-pretty-value-number {
|
|
338
357
|
color: var(--json-pretty-color-number);
|
|
339
358
|
}
|
|
359
|
+
|
|
340
360
|
.json-pretty-value-boolean {
|
|
341
361
|
color: var(--json-pretty-color-boolean);
|
|
342
362
|
}
|
|
363
|
+
|
|
343
364
|
.json-pretty-value-string {
|
|
344
365
|
color: var(--json-pretty-color-string);
|
|
345
366
|
}
|
|
367
|
+
|
|
346
368
|
.json-pretty-edit-input {
|
|
347
|
-
padding:
|
|
369
|
+
padding: 0 8px;
|
|
348
370
|
border: 1px solid #eee;
|
|
349
371
|
box-shadow: none;
|
|
350
372
|
box-sizing: border-box;
|
|
351
|
-
|
|
373
|
+
font: unset;
|
|
374
|
+
border-radius: 5px;
|
|
352
375
|
font-family: inherit;
|
|
353
376
|
color: #000;
|
|
354
377
|
font-weight: 400;
|
|
355
378
|
background-color: #fff;
|
|
356
|
-
font: unset;
|
|
357
379
|
height: 16px;
|
|
358
380
|
}
|
|
359
381
|
</style>
|
|
@@ -14,25 +14,23 @@
|
|
|
14
14
|
...style,
|
|
15
15
|
}
|
|
16
16
|
: style
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
v-if="autoVirtual"
|
|
17
|
+
">
|
|
18
|
+
<Empty v-if="isEmpty" />
|
|
19
|
+
<VirtualList
|
|
20
|
+
v-else-if="autoVirtual"
|
|
21
21
|
:height="state.height"
|
|
22
22
|
:pageSize="pageSize"
|
|
23
23
|
:data="flatData"
|
|
24
24
|
scroll-with-animation
|
|
25
25
|
showBackTop
|
|
26
|
-
scrollX
|
|
27
|
-
>
|
|
26
|
+
scrollX>
|
|
28
27
|
<template v-slot="{ list, start, itemsHeight, onSizeChange }">
|
|
29
28
|
<AutoSize
|
|
30
29
|
v-for="(item, index) in list"
|
|
31
30
|
:index="start + index"
|
|
32
31
|
:key="start + index"
|
|
33
32
|
:itemsHeight="itemsHeight"
|
|
34
|
-
:onSizeChange="onSizeChange"
|
|
35
|
-
>
|
|
33
|
+
:onSizeChange="onSizeChange">
|
|
36
34
|
<TreeNode
|
|
37
35
|
:data="data"
|
|
38
36
|
:rootPath="rootPath"
|
|
@@ -65,11 +63,10 @@
|
|
|
65
63
|
itemHeight && itemHeight !== 20
|
|
66
64
|
? { lineHeight: `${itemHeight}px` }
|
|
67
65
|
: {}
|
|
68
|
-
"
|
|
69
|
-
/>
|
|
66
|
+
" />
|
|
70
67
|
</AutoSize>
|
|
71
68
|
</template>
|
|
72
|
-
</
|
|
69
|
+
</VirtualList>
|
|
73
70
|
<template v-else>
|
|
74
71
|
<TreeNode
|
|
75
72
|
v-for="item in flatData"
|
|
@@ -105,11 +102,13 @@
|
|
|
105
102
|
itemHeight && itemHeight !== 20
|
|
106
103
|
? { lineHeight: `${itemHeight}px` }
|
|
107
104
|
: {}
|
|
108
|
-
"
|
|
109
|
-
/>
|
|
105
|
+
" />
|
|
110
106
|
</template>
|
|
111
107
|
|
|
112
|
-
<view
|
|
108
|
+
<view
|
|
109
|
+
v-if="showCopyAll && !isEmpty"
|
|
110
|
+
class="json-pretty-tree-copy"
|
|
111
|
+
@click="onCopyAll">
|
|
113
112
|
Copy All
|
|
114
113
|
</view>
|
|
115
114
|
</view>
|
|
@@ -121,20 +120,20 @@ import {
|
|
|
121
120
|
computed,
|
|
122
121
|
watchEffect,
|
|
123
122
|
watch,
|
|
124
|
-
defineEmits,
|
|
125
123
|
onMounted,
|
|
126
124
|
onUpdated,
|
|
127
125
|
onUnmounted,
|
|
128
126
|
} from 'vue';
|
|
129
127
|
import TreeNode from './components/TreeNode/index.vue';
|
|
130
128
|
|
|
131
|
-
import
|
|
132
|
-
import AutoSize from '../
|
|
129
|
+
import VirtualList from '../VirtualList/index.vue';
|
|
130
|
+
import AutoSize from '../VirtualList/AutoSize.vue';
|
|
133
131
|
|
|
134
132
|
import { emitError, jsonFlatten, cloneDeep, isFunction } from './utils';
|
|
135
133
|
|
|
136
|
-
import type { NodeDataType,
|
|
134
|
+
import type { NodeDataType, Tree } from './type';
|
|
137
135
|
import { setValueByPath } from '../../utils';
|
|
136
|
+
import Empty from '../Empty/index.vue';
|
|
138
137
|
|
|
139
138
|
// 定义 emits 类型
|
|
140
139
|
type Emits = {
|
|
@@ -281,9 +280,17 @@ const autoVirtual = computed(() => {
|
|
|
281
280
|
return false;
|
|
282
281
|
});
|
|
283
282
|
|
|
283
|
+
const isEmpty = computed(() => {
|
|
284
|
+
return (
|
|
285
|
+
!props.data ||
|
|
286
|
+
(Array.isArray(props.data) && props.data.length === 0) ||
|
|
287
|
+
(typeof props.data === 'object' && Object.keys(props.data).length === 0)
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
|
|
284
291
|
// 更新可见数据
|
|
285
292
|
// 优化 虚拟列表,每项高度自适应
|
|
286
|
-
const
|
|
293
|
+
const _updateVisibleData = (scrollTop: number = 0) => {
|
|
287
294
|
const flatDataValue = flatData.value ?? [];
|
|
288
295
|
if (autoVirtual.value) {
|
|
289
296
|
const visibleCount = props.height / props.itemHeight;
|
|
@@ -439,6 +446,13 @@ watch(
|
|
|
439
446
|
},
|
|
440
447
|
);
|
|
441
448
|
|
|
449
|
+
watch(
|
|
450
|
+
() => props.height,
|
|
451
|
+
(val) => {
|
|
452
|
+
state.height = val;
|
|
453
|
+
},
|
|
454
|
+
);
|
|
455
|
+
|
|
442
456
|
// 生命周期钩子
|
|
443
457
|
onMounted(() => {
|
|
444
458
|
// updateVisibleData();
|
|
@@ -455,12 +469,12 @@ onUnmounted(() => {
|
|
|
455
469
|
|
|
456
470
|
<style>
|
|
457
471
|
.json-pretty-tree {
|
|
458
|
-
/* theme color */
|
|
459
|
-
--json-pretty-color-primary: #9254de;
|
|
460
|
-
--json-pretty-color-info: #1d8ce0;
|
|
461
|
-
--json-pretty-color-error: #ff4d4f;
|
|
462
|
-
--json-pretty-color-success: #
|
|
463
|
-
--json-pretty-color-nil: #020201;
|
|
472
|
+
/* theme color - link to global theme variables */
|
|
473
|
+
--json-pretty-color-primary: var(--dev-tool-main-color, #9254de);
|
|
474
|
+
--json-pretty-color-info: var(--dev-tool-number-color, #1d8ce0);
|
|
475
|
+
--json-pretty-color-error: var(--dev-tool-error-color, #ff4d4f);
|
|
476
|
+
--json-pretty-color-success: var(--dev-tool-string-color, #888);
|
|
477
|
+
--json-pretty-color-nil: var(--dev-tool-nil-color, #020201);
|
|
464
478
|
|
|
465
479
|
/* field values color */
|
|
466
480
|
--json-pretty-color-string: var(--json-pretty-color-success);
|
|
@@ -470,17 +484,22 @@ onUnmounted(() => {
|
|
|
470
484
|
--json-pretty-color-undefined: var(--json-pretty-color-nil);
|
|
471
485
|
|
|
472
486
|
/* highlight */
|
|
473
|
-
--json-pretty-highlight-bg-color:
|
|
474
|
-
|
|
487
|
+
--json-pretty-highlight-bg-color: var(
|
|
488
|
+
--dev-tool-active-bg-color,
|
|
489
|
+
rgb(146 84 222 / 10%)
|
|
490
|
+
);
|
|
491
|
+
--json-pretty-highlight-bg-color-dark: var(
|
|
492
|
+
--dev-tool-active-bg-color,
|
|
493
|
+
#2e4558
|
|
494
|
+
);
|
|
475
495
|
|
|
476
496
|
/* comment */
|
|
477
|
-
--json-pretty-comment-color: #bfcbd9;
|
|
497
|
+
--json-pretty-comment-color: var(--dev-tool-note-color, #bfcbd9);
|
|
478
498
|
|
|
479
499
|
/* common border-color */
|
|
480
|
-
--json-pretty-border-color: #bfcbd9;
|
|
500
|
+
--json-pretty-border-color: var(--dev-tool-border-color, #bfcbd9);
|
|
481
501
|
|
|
482
|
-
font-family:
|
|
483
|
-
'Monaco', 'Menlo', 'Consolas', 'Bitstream Vera Sans Mono', monospace;
|
|
502
|
+
font-family: Monaco, Menlo, Consolas, 'Bitstream Vera Sans Mono', monospace;
|
|
484
503
|
font-size: v-bind(fontSize);
|
|
485
504
|
text-align: left;
|
|
486
505
|
overflow: auto;
|
|
@@ -496,12 +515,6 @@ onUnmounted(() => {
|
|
|
496
515
|
white-space: nowrap;
|
|
497
516
|
}
|
|
498
517
|
|
|
499
|
-
.dark {
|
|
500
|
-
/* 深色主题样式 */
|
|
501
|
-
--json-pretty-color-nil: #bfcbd9;
|
|
502
|
-
--json-pretty-color-undefined: var(--json-pretty-color-nil);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
518
|
.json-pretty-tree-copy {
|
|
506
519
|
padding: 0 12px;
|
|
507
520
|
position: absolute;
|
|
@@ -512,4 +525,14 @@ onUnmounted(() => {
|
|
|
512
525
|
border-radius: 4px;
|
|
513
526
|
background-color: var(--json-pretty-highlight-bg-color);
|
|
514
527
|
}
|
|
528
|
+
|
|
529
|
+
.json-pretty-empty {
|
|
530
|
+
display: flex;
|
|
531
|
+
align-items: center;
|
|
532
|
+
justify-content: center;
|
|
533
|
+
height: 100%;
|
|
534
|
+
color: #909399;
|
|
535
|
+
font-size: 14px;
|
|
536
|
+
min-height: 60px;
|
|
537
|
+
}
|
|
515
538
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
JSONDataType,
|
|
3
3
|
JSONFlattenOptions,
|
|
4
|
-
JSONFlattenReturnType
|
|
5
|
-
} from
|
|
4
|
+
JSONFlattenReturnType,
|
|
5
|
+
} from '../type';
|
|
6
6
|
|
|
7
7
|
export function emitError(message: string): void {
|
|
8
8
|
throw new Error(`[JsonPretty] ${message}`);
|
|
@@ -14,46 +14,46 @@ export function getDataType(value: unknown): string {
|
|
|
14
14
|
|
|
15
15
|
export function jsonFlatten(
|
|
16
16
|
data: JSONDataType,
|
|
17
|
-
path =
|
|
17
|
+
path = 'root',
|
|
18
18
|
level = 0,
|
|
19
|
-
options?: JSONFlattenOptions
|
|
19
|
+
options?: JSONFlattenOptions,
|
|
20
20
|
): JSONFlattenReturnType[] {
|
|
21
21
|
const {
|
|
22
22
|
key,
|
|
23
23
|
index,
|
|
24
|
-
type =
|
|
24
|
+
type = 'content',
|
|
25
25
|
showComma = false,
|
|
26
|
-
length = 1
|
|
26
|
+
length = 1,
|
|
27
27
|
} = options || ({} as JSONFlattenOptions);
|
|
28
28
|
const dataType = getDataType(data);
|
|
29
29
|
|
|
30
|
-
if (dataType ===
|
|
30
|
+
if (dataType === 'array') {
|
|
31
31
|
const inner = arrFlat(
|
|
32
32
|
(data as JSONDataType[]).map((item, idx, arr) =>
|
|
33
33
|
jsonFlatten(item, `${path}[${idx}]`, level + 1, {
|
|
34
34
|
index: idx,
|
|
35
35
|
showComma: idx !== arr.length - 1,
|
|
36
36
|
length,
|
|
37
|
-
type
|
|
38
|
-
})
|
|
39
|
-
)
|
|
37
|
+
type,
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
40
|
) as JSONFlattenReturnType[];
|
|
41
41
|
return [
|
|
42
|
-
jsonFlatten(
|
|
42
|
+
jsonFlatten('[', path, level, {
|
|
43
43
|
showComma: false,
|
|
44
44
|
key,
|
|
45
45
|
length: (data as unknown[]).length,
|
|
46
|
-
type:
|
|
47
|
-
})[0]
|
|
46
|
+
type: 'arrayStart',
|
|
47
|
+
})[0],
|
|
48
48
|
].concat(
|
|
49
49
|
inner,
|
|
50
|
-
jsonFlatten(
|
|
50
|
+
jsonFlatten(']', path, level, {
|
|
51
51
|
showComma,
|
|
52
52
|
length: (data as unknown[]).length,
|
|
53
|
-
type:
|
|
54
|
-
})[0]
|
|
53
|
+
type: 'arrayEnd',
|
|
54
|
+
})[0],
|
|
55
55
|
);
|
|
56
|
-
} else if (dataType ===
|
|
56
|
+
} else if (dataType === 'object') {
|
|
57
57
|
const keys = Object.keys(data as Record<string, JSONDataType>);
|
|
58
58
|
const inner = arrFlat(
|
|
59
59
|
keys.map((objKey, idx, arr) =>
|
|
@@ -67,45 +67,45 @@ export function jsonFlatten(
|
|
|
67
67
|
key: objKey,
|
|
68
68
|
showComma: idx !== arr.length - 1,
|
|
69
69
|
length,
|
|
70
|
-
type
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
)
|
|
70
|
+
type,
|
|
71
|
+
},
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
74
|
) as JSONFlattenReturnType[];
|
|
75
75
|
return [
|
|
76
|
-
jsonFlatten(
|
|
76
|
+
jsonFlatten('{', path, level, {
|
|
77
77
|
showComma: false,
|
|
78
78
|
key,
|
|
79
79
|
index,
|
|
80
80
|
length: keys.length,
|
|
81
|
-
type:
|
|
82
|
-
})[0]
|
|
81
|
+
type: 'objectStart',
|
|
82
|
+
})[0],
|
|
83
83
|
].concat(
|
|
84
84
|
inner,
|
|
85
|
-
jsonFlatten(
|
|
85
|
+
jsonFlatten('}', path, level, {
|
|
86
86
|
showComma,
|
|
87
87
|
length: keys.length,
|
|
88
|
-
type:
|
|
89
|
-
})[0]
|
|
88
|
+
type: 'objectEnd',
|
|
89
|
+
})[0],
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
return [
|
|
94
94
|
{
|
|
95
|
-
content: data as JSONFlattenReturnType[
|
|
95
|
+
content: data as JSONFlattenReturnType['content'],
|
|
96
96
|
level,
|
|
97
97
|
key,
|
|
98
98
|
index,
|
|
99
99
|
path,
|
|
100
100
|
showComma,
|
|
101
101
|
length,
|
|
102
|
-
type
|
|
103
|
-
}
|
|
102
|
+
type,
|
|
103
|
+
},
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export function arrFlat<T extends unknown[]>(arr: T): unknown[] {
|
|
108
|
-
if (typeof Array.prototype.flat ===
|
|
108
|
+
if (typeof Array.prototype.flat === 'function') {
|
|
109
109
|
return arr.flat();
|
|
110
110
|
}
|
|
111
111
|
const stack = [...arr];
|
|
@@ -121,14 +121,11 @@ export function arrFlat<T extends unknown[]>(arr: T): unknown[] {
|
|
|
121
121
|
return result;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
export function cloneDeep<T
|
|
125
|
-
source: T,
|
|
126
|
-
hash = new WeakMap()
|
|
127
|
-
): T {
|
|
124
|
+
export function cloneDeep<T>(source: T, hash = new WeakMap()): T {
|
|
128
125
|
if (source === null || source === undefined) return source;
|
|
129
126
|
if (source instanceof Date) return new Date(source) as T;
|
|
130
127
|
if (source instanceof RegExp) return new RegExp(source) as T;
|
|
131
|
-
if (typeof source !==
|
|
128
|
+
if (typeof source !== 'object') return source;
|
|
132
129
|
if (hash.get(source as Record<string, unknown>))
|
|
133
130
|
return hash.get(source as Record<string, unknown>);
|
|
134
131
|
|
|
@@ -147,18 +144,18 @@ export function cloneDeep<T extends unknown>(
|
|
|
147
144
|
|
|
148
145
|
export function stringToAutoType(source: string): unknown {
|
|
149
146
|
let value;
|
|
150
|
-
if (source ===
|
|
151
|
-
else if (source ===
|
|
152
|
-
else if (source ===
|
|
153
|
-
else if (source ===
|
|
147
|
+
if (source === 'null') value = null;
|
|
148
|
+
else if (source === 'undefined') value = undefined;
|
|
149
|
+
else if (source === 'true') value = true;
|
|
150
|
+
else if (source === 'false') value = false;
|
|
154
151
|
else if (
|
|
155
152
|
source[0] + source[source.length - 1] === '""' ||
|
|
156
153
|
source[0] + source[source.length - 1] === "''"
|
|
157
154
|
) {
|
|
158
155
|
value = source.slice(1, -1);
|
|
159
156
|
} else if (
|
|
160
|
-
(typeof Number(source) ===
|
|
161
|
-
source ===
|
|
157
|
+
(typeof Number(source) === 'number' && !isNaN(Number(source))) ||
|
|
158
|
+
source === 'NaN'
|
|
162
159
|
) {
|
|
163
160
|
value = Number(source);
|
|
164
161
|
} else {
|
|
@@ -167,6 +164,6 @@ export function stringToAutoType(source: string): unknown {
|
|
|
167
164
|
return value;
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
export function isFunction(value: unknown): value is
|
|
171
|
-
return typeof value ===
|
|
167
|
+
export function isFunction(value: unknown): value is (...args: any[]) => any {
|
|
168
|
+
return typeof value === 'function';
|
|
172
169
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<movable-area class="movable-area" :style="areaStyle">
|
|
3
|
+
<movable-view
|
|
4
|
+
class="movable-view"
|
|
5
|
+
:style="viewStyle"
|
|
6
|
+
:x="localX"
|
|
7
|
+
:y="localY"
|
|
8
|
+
direction="all"
|
|
9
|
+
@change="onChange">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</movable-view>
|
|
12
|
+
</movable-area>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { debounce } from '../../utils';
|
|
17
|
+
import { ref, computed, watch } from 'vue';
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(
|
|
20
|
+
defineProps<{
|
|
21
|
+
x?: number;
|
|
22
|
+
y?: number;
|
|
23
|
+
width?: string;
|
|
24
|
+
height?: string;
|
|
25
|
+
zIndex?: number;
|
|
26
|
+
customStyle?: Record<string, any>;
|
|
27
|
+
contentHeight?: number;
|
|
28
|
+
}>(),
|
|
29
|
+
{
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
width: '100px',
|
|
33
|
+
height: '100px',
|
|
34
|
+
zIndex: 1000,
|
|
35
|
+
contentHeight: 0,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const emit = defineEmits<{
|
|
40
|
+
(e: 'update:x', val: number): void;
|
|
41
|
+
(e: 'update:y', val: number): void;
|
|
42
|
+
(e: 'change', detail: any): void;
|
|
43
|
+
}>();
|
|
44
|
+
|
|
45
|
+
const localX = ref(props.x);
|
|
46
|
+
const localY = ref(props.y);
|
|
47
|
+
|
|
48
|
+
watch([() => props.x, () => props.y], ([newX, newY]) => {
|
|
49
|
+
if (newX !== undefined) localX.value = newX;
|
|
50
|
+
if (newY !== undefined) localY.value = newY;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const areaStyle = computed(() => {
|
|
54
|
+
const { _paddingBottom, paddingTop, ...rest } = (props.customStyle ||
|
|
55
|
+
{}) as any;
|
|
56
|
+
return {
|
|
57
|
+
...rest,
|
|
58
|
+
top: paddingTop || 0,
|
|
59
|
+
height: props.contentHeight + 'px',
|
|
60
|
+
position: 'fixed' as const,
|
|
61
|
+
left: 0,
|
|
62
|
+
width: '100vw',
|
|
63
|
+
pointerEvents: 'none' as const,
|
|
64
|
+
zIndex: props.zIndex,
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const viewStyle = computed(() => ({
|
|
69
|
+
width: props.width,
|
|
70
|
+
height: props.height,
|
|
71
|
+
pointerEvents: 'auto' as const,
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
const onChange = debounce((e: any) => {
|
|
75
|
+
localX.value = e.detail.x;
|
|
76
|
+
localY.value = e.detail.y;
|
|
77
|
+
emit('update:x', e.detail.x);
|
|
78
|
+
emit('update:y', e.detail.y);
|
|
79
|
+
emit('change', e);
|
|
80
|
+
}, 500);
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<style scoped>
|
|
84
|
+
.movable-area {
|
|
85
|
+
height: 100vh;
|
|
86
|
+
width: 100vw;
|
|
87
|
+
touch-action: none;
|
|
88
|
+
}
|
|
89
|
+
</style>
|