vite-uni-dev-tool 1.0.0 → 1.1.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 +46 -0
- package/dist/const.cjs +1 -1
- package/dist/const.d.ts +12 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +1 -1
- package/dist/core-shared.d.ts +1 -1
- package/dist/core-shared.d.ts.map +1 -1
- package/dist/core-shared.js +1 -1
- package/dist/core.d.ts +10 -3
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2 -2
- package/dist/i18n/locales/en.cjs +1 -1
- package/dist/i18n/locales/en.d.ts +81 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.cjs +1 -1
- package/dist/i18n/locales/zh-Hans.d.ts +82 -1
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/modules/devConsole/index.cjs +1 -1
- package/dist/modules/devConsole/index.js +3 -3
- package/dist/modules/devEvent/index.cjs +3 -3
- package/dist/modules/devEvent/index.d.ts +1 -0
- package/dist/modules/devEvent/index.d.ts.map +1 -1
- package/dist/modules/devEvent/index.js +3 -3
- package/dist/modules/devIntercept/index.cjs +14 -13
- package/dist/modules/devIntercept/index.d.ts +19 -0
- package/dist/modules/devIntercept/index.d.ts.map +1 -1
- package/dist/modules/devIntercept/index.js +14 -13
- package/dist/modules/devStore/index.cjs +1 -1
- package/dist/modules/devStore/index.d.ts +21 -0
- package/dist/modules/devStore/index.d.ts.map +1 -1
- package/dist/modules/devStore/index.js +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.js +1 -1
- package/dist/type.d.ts +47 -2
- package/dist/type.d.ts.map +1 -1
- package/dist/utils/language.cjs +1 -1
- package/dist/utils/language.d.ts.map +1 -1
- package/dist/utils/language.js +1 -1
- package/dist/utils/object.cjs +1 -1
- package/dist/utils/object.d.ts.map +1 -1
- package/dist/utils/object.js +1 -1
- package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -0
- package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -0
- package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -0
- package/dist/v3/{CaptureScreen → DevTool/components/CaptureScreen}/index.vue +109 -109
- package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/ConsoleItem.vue +225 -224
- package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/RunJSInput.vue +247 -249
- package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/index.vue +171 -160
- package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/staticTips.ts +1145 -1145
- package/dist/v3/{DevToolButton → DevTool/components/DevToolButton}/index.vue +7 -4
- package/dist/v3/{DevToolTitle → DevTool/components/DevToolTitle}/index.vue +24 -24
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/DevToolOverlay.vue +197 -182
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/const.ts +28 -5
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/dataUtils.ts +48 -48
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolData.ts +387 -338
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolHandlers.ts +629 -549
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolOverlay.ts +197 -184
- package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.vue +67 -16
- package/dist/v3/{ElEvent → DevTool/components/ElEvent}/ElEventItem.vue +105 -105
- package/dist/v3/{ElEvent → DevTool/components/ElEvent}/index.vue +106 -109
- package/dist/v3/{Instance → DevTool/components/Instance}/components/InstanceTreeNode.vue +265 -265
- package/dist/v3/{Instance → DevTool/components/Instance}/flatten.ts +226 -226
- package/dist/v3/{Instance → DevTool/components/Instance}/index.vue +94 -94
- package/dist/v3/{Instance → DevTool/components/Instance}/registry.ts +49 -49
- package/dist/v3/{Instance → DevTool/components/Instance}/transformTree.ts +375 -375
- package/dist/v3/{Instance → DevTool/components/Instance}/transformTreeCtx.ts +268 -268
- package/dist/v3/{Instance → DevTool/components/Instance}/typing.d.ts +43 -43
- package/dist/v3/{InstanceDetail → DevTool/components/InstanceDetail}/index.vue +485 -485
- package/dist/v3/{JsonDetail → DevTool/components/JsonDetail}/index.vue +70 -70
- package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCItem.vue +112 -113
- package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCTool.vue +454 -478
- package/dist/v3/{NFCList → DevTool/components/NFCList}/const.ts +56 -56
- package/dist/v3/{NFCList → DevTool/components/NFCList}/index.vue +94 -98
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptConfig.vue +624 -608
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptItem.vue +140 -140
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkDetail.vue +287 -296
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkIntercept.vue +88 -93
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkItem.vue +163 -167
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkSend.vue +589 -556
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/const.ts +4 -4
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/hooks/useNetworkForm.ts +86 -86
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/index.vue +160 -160
- package/dist/v3/{NetworkList → DevTool/components/NetworkList}/utils.ts +101 -101
- package/dist/v3/{Performance → DevTool/components/Performance}/index.vue +498 -495
- package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceMetrics.vue +153 -153
- package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceWidget.vue +12 -9
- package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceChart.ts +460 -460
- package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceData.ts +258 -258
- package/dist/v3/{PiniaList → DevTool/components/PiniaList}/index.vue +93 -94
- package/dist/v3/{RouteList → DevTool/components/RouteList}/index.vue +21 -24
- package/dist/v3/{RunJS → DevTool/components/RunJS}/index.vue +148 -148
- package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/ScanCodeItem.vue +97 -98
- package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/index.vue +100 -104
- package/dist/v3/{SettingButton → DevTool/components/SettingButton}/index.vue +45 -45
- package/dist/v3/{SettingList → DevTool/components/SettingList}/index.vue +218 -150
- package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -0
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingDevTool.vue +212 -208
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingInfo.vue +157 -119
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLanguage.vue +74 -74
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLog.vue +230 -230
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingNetwork.vue +3 -3
- package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingTheme.vue +37 -7
- package/dist/v3/{SettingList → DevTool/components/SettingList}/typing.d.ts +2 -2
- package/dist/v3/{SourceCode → DevTool/components/SourceCode}/Line.vue +127 -116
- package/dist/v3/{SourceCode → DevTool/components/SourceCode}/index.vue +8 -8
- package/dist/v3/{SourceCode → DevTool/components/SourceCode}/parseCode.ts +609 -701
- package/dist/v3/{StorageList → DevTool/components/StorageList}/index.vue +174 -174
- package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferDetail.vue +268 -268
- package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferItem.vue +4 -4
- package/dist/v3/{TransferList → DevTool/components/TransferList}/index.vue +8 -8
- package/dist/v3/{UniEvent → DevTool/components/UniEvent}/UniEventItem.vue +6 -7
- package/dist/v3/{UniEvent → DevTool/components/UniEvent}/index.vue +6 -6
- package/dist/v3/{VuexList → DevTool/components/VuexList}/index.vue +84 -84
- package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketDetail.vue +8 -8
- package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketItem.vue +4 -4
- package/dist/v3/{WebSocket → DevTool/components/WebSocket}/index.vue +8 -8
- package/dist/v3/DevTool/index.vue +179 -5
- package/dist/v3/{AppTransition → components/AppTransition}/index.vue +176 -170
- package/dist/v3/{AutoSizer → components/AutoSizer}/index.vue +192 -192
- package/dist/v3/{AutoSizer → components/AutoSizer}/index1.vue +184 -184
- package/dist/v3/{AutoSizer → components/AutoSizer}/utils.ts +49 -49
- package/dist/v3/components/Barrage/BarrageItem.vue +137 -0
- package/dist/v3/components/Barrage/index.vue +202 -0
- package/dist/v3/{CircularButton → components/CircularButton}/index.vue +84 -84
- package/dist/v3/{CustomSwiper → components/CustomSwiper}/CustomSwiperItem.vue +49 -49
- package/dist/v3/{CustomSwiper → components/CustomSwiper}/index.vue +104 -104
- package/dist/v3/{DraggableContainer → components/DraggableContainer}/index.vue +1 -1
- package/dist/v3/{Empty → components/Empty}/index.vue +29 -29
- package/dist/v3/{FilterInput → components/FilterInput}/index.vue +1 -1
- package/dist/v3/{FilterSelect → components/FilterSelect}/index.vue +179 -179
- package/dist/v3/{JsonPretty → components/JsonPretty}/components/Brackets/index.vue +27 -27
- package/dist/v3/{JsonPretty → components/JsonPretty}/components/Carets/index.vue +59 -59
- package/dist/v3/{JsonPretty → components/JsonPretty}/components/CheckController/index.vue +136 -136
- package/dist/v3/{JsonPretty → components/JsonPretty}/components/TreeNode/index.vue +387 -381
- package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useClipboard.ts +21 -21
- package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useError.ts +21 -21
- package/dist/v3/{JsonPretty → components/JsonPretty}/index.vue +16 -13
- package/dist/v3/{JsonPretty → components/JsonPretty}/type.ts +127 -126
- package/dist/v3/{JsonPretty → components/JsonPretty}/utils/index.ts +169 -169
- package/dist/v3/{MovableContainer → components/MovableContainer}/index.vue +1 -1
- package/dist/v3/{Pick → components/Pick}/index.vue +322 -322
- package/dist/v3/{Tabs → components/Tabs}/index.vue +30 -4
- package/dist/v3/{Tag → components/Tag}/index.vue +113 -113
- package/dist/v3/{VirtualList → components/VirtualList}/AutoSize.vue +40 -40
- package/dist/v3/{VirtualList → components/VirtualList}/index.vue +416 -412
- package/dist/v3/hooks/useBluetooth/index.ts +561 -0
- package/dist/v3/hooks/useContainerStyle.ts +153 -153
- package/dist/v3/hooks/useNFC/index.ts +107 -107
- package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
- package/dist/v3/hooks/useNFC/utils.ts +754 -754
- package/dist/v3/hooks/useRequest/index.ts +586 -573
- package/dist/v3/hooks/useRequest/utils.ts +267 -267
- package/dist/v3/hooks/useScanCode/index.ts +206 -206
- package/dist/v3/hooks/useWebsocket/README.md +79 -0
- package/dist/v3/hooks/useWebsocket/index.ts +253 -0
- package/dist/v3/styles/theme.css +17 -10
- package/dist/v3/styles/theme.ts +12 -12
- package/package.json +59 -64
- package/dist/plugins/uniParseStock/index.d.ts +0 -10
- package/dist/plugins/uniParseStock/index.d.ts.map +0 -1
- /package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.css +0 -0
- /package/dist/v3/{SettingList → DevTool/components/SettingList}/index.css +0 -0
- /package/dist/v3/{Empty → components/Empty}/empty.png +0 -0
- /package/dist/v3/{VirtualList → components/VirtualList}/readme.md +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="actualVisible"
|
|
4
|
+
class="barrage-container"
|
|
5
|
+
:style="{ zIndex: props.zIndex }">
|
|
6
|
+
<BarrageItem
|
|
7
|
+
v-for="item in items"
|
|
8
|
+
:key="item.id"
|
|
9
|
+
:text="item.text"
|
|
10
|
+
:type="item.type"
|
|
11
|
+
:top="item.top"
|
|
12
|
+
:duration="item.duration"
|
|
13
|
+
:delay="item.delay"
|
|
14
|
+
:maxLength="props.maxLength"
|
|
15
|
+
@remove="removeItem(item.id)" />
|
|
16
|
+
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { ref, onMounted, watch, computed } from 'vue';
|
|
21
|
+
import { onShow, onHide } from '@dcloudio/uni-app';
|
|
22
|
+
import BarrageItem from './BarrageItem.vue';
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(
|
|
25
|
+
defineProps<{
|
|
26
|
+
maxTracks?: number;
|
|
27
|
+
trackHeight?: number;
|
|
28
|
+
startTop?: number;
|
|
29
|
+
duration?: number;
|
|
30
|
+
maxLength?: number;
|
|
31
|
+
visible?: boolean;
|
|
32
|
+
zIndex?: number;
|
|
33
|
+
}>(),
|
|
34
|
+
{
|
|
35
|
+
maxTracks: 10,
|
|
36
|
+
trackHeight: 36,
|
|
37
|
+
startTop: 40,
|
|
38
|
+
duration: 6,
|
|
39
|
+
maxLength: 100,
|
|
40
|
+
visible: true,
|
|
41
|
+
zIndex: 10000,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const actualVisible = computed(() => props.visible);
|
|
46
|
+
|
|
47
|
+
const items = ref<
|
|
48
|
+
{
|
|
49
|
+
id: number;
|
|
50
|
+
text: string;
|
|
51
|
+
type: string;
|
|
52
|
+
top: number;
|
|
53
|
+
duration: number;
|
|
54
|
+
delay: number;
|
|
55
|
+
}[]
|
|
56
|
+
>([]);
|
|
57
|
+
let nextId = 0;
|
|
58
|
+
|
|
59
|
+
// 页面是否在前台(用于防止页面隐藏时弹幕堆积)
|
|
60
|
+
let isPageActive = true;
|
|
61
|
+
|
|
62
|
+
// 记录每个轨道的最后一条弹幕开始的时间 + 安全间隔
|
|
63
|
+
const laneNextAvailableTime = ref<number[]>(new Array(props.maxTracks).fill(0));
|
|
64
|
+
const laneLastWidth = ref<number[]>(new Array(props.maxTracks).fill(0));
|
|
65
|
+
|
|
66
|
+
watch(
|
|
67
|
+
() => props.maxTracks,
|
|
68
|
+
(val: number) => {
|
|
69
|
+
laneNextAvailableTime.value = new Array(val).fill(0);
|
|
70
|
+
laneLastWidth.value = new Array(val).fill(0);
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const screenWidth = ref(375);
|
|
75
|
+
|
|
76
|
+
function getBestLane(
|
|
77
|
+
text: string,
|
|
78
|
+
duration: number,
|
|
79
|
+
): { index: number; delay: number } {
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
const chineseCount = (text.match(/[\u4e00-\u9fa5]/g) || []).length;
|
|
82
|
+
const emojiCount = (
|
|
83
|
+
text.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|\u2600-\u27BF/g) || []
|
|
84
|
+
).length;
|
|
85
|
+
const otherCount = text.length - chineseCount - emojiCount;
|
|
86
|
+
const estimatedWidth =
|
|
87
|
+
chineseCount * 14 + emojiCount * 20 + otherCount * 8 + 80;
|
|
88
|
+
|
|
89
|
+
let bestLane = 0;
|
|
90
|
+
let minStartTime = Infinity;
|
|
91
|
+
|
|
92
|
+
for (let i = 0; i < props.maxTracks; i++) {
|
|
93
|
+
const nextCanStart = laneNextAvailableTime.value[i] || 0;
|
|
94
|
+
if (nextCanStart <= now) {
|
|
95
|
+
bestLane = i;
|
|
96
|
+
minStartTime = now;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (nextCanStart < minStartTime) {
|
|
100
|
+
minStartTime = nextCanStart;
|
|
101
|
+
bestLane = i;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const startTime = Math.max(now, minStartTime);
|
|
106
|
+
const delay = startTime - now;
|
|
107
|
+
const lastWidth = laneLastWidth.value[bestLane] || 0;
|
|
108
|
+
const s = screenWidth.value || 375;
|
|
109
|
+
|
|
110
|
+
const enterTimeNew =
|
|
111
|
+
(estimatedWidth / ((s + estimatedWidth) / duration)) * 1000;
|
|
112
|
+
const enterTimePrev = (lastWidth / ((s + lastWidth) / duration)) * 1000;
|
|
113
|
+
const safeInterval = Math.max(enterTimeNew, enterTimePrev) + 300;
|
|
114
|
+
|
|
115
|
+
laneNextAvailableTime.value[bestLane] = startTime + safeInterval;
|
|
116
|
+
laneLastWidth.value[bestLane] = estimatedWidth;
|
|
117
|
+
|
|
118
|
+
return { index: bestLane, delay };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 添加一条弹幕 (通用接口)
|
|
123
|
+
* @param text 文字内容
|
|
124
|
+
* @param type 类型,用于区分颜色样式
|
|
125
|
+
*/
|
|
126
|
+
function add(text: string, type: string = 'log') {
|
|
127
|
+
if (!isPageActive || !actualVisible.value) return;
|
|
128
|
+
|
|
129
|
+
const id = nextId++;
|
|
130
|
+
const duration = props.duration;
|
|
131
|
+
|
|
132
|
+
let finalText = text;
|
|
133
|
+
if (finalText.length > props.maxLength) {
|
|
134
|
+
finalText = finalText.slice(0, props.maxLength) + '...';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const { index: laneIndex, delay } = getBestLane(finalText, duration);
|
|
138
|
+
const top = props.startTop + laneIndex * props.trackHeight;
|
|
139
|
+
|
|
140
|
+
items.value.push({
|
|
141
|
+
id,
|
|
142
|
+
text: finalText,
|
|
143
|
+
type,
|
|
144
|
+
top,
|
|
145
|
+
duration,
|
|
146
|
+
delay,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function removeItem(id: number) {
|
|
151
|
+
const index = items.value.findIndex((item) => item.id === id);
|
|
152
|
+
if (index !== -1) {
|
|
153
|
+
items.value.splice(index, 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 清空弹幕
|
|
159
|
+
*/
|
|
160
|
+
function clear() {
|
|
161
|
+
items.value = [];
|
|
162
|
+
laneNextAvailableTime.value = new Array(props.maxTracks).fill(0);
|
|
163
|
+
laneLastWidth.value = new Array(props.maxTracks).fill(0);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onMounted(() => {
|
|
167
|
+
try {
|
|
168
|
+
const sys = uni.getSystemInfoSync();
|
|
169
|
+
if (sys.windowWidth) screenWidth.value = sys.windowWidth;
|
|
170
|
+
} catch (_err) {
|
|
171
|
+
// 降级使用 375 默认宽度
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
onShow(() => {
|
|
176
|
+
isPageActive = true;
|
|
177
|
+
clear();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
onHide(() => {
|
|
181
|
+
isPageActive = false;
|
|
182
|
+
items.value = [];
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
defineExpose({
|
|
186
|
+
add,
|
|
187
|
+
clear,
|
|
188
|
+
});
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<style scoped>
|
|
192
|
+
.barrage-container {
|
|
193
|
+
position: fixed;
|
|
194
|
+
top: 0;
|
|
195
|
+
left: 0;
|
|
196
|
+
width: 100%;
|
|
197
|
+
height: 100%;
|
|
198
|
+
pointer-events: none;
|
|
199
|
+
z-index: 10000;
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
}
|
|
202
|
+
</style>
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="circular-button"
|
|
4
|
-
:style="[computedStyle, customStyle]"
|
|
5
|
-
@click="onClick">
|
|
6
|
-
<slot>{{ text }}</slot>
|
|
7
|
-
</view>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script lang="ts" setup>
|
|
11
|
-
import { computed } from 'vue';
|
|
12
|
-
|
|
13
|
-
const props = withDefaults(
|
|
14
|
-
defineProps<{
|
|
15
|
-
text?: string;
|
|
16
|
-
customStyle?: string | Record<string, any>;
|
|
17
|
-
size?: string | number;
|
|
18
|
-
type?: 'default' | 'primary' | 'warn' | 'error';
|
|
19
|
-
}>(),
|
|
20
|
-
{
|
|
21
|
-
text: '',
|
|
22
|
-
size: '22px',
|
|
23
|
-
type: 'default',
|
|
24
|
-
},
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const emit = defineEmits<{
|
|
28
|
-
(e: 'click', event: MouseEvent | TouchEvent): void;
|
|
29
|
-
}>();
|
|
30
|
-
|
|
31
|
-
const computedStyle = computed(() => {
|
|
32
|
-
const sizeValue =
|
|
33
|
-
typeof props.size === 'number' ? `${props.size}px` : props.size;
|
|
34
|
-
return {
|
|
35
|
-
width: sizeValue,
|
|
36
|
-
height: sizeValue,
|
|
37
|
-
fontSize: `calc(${sizeValue} * 0.6)`,
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
function onClick(e: MouseEvent | TouchEvent) {
|
|
42
|
-
emit('click', e);
|
|
43
|
-
}
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<style scoped>
|
|
47
|
-
.circular-button {
|
|
48
|
-
flex-shrink: 0;
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
border-radius: 50%;
|
|
53
|
-
border: 1px solid var(--dev-tool-border-color);
|
|
54
|
-
box-sizing: border-box;
|
|
55
|
-
color: var(--dev-tool-text-color);
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
user-select: none;
|
|
58
|
-
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
59
|
-
pointer-events: auto;
|
|
60
|
-
background-color: transparent;
|
|
61
|
-
line-height: 1;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* Hover state - using active bg color for consistency */
|
|
65
|
-
@media (hover: hover) {
|
|
66
|
-
.circular-button:hover {
|
|
67
|
-
background-color: var(--dev-tool-active-bg-color);
|
|
68
|
-
border-color: var(--dev-tool-text-color);
|
|
69
|
-
opacity: 0.9;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.circular-button:active {
|
|
74
|
-
transform: scale(0.85);
|
|
75
|
-
background-color: var(--dev-tool-active-bg-color);
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Different types if needed */
|
|
80
|
-
.circular-button-primary {
|
|
81
|
-
color: var(--dev-tool-main-color);
|
|
82
|
-
border-color: var(--dev-tool-main-color);
|
|
83
|
-
}
|
|
84
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="circular-button"
|
|
4
|
+
:style="[computedStyle, customStyle]"
|
|
5
|
+
@click="onClick">
|
|
6
|
+
<slot>{{ text }}</slot>
|
|
7
|
+
</view>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { computed } from 'vue';
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(
|
|
14
|
+
defineProps<{
|
|
15
|
+
text?: string;
|
|
16
|
+
customStyle?: string | Record<string, any>;
|
|
17
|
+
size?: string | number;
|
|
18
|
+
type?: 'default' | 'primary' | 'warn' | 'error';
|
|
19
|
+
}>(),
|
|
20
|
+
{
|
|
21
|
+
text: '',
|
|
22
|
+
size: '22px',
|
|
23
|
+
type: 'default',
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{
|
|
28
|
+
(e: 'click', event: MouseEvent | TouchEvent): void;
|
|
29
|
+
}>();
|
|
30
|
+
|
|
31
|
+
const computedStyle = computed(() => {
|
|
32
|
+
const sizeValue =
|
|
33
|
+
typeof props.size === 'number' ? `${props.size}px` : props.size;
|
|
34
|
+
return {
|
|
35
|
+
width: sizeValue,
|
|
36
|
+
height: sizeValue,
|
|
37
|
+
fontSize: `calc(${sizeValue} * 0.6)`,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function onClick(e: MouseEvent | TouchEvent) {
|
|
42
|
+
emit('click', e);
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<style scoped>
|
|
47
|
+
.circular-button {
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
border: 1px solid var(--dev-tool-border-color);
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
color: var(--dev-tool-text-color);
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
user-select: none;
|
|
58
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
59
|
+
pointer-events: auto;
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
line-height: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Hover state - using active bg color for consistency */
|
|
65
|
+
@media (hover: hover) {
|
|
66
|
+
.circular-button:hover {
|
|
67
|
+
background-color: var(--dev-tool-active-bg-color);
|
|
68
|
+
border-color: var(--dev-tool-text-color);
|
|
69
|
+
opacity: 0.9;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.circular-button:active {
|
|
74
|
+
transform: scale(0.85);
|
|
75
|
+
background-color: var(--dev-tool-active-bg-color);
|
|
76
|
+
opacity: 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Different types if needed */
|
|
80
|
+
.circular-button-primary {
|
|
81
|
+
color: var(--dev-tool-main-color);
|
|
82
|
+
border-color: var(--dev-tool-main-color);
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="custom-swiper-item" :style="customStyle">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
export default {
|
|
9
|
-
options: {
|
|
10
|
-
virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
defineProps<{
|
|
17
|
-
customStyle?: string | Record<string, any>;
|
|
18
|
-
}>();
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<style scoped>
|
|
22
|
-
.custom-swiper-item {
|
|
23
|
-
flex-shrink: 0;
|
|
24
|
-
width: 100%;
|
|
25
|
-
height: 100%;
|
|
26
|
-
overflow-y: auto;
|
|
27
|
-
box-sizing: border-box;
|
|
28
|
-
|
|
29
|
-
/* 解决模糊问题 */
|
|
30
|
-
backface-visibility: hidden;
|
|
31
|
-
transform: translateZ(0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* #ifdef H5 || APP-PLUS */
|
|
35
|
-
.custom-swiper-item::-webkit-scrollbar {
|
|
36
|
-
display: none;
|
|
37
|
-
width: 0;
|
|
38
|
-
height: 0;
|
|
39
|
-
background-color: transparent;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.custom-swiper-item::-webkit-scrollbar-thumb {
|
|
43
|
-
width: 0;
|
|
44
|
-
height: 0;
|
|
45
|
-
background-color: transparent;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* #endif */
|
|
49
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="custom-swiper-item" :style="customStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
options: {
|
|
10
|
+
virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
defineProps<{
|
|
17
|
+
customStyle?: string | Record<string, any>;
|
|
18
|
+
}>();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
.custom-swiper-item {
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
overflow-y: auto;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
|
|
29
|
+
/* 解决模糊问题 */
|
|
30
|
+
backface-visibility: hidden;
|
|
31
|
+
transform: translateZ(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* #ifdef H5 || APP-PLUS */
|
|
35
|
+
.custom-swiper-item::-webkit-scrollbar {
|
|
36
|
+
display: none;
|
|
37
|
+
width: 0;
|
|
38
|
+
height: 0;
|
|
39
|
+
background-color: transparent;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.custom-swiper-item::-webkit-scrollbar-thumb {
|
|
43
|
+
width: 0;
|
|
44
|
+
height: 0;
|
|
45
|
+
background-color: transparent;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* #endif */
|
|
49
|
+
</style>
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="custom-swiper"
|
|
4
|
-
@touchstart="onTouchStart"
|
|
5
|
-
@touchend="onTouchEnd"
|
|
6
|
-
@mousedown="onMouseDown"
|
|
7
|
-
@mouseup="onMouseUp"
|
|
8
|
-
@mouseleave="onMouseLeave">
|
|
9
|
-
<view class="custom-swiper-wrapper" :style="wrapperStyle">
|
|
10
|
-
<slot></slot>
|
|
11
|
-
</view>
|
|
12
|
-
</view>
|
|
13
|
-
</template>
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
export default {
|
|
16
|
-
options: {
|
|
17
|
-
virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
</script>
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { computed, ref } from 'vue';
|
|
23
|
-
|
|
24
|
-
const props = defineProps<{
|
|
25
|
-
modelValue: number;
|
|
26
|
-
itemCount: number;
|
|
27
|
-
}>();
|
|
28
|
-
|
|
29
|
-
const emit = defineEmits<{
|
|
30
|
-
(e: 'update:modelValue', value: number): void;
|
|
31
|
-
(e: 'change', value: number): void;
|
|
32
|
-
}>();
|
|
33
|
-
|
|
34
|
-
const touchStart = ref({ x: 0, y: 0 });
|
|
35
|
-
|
|
36
|
-
const isDragging = ref(false);
|
|
37
|
-
|
|
38
|
-
const wrapperStyle = computed(() => ({
|
|
39
|
-
transform: `translateX(-${props.modelValue * 100}%)`,
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
// 统一处理滑动逻辑
|
|
43
|
-
function handleSwipe(deltaX: number, deltaY: number) {
|
|
44
|
-
if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
45
|
-
if (deltaX > 0 && props.modelValue > 0) {
|
|
46
|
-
const next = props.modelValue - 1;
|
|
47
|
-
emit('update:modelValue', next);
|
|
48
|
-
emit('change', next);
|
|
49
|
-
} else if (deltaX < 0 && props.modelValue < props.itemCount - 1) {
|
|
50
|
-
const next = props.modelValue + 1;
|
|
51
|
-
emit('update:modelValue', next);
|
|
52
|
-
emit('change', next);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 触摸事件处理
|
|
58
|
-
function onTouchStart(e: TouchEvent) {
|
|
59
|
-
const touch = e.touches[0];
|
|
60
|
-
touchStart.value = { x: touch.clientX, y: touch.clientY };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function onTouchEnd(e: TouchEvent) {
|
|
64
|
-
const touch = e.changedTouches[0];
|
|
65
|
-
const deltaX = touch.clientX - touchStart.value.x;
|
|
66
|
-
const deltaY = touch.clientY - touchStart.value.y;
|
|
67
|
-
handleSwipe(deltaX, deltaY);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 鼠标事件处理
|
|
71
|
-
function onMouseDown(e: MouseEvent) {
|
|
72
|
-
isDragging.value = true;
|
|
73
|
-
touchStart.value = { x: e.clientX, y: e.clientY };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function onMouseUp(e: MouseEvent) {
|
|
77
|
-
if (!isDragging.value) return;
|
|
78
|
-
isDragging.value = false;
|
|
79
|
-
const deltaX = e.clientX - touchStart.value.x;
|
|
80
|
-
const deltaY = e.clientY - touchStart.value.y;
|
|
81
|
-
handleSwipe(deltaX, deltaY);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function onMouseLeave() {
|
|
85
|
-
isDragging.value = false;
|
|
86
|
-
}
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<style scoped>
|
|
90
|
-
.custom-swiper {
|
|
91
|
-
width: 100%;
|
|
92
|
-
height: 100%;
|
|
93
|
-
overflow: hidden;
|
|
94
|
-
position: relative;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.custom-swiper-wrapper {
|
|
98
|
-
display: flex;
|
|
99
|
-
width: 100%;
|
|
100
|
-
height: 100%;
|
|
101
|
-
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
102
|
-
will-change: transform;
|
|
103
|
-
}
|
|
104
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="custom-swiper"
|
|
4
|
+
@touchstart="onTouchStart"
|
|
5
|
+
@touchend="onTouchEnd"
|
|
6
|
+
@mousedown="onMouseDown"
|
|
7
|
+
@mouseup="onMouseUp"
|
|
8
|
+
@mouseleave="onMouseLeave">
|
|
9
|
+
<view class="custom-swiper-wrapper" :style="wrapperStyle">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
export default {
|
|
16
|
+
options: {
|
|
17
|
+
virtualHost: true, // 开启虚拟节点,使组件标签不渲染,属性直接透传
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { computed, ref } from 'vue';
|
|
23
|
+
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
modelValue: number;
|
|
26
|
+
itemCount: number;
|
|
27
|
+
}>();
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits<{
|
|
30
|
+
(e: 'update:modelValue', value: number): void;
|
|
31
|
+
(e: 'change', value: number): void;
|
|
32
|
+
}>();
|
|
33
|
+
|
|
34
|
+
const touchStart = ref({ x: 0, y: 0 });
|
|
35
|
+
|
|
36
|
+
const isDragging = ref(false);
|
|
37
|
+
|
|
38
|
+
const wrapperStyle = computed(() => ({
|
|
39
|
+
transform: `translateX(-${props.modelValue * 100}%)`,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
// 统一处理滑动逻辑
|
|
43
|
+
function handleSwipe(deltaX: number, deltaY: number) {
|
|
44
|
+
if (Math.abs(deltaX) > 50 && Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
45
|
+
if (deltaX > 0 && props.modelValue > 0) {
|
|
46
|
+
const next = props.modelValue - 1;
|
|
47
|
+
emit('update:modelValue', next);
|
|
48
|
+
emit('change', next);
|
|
49
|
+
} else if (deltaX < 0 && props.modelValue < props.itemCount - 1) {
|
|
50
|
+
const next = props.modelValue + 1;
|
|
51
|
+
emit('update:modelValue', next);
|
|
52
|
+
emit('change', next);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 触摸事件处理
|
|
58
|
+
function onTouchStart(e: TouchEvent) {
|
|
59
|
+
const touch = e.touches[0];
|
|
60
|
+
touchStart.value = { x: touch.clientX, y: touch.clientY };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function onTouchEnd(e: TouchEvent) {
|
|
64
|
+
const touch = e.changedTouches[0];
|
|
65
|
+
const deltaX = touch.clientX - touchStart.value.x;
|
|
66
|
+
const deltaY = touch.clientY - touchStart.value.y;
|
|
67
|
+
handleSwipe(deltaX, deltaY);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 鼠标事件处理
|
|
71
|
+
function onMouseDown(e: MouseEvent) {
|
|
72
|
+
isDragging.value = true;
|
|
73
|
+
touchStart.value = { x: e.clientX, y: e.clientY };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function onMouseUp(e: MouseEvent) {
|
|
77
|
+
if (!isDragging.value) return;
|
|
78
|
+
isDragging.value = false;
|
|
79
|
+
const deltaX = e.clientX - touchStart.value.x;
|
|
80
|
+
const deltaY = e.clientY - touchStart.value.y;
|
|
81
|
+
handleSwipe(deltaX, deltaY);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function onMouseLeave() {
|
|
85
|
+
isDragging.value = false;
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<style scoped>
|
|
90
|
+
.custom-swiper {
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 100%;
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
position: relative;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.custom-swiper-wrapper {
|
|
98
|
+
display: flex;
|
|
99
|
+
width: 100%;
|
|
100
|
+
height: 100%;
|
|
101
|
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
102
|
+
will-change: transform;
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
* 适用于 DevTool 窗口化及悬浮窗展示
|
|
34
34
|
*/
|
|
35
35
|
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
|
36
|
-
import { debounce } from '
|
|
36
|
+
import { debounce } from '../../../utils';
|
|
37
37
|
|
|
38
38
|
const props = withDefaults(
|
|
39
39
|
defineProps<{
|