vite-uni-dev-tool 0.0.12 → 0.0.14
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/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AppInfo/index.vue +41 -0
- package/dist/v2/AutoSizer/index.vue +189 -0
- package/dist/v2/AutoSizer/index1.vue +193 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/CaptureScreen/index.vue +78 -0
- package/dist/v2/CloseButton/index.vue +32 -0
- package/dist/v2/Connection/index.vue +94 -0
- package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
- package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
- package/dist/v2/ConsoleList/index.vue +164 -0
- package/dist/v2/ConsoleList/staticTips.js +1144 -0
- package/dist/v2/DevTool/index.vue +162 -0
- package/dist/v2/DevToolButton/index.vue +228 -0
- package/dist/v2/DevToolTitle/index.vue +28 -0
- package/dist/v2/DevToolWindow/index.vue +1051 -0
- package/dist/v2/DeviceInfo/index.vue +48 -0
- package/dist/v2/Empty/index.vue +40 -0
- package/dist/v2/FilterInput/index.vue +100 -0
- package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
- package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
- package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
- package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/index.vue +531 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v2/JsonPretty/utils/index.js +211 -0
- package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
- package/dist/v2/NetworkList/NetworkItem.vue +135 -0
- package/dist/v2/NetworkList/index.vue +148 -0
- package/dist/v2/PiniaList/index.vue +79 -0
- package/dist/v2/RouteList/index.vue +137 -0
- package/dist/v2/SettingList/index.vue +318 -0
- package/dist/v2/SourceCode/index.vue +237 -0
- package/dist/v2/StorageList/index.vue +165 -0
- package/dist/v2/SystemInfo/index.vue +49 -0
- package/dist/v2/Tabs/index.vue +127 -0
- package/dist/v2/Tag/index.vue +91 -0
- package/dist/v2/UniEvent/UniEventItem.vue +157 -0
- package/dist/v2/UniEvent/index.vue +127 -0
- package/dist/v2/UploadList/UploadDetail.vue +204 -0
- package/dist/v2/UploadList/UploadItem.vue +134 -0
- package/dist/v2/UploadList/index.vue +143 -0
- package/dist/v2/VirtualList/index.vue +140 -0
- package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
- package/dist/v2/VirtualListPro/index.vue +255 -0
- package/dist/v2/VuexList/index.vue +80 -0
- package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
- package/dist/v2/WebSocket/WebSocketList.vue +183 -0
- package/dist/v2/WebSocket/index.vue +155 -0
- package/dist/v2/WindowInfo/index.vue +49 -0
- package/{dev/components → dist/v3}/AppInfo/index.vue +0 -1
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.ts +49 -0
- package/{dev/components → dist/v3}/CloseButton/index.vue +5 -2
- package/{dev/components → dist/v3}/ConsoleList/ConsoleItem.vue +10 -9
- package/{dev/components → dist/v3}/ConsoleList/RunJSInput.vue +5 -2
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/{dev/components → dist/v3}/DevTool/index.vue +33 -4
- package/{dev/components → dist/v3}/DevToolWindow/index.vue +67 -4
- package/dist/v3/Empty/empty.png +0 -0
- package/{dev/components → dist/v3}/FilterInput/index.vue +5 -4
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
- package/{dev/components → dist/v3}/JsonPretty/index.vue +10 -10
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.ts +125 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/{dev/components → dist/v3}/NetworkList/NetworkDetail.vue +2 -2
- package/{dev/components → dist/v3}/NetworkList/NetworkItem.vue +2 -1
- package/dist/v3/RunJS/index.vue +128 -0
- package/{dev/components → dist/v3}/SettingList/index.vue +128 -37
- package/{dev/components → dist/v3}/SourceCode/index.vue +2 -2
- package/{dev/components → dist/v3}/Tag/index.vue +4 -4
- package/{dev/components → dist/v3}/UploadList/UploadDetail.vue +3 -15
- package/{dev/components → dist/v3}/UploadList/UploadItem.vue +1 -1
- package/dist/v3/VirtualListPro/readme.md +40 -0
- package/{dev/components → dist/v3}/WebSocket/WebSocketItem.vue +1 -1
- package/{dev/components → dist/v3}/WebSocket/WebSocketList.vue +3 -15
- package/package.json +5 -5
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/const.ts +0 -164
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -810
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -732
- package/dev/devToolInfo/index.ts +0 -26
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -291
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -51
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -77
- package/dev/utils/object.ts +0 -306
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
- /package/{dev/components → dist/v2}/AutoSizer/utils.ts +0 -0
- /package/{dev/components → dist/v2}/Empty/empty.png +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useClipboard.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useError.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/type.ts +0 -0
- /package/{dev/components → dist/v2}/RunJS/index.vue +0 -0
- /package/{dev/components → dist/v2}/VirtualListPro/readme.md +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index.vue +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index1.vue +0 -0
- /package/{dev/components → dist/v3}/CaptureScreen/index.vue +0 -0
- /package/{dev/components → dist/v3}/Connection/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/staticTips.ts +0 -0
- /package/{dev/components → dist/v3}/DevToolButton/index.vue +0 -0
- /package/{dev/components → dist/v3}/DevToolTitle/index.vue +0 -0
- /package/{dev/components → dist/v3}/DeviceInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Empty/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Brackets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Carets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/CheckController/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/TreeNode/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/utils/index.ts +0 -0
- /package/{dev/components → dist/v3}/NetworkList/index.vue +0 -0
- /package/{dev/components → dist/v3}/PiniaList/index.vue +0 -0
- /package/{dev/components → dist/v3}/RouteList/index.vue +0 -0
- /package/{dev/components → dist/v3}/StorageList/index.vue +0 -0
- /package/{dev/components → dist/v3}/SystemInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Tabs/index.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/UniEventItem.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/index.vue +0 -0
- /package/{dev/components → dist/v3}/UploadList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/AutoSize.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/index.vue +0 -0
- /package/{dev/components → dist/v3}/VuexList/index.vue +0 -0
- /package/{dev/components → dist/v3}/WebSocket/index.vue +0 -0
- /package/{dev/components → dist/v3}/WindowInfo/index.vue +0 -0
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="dev-tool-code">
|
|
3
|
-
<view class="dev-tool-code-control">
|
|
4
|
-
<FilterInput
|
|
5
|
-
v-model="modelValue"
|
|
6
|
-
style="width: 100%"
|
|
7
|
-
@search="onSearch"
|
|
8
|
-
/>
|
|
9
|
-
<CloseButton style="margin-left: auto" @click="onClose" />
|
|
10
|
-
</view>
|
|
11
|
-
<view class="dev-tool-code-title">{{ fileName }}</view>
|
|
12
|
-
<scroll-view
|
|
13
|
-
scroll-y="true"
|
|
14
|
-
scroll-x="true"
|
|
15
|
-
class="dev-tool-code-list"
|
|
16
|
-
scroll-with-animation="true"
|
|
17
|
-
:scroll-top="scrollTop"
|
|
18
|
-
:scroll-into-view="scrollIntoView"
|
|
19
|
-
>
|
|
20
|
-
<view
|
|
21
|
-
v-for="(code, index) in codes"
|
|
22
|
-
:id="`dev-tool-code-item-${index}`"
|
|
23
|
-
:key="index"
|
|
24
|
-
:class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
|
|
25
|
-
>
|
|
26
|
-
<view class="dev-tool-code-item-index">
|
|
27
|
-
{{ start + index + 1 }}
|
|
28
|
-
</view>
|
|
29
|
-
|
|
30
|
-
<view class="dev-tool-code-item-content" v-html="code"></view>
|
|
31
|
-
</view>
|
|
32
|
-
<Empty v-if="!codes || codes.length === 0" />
|
|
33
|
-
</scroll-view>
|
|
34
|
-
</view>
|
|
35
|
-
</template>
|
|
36
|
-
<script lang="ts" setup>
|
|
37
|
-
import { computed, ref, nextTick, onMounted } from 'vue';
|
|
38
|
-
import FilterInput from '../FilterInput/index.vue';
|
|
39
|
-
import CloseButton from '../CloseButton/index.vue';
|
|
40
|
-
import Empty from '../Empty/index.vue';
|
|
41
|
-
import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
|
|
42
|
-
|
|
43
|
-
const props = defineProps<{
|
|
44
|
-
url: string;
|
|
45
|
-
sourceFileServers?: string[];
|
|
46
|
-
mode?: string;
|
|
47
|
-
}>();
|
|
48
|
-
|
|
49
|
-
const emit = defineEmits<{ (e: 'close'): void }>();
|
|
50
|
-
|
|
51
|
-
const modelValue = ref('');
|
|
52
|
-
const scrollTop = ref(0);
|
|
53
|
-
const fileName = computed(() => {
|
|
54
|
-
const name =
|
|
55
|
-
props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
|
|
56
|
-
return name;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
|
|
60
|
-
|
|
61
|
-
let backupCodes: string[] = [];
|
|
62
|
-
|
|
63
|
-
const codes = ref<string[]>([]);
|
|
64
|
-
|
|
65
|
-
const scrollIntoView = ref('');
|
|
66
|
-
|
|
67
|
-
const start = computed(() => {
|
|
68
|
-
return activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
function onClose() {
|
|
72
|
-
emit('close');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function onSearch(value: string) {
|
|
76
|
-
codes.value = backupCodes.map((code) => {
|
|
77
|
-
return hightLight(code, value);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let index = 0;
|
|
82
|
-
function getCode(url: string, i: number = 0) {
|
|
83
|
-
let allUrl = url;
|
|
84
|
-
// 平台判断
|
|
85
|
-
if (isAndroid()) {
|
|
86
|
-
if (!props.sourceFileServers?.[i]) {
|
|
87
|
-
index = 0;
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
allUrl = props.sourceFileServers?.[i] + '/src/' + url;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
uni.showLoading({ mask: true });
|
|
95
|
-
uni.request({
|
|
96
|
-
url: allUrl,
|
|
97
|
-
success: (res) => {
|
|
98
|
-
if (typeof res.data === 'string') {
|
|
99
|
-
// 为什么要注释掉?
|
|
100
|
-
// 在 Android 识别到标签后会进行重启,导致代码无法显示
|
|
101
|
-
// TODO: 还有其它原因导致重启
|
|
102
|
-
const str = res.data
|
|
103
|
-
?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
|
|
104
|
-
?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
|
|
105
|
-
?.replace(/<style/, '// [DevTool] 注释 <style')
|
|
106
|
-
?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
|
|
107
|
-
backupCodes = escapeHTML(str ?? '')
|
|
108
|
-
.toString()
|
|
109
|
-
.split('\n');
|
|
110
|
-
|
|
111
|
-
const start =
|
|
112
|
-
activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
|
|
113
|
-
|
|
114
|
-
const end =
|
|
115
|
-
activeRowCol.value.row + 20 > backupCodes.length
|
|
116
|
-
? backupCodes.length
|
|
117
|
-
: activeRowCol.value.row + 20;
|
|
118
|
-
|
|
119
|
-
// backupCodes.slice(start, end);
|
|
120
|
-
|
|
121
|
-
codes.value = backupCodes.slice(start, end);
|
|
122
|
-
|
|
123
|
-
activeRowCol.value.activeRow = activeRowCol.value.row - start;
|
|
124
|
-
|
|
125
|
-
nextTick(() => {
|
|
126
|
-
scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
fail: (err) => {
|
|
131
|
-
index++;
|
|
132
|
-
getCode(url, index);
|
|
133
|
-
uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
|
|
134
|
-
},
|
|
135
|
-
complete: () => {
|
|
136
|
-
uni.hideLoading();
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** 开发环境获取源代码 */
|
|
142
|
-
function getSourceCodeDev(url: string) {
|
|
143
|
-
if (!url) {
|
|
144
|
-
uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
|
|
145
|
-
uni?.__dev__console?.log('[DevTool] url 处理异常');
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getCode(url, index);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
onMounted(() => {
|
|
153
|
-
let url = props?.url;
|
|
154
|
-
|
|
155
|
-
const { path, col, row } = parseStock(props?.url ?? '');
|
|
156
|
-
|
|
157
|
-
if (path) {
|
|
158
|
-
url = path;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
activeRowCol.value.col = col;
|
|
162
|
-
activeRowCol.value.row = row;
|
|
163
|
-
|
|
164
|
-
if (props.mode === 'development') {
|
|
165
|
-
// 开发环境查看源码
|
|
166
|
-
getSourceCodeDev(url);
|
|
167
|
-
} else if (props.mode === 'production') {
|
|
168
|
-
// TODO 生产环境查看源码
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
</script>
|
|
172
|
-
<style scoped>
|
|
173
|
-
.dev-tool-code {
|
|
174
|
-
position: fixed;
|
|
175
|
-
width: 100vw;
|
|
176
|
-
height: 100vh;
|
|
177
|
-
z-index: 1000;
|
|
178
|
-
top: 0;
|
|
179
|
-
left: 0;
|
|
180
|
-
padding: 0 16px;
|
|
181
|
-
|
|
182
|
-
background-color: rgba(255, 255, 255, 0.95);
|
|
183
|
-
box-sizing: border-box;
|
|
184
|
-
color: #000;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.dev-tool-code-control {
|
|
188
|
-
display: flex;
|
|
189
|
-
align-items: center;
|
|
190
|
-
gap: 12px;
|
|
191
|
-
height: 32px;
|
|
192
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
193
|
-
box-sizing: border-box;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.dev-tool-code-title {
|
|
197
|
-
height: 32px;
|
|
198
|
-
line-height: 32px;
|
|
199
|
-
margin-bottom: 4px;
|
|
200
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
201
|
-
box-sizing: border-box;
|
|
202
|
-
white-space: nowrap;
|
|
203
|
-
overflow: auto;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.dev-tool-code-list {
|
|
207
|
-
height: calc(100% - 68px);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.dev-tool-code-item {
|
|
211
|
-
display: flex;
|
|
212
|
-
align-items: center;
|
|
213
|
-
height: 28px;
|
|
214
|
-
}
|
|
215
|
-
.dev-tool-code-item-active {
|
|
216
|
-
color: #fff;
|
|
217
|
-
background-color: var(--dev-tool-main-color);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.dev-tool-code-item-index {
|
|
221
|
-
flex-shrink: 0;
|
|
222
|
-
width: 20px;
|
|
223
|
-
margin-right: 8px;
|
|
224
|
-
text-align: right;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.dev-tool-code-item-content {
|
|
228
|
-
white-space: pre;
|
|
229
|
-
}
|
|
230
|
-
</style>
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="dev-tool-code">
|
|
3
|
-
<view class="dev-tool-code-control">
|
|
4
|
-
<FilterInput
|
|
5
|
-
v-model="modelValue"
|
|
6
|
-
style="width: 100%"
|
|
7
|
-
@search="onSearch"
|
|
8
|
-
/>
|
|
9
|
-
<CloseButton style="margin-left: auto" @click="onClose" />
|
|
10
|
-
</view>
|
|
11
|
-
<view class="dev-tool-code-title">{{ fileName }}</view>
|
|
12
|
-
<scroll-view
|
|
13
|
-
scroll-y="true"
|
|
14
|
-
scroll-x="true"
|
|
15
|
-
class="dev-tool-code-list"
|
|
16
|
-
scroll-with-animation="true"
|
|
17
|
-
:scroll-top="scrollTop"
|
|
18
|
-
:scroll-into-view="scrollIntoView"
|
|
19
|
-
>
|
|
20
|
-
<view
|
|
21
|
-
v-for="(code, index) in codes"
|
|
22
|
-
:id="`dev-tool-code-item-${index}`"
|
|
23
|
-
:key="index"
|
|
24
|
-
:class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
|
|
25
|
-
>
|
|
26
|
-
<view class="dev-tool-code-item-index"> {{ index + 1 }}</view>
|
|
27
|
-
|
|
28
|
-
<view class="dev-tool-code-item-content" v-html="code"></view>
|
|
29
|
-
</view>
|
|
30
|
-
<Empty v-if="!codes || codes.length === 0" />
|
|
31
|
-
</scroll-view>
|
|
32
|
-
</view>
|
|
33
|
-
</template>
|
|
34
|
-
<script lang="ts" setup>
|
|
35
|
-
import { computed, ref, nextTick, onMounted } from 'vue';
|
|
36
|
-
import FilterInput from '../FilterInput/index.vue';
|
|
37
|
-
import CloseButton from '../CloseButton/index.vue';
|
|
38
|
-
import Empty from '../Empty/index.vue';
|
|
39
|
-
import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
|
|
40
|
-
|
|
41
|
-
const props = defineProps<{
|
|
42
|
-
url: string;
|
|
43
|
-
sourceFileServers?: string[];
|
|
44
|
-
mode?: string;
|
|
45
|
-
}>();
|
|
46
|
-
|
|
47
|
-
const emit = defineEmits<{ (e: 'close'): void }>();
|
|
48
|
-
|
|
49
|
-
const modelValue = ref('');
|
|
50
|
-
const scrollTop = ref(0);
|
|
51
|
-
const fileName = computed(() => {
|
|
52
|
-
const name =
|
|
53
|
-
props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
|
|
54
|
-
return name;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
|
|
58
|
-
|
|
59
|
-
let backupCodes: string[] = [];
|
|
60
|
-
|
|
61
|
-
const codes = ref<string[]>([]);
|
|
62
|
-
|
|
63
|
-
const scrollIntoView = ref('');
|
|
64
|
-
|
|
65
|
-
function onClose() {
|
|
66
|
-
emit('close');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function onSearch(value: string) {
|
|
70
|
-
codes.value = backupCodes.map((code) => {
|
|
71
|
-
return hightLight(code, value);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let index = 0;
|
|
76
|
-
function getCode(url: string, i: number = 0) {
|
|
77
|
-
let allUrl = url;
|
|
78
|
-
// 平台判断
|
|
79
|
-
if (isAndroid()) {
|
|
80
|
-
if (!props.sourceFileServers?.[i]) {
|
|
81
|
-
index = 0;
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
allUrl = props.sourceFileServers?.[i] + '/src/' + url;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
uni.showLoading({ mask: true });
|
|
89
|
-
uni.request({
|
|
90
|
-
url: allUrl,
|
|
91
|
-
success: (res) => {
|
|
92
|
-
if (typeof res.data === 'string') {
|
|
93
|
-
// 为什么要注释掉?
|
|
94
|
-
// 在 Android 识别到标签后会进行重启,导致代码无法显示
|
|
95
|
-
// TODO: 还有其它原因导致重启
|
|
96
|
-
const str = res.data
|
|
97
|
-
?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
|
|
98
|
-
?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
|
|
99
|
-
?.replace(/<style/, '// [DevTool] 注释 <style')
|
|
100
|
-
?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
|
|
101
|
-
backupCodes = escapeHTML(str ?? '')
|
|
102
|
-
.toString()
|
|
103
|
-
.split('\n');
|
|
104
|
-
|
|
105
|
-
const start =
|
|
106
|
-
activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
|
|
107
|
-
|
|
108
|
-
const end =
|
|
109
|
-
activeRowCol.value.row + 20 > backupCodes.length
|
|
110
|
-
? backupCodes.length
|
|
111
|
-
: activeRowCol.value.row + 20;
|
|
112
|
-
|
|
113
|
-
// backupCodes.slice(start, end);
|
|
114
|
-
|
|
115
|
-
codes.value = backupCodes.slice(start, end);
|
|
116
|
-
|
|
117
|
-
activeRowCol.value.activeRow = activeRowCol.value.row - start;
|
|
118
|
-
|
|
119
|
-
nextTick(() => {
|
|
120
|
-
scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
fail: (err) => {
|
|
125
|
-
index++;
|
|
126
|
-
getCode(url, index);
|
|
127
|
-
uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
|
|
128
|
-
},
|
|
129
|
-
complete: () => {
|
|
130
|
-
uni.hideLoading();
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** 开发环境获取源代码 */
|
|
136
|
-
function getSourceCodeDev(url: string) {
|
|
137
|
-
if (!url) {
|
|
138
|
-
uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
|
|
139
|
-
uni?.__dev__console?.log('[DevTool] url 处理异常');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
getCode(url, index);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
onMounted(() => {
|
|
147
|
-
let url = props?.url;
|
|
148
|
-
|
|
149
|
-
const { path, col, row } = parseStock(props?.url ?? '');
|
|
150
|
-
|
|
151
|
-
if (path) {
|
|
152
|
-
url = path;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
activeRowCol.value.col = col;
|
|
156
|
-
activeRowCol.value.row = row;
|
|
157
|
-
|
|
158
|
-
if (props.mode === 'development') {
|
|
159
|
-
// 开发环境查看源码
|
|
160
|
-
getSourceCodeDev(url);
|
|
161
|
-
} else if (props.mode === 'production') {
|
|
162
|
-
// TODO 生产环境查看源码
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
</script>
|
|
166
|
-
<style scoped>
|
|
167
|
-
.dev-tool-code {
|
|
168
|
-
position: fixed;
|
|
169
|
-
width: 100vw;
|
|
170
|
-
height: 100vh;
|
|
171
|
-
z-index: 1000;
|
|
172
|
-
top: 0;
|
|
173
|
-
left: 0;
|
|
174
|
-
padding: 0 16px;
|
|
175
|
-
/* #ifdef H5 */
|
|
176
|
-
padding: 50px 16px;
|
|
177
|
-
/* #endif */
|
|
178
|
-
|
|
179
|
-
background-color: rgba(255, 255, 255, 0.95);
|
|
180
|
-
box-sizing: border-box;
|
|
181
|
-
color: #000;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.dev-tool-code-control {
|
|
185
|
-
display: flex;
|
|
186
|
-
align-items: center;
|
|
187
|
-
gap: 12px;
|
|
188
|
-
height: 32px;
|
|
189
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
190
|
-
box-sizing: border-box;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.dev-tool-code-title {
|
|
194
|
-
height: 32px;
|
|
195
|
-
line-height: 32px;
|
|
196
|
-
margin-bottom: 4px;
|
|
197
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
198
|
-
box-sizing: border-box;
|
|
199
|
-
white-space: nowrap;
|
|
200
|
-
overflow: auto;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
.dev-tool-code-list {
|
|
204
|
-
height: calc(100% - 68px);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
.dev-tool-code-item {
|
|
208
|
-
display: flex;
|
|
209
|
-
align-items: center;
|
|
210
|
-
height: 28px;
|
|
211
|
-
}
|
|
212
|
-
.dev-tool-code-item-active {
|
|
213
|
-
color: #fff;
|
|
214
|
-
background-color: var(--dev-tool-main-color);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
.dev-tool-code-item-index {
|
|
218
|
-
flex-shrink: 0;
|
|
219
|
-
width: 20px;
|
|
220
|
-
margin-right: 8px;
|
|
221
|
-
text-align: right;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.dev-tool-code-item-content {
|
|
225
|
-
white-space: pre;
|
|
226
|
-
}
|
|
227
|
-
</style>
|
package/dev/const.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 调试按钮事件
|
|
3
|
-
*/
|
|
4
|
-
export const DEV_BUTTON_VISIBLE = 'dev-button-visible';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 调试弹窗事件
|
|
8
|
-
*/
|
|
9
|
-
export const DEV_WINDOW_VISIBLE = 'dev-window-visible';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* app 发出的信息
|
|
13
|
-
*/
|
|
14
|
-
export const DEV_APP_MESSAGE = 'dev-app-message';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 调试弹窗发出的消息
|
|
18
|
-
*/
|
|
19
|
-
export const DEV_WINDOW_MESSAGE = 'dev-window-message';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 调试器销毁
|
|
23
|
-
*/
|
|
24
|
-
export const DEV_IS_DESTROY = 'dev-is-destroy';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 清空console
|
|
28
|
-
*/
|
|
29
|
-
export const DEV_CONSOLE_CLEAR = 'dev-console-clear';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 清空network
|
|
33
|
-
*/
|
|
34
|
-
export const DEV_NETWORK_CLEAR = 'dev-network-clear';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 清空websocket
|
|
38
|
-
*/
|
|
39
|
-
export const DEV_WEBSOCKET_CLEAR = 'dev-websocket-clear';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 清空upload
|
|
43
|
-
*/
|
|
44
|
-
export const DEV_UPLOAD_CLEAR = 'dev-upload-clear';
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 清空storage
|
|
48
|
-
*/
|
|
49
|
-
export const DEV_STORAGE_CLEAR = 'dev-storage-clear';
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 刷新storage
|
|
53
|
-
*/
|
|
54
|
-
export const DEV_STORAGE_REFRESH = 'dev-storage-refresh';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 移除storage
|
|
58
|
-
*/
|
|
59
|
-
export const DEV_STORAGE_REMOVE = 'dev-storage-remove';
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 新增storage
|
|
63
|
-
*/
|
|
64
|
-
export const DEV_STORAGE_ADD = 'dev-storage-add';
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 更新storage
|
|
68
|
-
*/
|
|
69
|
-
export const DEV_STORAGE_UPDATE = 'dev-storage-update';
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 页面跳转
|
|
73
|
-
*/
|
|
74
|
-
export const DEV_PAGE_JUMP = 'dev-page-jump';
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 隐藏调试按钮
|
|
78
|
-
*/
|
|
79
|
-
export const DEV_BUTTON_SHOW_OR_HIDE = 'dev-button-show-or-hide';
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 重启调试器
|
|
83
|
-
*/
|
|
84
|
-
export const DEV_RESTART_DEBUGGER = 'dev-restart-debugger';
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 重启app
|
|
88
|
-
*/
|
|
89
|
-
export const DEV_RESTART_APP = 'dev-restart-app';
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* 导出日志
|
|
93
|
-
*/
|
|
94
|
-
export const DEV_EXPORT_LOG = 'dev-export-log';
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 改变vuex数据
|
|
98
|
-
*/
|
|
99
|
-
export const DEV_VUEX_CHANGE = 'dev-vuex-change';
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 改变pinia
|
|
103
|
-
*/
|
|
104
|
-
export const DEV_PINIA_CHANGE = 'dev-pinia-change';
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 清除日志缓存
|
|
108
|
-
*/
|
|
109
|
-
export const DEV_LOG_CACHE_CLEAR = 'dev-log-cache-clear';
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* 销毁调试工具
|
|
113
|
-
*/
|
|
114
|
-
export const DEV_DESTROY = 'dev-destroy';
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 显示调试弹窗
|
|
118
|
-
*/
|
|
119
|
-
export const DEV_WINDOW_OPEN = 'dev-window-open';
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 显示调试弹窗
|
|
123
|
-
*/
|
|
124
|
-
export const DEV_WINDOW_CLOSE = 'dev-window-close';
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* 刷新路由列表
|
|
128
|
-
*/
|
|
129
|
-
export const DEV_ROUTE_REFRESH = 'dev-route-refresh';
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 获取 dev option
|
|
133
|
-
*/
|
|
134
|
-
export const DEV_OPTION = 'dev-option';
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* 获取options
|
|
138
|
-
*/
|
|
139
|
-
export const DEV_OPTION_GET = 'dev-option-get';
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 发送 options
|
|
143
|
-
*/
|
|
144
|
-
export const DEV_OPTION_SEND = 'dev-option-send';
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* 清空事件
|
|
148
|
-
*/
|
|
149
|
-
export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 运行js
|
|
153
|
-
*/
|
|
154
|
-
export const DEV_RUN_JS = 'dev-uni-run-js';
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* 清空截屏列表
|
|
158
|
-
*/
|
|
159
|
-
export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 存储的dev-tool 信息
|
|
163
|
-
*/
|
|
164
|
-
export const DEV_TOOL_INFO = 'dev-tool-info';
|