oxy-uni-ui 2.1.1 → 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 +13 -2
- package/components/oxy-checkbox/index.scss +37 -2
- package/components/oxy-sort-button/index.scss +3 -4
- package/components/oxy-tag/index.scss +157 -17
- package/components/oxy-tag/oxy-tag.vue +14 -2
- package/components/oxy-tag/types.ts +9 -0
- 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,219 @@
|
|
|
1
|
+
const EVENT_HOST_READY = "devTools_ui_host_ready";
|
|
2
|
+
const EVENT_HOST_DESTROYED = "devTools_ui_host_destroyed";
|
|
3
|
+
const EVENT_MODAL_SHOW = "devTools_ui_modal_show";
|
|
4
|
+
const EVENT_TOAST_SHOW = "devTools_ui_toast_show";
|
|
5
|
+
const EVENT_LOADING_SHOW = "devTools_ui_loading_show";
|
|
6
|
+
const EVENT_LOADING_HIDE = "devTools_ui_loading_hide";
|
|
7
|
+
const EVENT_ACTION_SHEET_SHOW = "devTools_ui_action_sheet_show";
|
|
8
|
+
|
|
9
|
+
let hasInstall = false;
|
|
10
|
+
let hostReady = false;
|
|
11
|
+
let modalId = 0;
|
|
12
|
+
let actionSheetId = 0;
|
|
13
|
+
let onceSupported = null;
|
|
14
|
+
const pendingActions = [];
|
|
15
|
+
|
|
16
|
+
function safeCall(fn, payload) {
|
|
17
|
+
try {
|
|
18
|
+
if (typeof fn === "function") {
|
|
19
|
+
fn(payload);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function createModalResult(confirm = false, cancel = false, content = "") {
|
|
25
|
+
return {
|
|
26
|
+
confirm,
|
|
27
|
+
cancel,
|
|
28
|
+
content,
|
|
29
|
+
errMsg: "showModal:ok",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function flushPendingActions() {
|
|
34
|
+
if (!hostReady) return;
|
|
35
|
+
while (pendingActions.length > 0) {
|
|
36
|
+
const action = pendingActions.shift();
|
|
37
|
+
safeCall(action);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function emitUiEvent(eventName, payload) {
|
|
42
|
+
const action = () => {
|
|
43
|
+
uni.$emit(eventName, payload);
|
|
44
|
+
};
|
|
45
|
+
if (hostReady) {
|
|
46
|
+
action();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
pendingActions.push(action);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function inferModalTone(options = {}) {
|
|
53
|
+
const explicitTone = String(options.tone || options.type || "").toLowerCase();
|
|
54
|
+
if (["warn", "warning", "danger", "error"].indexOf(explicitTone) > -1) {
|
|
55
|
+
return "warning";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const text = `${String(options.title || "")} ${String(options.content || "")}`;
|
|
59
|
+
if (/警告|危险|删除|清空|不可恢复|风险/.test(text)) {
|
|
60
|
+
return "warning";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return "default";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const devUi = {
|
|
67
|
+
install() {
|
|
68
|
+
if (hasInstall) return;
|
|
69
|
+
hasInstall = true;
|
|
70
|
+
uni.$on(EVENT_HOST_READY, () => {
|
|
71
|
+
hostReady = true;
|
|
72
|
+
flushPendingActions();
|
|
73
|
+
});
|
|
74
|
+
uni.$on(EVENT_HOST_DESTROYED, () => {
|
|
75
|
+
hostReady = false;
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
showModal(options = {}) {
|
|
79
|
+
const id = ++modalId;
|
|
80
|
+
const resultEvent = `devTools_ui_modal_result_${id}`;
|
|
81
|
+
const tone = inferModalTone(options);
|
|
82
|
+
const modalOptions = {
|
|
83
|
+
title: options.title || "提示",
|
|
84
|
+
content: options.content || "",
|
|
85
|
+
tone,
|
|
86
|
+
showCancel: options.showCancel !== false,
|
|
87
|
+
cancelText: options.cancelText || "取消",
|
|
88
|
+
cancelColor: options.cancelColor || "#6b7280",
|
|
89
|
+
confirmText: options.confirmText || "确定",
|
|
90
|
+
confirmColor: options.confirmColor || (tone === "warning" ? "#dc2626" : "#3b82f6"),
|
|
91
|
+
editable: options.editable === true,
|
|
92
|
+
placeholderText: options.placeholderText || "",
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
return new Promise((resolve) => {
|
|
96
|
+
const handler = (res) => {
|
|
97
|
+
if (onceSupported === false) {
|
|
98
|
+
uni.$off(resultEvent, handler);
|
|
99
|
+
}
|
|
100
|
+
safeCall(options.success, res);
|
|
101
|
+
safeCall(options.complete, res);
|
|
102
|
+
resolve(res);
|
|
103
|
+
};
|
|
104
|
+
if (onceSupported === null) {
|
|
105
|
+
onceSupported = typeof uni.$once === "function";
|
|
106
|
+
}
|
|
107
|
+
if (onceSupported) {
|
|
108
|
+
uni.$once(resultEvent, handler);
|
|
109
|
+
} else {
|
|
110
|
+
uni.$on(resultEvent, handler);
|
|
111
|
+
}
|
|
112
|
+
emitUiEvent(EVENT_MODAL_SHOW, {
|
|
113
|
+
id,
|
|
114
|
+
resultEvent,
|
|
115
|
+
options: modalOptions,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
showToast(options = {}) {
|
|
120
|
+
const toastOptions = {
|
|
121
|
+
title: options.title || "",
|
|
122
|
+
icon: options.icon || "none",
|
|
123
|
+
duration: typeof options.duration === "number" ? options.duration : 1500,
|
|
124
|
+
mask: options.mask === true,
|
|
125
|
+
};
|
|
126
|
+
emitUiEvent(EVENT_TOAST_SHOW, toastOptions);
|
|
127
|
+
const res = { errMsg: "showToast:ok" };
|
|
128
|
+
safeCall(options.success, res);
|
|
129
|
+
safeCall(options.complete, res);
|
|
130
|
+
},
|
|
131
|
+
showActionSheet(options = {}) {
|
|
132
|
+
const id = ++actionSheetId;
|
|
133
|
+
const resultEvent = `devTools_ui_action_sheet_result_${id}`;
|
|
134
|
+
const cancelIndex = typeof options.cancelIndex === "number" ? options.cancelIndex : -1;
|
|
135
|
+
const destructiveIndex = typeof options.destructiveIndex === "number" ? options.destructiveIndex : -1;
|
|
136
|
+
const selectedIndex = typeof options.selectedIndex === "number" ? options.selectedIndex : -1;
|
|
137
|
+
const itemList = Array.isArray(options.itemList)
|
|
138
|
+
? options.itemList.map((item) => {
|
|
139
|
+
if (item && typeof item === "object") {
|
|
140
|
+
return {
|
|
141
|
+
title: String(item.title || item.text || ""),
|
|
142
|
+
msg: item.msg ? String(item.msg) : "",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
title: String(item),
|
|
147
|
+
msg: "",
|
|
148
|
+
};
|
|
149
|
+
})
|
|
150
|
+
: [];
|
|
151
|
+
const actionSheetOptions = {
|
|
152
|
+
title: options.title || "",
|
|
153
|
+
itemList,
|
|
154
|
+
itemColor: options.itemColor || "#1e3a8a",
|
|
155
|
+
selectedIndex,
|
|
156
|
+
selectedColor: options.selectedColor || "#2563eb",
|
|
157
|
+
cancelText: options.cancelText || "取消",
|
|
158
|
+
cancelIndex,
|
|
159
|
+
destructiveIndex,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return new Promise((resolve) => {
|
|
163
|
+
const done = (res) => {
|
|
164
|
+
if (onceSupported === false) {
|
|
165
|
+
uni.$off(resultEvent, done);
|
|
166
|
+
}
|
|
167
|
+
const isCancel = !res || res.cancel === true || res.tapIndex === -1;
|
|
168
|
+
if (isCancel) {
|
|
169
|
+
const cancelRes = {
|
|
170
|
+
errMsg: "showActionSheet:fail cancel",
|
|
171
|
+
};
|
|
172
|
+
safeCall(options.fail, cancelRes);
|
|
173
|
+
safeCall(options.complete, cancelRes);
|
|
174
|
+
resolve(cancelRes);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const okRes = {
|
|
178
|
+
tapIndex: Number(res.tapIndex),
|
|
179
|
+
errMsg: "showActionSheet:ok",
|
|
180
|
+
};
|
|
181
|
+
safeCall(options.success, okRes);
|
|
182
|
+
safeCall(options.complete, okRes);
|
|
183
|
+
resolve(okRes);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
if (onceSupported === null) {
|
|
187
|
+
onceSupported = typeof uni.$once === "function";
|
|
188
|
+
}
|
|
189
|
+
if (onceSupported) {
|
|
190
|
+
uni.$once(resultEvent, done);
|
|
191
|
+
} else {
|
|
192
|
+
uni.$on(resultEvent, done);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
emitUiEvent(EVENT_ACTION_SHEET_SHOW, {
|
|
196
|
+
id,
|
|
197
|
+
resultEvent,
|
|
198
|
+
options: actionSheetOptions,
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
showLoading(options = {}) {
|
|
203
|
+
const loadingOptions = {
|
|
204
|
+
title: options.title || "加载中...",
|
|
205
|
+
mask: options.mask === true,
|
|
206
|
+
};
|
|
207
|
+
emitUiEvent(EVENT_LOADING_SHOW, loadingOptions);
|
|
208
|
+
const res = { errMsg: "showLoading:ok" };
|
|
209
|
+
safeCall(options.success, res);
|
|
210
|
+
safeCall(options.complete, res);
|
|
211
|
+
},
|
|
212
|
+
hideLoading() {
|
|
213
|
+
emitUiEvent(EVENT_LOADING_HIDE);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
devUi.install();
|
|
218
|
+
|
|
219
|
+
export default devUi;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制调试工具
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 入口文件
|
|
7
|
+
*/
|
|
8
|
+
function init(options, devTools) {
|
|
9
|
+
|
|
10
|
+
let sysInfo = uni.getSystemInfoSync()
|
|
11
|
+
|
|
12
|
+
let tagConfig = uni.getStorageSync("devTools_tagConfig");
|
|
13
|
+
if (!tagConfig) {
|
|
14
|
+
tagConfig = {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tagConfig = Object.assign({
|
|
18
|
+
show: options.bubble.status,
|
|
19
|
+
x: sysInfo.screenWidth - 90,
|
|
20
|
+
y: sysInfo.screenHeight - 90,
|
|
21
|
+
}, tagConfig)
|
|
22
|
+
tagConfig.show = options.bubble.status;
|
|
23
|
+
|
|
24
|
+
// 拖动范围限制
|
|
25
|
+
let dragLimit = {
|
|
26
|
+
min: { x: 0, y: sysInfo.statusBarHeight, },
|
|
27
|
+
max: {
|
|
28
|
+
x: sysInfo.screenWidth - 70,
|
|
29
|
+
y: sysInfo.screenHeight - 24,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let view = new plus.nativeObj.View('debugTag', {
|
|
34
|
+
top: tagConfig.y + 'px',
|
|
35
|
+
left: tagConfig.x + 'px',
|
|
36
|
+
height: '24px',
|
|
37
|
+
width: '70px',
|
|
38
|
+
// backgroundColor: options.bubble.bgColor,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
view.drawRect({
|
|
42
|
+
color: options.bubble.bgColor,
|
|
43
|
+
// borderColor: "#222222",
|
|
44
|
+
// borderWidth: '1px',
|
|
45
|
+
radius: '6px',
|
|
46
|
+
}, {
|
|
47
|
+
top: '0px',
|
|
48
|
+
left: '0px',
|
|
49
|
+
height: '24px',
|
|
50
|
+
width: '70px',
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
view.drawText(options.bubble.text, {}, {
|
|
54
|
+
size: '12px',
|
|
55
|
+
color: options.bubble.color,
|
|
56
|
+
weight: 'bold'
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (tagConfig.show) {
|
|
60
|
+
view.show();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function hideBubble() {
|
|
64
|
+
if (!tagConfig.show) return;
|
|
65
|
+
view.hide();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function showBubble() {
|
|
69
|
+
if (!tagConfig.show) return;
|
|
70
|
+
view.show();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
uni.$on("devTools_overlay_show", hideBubble)
|
|
74
|
+
uni.$on("devTools_overlay_hide", showBubble)
|
|
75
|
+
|
|
76
|
+
let isTouch = false;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
let touchStart = {
|
|
80
|
+
l: 0,
|
|
81
|
+
t: 0,
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0,
|
|
84
|
+
time: 0,
|
|
85
|
+
hasMove: false,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
view.addEventListener("touchstart", (e) => {
|
|
89
|
+
isTouch = true;
|
|
90
|
+
touchStart.l = e.clientX;
|
|
91
|
+
touchStart.t = e.clientY;
|
|
92
|
+
touchStart.time = new Date().getTime();
|
|
93
|
+
touchStart.hasMove = false;
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
view.addEventListener("touchmove", (e) => {
|
|
97
|
+
if (!isTouch) return;
|
|
98
|
+
let x = e.screenX - touchStart.l;
|
|
99
|
+
let y = e.screenY - touchStart.t;
|
|
100
|
+
const moveDistance = Math.sqrt(x * x + y * y);
|
|
101
|
+
if (!touchStart.hasMove && moveDistance < 6) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!touchStart.hasMove) {
|
|
105
|
+
touchStart.hasMove = true;
|
|
106
|
+
}
|
|
107
|
+
x = Math.min(Math.max(x, dragLimit.min.x), dragLimit.max.x)
|
|
108
|
+
y = Math.min(Math.max(y, dragLimit.min.y), dragLimit.max.y)
|
|
109
|
+
|
|
110
|
+
view.setStyle({
|
|
111
|
+
top: y + 'px',
|
|
112
|
+
left: x + 'px',
|
|
113
|
+
})
|
|
114
|
+
touchStart.x = x;
|
|
115
|
+
touchStart.y = y;
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
view.addEventListener("touchend", (e) => {
|
|
119
|
+
isTouch = false;
|
|
120
|
+
if (
|
|
121
|
+
!touchStart.hasMove
|
|
122
|
+
|| touchStart.time > (new Date().getTime() - 300)
|
|
123
|
+
) {// 单击事件
|
|
124
|
+
devTools.show()
|
|
125
|
+
|
|
126
|
+
} else { //拖拽结束事件
|
|
127
|
+
|
|
128
|
+
tagConfig.x = touchStart.x;
|
|
129
|
+
tagConfig.y = touchStart.y;
|
|
130
|
+
|
|
131
|
+
uni.setStorageSync("devTools_tagConfig", tagConfig)
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
uni.setStorageSync("devTools_tagConfig", tagConfig)
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default init;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import devCache from "./devCache";
|
|
2
|
+
import devOptions from "./devOptions";
|
|
3
|
+
import jsonCompress from "./jsonCompress";
|
|
4
|
+
/**
|
|
5
|
+
* ! vue报错捕获
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* * vue错误日志上报
|
|
12
|
+
* @param {'ve'|'vw'|'oe'|'n'} type 错误类型
|
|
13
|
+
*/
|
|
14
|
+
function errorReport(msg, trace, type = "n") {
|
|
15
|
+
try {
|
|
16
|
+
if (!msg) return false;
|
|
17
|
+
|
|
18
|
+
if (msg instanceof Error) {
|
|
19
|
+
msg = msg.message;
|
|
20
|
+
}
|
|
21
|
+
let options = devOptions.getOptions()
|
|
22
|
+
if (!options.error.status) return;
|
|
23
|
+
|
|
24
|
+
let page = "未知";
|
|
25
|
+
try {
|
|
26
|
+
let pages = getCurrentPages()
|
|
27
|
+
let item = pages[pages.length - 1];
|
|
28
|
+
if (item && item.route) {
|
|
29
|
+
page = item.route;
|
|
30
|
+
}
|
|
31
|
+
} catch (error) { }
|
|
32
|
+
|
|
33
|
+
let logs = devCache.get("errorReport");
|
|
34
|
+
if (!logs) logs = [];
|
|
35
|
+
if (logs.length >= options.error.cache.rowMax) {
|
|
36
|
+
logs = logs.splice(0, options.error.cache.rowMax)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
msg = String(msg)
|
|
40
|
+
msg = jsonCompress.compressObject(msg, options.error.cache.rowSize / 2)
|
|
41
|
+
trace = String(trace)
|
|
42
|
+
trace = jsonCompress.compressObject(trace, options.error.cache.rowSize / 2)
|
|
43
|
+
|
|
44
|
+
logs.unshift({
|
|
45
|
+
t: new Date().getTime(),
|
|
46
|
+
m: msg,
|
|
47
|
+
tr: trace,
|
|
48
|
+
p: page,
|
|
49
|
+
type,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
console.error("__ignoreReport__", msg, trace)
|
|
53
|
+
|
|
54
|
+
logs = jsonCompress.compressArray(logs, "end", options.error.cache.size)
|
|
55
|
+
|
|
56
|
+
devCache.set("errorReport", logs)
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.log("errorReport error: ", error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export default errorReport;
|