vite-uni-dev-tool 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -1
- 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 +15 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
- package/dev/components/ConsoleList/RunJSInput.vue +0 -235
- package/dev/components/ConsoleList/index.vue +0 -130
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -182
- package/dev/components/DevToolButton/index.vue +0 -213
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1037
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -474
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -197
- package/dev/components/NetworkList/NetworkItem.vue +0 -106
- package/dev/components/NetworkList/index.vue +0 -115
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -110
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -225
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -124
- package/dev/components/UniEvent/index.vue +0 -94
- package/dev/components/UploadList/UploadDetail.vue +0 -208
- package/dev/components/UploadList/UploadItem.vue +0 -111
- package/dev/components/UploadList/index.vue +0 -104
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -175
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -98
- package/dev/components/WebSocket/WebSocketList.vue +0 -176
- package/dev/components/WebSocket/index.vue +0 -111
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -166
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -806
- 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 -718
- 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 -264
- 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 -46
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -72
- package/dev/utils/object.ts +0 -298
- 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
|
@@ -1,182 +0,0 @@
|
|
|
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
|
-
@click="onDevToolButtonClick"
|
|
11
|
-
/>
|
|
12
|
-
<DevToolWindow
|
|
13
|
-
:open="devToolWindowVisible"
|
|
14
|
-
:data="windowData"
|
|
15
|
-
:sourceFileServers="sourceFileServers"
|
|
16
|
-
:mode="mode"
|
|
17
|
-
:useDevSource="useDevSource"
|
|
18
|
-
@close="onShowDevToolWindow(false)"
|
|
19
|
-
@sendMessage="onSendMessage"
|
|
20
|
-
/>
|
|
21
|
-
<!-- <view class="devTool-canvas">
|
|
22
|
-
<canvas canvas-id="fullscreenCanvas" id="fullscreenCanvas" />
|
|
23
|
-
</view> -->
|
|
24
|
-
</view>
|
|
25
|
-
</template>
|
|
26
|
-
<script lang="ts" setup>
|
|
27
|
-
import { onShow, onHide, onUnload, onLoad } from '@dcloudio/uni-app';
|
|
28
|
-
import { reactive, ref, nextTick } from 'vue';
|
|
29
|
-
import DevToolButton from '../DevToolButton/index.vue';
|
|
30
|
-
import DevToolWindow from '../DevToolWindow/index.vue';
|
|
31
|
-
import { eventBus } from '../../core';
|
|
32
|
-
|
|
33
|
-
import {
|
|
34
|
-
EVENT_DEV_BUTTON,
|
|
35
|
-
EVENT_DEV_WINDOW,
|
|
36
|
-
DEV_WINDOW_MESSAGE,
|
|
37
|
-
DEV_WINDOW_OPEN,
|
|
38
|
-
DEV_WINDOW_CLOSE,
|
|
39
|
-
DEV_OPTION_GET,
|
|
40
|
-
DEV_OPTION_SEND,
|
|
41
|
-
} from '../../const';
|
|
42
|
-
import type { DevTool } from '../../type';
|
|
43
|
-
|
|
44
|
-
let isActive = false;
|
|
45
|
-
|
|
46
|
-
const buttonProps = reactive({
|
|
47
|
-
buttonSize: 50,
|
|
48
|
-
buttonText: '🐜',
|
|
49
|
-
buttonColor: '#fff',
|
|
50
|
-
buttonFontSize: '16px',
|
|
51
|
-
buttonBackgroundColor: 'rgba(255, 255, 255, 0)',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const windowData = ref<DevTool.WindowData>({});
|
|
55
|
-
|
|
56
|
-
const devToolWindowVisible = ref(false);
|
|
57
|
-
const devToolButtonVisible = ref(false);
|
|
58
|
-
|
|
59
|
-
const sourceFileServers = ref<string[]>([]);
|
|
60
|
-
|
|
61
|
-
const mode = ref<string>();
|
|
62
|
-
|
|
63
|
-
const useDevSource = ref(false);
|
|
64
|
-
|
|
65
|
-
function onDevToolButtonClick() {
|
|
66
|
-
onShowDevToolWindow(true);
|
|
67
|
-
onSendMessage({
|
|
68
|
-
type: DEV_WINDOW_OPEN,
|
|
69
|
-
data: {},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function onShowDevToolButton(show: boolean) {
|
|
74
|
-
if (!isActive) return;
|
|
75
|
-
devToolButtonVisible.value = show ?? uni.getStorageSync(EVENT_DEV_BUTTON);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function onShowDevToolWindow(show: boolean) {
|
|
79
|
-
if (!isActive) return;
|
|
80
|
-
|
|
81
|
-
devToolWindowVisible.value = show;
|
|
82
|
-
uni.setStorageSync(EVENT_DEV_WINDOW, show);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function onSendMessage(param: { type: string; data: Record<string, any> }) {
|
|
86
|
-
eventBus.emit(DEV_WINDOW_MESSAGE, param);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function onDevOptionSend(options: DevTool.DevToolOptions) {
|
|
90
|
-
if (options) {
|
|
91
|
-
buttonProps.buttonSize = options.buttonSize ?? 50;
|
|
92
|
-
buttonProps.buttonText = options.buttonText ?? '🐜';
|
|
93
|
-
buttonProps.buttonColor = options.buttonColor ?? '#fff';
|
|
94
|
-
buttonProps.buttonFontSize = options.buttonFontSize ?? '16px';
|
|
95
|
-
buttonProps.buttonBackgroundColor =
|
|
96
|
-
options.buttonBackgroundColor ?? 'rgba(255, 255, 255, 0)';
|
|
97
|
-
|
|
98
|
-
sourceFileServers.value = options.sourceFileServers ?? [];
|
|
99
|
-
|
|
100
|
-
mode.value = options.mode ?? '';
|
|
101
|
-
|
|
102
|
-
useDevSource.value = options.useDevSource ?? false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
onLoad(() => {
|
|
107
|
-
// 共享状态
|
|
108
|
-
|
|
109
|
-
const show = uni.getStorageSync(EVENT_DEV_WINDOW) || false;
|
|
110
|
-
|
|
111
|
-
isActive = true;
|
|
112
|
-
devToolButtonVisible.value = uni.getStorageSync(EVENT_DEV_BUTTON) || false;
|
|
113
|
-
devToolWindowVisible.value = show;
|
|
114
|
-
eventBus.on(EVENT_DEV_BUTTON, onShowDevToolButton);
|
|
115
|
-
eventBus.on(EVENT_DEV_WINDOW, onShowDevToolWindow);
|
|
116
|
-
eventBus.on(DEV_OPTION_SEND, onDevOptionSend);
|
|
117
|
-
|
|
118
|
-
nextTick(() => {
|
|
119
|
-
eventBus.emit(DEV_WINDOW_MESSAGE, { type: DEV_OPTION_GET, data: {} });
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
onUnload(() => {
|
|
124
|
-
eventBus.emit(DEV_WINDOW_MESSAGE, {
|
|
125
|
-
type: DEV_WINDOW_CLOSE,
|
|
126
|
-
data: {},
|
|
127
|
-
});
|
|
128
|
-
eventBus.off(EVENT_DEV_BUTTON, onShowDevToolButton);
|
|
129
|
-
eventBus.off(EVENT_DEV_WINDOW, onShowDevToolWindow);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
onShow(() => {
|
|
133
|
-
isActive = true;
|
|
134
|
-
devToolWindowVisible.value = uni.getStorageSync(EVENT_DEV_WINDOW) || false;
|
|
135
|
-
devToolButtonVisible.value = uni.getStorageSync(EVENT_DEV_BUTTON) || false;
|
|
136
|
-
if (devToolWindowVisible.value) {
|
|
137
|
-
onSendMessage({
|
|
138
|
-
type: DEV_WINDOW_OPEN,
|
|
139
|
-
data: {},
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
onHide(() => {
|
|
144
|
-
isActive = false;
|
|
145
|
-
devToolWindowVisible.value = false;
|
|
146
|
-
});
|
|
147
|
-
</script>
|
|
148
|
-
<style scoped>
|
|
149
|
-
.dev-tool {
|
|
150
|
-
--dev-tool-main-color: #9254de;
|
|
151
|
-
--dev-tool-border-color: #f0f0f0;
|
|
152
|
-
--dev-tool-normal-bg-color: #f9f9f9;
|
|
153
|
-
--dev-tool-warn-color: #ffa940;
|
|
154
|
-
--dev-tool-warn-bg-color: #fff7e6;
|
|
155
|
-
--dev-tool-error-color: #ff4d4f;
|
|
156
|
-
--dev-tool-error-bg-color: #fff1f0;
|
|
157
|
-
--dev-tool-success-color: #bae637;
|
|
158
|
-
--dev-tool-success-bg-color: #fcffe6;
|
|
159
|
-
|
|
160
|
-
--dev-tool-base-font-size: 12px;
|
|
161
|
-
--dev-tool-tag-font-size: 10px;
|
|
162
|
-
--dev-tool-tips-font-size: 10px;
|
|
163
|
-
font-size: 12px;
|
|
164
|
-
|
|
165
|
-
-webkit-tap-highlight-color: transparent;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.dev-tool-canvas {
|
|
169
|
-
position: fixed;
|
|
170
|
-
z-index: -1000;
|
|
171
|
-
top: 0;
|
|
172
|
-
left: 0;
|
|
173
|
-
width: 100vw;
|
|
174
|
-
height: 100vh;
|
|
175
|
-
opacity: 0;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
#fullscreenCanvas {
|
|
179
|
-
width: 100vw;
|
|
180
|
-
height: 100vh;
|
|
181
|
-
}
|
|
182
|
-
</style>
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
ref="buttonRef"
|
|
4
|
-
class="dev-tool-button"
|
|
5
|
-
:style="{
|
|
6
|
-
fontSize: props.buttonFontSize,
|
|
7
|
-
backgroundColor: props.buttonBackgroundColor,
|
|
8
|
-
color: props.buttonColor,
|
|
9
|
-
width: props.buttonSize + 'px',
|
|
10
|
-
height: props.buttonSize + 'px',
|
|
11
|
-
cursor: isDragging ? 'move' : 'pointer',
|
|
12
|
-
...buttonPosition,
|
|
13
|
-
}"
|
|
14
|
-
@touchstart="onTouchStart"
|
|
15
|
-
@touchmove="onTouchMove"
|
|
16
|
-
@touchend="onTouchEnd"
|
|
17
|
-
@mousedown="onMouseDown"
|
|
18
|
-
>
|
|
19
|
-
{{ buttonText }}
|
|
20
|
-
</view>
|
|
21
|
-
</template>
|
|
22
|
-
<script lang="ts" setup>
|
|
23
|
-
import { onShow, onHide } from '@dcloudio/uni-app';
|
|
24
|
-
import { ref, computed, reactive, onMounted } from 'vue';
|
|
25
|
-
import { DEV_BUTTON_INFO } from '../../const';
|
|
26
|
-
|
|
27
|
-
const emit = defineEmits<{ (e: 'click'): void }>();
|
|
28
|
-
const props = withDefaults(
|
|
29
|
-
defineProps<{
|
|
30
|
-
buttonSize?: number;
|
|
31
|
-
buttonText?: string;
|
|
32
|
-
buttonColor?: string;
|
|
33
|
-
buttonFontSize?: string;
|
|
34
|
-
buttonBackgroundColor?: string;
|
|
35
|
-
}>(),
|
|
36
|
-
{ buttonSize: 50 },
|
|
37
|
-
);
|
|
38
|
-
const sizeHalf = props.buttonSize / 2;
|
|
39
|
-
|
|
40
|
-
let page: { pageX: number; pageY: number } = { pageX: 0, pageY: 0 };
|
|
41
|
-
let startTime = 0;
|
|
42
|
-
|
|
43
|
-
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
|
|
44
|
-
// const buttonRef = ref();
|
|
45
|
-
const buttonPosition = reactive({
|
|
46
|
-
left: windowWidth - props.buttonSize + 'px',
|
|
47
|
-
top: '80vh',
|
|
48
|
-
transition: 'none',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const isTouchDevice = computed(() => {
|
|
52
|
-
return typeof window !== 'undefined' && 'ontouchstart' in window;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
function onTouchStart(touch: TouchEvent) {
|
|
56
|
-
page.pageX = touch.touches?.[0]?.pageX;
|
|
57
|
-
page.pageY = touch.touches?.[0]?.pageY;
|
|
58
|
-
startTime = Date.now();
|
|
59
|
-
buttonPosition.transition = 'none';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function onTouchMove(touch: TouchEvent) {
|
|
63
|
-
touch?.preventDefault?.();
|
|
64
|
-
touch?.stopPropagation?.();
|
|
65
|
-
if (!page) return;
|
|
66
|
-
if (Date.now() - startTime < 150) return;
|
|
67
|
-
|
|
68
|
-
if (mouseUpTimer) {
|
|
69
|
-
clearTimeout(mouseUpTimer);
|
|
70
|
-
}
|
|
71
|
-
updatePosition(
|
|
72
|
-
touch.touches[0].pageX,
|
|
73
|
-
touch.touches[0].pageY,
|
|
74
|
-
isTouchDevice.value,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function onTouchEnd() {
|
|
79
|
-
if (Date.now() - startTime < 100) {
|
|
80
|
-
emit('click');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (mouseUpTimer) {
|
|
84
|
-
clearTimeout(mouseUpTimer);
|
|
85
|
-
}
|
|
86
|
-
mouseUpTimer = setTimeout(() => {
|
|
87
|
-
onResize();
|
|
88
|
-
}, 3000);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
let isDragging = ref(false); // 是否开始拖拽
|
|
92
|
-
|
|
93
|
-
// 鼠标事件处理
|
|
94
|
-
function onMouseDown(event: MouseEvent) {
|
|
95
|
-
if (isTouchDevice.value) return;
|
|
96
|
-
page.pageX = event.pageX;
|
|
97
|
-
page.pageY = event.pageY;
|
|
98
|
-
startTime = Date.now();
|
|
99
|
-
isDragging.value = true; // 开始鼠标按下时标记为拖拽状态
|
|
100
|
-
event.preventDefault(); // 防止选中内容
|
|
101
|
-
event.stopPropagation(); // 防止事件冒泡
|
|
102
|
-
buttonPosition.transition = 'none';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
let timer: number | null = null;
|
|
106
|
-
function onResize() {
|
|
107
|
-
const { windowWidth } = uni.getSystemInfoSync();
|
|
108
|
-
|
|
109
|
-
buttonPosition.transition = 'all 0.3s ease-in-out';
|
|
110
|
-
buttonPosition.left = windowWidth - props.buttonSize + 'px';
|
|
111
|
-
if (timer) {
|
|
112
|
-
clearTimeout(timer);
|
|
113
|
-
}
|
|
114
|
-
timer = setTimeout(() => {
|
|
115
|
-
buttonPosition.transition = 'none';
|
|
116
|
-
|
|
117
|
-
uni.setStorageSync(DEV_BUTTON_INFO, {
|
|
118
|
-
left: buttonPosition.left,
|
|
119
|
-
top: buttonPosition.top,
|
|
120
|
-
});
|
|
121
|
-
}, 350);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
onMounted(() => {
|
|
125
|
-
const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
|
|
126
|
-
left: windowWidth - props.buttonSize + 'px',
|
|
127
|
-
top: '80vh',
|
|
128
|
-
};
|
|
129
|
-
buttonPosition.left = left;
|
|
130
|
-
buttonPosition.top = top;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
onShow(() => {
|
|
134
|
-
const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
|
|
135
|
-
left: windowWidth - props.buttonSize + 'px',
|
|
136
|
-
top: '80vh',
|
|
137
|
-
};
|
|
138
|
-
buttonPosition.left = left;
|
|
139
|
-
buttonPosition.top = top;
|
|
140
|
-
|
|
141
|
-
// #ifdef H5
|
|
142
|
-
window.addEventListener('mousemove', onMouseMove);
|
|
143
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
144
|
-
window.addEventListener('resize', onResize);
|
|
145
|
-
// #endif
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
onHide(() => {
|
|
149
|
-
// #ifdef H5
|
|
150
|
-
window.removeEventListener('mousemove', onMouseMove);
|
|
151
|
-
window.removeEventListener('mouseup', onMouseUp);
|
|
152
|
-
window.removeEventListener('resize', onResize);
|
|
153
|
-
// #endif
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
function onMouseMove(event: MouseEvent) {
|
|
157
|
-
if (!isDragging.value) return; // 不是拖拽状态则不处理
|
|
158
|
-
event.preventDefault(); // 防止默认行为
|
|
159
|
-
const mouseX = event.pageX;
|
|
160
|
-
const mouseY = event.pageY;
|
|
161
|
-
if (mouseUpTimer) {
|
|
162
|
-
clearTimeout(mouseUpTimer);
|
|
163
|
-
}
|
|
164
|
-
updatePosition(mouseX, mouseY);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let mouseUpTimer: number | null = null;
|
|
168
|
-
function onMouseUp() {
|
|
169
|
-
isDragging.value = false; // 鼠标释放时取消拖拽状态
|
|
170
|
-
if (Date.now() - startTime < 150) {
|
|
171
|
-
emit('click');
|
|
172
|
-
}
|
|
173
|
-
if (mouseUpTimer) {
|
|
174
|
-
clearTimeout(mouseUpTimer);
|
|
175
|
-
}
|
|
176
|
-
mouseUpTimer = setTimeout(() => {
|
|
177
|
-
onResize();
|
|
178
|
-
}, 3000);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 统一的位置更新函数
|
|
182
|
-
function updatePosition(x: number, y: number, isTouch = false) {
|
|
183
|
-
if (y - sizeHalf > 0 && y < windowHeight - sizeHalf) {
|
|
184
|
-
if (isTouch) {
|
|
185
|
-
buttonPosition.top = y + sizeHalf + 'px';
|
|
186
|
-
} else {
|
|
187
|
-
buttonPosition.top = y - sizeHalf + 'px';
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (x - sizeHalf > 0 && x < windowWidth - sizeHalf) {
|
|
191
|
-
buttonPosition.left = x - sizeHalf + 'px';
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
</script>
|
|
195
|
-
<style scoped>
|
|
196
|
-
.dev-tool-button {
|
|
197
|
-
position: fixed;
|
|
198
|
-
z-index: 1000;
|
|
199
|
-
top: 80vh;
|
|
200
|
-
right: 0;
|
|
201
|
-
display: flex;
|
|
202
|
-
align-items: center;
|
|
203
|
-
justify-content: center;
|
|
204
|
-
|
|
205
|
-
width: 50px;
|
|
206
|
-
height: 50px;
|
|
207
|
-
border-radius: 50%;
|
|
208
|
-
font-size: 16px;
|
|
209
|
-
|
|
210
|
-
background-color: rgba(255, 255, 255, 0);
|
|
211
|
-
cursor: pointer;
|
|
212
|
-
}
|
|
213
|
-
</style>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="dev-tool-title" :style="style"> <slot /> </view>
|
|
3
|
-
</template>
|
|
4
|
-
<script lang="ts" setup>
|
|
5
|
-
defineProps<{ style?: any }>();
|
|
6
|
-
</script>
|
|
7
|
-
<style scoped>
|
|
8
|
-
.dev-tool-title {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
height: 32px;
|
|
12
|
-
}
|
|
13
|
-
.dev-tool-title::before {
|
|
14
|
-
content: '';
|
|
15
|
-
margin-right: 8px;
|
|
16
|
-
width: 2px;
|
|
17
|
-
height: 18px;
|
|
18
|
-
border-radius: 2px;
|
|
19
|
-
background-color: var(--dev-tool-main-color);
|
|
20
|
-
}
|
|
21
|
-
</style>
|