vite-uni-dev-tool 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/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.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -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/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.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/index.vue +531 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -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/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/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/{dev/components → dist/v3}/AppInfo/index.vue +0 -1
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.ts +49 -0
- package/{dev/components → dist/v3}/CloseButton/index.vue +5 -2
- package/{dev/components → dist/v3}/ConsoleList/ConsoleItem.vue +10 -9
- package/{dev/components → dist/v3}/ConsoleList/RunJSInput.vue +5 -2
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/{dev/components → dist/v3}/DevTool/index.vue +33 -4
- package/{dev/components → dist/v3}/DevToolWindow/index.vue +67 -4
- package/dist/v3/Empty/empty.png +0 -0
- package/{dev/components → dist/v3}/FilterInput/index.vue +5 -4
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
- package/{dev/components → dist/v3}/JsonPretty/index.vue +10 -10
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.ts +125 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/{dev/components → dist/v3}/NetworkList/NetworkDetail.vue +2 -2
- package/{dev/components → dist/v3}/NetworkList/NetworkItem.vue +2 -1
- package/dist/v3/RunJS/index.vue +128 -0
- package/{dev/components → dist/v3}/SettingList/index.vue +128 -37
- package/{dev/components → dist/v3}/SourceCode/index.vue +2 -2
- package/{dev/components → dist/v3}/Tag/index.vue +4 -4
- package/{dev/components → dist/v3}/UploadList/UploadDetail.vue +3 -15
- package/{dev/components → dist/v3}/UploadList/UploadItem.vue +1 -1
- package/dist/v3/VirtualListPro/readme.md +40 -0
- package/{dev/components → dist/v3}/WebSocket/WebSocketItem.vue +1 -1
- package/{dev/components → dist/v3}/WebSocket/WebSocketList.vue +3 -15
- package/package.json +5 -5
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/const.ts +0 -164
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -810
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -732
- package/dev/devToolInfo/index.ts +0 -26
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -291
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -51
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -77
- package/dev/utils/object.ts +0 -306
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
- /package/{dev/components → dist/v2}/AutoSizer/utils.ts +0 -0
- /package/{dev/components → dist/v2}/Empty/empty.png +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useClipboard.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useError.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/type.ts +0 -0
- /package/{dev/components → dist/v2}/RunJS/index.vue +0 -0
- /package/{dev/components → dist/v2}/VirtualListPro/readme.md +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index.vue +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index1.vue +0 -0
- /package/{dev/components → dist/v3}/CaptureScreen/index.vue +0 -0
- /package/{dev/components → dist/v3}/Connection/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/staticTips.ts +0 -0
- /package/{dev/components → dist/v3}/DevToolButton/index.vue +0 -0
- /package/{dev/components → dist/v3}/DevToolTitle/index.vue +0 -0
- /package/{dev/components → dist/v3}/DeviceInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Empty/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Brackets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Carets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/CheckController/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/TreeNode/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/utils/index.ts +0 -0
- /package/{dev/components → dist/v3}/NetworkList/index.vue +0 -0
- /package/{dev/components → dist/v3}/PiniaList/index.vue +0 -0
- /package/{dev/components → dist/v3}/RouteList/index.vue +0 -0
- /package/{dev/components → dist/v3}/StorageList/index.vue +0 -0
- /package/{dev/components → dist/v3}/SystemInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Tabs/index.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/UniEventItem.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/index.vue +0 -0
- /package/{dev/components → dist/v3}/UploadList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/AutoSize.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/index.vue +0 -0
- /package/{dev/components → dist/v3}/VuexList/index.vue +0 -0
- /package/{dev/components → dist/v3}/WebSocket/index.vue +0 -0
- /package/{dev/components → dist/v3}/WindowInfo/index.vue +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dev-tool">
|
|
3
|
+
<DevToolButton
|
|
4
|
+
v-if="devToolButtonVisible"
|
|
5
|
+
:buttonSize="buttonProps.buttonSize"
|
|
6
|
+
:buttonText="buttonProps.buttonText"
|
|
7
|
+
:buttonColor="buttonProps.buttonColor"
|
|
8
|
+
:buttonFontSize="buttonProps.buttonFontSize"
|
|
9
|
+
:buttonBackgroundColor="buttonProps.buttonBackgroundColor"
|
|
10
|
+
:zIndex="zIndex"
|
|
11
|
+
@click="onDevToolButtonClick"
|
|
12
|
+
/>
|
|
13
|
+
<DevToolWindow
|
|
14
|
+
:open="devToolWindowVisible"
|
|
15
|
+
:data="windowData"
|
|
16
|
+
:sourceFileServers="sourceFileServers"
|
|
17
|
+
:mode="mode"
|
|
18
|
+
:useDevSource="useDevSource"
|
|
19
|
+
:zIndex="zIndex + 1"
|
|
20
|
+
@close="onShowDevToolWindow(false)"
|
|
21
|
+
@sendMessage="onSendMessage"
|
|
22
|
+
/>
|
|
23
|
+
</view>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import DevToolButton from '../DevToolButton/index.vue';
|
|
28
|
+
import DevToolWindow from '../DevToolWindow/index.vue';
|
|
29
|
+
import { eventBus } from '../../core';
|
|
30
|
+
import {
|
|
31
|
+
DEV_BUTTON_VISIBLE,
|
|
32
|
+
DEV_WINDOW_VISIBLE,
|
|
33
|
+
DEV_WINDOW_MESSAGE,
|
|
34
|
+
DEV_WINDOW_OPEN,
|
|
35
|
+
DEV_WINDOW_CLOSE,
|
|
36
|
+
DEV_OPTION_GET,
|
|
37
|
+
DEV_OPTION_SEND,
|
|
38
|
+
} from '../../const';
|
|
39
|
+
import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
components: {
|
|
43
|
+
DevToolButton,
|
|
44
|
+
DevToolWindow,
|
|
45
|
+
},
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
isActive: false,
|
|
49
|
+
buttonProps: {
|
|
50
|
+
buttonSize: 50,
|
|
51
|
+
buttonText: '🐜',
|
|
52
|
+
buttonColor: '#fff',
|
|
53
|
+
buttonFontSize: '16px',
|
|
54
|
+
buttonBackgroundColor: 'rgba(255, 255, 255, 0)',
|
|
55
|
+
},
|
|
56
|
+
windowData: {},
|
|
57
|
+
devToolWindowVisible: false,
|
|
58
|
+
devToolButtonVisible: false,
|
|
59
|
+
sourceFileServers: [],
|
|
60
|
+
mode: '',
|
|
61
|
+
zIndex: 1000,
|
|
62
|
+
useDevSource: false,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
beforeMount() {
|
|
66
|
+
// 初始化状态
|
|
67
|
+
const {
|
|
68
|
+
devToolButtonVisible: showButton = false,
|
|
69
|
+
devToolWindowVisible: showWindow = false,
|
|
70
|
+
} = getDevToolInfo();
|
|
71
|
+
|
|
72
|
+
this.isActive = true;
|
|
73
|
+
this.devToolButtonVisible = showButton;
|
|
74
|
+
this.devToolWindowVisible = showWindow;
|
|
75
|
+
|
|
76
|
+
// 注册事件监听
|
|
77
|
+
eventBus.on(DEV_BUTTON_VISIBLE, this.onShowDevToolButton);
|
|
78
|
+
eventBus.on(DEV_WINDOW_VISIBLE, this.onShowDevToolWindow);
|
|
79
|
+
eventBus.on(DEV_OPTION_SEND, this.onDevOptionSend);
|
|
80
|
+
|
|
81
|
+
// 下一帧发送获取配置请求
|
|
82
|
+
this.$nextTick(() => {
|
|
83
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, { type: DEV_OPTION_GET, data: {} });
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
beforeUnmount() {
|
|
87
|
+
// 触发关闭事件并移除监听
|
|
88
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, {
|
|
89
|
+
type: DEV_WINDOW_CLOSE,
|
|
90
|
+
data: {},
|
|
91
|
+
});
|
|
92
|
+
eventBus.off(DEV_BUTTON_VISIBLE, this.onShowDevToolButton);
|
|
93
|
+
eventBus.off(DEV_WINDOW_VISIBLE, this.onShowDevToolWindow);
|
|
94
|
+
},
|
|
95
|
+
onShow() {
|
|
96
|
+
this.isActive = true;
|
|
97
|
+
const {
|
|
98
|
+
devToolButtonVisible: showButton = false,
|
|
99
|
+
devToolWindowVisible: showWindow = false,
|
|
100
|
+
} = getDevToolInfo();
|
|
101
|
+
|
|
102
|
+
this.devToolWindowVisible = showWindow;
|
|
103
|
+
this.devToolButtonVisible = showButton;
|
|
104
|
+
|
|
105
|
+
// 如果窗口可见,触发打开事件
|
|
106
|
+
if (this.devToolWindowVisible) {
|
|
107
|
+
this.onSendMessage({
|
|
108
|
+
type: DEV_WINDOW_OPEN,
|
|
109
|
+
data: {},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
onHide() {
|
|
114
|
+
this.isActive = false;
|
|
115
|
+
this.devToolWindowVisible = false;
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
onDevToolButtonClick() {
|
|
119
|
+
this.onShowDevToolWindow(true);
|
|
120
|
+
this.onSendMessage({
|
|
121
|
+
type: DEV_WINDOW_OPEN,
|
|
122
|
+
data: {},
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
onShowDevToolButton(show) {
|
|
126
|
+
if (!this.isActive) return;
|
|
127
|
+
const { devToolButtonVisible: showButton = false } = getDevToolInfo();
|
|
128
|
+
this.devToolButtonVisible = show ?? showButton;
|
|
129
|
+
},
|
|
130
|
+
onShowDevToolWindow(show) {
|
|
131
|
+
if (!this.isActive) return;
|
|
132
|
+
|
|
133
|
+
this.devToolWindowVisible = show;
|
|
134
|
+
setDevToolInfo({
|
|
135
|
+
devToolWindowVisible: show,
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
onSendMessage(param) {
|
|
139
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, param);
|
|
140
|
+
},
|
|
141
|
+
onDevOptionSend(options) {
|
|
142
|
+
if (options) {
|
|
143
|
+
// 更新按钮配置
|
|
144
|
+
this.buttonProps.buttonSize = options.buttonSize ?? 50;
|
|
145
|
+
this.buttonProps.buttonText = options.buttonText ?? '🐜';
|
|
146
|
+
this.buttonProps.buttonColor = options.buttonColor ?? '#fff';
|
|
147
|
+
this.buttonProps.buttonFontSize = options.buttonFontSize ?? '16px';
|
|
148
|
+
this.buttonProps.buttonBackgroundColor =
|
|
149
|
+
options.buttonBackgroundColor ?? 'rgba(255, 255, 255, 0)';
|
|
150
|
+
|
|
151
|
+
// 更新其他配置
|
|
152
|
+
this.sourceFileServers = options.sourceFileServers ?? [];
|
|
153
|
+
this.mode = options.mode ?? '';
|
|
154
|
+
this.useDevSource = options.useDevSource ?? false;
|
|
155
|
+
this.zIndex = options.zIndex ?? 1000;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<style scoped></style>
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
ref="buttonRef"
|
|
4
|
+
class="dev-tool-button"
|
|
5
|
+
:style="{
|
|
6
|
+
fontSize: buttonFontSize,
|
|
7
|
+
backgroundColor: buttonBackgroundColor,
|
|
8
|
+
color: buttonColor,
|
|
9
|
+
width: buttonSize + 'px',
|
|
10
|
+
height: buttonSize + 'px',
|
|
11
|
+
cursor: isDragging ? 'move' : 'pointer',
|
|
12
|
+
zIndex: zIndex,
|
|
13
|
+
...buttonPosition,
|
|
14
|
+
}"
|
|
15
|
+
@touchstart="onTouchStart"
|
|
16
|
+
@touchmove="onTouchMove"
|
|
17
|
+
@touchend="onTouchEnd"
|
|
18
|
+
@mousedown="onMouseDown"
|
|
19
|
+
>
|
|
20
|
+
{{ buttonText }}
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
props: {
|
|
29
|
+
buttonSize: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 50,
|
|
32
|
+
},
|
|
33
|
+
buttonText: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: '',
|
|
36
|
+
},
|
|
37
|
+
buttonColor: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: '#fff',
|
|
40
|
+
},
|
|
41
|
+
buttonFontSize: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '16px',
|
|
44
|
+
},
|
|
45
|
+
buttonBackgroundColor: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: 'rgba(255, 255, 255, 0)',
|
|
48
|
+
},
|
|
49
|
+
zIndex: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 1000,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
data() {
|
|
56
|
+
return {
|
|
57
|
+
buttonPosition: {
|
|
58
|
+
left: '',
|
|
59
|
+
top: '',
|
|
60
|
+
transition: 'none',
|
|
61
|
+
},
|
|
62
|
+
isDragging: false,
|
|
63
|
+
page: { pageX: 0, pageY: 0 },
|
|
64
|
+
startTime: 0,
|
|
65
|
+
timer: null,
|
|
66
|
+
mouseUpTimer: null,
|
|
67
|
+
windowWidth: 0,
|
|
68
|
+
windowHeight: 0,
|
|
69
|
+
sizeHalf: 0,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
computed: {
|
|
74
|
+
isTouchDevice() {
|
|
75
|
+
return typeof window !== 'undefined' && 'ontouchstart' in window;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
mounted() {
|
|
80
|
+
const sysInfo = uni.getSystemInfoSync();
|
|
81
|
+
this.windowWidth = sysInfo.windowWidth;
|
|
82
|
+
this.windowHeight = sysInfo.windowHeight;
|
|
83
|
+
this.sizeHalf = this.buttonSize / 2;
|
|
84
|
+
|
|
85
|
+
// 初始化位置
|
|
86
|
+
const { left, top } = getDevToolInfo();
|
|
87
|
+
this.buttonPosition.left =
|
|
88
|
+
left || this.windowWidth - this.buttonSize + 'px';
|
|
89
|
+
this.buttonPosition.top = top || '80vh';
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
onShow() {
|
|
93
|
+
// H5 环境下注册鼠标事件
|
|
94
|
+
// #ifdef H5
|
|
95
|
+
window.addEventListener('mousemove', this.onMouseMove);
|
|
96
|
+
window.addEventListener('mouseup', this.onMouseUp);
|
|
97
|
+
window.addEventListener('resize', this.onResize);
|
|
98
|
+
// #endif
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
onHide() {
|
|
102
|
+
// #ifdef H5
|
|
103
|
+
window.removeEventListener('mousemove', this.onMouseMove);
|
|
104
|
+
window.removeEventListener('mouseup', this.onMouseUp);
|
|
105
|
+
window.removeEventListener('resize', this.onResize);
|
|
106
|
+
// #endif
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
methods: {
|
|
110
|
+
onTouchStart(touch) {
|
|
111
|
+
touch.stopPropagation();
|
|
112
|
+
this.page.pageX = touch.touches?.[0]?.pageX;
|
|
113
|
+
this.page.pageY = touch.touches?.[0]?.pageY;
|
|
114
|
+
this.startTime = Date.now();
|
|
115
|
+
this.buttonPosition.transition = 'none';
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
onTouchMove(touch) {
|
|
119
|
+
touch?.preventDefault?.();
|
|
120
|
+
touch?.stopPropagation?.();
|
|
121
|
+
if (!this.page) return;
|
|
122
|
+
if (Date.now() - this.startTime < 150) return;
|
|
123
|
+
|
|
124
|
+
if (this.mouseUpTimer) {
|
|
125
|
+
clearTimeout(this.mouseUpTimer);
|
|
126
|
+
}
|
|
127
|
+
this.updatePosition(
|
|
128
|
+
touch.touches[0].pageX,
|
|
129
|
+
touch.touches[0].pageY,
|
|
130
|
+
this.isTouchDevice,
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
onTouchEnd(e) {
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
if (Date.now() - this.startTime < 100) {
|
|
137
|
+
this.$emit('click');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.mouseUpTimer) {
|
|
141
|
+
clearTimeout(this.mouseUpTimer);
|
|
142
|
+
}
|
|
143
|
+
this.mouseUpTimer = setTimeout(() => {
|
|
144
|
+
this.onResize();
|
|
145
|
+
}, 3000);
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
onMouseDown(event) {
|
|
149
|
+
if (this.isTouchDevice) return;
|
|
150
|
+
this.page.pageX = event.pageX;
|
|
151
|
+
this.page.pageY = event.pageY;
|
|
152
|
+
this.startTime = Date.now();
|
|
153
|
+
this.isDragging = true;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
this.buttonPosition.transition = 'none';
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
onMouseMove(event) {
|
|
160
|
+
if (!this.isDragging) return;
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
const mouseX = event.pageX;
|
|
163
|
+
const mouseY = event.pageY;
|
|
164
|
+
if (this.mouseUpTimer) {
|
|
165
|
+
clearTimeout(this.mouseUpTimer);
|
|
166
|
+
}
|
|
167
|
+
this.updatePosition(mouseX, mouseY);
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
onMouseUp() {
|
|
171
|
+
this.isDragging = false;
|
|
172
|
+
if (Date.now() - this.startTime < 150) {
|
|
173
|
+
this.$emit('click');
|
|
174
|
+
}
|
|
175
|
+
if (this.mouseUpTimer) {
|
|
176
|
+
clearTimeout(this.mouseUpTimer);
|
|
177
|
+
}
|
|
178
|
+
this.mouseUpTimer = setTimeout(() => {
|
|
179
|
+
this.onResize();
|
|
180
|
+
}, 3000);
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
onResize() {
|
|
184
|
+
const { windowWidth } = uni.getSystemInfoSync();
|
|
185
|
+
|
|
186
|
+
this.buttonPosition.transition = 'all 0.3s ease-in-out';
|
|
187
|
+
this.buttonPosition.left = windowWidth - this.buttonSize + 'px';
|
|
188
|
+
|
|
189
|
+
if (this.timer) {
|
|
190
|
+
clearTimeout(this.timer);
|
|
191
|
+
}
|
|
192
|
+
this.timer = setTimeout(() => {
|
|
193
|
+
this.buttonPosition.transition = 'none';
|
|
194
|
+
setDevToolInfo({
|
|
195
|
+
left: this.buttonPosition.left,
|
|
196
|
+
top: this.buttonPosition.top,
|
|
197
|
+
});
|
|
198
|
+
}, 350);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
updatePosition(x, y, isTouch = false) {
|
|
202
|
+
// 限制 Y 轴位置
|
|
203
|
+
if (y - this.sizeHalf > 0 && y < this.windowHeight - this.sizeHalf) {
|
|
204
|
+
if (isTouch) {
|
|
205
|
+
this.buttonPosition.top = y + this.sizeHalf + 'px';
|
|
206
|
+
} else {
|
|
207
|
+
this.buttonPosition.top = y - this.sizeHalf + 'px';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// 限制 X 轴位置
|
|
211
|
+
if (x - this.sizeHalf > 0 && x < this.windowWidth - this.sizeHalf) {
|
|
212
|
+
this.buttonPosition.left = x - this.sizeHalf + 'px';
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
</script>
|
|
218
|
+
|
|
219
|
+
<style scoped>
|
|
220
|
+
.dev-tool-button {
|
|
221
|
+
position: fixed;
|
|
222
|
+
display: flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
justify-content: center;
|
|
225
|
+
border-radius: 50%;
|
|
226
|
+
cursor: pointer;
|
|
227
|
+
}
|
|
228
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dev-tool-title" :style="innerStyle"> <slot /> </view>
|
|
3
|
+
</template>
|
|
4
|
+
<script>
|
|
5
|
+
export default {
|
|
6
|
+
props: {
|
|
7
|
+
innerStyle: {
|
|
8
|
+
type: [Object, String],
|
|
9
|
+
default: () => ({}),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
<style scoped>
|
|
15
|
+
.dev-tool-title {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
height: 32px;
|
|
19
|
+
}
|
|
20
|
+
.dev-tool-title::before {
|
|
21
|
+
content: '';
|
|
22
|
+
margin-right: 8px;
|
|
23
|
+
width: 2px;
|
|
24
|
+
height: 18px;
|
|
25
|
+
border-radius: 2px;
|
|
26
|
+
background-color: var(--dev-tool-main-color);
|
|
27
|
+
}
|
|
28
|
+
</style>
|