oxy-uni-ui 2.1.0 → 2.1.2
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/attributes.json +1 -1
- package/components/common/abstracts/variable.scss +145 -100
- package/components/common/util.ts +25 -0
- package/components/composables/useDynamicVirtualScroll.ts +80 -0
- package/components/oxy-action-sheet/index.scss +6 -6
- package/components/oxy-backtop/index.scss +1 -1
- package/components/oxy-badge/index.scss +2 -2
- package/components/oxy-button/index.scss +3 -6
- package/components/oxy-calendar/index.scss +2 -2
- package/components/oxy-calendar/oxy-calendar.vue +3 -3
- package/components/oxy-calendar-view/monthPanel/month-panel.vue +72 -37
- package/components/oxy-calendar-view/monthPanel/types.ts +43 -1
- package/components/oxy-calendar-view/types.ts +1 -1
- package/components/oxy-calendar-view/utils.ts +12 -1
- package/components/oxy-calendar-view/yearPanel/types.ts +36 -2
- package/components/oxy-calendar-view/yearPanel/year-panel.vue +64 -45
- package/components/oxy-card/index.scss +4 -4
- package/components/oxy-cell/index.scss +1 -1
- package/components/oxy-cell-group/index.scss +2 -2
- package/components/oxy-checkbox/index.scss +87 -197
- package/components/oxy-collapse/index.scss +1 -1
- package/components/oxy-collapse-item/index.scss +2 -2
- package/components/oxy-corner/index.scss +3 -3
- package/components/oxy-count-to/oxy-count-to.vue +3 -3
- package/components/oxy-count-to/types.ts +1 -1
- package/components/oxy-date-strip-item/index.scss +4 -4
- package/components/oxy-datetime-picker/types.ts +1 -1
- package/components/oxy-datetime-picker-view/types.ts +2 -2
- package/components/oxy-fab/index.scss +1 -5
- package/components/oxy-file-list/index.scss +2 -2
- package/components/oxy-footer/index.scss +2 -2
- package/components/oxy-footer/oxy-footer.vue +2 -3
- package/components/oxy-form-item/index.scss +0 -5
- package/components/oxy-grid/oxy-grid.vue +1 -1
- package/components/oxy-grid-item/index.scss +1 -1
- package/components/oxy-guidance/index.scss +2 -2
- package/components/oxy-img/index.scss +2 -2
- package/components/oxy-img-cropper/index.scss +0 -2
- package/components/oxy-img-lazy/index.scss +0 -1
- package/components/oxy-index-anchor/index.scss +3 -3
- package/components/oxy-input/index.scss +2 -2
- package/components/oxy-input-number/index.scss +21 -3
- package/components/oxy-input-number/oxy-input-number.vue +9 -1
- package/components/oxy-keyboard/index.scss +1 -1
- package/components/oxy-link/index.scss +11 -10
- package/components/oxy-loading/index.scss +1 -1
- package/components/oxy-loadmore/index.scss +1 -1
- package/components/oxy-message-box/index.scss +7 -7
- package/components/oxy-navbar/index.scss +1 -1
- package/components/oxy-navbar/oxy-navbar.vue +2 -3
- package/components/oxy-password-input/index.scss +4 -4
- package/components/oxy-picker/types.ts +1 -1
- package/components/oxy-picker-view/oxy-picker-view.vue +8 -5
- package/components/oxy-picker-view/types.ts +2 -2
- package/components/oxy-progress/index.scss +2 -2
- package/components/oxy-radio/index.scss +8 -4
- package/components/oxy-radio-group/index.scss +0 -1
- package/components/oxy-rich-text/index.scss +2 -6
- package/components/oxy-rich-text/mp-html/mp-html.d.ts +2 -0
- package/components/oxy-rich-text/mp-html/mp-html.vue +2 -1
- package/components/oxy-rich-text/mp-html/node/node.vue +23 -0
- package/components/oxy-rich-text/mp-html/parser.js +6 -6
- package/components/oxy-rich-text/oxy-rich-text.vue +23 -0
- package/components/oxy-search/index.scss +1 -1
- package/components/oxy-segmented/index.scss +4 -8
- package/components/oxy-select/index.scss +6 -6
- package/components/oxy-sidebar-item/index.scss +20 -11
- package/components/oxy-slider/index.scss +4 -5
- package/components/oxy-sort-button/index.scss +6 -9
- package/components/oxy-splitter-panel/index.scss +8 -8
- package/components/oxy-step/index.scss +9 -9
- package/components/oxy-swiper-nav/index.scss +2 -2
- package/components/oxy-switch/index.scss +3 -3
- package/components/oxy-tab/index.scss +8 -2
- package/components/oxy-tabbar/index.scss +3 -3
- package/components/oxy-tabbar/oxy-tabbar.vue +3 -3
- package/components/oxy-table/index.scss +0 -1
- package/components/oxy-table-col/index.scss +1 -2
- package/components/oxy-tabs/index.scss +3 -3
- package/components/oxy-tag/index.scss +160 -20
- package/components/oxy-tag/oxy-tag.vue +14 -2
- package/components/oxy-tag/types.ts +9 -0
- package/components/oxy-text/index.scss +1 -1
- package/components/oxy-textarea/index.scss +2 -6
- package/components/oxy-toast/index.scss +1 -1
- package/components/oxy-tree/index.scss +31 -11
- package/components/oxy-tree/oxy-tree.vue +113 -2
- package/components/oxy-tree/types.ts +1 -0
- package/components/oxy-upload/index.scss +3 -3
- package/components/oxy-video-preview/index.scss +3 -3
- package/components/oxy-virtual-scroll/index.scss +1 -1
- package/components/oxy-voice-player/index.scss +36 -36
- package/components/oxy-watermark/index.scss +1 -1
- package/dev-tools.ts +2 -0
- package/devTools/components/DevToolsOverlay.vue +56 -0
- package/devTools/components/DevToolsUiHost.vue +589 -0
- package/devTools/config.js +55 -0
- package/devTools/core/components/mpDevBubble.vue +174 -0
- package/devTools/core/libs/createH5Bubble.js +156 -0
- package/devTools/core/libs/devCache.js +151 -0
- package/devTools/core/libs/devOptions.js +163 -0
- package/devTools/core/libs/devUi.js +219 -0
- package/devTools/core/libs/drawView.js +140 -0
- package/devTools/core/libs/errorReport.js +64 -0
- package/devTools/core/libs/jsonCompress.js +334 -0
- package/devTools/core/libs/logReport.js +59 -0
- package/devTools/core/libs/pageLinkList.js +125 -0
- package/devTools/core/libs/timeFormat.js +94 -0
- package/devTools/core/proxy/console.js +430 -0
- package/devTools/core/proxy/index.js +36 -0
- package/devTools/core/proxy/request.js +495 -0
- package/devTools/core/proxy/storage.js +113 -0
- package/devTools/core/proxy/uniBus.js +153 -0
- package/devTools/core/proxy/uniListen.js +192 -0
- package/devTools/core/proxy/vueMixin.js +120 -0
- package/devTools/index.js +168 -0
- package/devTools/page/components/bottomTools.vue +1046 -0
- package/devTools/page/components/dialog/addStorage.vue +204 -0
- package/devTools/page/components/dialog/createDir.vue +366 -0
- package/devTools/page/components/dialog/editDialog.vue +192 -0
- package/devTools/page/components/dialog/routeDialog.vue +184 -0
- package/devTools/page/components/dialog/sendRequest.vue +603 -0
- package/devTools/page/components/dialog/textFileEditDialog.vue +391 -0
- package/devTools/page/components/libs/appDelDir.js +86 -0
- package/devTools/page/components/libs/dirReader.js +248 -0
- package/devTools/page/components/libs/fileSize.js +15 -0
- package/devTools/page/components/libs/getRuntimeInfo.js +134 -0
- package/devTools/page/components/listItem/consoleItem.vue +314 -0
- package/devTools/page/components/listItem/errorItem.vue +292 -0
- package/devTools/page/components/listItem/fileSysItem.vue +533 -0
- package/devTools/page/components/listItem/infoList.vue +100 -0
- package/devTools/page/components/listItem/jsRunnerItem.vue +255 -0
- package/devTools/page/components/listItem/logItem.vue +193 -0
- package/devTools/page/components/listItem/networkItem.vue +398 -0
- package/devTools/page/components/listItem/objectAnalysis.vue +651 -0
- package/devTools/page/components/listItem/pages.vue +319 -0
- package/devTools/page/components/listItem/routeItem.vue +153 -0
- package/devTools/page/components/listItem/setting.vue +734 -0
- package/devTools/page/components/listItem/storageList.vue +681 -0
- package/devTools/page/components/listItem/tools.vue +315 -0
- package/devTools/page/components/listItem/vuexList.vue +599 -0
- package/devTools/page/components/main.vue +1867 -0
- package/devTools/page/components/mixins/animationControl.js +91 -0
- package/devTools/page/components/mixins/mp.js +83 -0
- package/devTools/page/components/ui/btnTabs.vue +90 -0
- package/devTools/page/components/ui/codeHisPicker.vue +172 -0
- package/devTools/page/components/ui/h5Cell.vue +13 -0
- package/devTools/page/components/ui/menuBtn.vue +94 -0
- package/devTools/page/components/ui/mobileSwiperScroll.vue +74 -0
- package/devTools/page/components/ui/requestSpeedLimit.vue +52 -0
- package/devTools/page/components/ui/requestTimeoutMock.vue +55 -0
- package/devTools/page/components/ui/subTitleBar.vue +101 -0
- package/devTools/page/static/copy.png +0 -0
- package/devTools/page/static/delete.png +0 -0
- package/devTools/page/static/fileSys/AI.png +0 -0
- package/devTools/page/static/fileSys/DWG.png +0 -0
- package/devTools/page/static/fileSys/EXE.png +0 -0
- package/devTools/page/static/fileSys/GIF.png +0 -0
- package/devTools/page/static/fileSys/HTML.png +0 -0
- package/devTools/page/static/fileSys/PSD.png +0 -0
- package/devTools/page/static/fileSys/RVT.png +0 -0
- package/devTools/page/static/fileSys/SKP.png +0 -0
- package/devTools/page/static/fileSys/SVG.png +0 -0
- package/devTools/page/static/fileSys/excel.png +0 -0
- package/devTools/page/static/fileSys/pdf.png +0 -0
- package/devTools/page/static/fileSys/pptl.png +0 -0
- package/devTools/page/static/fileSys/shipin.png +0 -0
- package/devTools/page/static/fileSys/tupian.png +0 -0
- package/devTools/page/static/fileSys/txt.png +0 -0
- package/devTools/page/static/fileSys/weizhiwenjian.png +0 -0
- package/devTools/page/static/fileSys/wenjianjia.png +0 -0
- package/devTools/page/static/fileSys/word.png +0 -0
- package/devTools/page/static/fileSys/yasuo.png +0 -0
- package/devTools/page/static/fileSys/yinpin.png +0 -0
- package/devTools/page/static/fold.png +0 -0
- package/devTools/page/static/menu.png +0 -0
- package/devTools/page/static/refresh.png +0 -0
- package/devTools/page/static/unfold.png +0 -0
- package/devTools/tools.vue +25 -0
- package/devTools/type/devTools.d.ts +406 -0
- package/oxy-dev-tools/components/DevToolsUiHost.vue +555 -0
- package/oxy-dev-tools/config.js +61 -0
- package/oxy-dev-tools/core/components/mpDevBubble.vue +176 -0
- package/oxy-dev-tools/core/libs/createH5Bubble.js +156 -0
- package/oxy-dev-tools/core/libs/devCache.js +149 -0
- package/oxy-dev-tools/core/libs/devOptions.js +160 -0
- package/oxy-dev-tools/core/libs/devUi.js +219 -0
- package/oxy-dev-tools/core/libs/drawView.js +144 -0
- package/oxy-dev-tools/core/libs/errorReport.js +60 -0
- package/oxy-dev-tools/core/libs/jsonCompress.js +328 -0
- package/oxy-dev-tools/core/libs/logReport.js +55 -0
- package/oxy-dev-tools/core/libs/pageLinkList.js +121 -0
- package/oxy-dev-tools/core/libs/timeFormat.js +93 -0
- package/oxy-dev-tools/core/proxy/console.js +398 -0
- package/oxy-dev-tools/core/proxy/index.js +33 -0
- package/oxy-dev-tools/core/proxy/request.js +473 -0
- package/oxy-dev-tools/core/proxy/storage.js +96 -0
- package/oxy-dev-tools/core/proxy/uniBus.js +148 -0
- package/oxy-dev-tools/core/proxy/uniListen.js +190 -0
- package/oxy-dev-tools/core/proxy/vueMixin.js +115 -0
- package/oxy-dev-tools/index.ts +183 -0
- package/oxy-dev-tools/oxy-dev-tools.vue +62 -0
- package/oxy-dev-tools/page/components/bottomTools.vue +933 -0
- package/oxy-dev-tools/page/components/dialog/addStorage.vue +184 -0
- package/oxy-dev-tools/page/components/dialog/createDir.vue +352 -0
- package/oxy-dev-tools/page/components/dialog/editDialog.vue +178 -0
- package/oxy-dev-tools/page/components/dialog/routeDialog.vue +170 -0
- package/oxy-dev-tools/page/components/dialog/sendRequest.vue +530 -0
- package/oxy-dev-tools/page/components/dialog/textFileEditDialog.vue +379 -0
- package/oxy-dev-tools/page/components/libs/appDelDir.js +77 -0
- package/oxy-dev-tools/page/components/libs/dirReader.js +239 -0
- package/oxy-dev-tools/page/components/libs/fileSize.js +15 -0
- package/oxy-dev-tools/page/components/libs/getRuntimeInfo.js +132 -0
- package/oxy-dev-tools/page/components/listItem/consoleItem.vue +292 -0
- package/oxy-dev-tools/page/components/listItem/errorItem.vue +268 -0
- package/oxy-dev-tools/page/components/listItem/fileSysItem.vue +511 -0
- package/oxy-dev-tools/page/components/listItem/infoList.vue +89 -0
- package/oxy-dev-tools/page/components/listItem/jsRunnerItem.vue +236 -0
- package/oxy-dev-tools/page/components/listItem/logItem.vue +185 -0
- package/oxy-dev-tools/page/components/listItem/networkItem.vue +362 -0
- package/oxy-dev-tools/page/components/listItem/objectAnalysis.vue +642 -0
- package/oxy-dev-tools/page/components/listItem/pages.vue +285 -0
- package/oxy-dev-tools/page/components/listItem/routeItem.vue +140 -0
- package/oxy-dev-tools/page/components/listItem/setting.vue +687 -0
- package/oxy-dev-tools/page/components/listItem/storageList.vue +623 -0
- package/oxy-dev-tools/page/components/listItem/tools.vue +273 -0
- package/oxy-dev-tools/page/components/listItem/vuexList.vue +559 -0
- package/oxy-dev-tools/page/components/main.vue +1824 -0
- package/oxy-dev-tools/page/components/mixins/animationControl.js +80 -0
- package/oxy-dev-tools/page/components/mixins/mp.js +76 -0
- package/oxy-dev-tools/page/components/ui/btnTabs.vue +77 -0
- package/oxy-dev-tools/page/components/ui/codeHisPicker.vue +161 -0
- package/oxy-dev-tools/page/components/ui/h5Cell.vue +13 -0
- package/oxy-dev-tools/page/components/ui/menuBtn.vue +87 -0
- package/oxy-dev-tools/page/components/ui/mobileSwiperScroll.vue +71 -0
- package/oxy-dev-tools/page/components/ui/requestSpeedLimit.vue +47 -0
- package/oxy-dev-tools/page/components/ui/requestTimeoutMock.vue +50 -0
- package/oxy-dev-tools/page/components/ui/subTitleBar.vue +87 -0
- package/oxy-dev-tools/page/static/copy.png +0 -0
- package/oxy-dev-tools/page/static/delete.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/AI.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/DWG.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/EXE.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/GIF.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/HTML.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/PSD.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/RVT.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/SKP.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/SVG.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/excel.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/pdf.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/pptl.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/shipin.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/tupian.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/txt.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/weizhiwenjian.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/wenjianjia.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/word.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/yasuo.png +0 -0
- package/oxy-dev-tools/page/static/fileSys/yinpin.png +0 -0
- package/oxy-dev-tools/page/static/fold.png +0 -0
- package/oxy-dev-tools/page/static/menu.png +0 -0
- package/oxy-dev-tools/page/static/refresh.png +0 -0
- package/oxy-dev-tools/page/static/unfold.png +0 -0
- package/oxy-dev-tools/tools.vue +22 -0
- package/oxy-dev-tools/type/devTools.d.ts +406 -0
- package/package.json +1 -1
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="isMp && options && options.status && options.bubble.status"
|
|
4
|
+
class="mpDevBubble"
|
|
5
|
+
:style="{
|
|
6
|
+
left: `${tagConfig.x}px`,
|
|
7
|
+
top: `${tagConfig.y}px`,
|
|
8
|
+
'background-color': options.bubble.bgColor,
|
|
9
|
+
'box-shadow': `0px 0px 6px ${options.bubble.bgColor}`,
|
|
10
|
+
}"
|
|
11
|
+
@touchstart.stop="touchstart"
|
|
12
|
+
@touchmove.stop="touchmove"
|
|
13
|
+
@touchend.stop="touchend"
|
|
14
|
+
@mousedown.stop="touchstart"
|
|
15
|
+
>
|
|
16
|
+
<text
|
|
17
|
+
class="mpDevBubbleText"
|
|
18
|
+
:style="{
|
|
19
|
+
color: options.bubble.color,
|
|
20
|
+
'font-size': '20rpx',
|
|
21
|
+
}"
|
|
22
|
+
>
|
|
23
|
+
{{ options.bubble.text }}
|
|
24
|
+
</text>
|
|
25
|
+
</view>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
import devOptions from "../libs/devOptions";
|
|
29
|
+
import { reactive } from 'vue'
|
|
30
|
+
|
|
31
|
+
let options = devOptions.getOptions();
|
|
32
|
+
let sysInfo = uni.getSystemInfoSync();
|
|
33
|
+
let tagConfig = uni.getStorageSync("devTools_tagConfig");
|
|
34
|
+
if (!tagConfig) {
|
|
35
|
+
tagConfig = {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// #ifndef VUE3
|
|
39
|
+
tagConfig = Object.assign(
|
|
40
|
+
{
|
|
41
|
+
x: sysInfo.screenWidth - 150,
|
|
42
|
+
y: sysInfo.screenHeight - 240,
|
|
43
|
+
},
|
|
44
|
+
tagConfig
|
|
45
|
+
);
|
|
46
|
+
// #endif
|
|
47
|
+
|
|
48
|
+
// #ifdef VUE3
|
|
49
|
+
tagConfig = reactive(Object.assign(
|
|
50
|
+
{
|
|
51
|
+
x: sysInfo.screenWidth - 150,
|
|
52
|
+
y: sysInfo.screenHeight - 240,
|
|
53
|
+
},
|
|
54
|
+
tagConfig
|
|
55
|
+
));
|
|
56
|
+
// #endif
|
|
57
|
+
|
|
58
|
+
// 拖动范围限制
|
|
59
|
+
let dragLimit = {
|
|
60
|
+
min: { x: 0, y: 0 },
|
|
61
|
+
max: {
|
|
62
|
+
x: sysInfo.screenWidth - 70,
|
|
63
|
+
y: sysInfo.screenHeight - 24,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
tagConfig.x = Math.min(Math.max(tagConfig.x, dragLimit.min.x), dragLimit.max.x);
|
|
68
|
+
tagConfig.y = Math.min(Math.max(tagConfig.y, dragLimit.min.y), dragLimit.max.y);
|
|
69
|
+
|
|
70
|
+
let isTouch = false;
|
|
71
|
+
let touchStartPoint = {
|
|
72
|
+
clientX: 0,
|
|
73
|
+
clientY: 0,
|
|
74
|
+
tagX: tagConfig.x,
|
|
75
|
+
tagY: tagConfig.y,
|
|
76
|
+
hasMove: false,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
let isMp = false;
|
|
80
|
+
// #ifdef MP
|
|
81
|
+
isMp = true;
|
|
82
|
+
// #endif
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
isMp,
|
|
88
|
+
/**
|
|
89
|
+
* 标签参数
|
|
90
|
+
*/
|
|
91
|
+
options,
|
|
92
|
+
/**
|
|
93
|
+
* 标签坐标信息配置
|
|
94
|
+
*/
|
|
95
|
+
tagConfig,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
mounted() {
|
|
99
|
+
// #ifdef H5
|
|
100
|
+
document.addEventListener("mousemove", this.touchmove)
|
|
101
|
+
document.addEventListener("mouseup", this.touchend)
|
|
102
|
+
// #endif
|
|
103
|
+
},
|
|
104
|
+
beforeUnmount() {
|
|
105
|
+
// #ifdef H5
|
|
106
|
+
document.removeEventListener("mousemove", this.touchmove)
|
|
107
|
+
document.addEventListener("mouseup", this.touchend)
|
|
108
|
+
// #endif
|
|
109
|
+
},
|
|
110
|
+
methods: {
|
|
111
|
+
touchstart(e) {
|
|
112
|
+
if (isTouch) return;
|
|
113
|
+
if (e.preventDefault) {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
let clientX = e.clientX ? e.clientX : e.touches[0].clientX;
|
|
117
|
+
let clientY = e.clientY ? e.clientY : e.touches[0].clientY;
|
|
118
|
+
touchStartPoint.clientX = clientX;
|
|
119
|
+
touchStartPoint.clientY = clientY;
|
|
120
|
+
touchStartPoint.tagX = tagConfig.x;
|
|
121
|
+
touchStartPoint.tagY = tagConfig.y;
|
|
122
|
+
touchStartPoint.hasMove = false;
|
|
123
|
+
isTouch = true;
|
|
124
|
+
},
|
|
125
|
+
touchmove(e) {
|
|
126
|
+
if (!isTouch) return;
|
|
127
|
+
if (e.preventDefault) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
}
|
|
130
|
+
let clientX = e.clientX ? e.clientX : e.touches[0].clientX;
|
|
131
|
+
let clientY = e.clientY ? e.clientY : e.touches[0].clientY;
|
|
132
|
+
touchStartPoint.hasMove = true;
|
|
133
|
+
let offsetX = touchStartPoint.clientX - clientX;
|
|
134
|
+
let offsetY = touchStartPoint.clientY - clientY;
|
|
135
|
+
let tx = touchStartPoint.tagX - offsetX;
|
|
136
|
+
let ty = touchStartPoint.tagY - offsetY;
|
|
137
|
+
tx = Math.min(Math.max(tx, dragLimit.min.x), dragLimit.max.x);
|
|
138
|
+
ty = Math.min(Math.max(ty, dragLimit.min.y), dragLimit.max.y);
|
|
139
|
+
tagConfig.x = tx;
|
|
140
|
+
tagConfig.y = ty;
|
|
141
|
+
this.tagConfig.x = tx;
|
|
142
|
+
this.tagConfig.y = ty;
|
|
143
|
+
},
|
|
144
|
+
touchend(e) {
|
|
145
|
+
if (!isTouch) return;
|
|
146
|
+
if (e.preventDefault) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
}
|
|
149
|
+
isTouch = false;
|
|
150
|
+
uni.setStorageSync("devTools_tagConfig", tagConfig);
|
|
151
|
+
if (!touchStartPoint.hasMove) {
|
|
152
|
+
this.$devTools.show();
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
</script>
|
|
158
|
+
<style lang="scss" scoped>
|
|
159
|
+
.mpDevBubble {
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
position: fixed;
|
|
162
|
+
z-index: 9999999;
|
|
163
|
+
width: 70px;
|
|
164
|
+
height: 24px;
|
|
165
|
+
display: flex;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
align-items: center;
|
|
168
|
+
justify-content: center;
|
|
169
|
+
padding: 4px;
|
|
170
|
+
border-radius: 6px;
|
|
171
|
+
font-size: 10px;
|
|
172
|
+
cursor: grab;
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*! 创建h5页面上拖动的气泡标签
|
|
3
|
+
*/
|
|
4
|
+
function createH5Bubble(options, devTools) {
|
|
5
|
+
|
|
6
|
+
let tagConfig = localStorage.getItem("devTools_tagConfig");
|
|
7
|
+
if (!tagConfig) {
|
|
8
|
+
tagConfig = {}
|
|
9
|
+
} else {
|
|
10
|
+
tagConfig = JSON.parse(tagConfig)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
tagConfig = Object.assign({
|
|
14
|
+
show: options.bubble.status,
|
|
15
|
+
x: window.innerWidth - 90,
|
|
16
|
+
y: window.innerHeight - 90,
|
|
17
|
+
}, tagConfig);
|
|
18
|
+
|
|
19
|
+
tagConfig.show = options.bubble.status;
|
|
20
|
+
|
|
21
|
+
// 拖动范围限制
|
|
22
|
+
let dragLimit = {
|
|
23
|
+
min: { x: 0, y: 0, },
|
|
24
|
+
max: {
|
|
25
|
+
x: window.innerWidth - 70,
|
|
26
|
+
y: window.innerHeight - 24,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
tagConfig.x = Math.min(Math.max(tagConfig.x, dragLimit.min.x), dragLimit.max.x)
|
|
32
|
+
tagConfig.y = Math.min(Math.max(tagConfig.y, dragLimit.min.y), dragLimit.max.y)
|
|
33
|
+
|
|
34
|
+
let tag = document.createElement("div");
|
|
35
|
+
tag.style = `
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
position: fixed;
|
|
38
|
+
z-index: 9999999;
|
|
39
|
+
left: ${tagConfig.x}px;
|
|
40
|
+
top: ${tagConfig.y}px;
|
|
41
|
+
width: 70px;
|
|
42
|
+
height: 24px;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
padding: 4px;
|
|
48
|
+
border-radius: 6px;
|
|
49
|
+
background-color: ${options.bubble.bgColor};
|
|
50
|
+
color: ${options.bubble.color};
|
|
51
|
+
font-size: 10px;
|
|
52
|
+
cursor: grab;
|
|
53
|
+
box-shadow: 0px 0px 6px ${options.bubble.bgColor};
|
|
54
|
+
backdrop-filter: blur(1px);
|
|
55
|
+
`;
|
|
56
|
+
tag.innerHTML = options.bubble.text;
|
|
57
|
+
tag.setAttribute("id", "debugTag")
|
|
58
|
+
const canShowBubble = tagConfig.show === true;
|
|
59
|
+
|
|
60
|
+
if (canShowBubble) {
|
|
61
|
+
document.body.appendChild(tag)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function hideBubble() {
|
|
65
|
+
if (!canShowBubble) return;
|
|
66
|
+
tag.style.display = "none";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function showBubble() {
|
|
70
|
+
if (!canShowBubble) return;
|
|
71
|
+
if (!document.body.contains(tag)) {
|
|
72
|
+
document.body.appendChild(tag);
|
|
73
|
+
}
|
|
74
|
+
tag.style.display = "flex";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
uni.$on("devTools_overlay_show", hideBubble);
|
|
78
|
+
uni.$on("devTools_overlay_hide", showBubble);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 标签单击事件
|
|
82
|
+
*/
|
|
83
|
+
function tagClick() {
|
|
84
|
+
devTools.show()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let isTouch = false;
|
|
88
|
+
let touchStartPoint = {
|
|
89
|
+
clientX: 0,
|
|
90
|
+
clientY: 0,
|
|
91
|
+
tagX: tagConfig.x,
|
|
92
|
+
tagY: tagConfig.y,
|
|
93
|
+
hasMove: false,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function touchStart(e) {
|
|
97
|
+
if (isTouch) return;
|
|
98
|
+
if (e.preventDefault) {
|
|
99
|
+
e.preventDefault()
|
|
100
|
+
}
|
|
101
|
+
let clientX = e.clientX ? e.clientX : e.targetTouches[0].clientX;
|
|
102
|
+
let clientY = e.clientX ? e.clientY : e.targetTouches[0].clientY;
|
|
103
|
+
touchStartPoint.clientX = clientX;
|
|
104
|
+
touchStartPoint.clientY = clientY;
|
|
105
|
+
touchStartPoint.tagX = tagConfig.x;
|
|
106
|
+
touchStartPoint.tagY = tagConfig.y;
|
|
107
|
+
touchStartPoint.hasMove = false;
|
|
108
|
+
isTouch = true;
|
|
109
|
+
}
|
|
110
|
+
function touchMove(e) {
|
|
111
|
+
if (!isTouch) return;
|
|
112
|
+
if (e.preventDefault) {
|
|
113
|
+
e.preventDefault()
|
|
114
|
+
}
|
|
115
|
+
let clientX = e.clientX ? e.clientX : e.targetTouches[0].clientX;
|
|
116
|
+
let clientY = e.clientX ? e.clientY : e.targetTouches[0].clientY;
|
|
117
|
+
let offsetX = touchStartPoint.clientX - clientX;
|
|
118
|
+
let offsetY = touchStartPoint.clientY - clientY;
|
|
119
|
+
const moveDistance = Math.sqrt(offsetX * offsetX + offsetY * offsetY);
|
|
120
|
+
if (!touchStartPoint.hasMove && moveDistance < 6) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
touchStartPoint.hasMove = true;
|
|
124
|
+
let tx = touchStartPoint.tagX - offsetX;
|
|
125
|
+
let ty = touchStartPoint.tagY - offsetY;
|
|
126
|
+
tx = Math.min(Math.max(tx, dragLimit.min.x), dragLimit.max.x)
|
|
127
|
+
ty = Math.min(Math.max(ty, dragLimit.min.y), dragLimit.max.y)
|
|
128
|
+
tag.style.left = `${tx}px`;
|
|
129
|
+
tag.style.top = `${ty}px`;
|
|
130
|
+
tagConfig.x = tx;
|
|
131
|
+
tagConfig.y = ty;
|
|
132
|
+
}
|
|
133
|
+
function touchEnd(e) {
|
|
134
|
+
if (!isTouch) return;
|
|
135
|
+
if (e.preventDefault) {
|
|
136
|
+
e.preventDefault()
|
|
137
|
+
}
|
|
138
|
+
isTouch = false;
|
|
139
|
+
localStorage.setItem("devTools_tagConfig", JSON.stringify(tagConfig))
|
|
140
|
+
if (!touchStartPoint.hasMove) {
|
|
141
|
+
tagClick()
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
tag.addEventListener("touchstart", touchStart)
|
|
145
|
+
tag.addEventListener("touchmove", touchMove)
|
|
146
|
+
tag.addEventListener("touchend", touchEnd)
|
|
147
|
+
|
|
148
|
+
tag.addEventListener("mousedown", touchStart)
|
|
149
|
+
document.addEventListener("mousemove", touchMove)
|
|
150
|
+
document.addEventListener("mouseup", touchEnd)
|
|
151
|
+
|
|
152
|
+
localStorage.setItem("devTools_tagConfig", JSON.stringify(tagConfig))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export default createH5Bubble;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import devOptions from "./devOptions"
|
|
2
|
+
/**
|
|
3
|
+
* dev工具缓存管理
|
|
4
|
+
*/
|
|
5
|
+
export default {
|
|
6
|
+
/**
|
|
7
|
+
* 存储的键开始名称
|
|
8
|
+
*/
|
|
9
|
+
cacheKey: "devTools_v3_",
|
|
10
|
+
options: null,
|
|
11
|
+
/**
|
|
12
|
+
* 临时缓存对象
|
|
13
|
+
*/
|
|
14
|
+
tempCache: {
|
|
15
|
+
errorReport: [],
|
|
16
|
+
logReport: [],
|
|
17
|
+
console: [],
|
|
18
|
+
request: [],
|
|
19
|
+
uniBus: [],
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* 临时数据存放
|
|
23
|
+
*/
|
|
24
|
+
tempData: {},
|
|
25
|
+
/**
|
|
26
|
+
* 长列表配置缺省值
|
|
27
|
+
*/
|
|
28
|
+
defaultLongListSetting: {
|
|
29
|
+
status: false,
|
|
30
|
+
cache: {
|
|
31
|
+
status: false
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* 向缓存内写入数据
|
|
36
|
+
*/
|
|
37
|
+
set(key, value) {
|
|
38
|
+
try {
|
|
39
|
+
if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
|
|
40
|
+
const setting = this.getLongListSetting(key)
|
|
41
|
+
if (setting.status !== true) return;
|
|
42
|
+
if (!setting.cache || setting.cache.status !== true) {
|
|
43
|
+
// !不使用缓存
|
|
44
|
+
this.tempCache[key] = value;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
key = `${this.cacheKey}${key}`
|
|
49
|
+
|
|
50
|
+
this.tempData[key] = value;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.log("devCache.set error", error);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* 同步读取缓存数据
|
|
57
|
+
*/
|
|
58
|
+
get(key) {
|
|
59
|
+
try {
|
|
60
|
+
if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
|
|
61
|
+
const setting = this.getLongListSetting(key)
|
|
62
|
+
if (setting.status !== true) return [];
|
|
63
|
+
if (!setting.cache || setting.cache.status !== true) {
|
|
64
|
+
// !不使用缓存
|
|
65
|
+
return this.tempCache[key];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
key = `${this.cacheKey}${key}`
|
|
69
|
+
|
|
70
|
+
if (this.tempData.hasOwnProperty(key)) {
|
|
71
|
+
return this.tempData[key];
|
|
72
|
+
} else {
|
|
73
|
+
let value = uni.getStorageSync(key);
|
|
74
|
+
this.tempData[key] = value;
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.log("devCache.get error", error);
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* 向缓存内写入数据
|
|
84
|
+
*/
|
|
85
|
+
clearItem(key) {
|
|
86
|
+
try {
|
|
87
|
+
if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
|
|
88
|
+
const setting = this.getLongListSetting(key)
|
|
89
|
+
if (setting.status !== true) return [];
|
|
90
|
+
if (!setting.cache || setting.cache.status !== true) {
|
|
91
|
+
// !不使用缓存
|
|
92
|
+
delete this.tempData[key];
|
|
93
|
+
uni.removeStorageSync(key);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
key = `${this.cacheKey}${key}`;
|
|
97
|
+
delete this.tempData[key];
|
|
98
|
+
uni.removeStorageSync(key);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.log("devCache.clearItem error", JSON.stringify(error));
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
getLongListSetting(key) {
|
|
104
|
+
const optionsKey = {
|
|
105
|
+
errorReport: 'error',
|
|
106
|
+
logReport: 'logs',
|
|
107
|
+
console: 'console',
|
|
108
|
+
request: 'network',
|
|
109
|
+
uniBus: 'uniBus',
|
|
110
|
+
}
|
|
111
|
+
const optionName = optionsKey[key]
|
|
112
|
+
if (!optionName) {
|
|
113
|
+
return this.defaultLongListSetting
|
|
114
|
+
}
|
|
115
|
+
if (!this.options) {
|
|
116
|
+
this.options = devOptions.getOptions() || {}
|
|
117
|
+
}
|
|
118
|
+
const setting = this.options ? this.options[optionName] : null
|
|
119
|
+
if (!setting || typeof setting !== 'object') {
|
|
120
|
+
return this.defaultLongListSetting
|
|
121
|
+
}
|
|
122
|
+
return setting
|
|
123
|
+
},
|
|
124
|
+
/**
|
|
125
|
+
* 同步本地缓存
|
|
126
|
+
*/
|
|
127
|
+
syncLocalCache() {
|
|
128
|
+
let that = this;
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
try {
|
|
131
|
+
let waitSetKeys = Object.keys(that.tempData);
|
|
132
|
+
for (let i = 0; i < waitSetKeys.length; i++) {
|
|
133
|
+
const key = waitSetKeys[i];
|
|
134
|
+
uni.setStorage({
|
|
135
|
+
key,
|
|
136
|
+
data: that.tempData[key],
|
|
137
|
+
success() {
|
|
138
|
+
// console.log("set " + key + " success,length=" + that.tempData[key].length);
|
|
139
|
+
delete that.tempData[key];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.log("devCache error: ", error);
|
|
145
|
+
}
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
that.syncLocalCache();
|
|
148
|
+
}, 500);
|
|
149
|
+
}, Math.round(Math.random() * 3 * 1000) + 2000);
|
|
150
|
+
},
|
|
151
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import devCache from "./devCache";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 设置各端大小 kb
|
|
5
|
+
*/
|
|
6
|
+
const defSize = (h5, app, mp) => {
|
|
7
|
+
let r = 0;
|
|
8
|
+
// #ifdef H5
|
|
9
|
+
r = h5;
|
|
10
|
+
// #endif
|
|
11
|
+
// #ifdef MP
|
|
12
|
+
r = mp;
|
|
13
|
+
// #endif
|
|
14
|
+
// #ifdef APP-PLUS
|
|
15
|
+
r = app;
|
|
16
|
+
// #endif
|
|
17
|
+
return Math.ceil(r * 1024);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 获取配置
|
|
24
|
+
*/
|
|
25
|
+
export default {
|
|
26
|
+
/**
|
|
27
|
+
* 配置缓存key
|
|
28
|
+
*/
|
|
29
|
+
cacheKey: "options_v8",
|
|
30
|
+
/**
|
|
31
|
+
* 默认配置项
|
|
32
|
+
*/
|
|
33
|
+
defaultOptions: {
|
|
34
|
+
version: 3.81,
|
|
35
|
+
status: false, //调试工具总开关
|
|
36
|
+
bubble: { //调试弹窗气泡设置
|
|
37
|
+
status: false, // 气泡标签是否显示,生产环境建议关闭
|
|
38
|
+
text: "调试工具", // 气泡上展示的文字
|
|
39
|
+
color: "#ffffff", // 气泡文字颜色
|
|
40
|
+
bgColor: "rgba(250, 53, 52,0.7)", // 气泡背景颜色
|
|
41
|
+
},
|
|
42
|
+
console: {
|
|
43
|
+
status: true, // 开关
|
|
44
|
+
isOutput: true, //打印的日志是否对外输出到浏览器调试界面,建议在生产环境时开启
|
|
45
|
+
cache: {
|
|
46
|
+
status: true, //是否启用console缓存
|
|
47
|
+
size: defSize(512, 1024 * 2, 512),
|
|
48
|
+
rowSize: defSize(5.12, 20, 10),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
error: {
|
|
52
|
+
status: true,
|
|
53
|
+
cache: {
|
|
54
|
+
status: true,
|
|
55
|
+
size: defSize(512, 1024 * 2, 512),
|
|
56
|
+
rowSize: defSize(5.12, 20, 10),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
network: {
|
|
60
|
+
status: true,
|
|
61
|
+
cache: {
|
|
62
|
+
status: true,
|
|
63
|
+
size: defSize(512, 1024 * 2, 512),
|
|
64
|
+
rowSize: defSize(5.12, 20, 10),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
logs: {
|
|
68
|
+
status: true,
|
|
69
|
+
cache: {
|
|
70
|
+
status: true,
|
|
71
|
+
size: defSize(512, 1024 * 2, 512),
|
|
72
|
+
rowSize: defSize(0.4, 0.4, 0.4),
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
// uni event bus 监听设置
|
|
76
|
+
uniBus: {
|
|
77
|
+
status: true,
|
|
78
|
+
cache: {
|
|
79
|
+
status: true,
|
|
80
|
+
size: defSize(512, 1024 * 2, 512),
|
|
81
|
+
rowSize: defSize(5.12, 20, 10),
|
|
82
|
+
countMaxSize: defSize(512, 1024 * 2, 512), // bus统计上限 kb
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* 获取配置信息
|
|
88
|
+
*/
|
|
89
|
+
getOptions() {
|
|
90
|
+
try {
|
|
91
|
+
let options = devCache.get(this.cacheKey)
|
|
92
|
+
if (!options) {
|
|
93
|
+
return {
|
|
94
|
+
status: false, //默认关闭调试工具
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return options;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.log("devOptions.getOptions error: ", error);
|
|
100
|
+
return {
|
|
101
|
+
status: false, //默认关闭调试工具
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* 保存配置项
|
|
107
|
+
*/
|
|
108
|
+
setOptions(options) {
|
|
109
|
+
try {
|
|
110
|
+
if (!options) {
|
|
111
|
+
options = this.defaultOptions;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let data = deepMerge(this.defaultOptions, options)
|
|
115
|
+
|
|
116
|
+
devCache.set(this.cacheKey, data)
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.log("devOptions.setOptions error: ", error);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* 弹出错误信息
|
|
123
|
+
*/
|
|
124
|
+
outputError(msg) {
|
|
125
|
+
console.log('%c' + msg, `
|
|
126
|
+
padding: 4px;
|
|
127
|
+
background-color: red;
|
|
128
|
+
color: #fff;
|
|
129
|
+
font-size: 15px;
|
|
130
|
+
`)
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 深度合并对象
|
|
141
|
+
*/
|
|
142
|
+
function deepMerge(target, ...sources) {
|
|
143
|
+
try {
|
|
144
|
+
if (!sources.length) return target; // 如果没有源对象则直接返回目标对象
|
|
145
|
+
|
|
146
|
+
const source = sources[0];
|
|
147
|
+
|
|
148
|
+
for (let key in source) {
|
|
149
|
+
if (source.hasOwnProperty(key)) {
|
|
150
|
+
if (typeof source[key] === 'object' && typeof target[key] !== undefined) {
|
|
151
|
+
target[key] = deepMerge({}, target[key], source[key]); // 若属性值为对象类型且目标对象已存在该属性,则递归调用deepMerge函数进行合并
|
|
152
|
+
} else {
|
|
153
|
+
target[key] = source[key]; // 否则将源对象的属性赋值到目标对象上
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return deepMerge(target, ...sources.slice(1)); // 处理完第一个源对象后再次调用deepMerge函数处理其他源对象
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.log("deepMerge error", error);
|
|
161
|
+
return {}
|
|
162
|
+
}
|
|
163
|
+
}
|