vite-uni-dev-tool 0.0.1
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 +120 -0
- package/dev/components/Button/index.vue +34 -0
- package/dev/components/Checkbox/index.vue +40 -0
- package/dev/components/CloseButton/index.vue +25 -0
- package/dev/components/Connection/index.vue +98 -0
- package/dev/components/ConsoleList/ConsoleItem.vue +89 -0
- package/dev/components/ConsoleList/index.vue +98 -0
- package/dev/components/DevTool/index.vue +165 -0
- package/dev/components/DevToolButton/index.vue +213 -0
- package/dev/components/DevToolWindow/index.vue +847 -0
- package/dev/components/DeviceInfo/index.vue +32 -0
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +28 -0
- package/dev/components/FilterInput/index.vue +86 -0
- package/dev/components/JsonPretty/components/Brackets/index.vue +23 -0
- package/dev/components/JsonPretty/components/Carets/index.vue +63 -0
- package/dev/components/JsonPretty/components/CheckController/index.vue +108 -0
- package/dev/components/JsonPretty/components/TreeNode/index.vue +348 -0
- package/dev/components/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dev/components/JsonPretty/hooks/useError.ts +21 -0
- package/dev/components/JsonPretty/index.vue +463 -0
- package/dev/components/JsonPretty/type.ts +123 -0
- package/dev/components/JsonPretty/utils/index.ts +172 -0
- package/dev/components/NetworkList/NetworkDetail.vue +197 -0
- package/dev/components/NetworkList/NetworkItem.vue +106 -0
- package/dev/components/NetworkList/index.vue +108 -0
- package/dev/components/PiniaList/index.vue +64 -0
- package/dev/components/RouteList/index.vue +98 -0
- package/dev/components/SettingList/index.vue +235 -0
- package/dev/components/StorageList/index.vue +170 -0
- package/dev/components/SystemInfo/index.vue +34 -0
- package/dev/components/Tabs/index.vue +110 -0
- package/dev/components/Tag/index.vue +89 -0
- package/dev/components/UploadList/UploadDetail.vue +208 -0
- package/dev/components/UploadList/UploadItem.vue +111 -0
- package/dev/components/UploadList/index.vue +94 -0
- package/dev/components/VuexList/index.vue +54 -0
- package/dev/components/WebSocket/WebSocketItem.vue +98 -0
- package/dev/components/WebSocket/WebSocketList.vue +176 -0
- package/dev/components/WebSocket/index.vue +99 -0
- package/dev/components/WindowInfo/index.vue +33 -0
- package/dev/const.ts +95 -0
- package/dev/core.ts +103 -0
- package/dev/devConsole/index.ts +334 -0
- package/dev/devEvent/index.ts +665 -0
- package/dev/devIntercept/index.ts +629 -0
- package/dev/devStore/index.ts +581 -0
- package/dev/index.d.ts +6 -0
- package/dev/index.d.ts.map +1 -0
- package/dev/index.js +1 -0
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +66 -0
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dev/plugins/uniDevTool/uniDevTool.js +13 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +28 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -0
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +5 -0
- package/dev/shims-uni.d.ts +43 -0
- package/dev/type.ts +188 -0
- package/dev/utils/date.ts +75 -0
- package/dev/utils/file.ts +121 -0
- package/dev/utils/function.ts +192 -0
- package/dev/utils/index.ts +25 -0
- package/dev/utils/ip.ts +79 -0
- package/dev/utils/language.ts +19 -0
- package/dev/utils/object.ts +235 -0
- package/dev/utils/page.ts +13 -0
- package/dev/utils/string.ts +23 -0
- package/dev/utils/utils.ts +198 -0
- package/package.json +34 -0
|
@@ -0,0 +1,213 @@
|
|
|
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: NodeJS.Timeout | 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: NodeJS.Timeout | 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: 9999;
|
|
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>
|