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,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绘制调试工具
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 入口文件
|
|
7
|
+
*/
|
|
8
|
+
function init(options, devTools) {
|
|
9
|
+
let sysInfo = uni.getSystemInfoSync()
|
|
10
|
+
|
|
11
|
+
let tagConfig = uni.getStorageSync('devTools_tagConfig')
|
|
12
|
+
if (!tagConfig) {
|
|
13
|
+
tagConfig = {}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
tagConfig = Object.assign(
|
|
17
|
+
{
|
|
18
|
+
show: options.bubble.status,
|
|
19
|
+
x: sysInfo.screenWidth - 90,
|
|
20
|
+
y: sysInfo.screenHeight - 90
|
|
21
|
+
},
|
|
22
|
+
tagConfig
|
|
23
|
+
)
|
|
24
|
+
tagConfig.show = options.bubble.status
|
|
25
|
+
|
|
26
|
+
// 拖动范围限制
|
|
27
|
+
let dragLimit = {
|
|
28
|
+
min: { x: 0, y: sysInfo.statusBarHeight },
|
|
29
|
+
max: {
|
|
30
|
+
x: sysInfo.screenWidth - 70,
|
|
31
|
+
y: sysInfo.screenHeight - 24
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let view = new plus.nativeObj.View('debugTag', {
|
|
36
|
+
top: tagConfig.y + 'px',
|
|
37
|
+
left: tagConfig.x + 'px',
|
|
38
|
+
height: '24px',
|
|
39
|
+
width: '70px'
|
|
40
|
+
// backgroundColor: options.bubble.bgColor,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
view.drawRect(
|
|
44
|
+
{
|
|
45
|
+
color: options.bubble.bgColor,
|
|
46
|
+
// borderColor: "#222222",
|
|
47
|
+
// borderWidth: '1px',
|
|
48
|
+
radius: '6px'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
top: '0px',
|
|
52
|
+
left: '0px',
|
|
53
|
+
height: '24px',
|
|
54
|
+
width: '70px'
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
view.drawText(
|
|
59
|
+
options.bubble.text,
|
|
60
|
+
{},
|
|
61
|
+
{
|
|
62
|
+
size: '12px',
|
|
63
|
+
color: options.bubble.color,
|
|
64
|
+
weight: 'bold'
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if (tagConfig.show) {
|
|
69
|
+
view.show()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function hideBubble() {
|
|
73
|
+
if (!tagConfig.show) return
|
|
74
|
+
view.hide()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function showBubble() {
|
|
78
|
+
if (!tagConfig.show) return
|
|
79
|
+
view.show()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
uni.$on('devTools_overlay_show', hideBubble)
|
|
83
|
+
uni.$on('devTools_overlay_hide', showBubble)
|
|
84
|
+
|
|
85
|
+
let isTouch = false
|
|
86
|
+
|
|
87
|
+
let touchStart = {
|
|
88
|
+
l: 0,
|
|
89
|
+
t: 0,
|
|
90
|
+
x: 0,
|
|
91
|
+
y: 0,
|
|
92
|
+
time: 0,
|
|
93
|
+
hasMove: false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
view.addEventListener('touchstart', (e) => {
|
|
97
|
+
isTouch = true
|
|
98
|
+
touchStart.l = e.clientX
|
|
99
|
+
touchStart.t = e.clientY
|
|
100
|
+
touchStart.time = new Date().getTime()
|
|
101
|
+
touchStart.hasMove = false
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
view.addEventListener('touchmove', (e) => {
|
|
105
|
+
if (!isTouch) return
|
|
106
|
+
let x = e.screenX - touchStart.l
|
|
107
|
+
let y = e.screenY - touchStart.t
|
|
108
|
+
const moveDistance = Math.sqrt(x * x + y * y)
|
|
109
|
+
if (!touchStart.hasMove && moveDistance < 6) {
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
if (!touchStart.hasMove) {
|
|
113
|
+
touchStart.hasMove = true
|
|
114
|
+
}
|
|
115
|
+
x = Math.min(Math.max(x, dragLimit.min.x), dragLimit.max.x)
|
|
116
|
+
y = Math.min(Math.max(y, dragLimit.min.y), dragLimit.max.y)
|
|
117
|
+
|
|
118
|
+
view.setStyle({
|
|
119
|
+
top: y + 'px',
|
|
120
|
+
left: x + 'px'
|
|
121
|
+
})
|
|
122
|
+
touchStart.x = x
|
|
123
|
+
touchStart.y = y
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
view.addEventListener('touchend', (e) => {
|
|
127
|
+
isTouch = false
|
|
128
|
+
if (!touchStart.hasMove || touchStart.time > new Date().getTime() - 300) {
|
|
129
|
+
// 单击事件
|
|
130
|
+
devTools.show()
|
|
131
|
+
} else {
|
|
132
|
+
//拖拽结束事件
|
|
133
|
+
|
|
134
|
+
tagConfig.x = touchStart.x
|
|
135
|
+
tagConfig.y = touchStart.y
|
|
136
|
+
|
|
137
|
+
uni.setStorageSync('devTools_tagConfig', tagConfig)
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
uni.setStorageSync('devTools_tagConfig', tagConfig)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default init
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import devCache from './devCache'
|
|
2
|
+
import devOptions from './devOptions'
|
|
3
|
+
import jsonCompress from './jsonCompress'
|
|
4
|
+
/**
|
|
5
|
+
* ! vue报错捕获
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* * vue错误日志上报
|
|
10
|
+
* @param {'ve'|'vw'|'oe'|'n'} type 错误类型
|
|
11
|
+
*/
|
|
12
|
+
function errorReport(msg, trace, type = 'n') {
|
|
13
|
+
try {
|
|
14
|
+
if (!msg) return false
|
|
15
|
+
|
|
16
|
+
if (msg instanceof Error) {
|
|
17
|
+
msg = msg.message
|
|
18
|
+
}
|
|
19
|
+
let options = devOptions.getOptions()
|
|
20
|
+
if (!options.error.status) return
|
|
21
|
+
|
|
22
|
+
let page = '未知'
|
|
23
|
+
try {
|
|
24
|
+
let pages = getCurrentPages()
|
|
25
|
+
let item = pages[pages.length - 1]
|
|
26
|
+
if (item && item.route) {
|
|
27
|
+
page = item.route
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {}
|
|
30
|
+
|
|
31
|
+
let logs = devCache.get('errorReport')
|
|
32
|
+
if (!logs) logs = []
|
|
33
|
+
if (logs.length >= options.error.cache.rowMax) {
|
|
34
|
+
logs = logs.splice(0, options.error.cache.rowMax)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
msg = String(msg)
|
|
38
|
+
msg = jsonCompress.compressObject(msg, options.error.cache.rowSize / 2)
|
|
39
|
+
trace = String(trace)
|
|
40
|
+
trace = jsonCompress.compressObject(trace, options.error.cache.rowSize / 2)
|
|
41
|
+
|
|
42
|
+
logs.unshift({
|
|
43
|
+
t: new Date().getTime(),
|
|
44
|
+
m: msg,
|
|
45
|
+
tr: trace,
|
|
46
|
+
p: page,
|
|
47
|
+
type
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
console.error('__ignoreReport__', msg, trace)
|
|
51
|
+
|
|
52
|
+
logs = jsonCompress.compressArray(logs, 'end', options.error.cache.size)
|
|
53
|
+
|
|
54
|
+
devCache.set('errorReport', logs)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.log('errorReport error: ', error)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default errorReport
|