vite-uni-dev-tool 0.0.12 → 0.0.13

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.
Files changed (181) hide show
  1. package/dist/const.d.ts +133 -0
  2. package/dist/const.d.ts.map +1 -0
  3. package/dist/const.js +36 -0
  4. package/dist/core.d.ts +52 -0
  5. package/dist/core.d.ts.map +1 -0
  6. package/dist/core.js +80 -0
  7. package/dist/devConsole/index.d.ts +169 -0
  8. package/dist/devConsole/index.d.ts.map +1 -0
  9. package/dist/devConsole/index.js +270 -0
  10. package/dist/devEvent/index.d.ts +286 -0
  11. package/dist/devEvent/index.d.ts.map +1 -0
  12. package/dist/devEvent/index.js +435 -0
  13. package/dist/devEventBus/index.d.ts +42 -0
  14. package/dist/devEventBus/index.d.ts.map +1 -0
  15. package/dist/devEventBus/index.js +70 -0
  16. package/dist/devIntercept/index.d.ts +119 -0
  17. package/dist/devIntercept/index.d.ts.map +1 -0
  18. package/dist/devIntercept/index.js +582 -0
  19. package/dist/devRunJS/index.d.ts +67 -0
  20. package/dist/devRunJS/index.d.ts.map +1 -0
  21. package/dist/devStore/index.d.ts +178 -0
  22. package/dist/devStore/index.d.ts.map +1 -0
  23. package/dist/devStore/index.js +395 -0
  24. package/dist/devToolInfo/index.d.ts +17 -0
  25. package/dist/devToolInfo/index.d.ts.map +1 -0
  26. package/dist/devToolInfo/index.js +15 -0
  27. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
  28. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  29. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  30. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  31. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  32. package/dist/plugins/utils/index.js +1 -0
  33. package/dist/type.d.ts +264 -0
  34. package/dist/type.d.ts.map +1 -0
  35. package/dist/utils/array.d.ts +2 -0
  36. package/dist/utils/array.d.ts.map +1 -0
  37. package/dist/utils/array.js +12 -0
  38. package/dist/utils/date.d.ts +19 -0
  39. package/dist/utils/date.d.ts.map +1 -0
  40. package/dist/utils/date.js +40 -0
  41. package/dist/utils/file.d.ts +11 -0
  42. package/dist/utils/file.d.ts.map +1 -0
  43. package/dist/utils/file.js +87 -0
  44. package/dist/utils/function.d.ts +28 -0
  45. package/dist/utils/function.d.ts.map +1 -0
  46. package/dist/utils/function.js +46 -0
  47. package/dist/utils/index.d.ts +11 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/index.js +55 -0
  50. package/dist/utils/ip.d.ts +5 -0
  51. package/dist/utils/ip.d.ts.map +1 -0
  52. package/dist/utils/ip.js +21 -0
  53. package/dist/utils/language.d.ts +29 -0
  54. package/dist/utils/language.d.ts.map +1 -0
  55. package/dist/utils/language.js +50 -0
  56. package/dist/utils/object.d.ts +49 -0
  57. package/dist/utils/object.d.ts.map +1 -0
  58. package/dist/utils/object.js +118 -0
  59. package/dist/utils/page.d.ts +7 -0
  60. package/dist/utils/page.d.ts.map +1 -0
  61. package/dist/utils/page.js +7 -0
  62. package/dist/utils/platform.d.ts +4 -0
  63. package/dist/utils/platform.d.ts.map +1 -0
  64. package/dist/utils/platform.js +14 -0
  65. package/dist/utils/string.d.ts +45 -0
  66. package/dist/utils/string.d.ts.map +1 -0
  67. package/dist/utils/string.js +88 -0
  68. package/dist/utils/utils.d.ts +16 -0
  69. package/dist/utils/utils.d.ts.map +1 -0
  70. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  71. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  72. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  73. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  74. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  75. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  76. package/dist/v2/JsonPretty/type.d.ts +93 -0
  77. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  78. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  79. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  80. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  81. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  82. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  83. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  84. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  85. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  86. package/dist/v3/JsonPretty/type.d.ts +93 -0
  87. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  88. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  89. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  90. package/package.json +5 -5
  91. package/dev/components/AppInfo/index.vue +0 -36
  92. package/dev/components/AutoSizer/index.vue +0 -193
  93. package/dev/components/AutoSizer/index1.vue +0 -186
  94. package/dev/components/AutoSizer/utils.ts +0 -49
  95. package/dev/components/Button/index.vue +0 -34
  96. package/dev/components/CaptureScreen/index.vue +0 -62
  97. package/dev/components/Checkbox/index.vue +0 -40
  98. package/dev/components/CloseButton/index.vue +0 -26
  99. package/dev/components/Code/index.vue +0 -230
  100. package/dev/components/Connection/index.vue +0 -88
  101. package/dev/components/ConsoleList/Code.vue +0 -227
  102. package/dev/components/ConsoleList/ConsoleItem.vue +0 -207
  103. package/dev/components/ConsoleList/RunJSInput.vue +0 -237
  104. package/dev/components/ConsoleList/index.vue +0 -139
  105. package/dev/components/ConsoleList/staticTips.ts +0 -1145
  106. package/dev/components/DevTool/index.vue +0 -188
  107. package/dev/components/DevToolButton/index.vue +0 -210
  108. package/dev/components/DevToolTitle/index.vue +0 -21
  109. package/dev/components/DevToolWindow/index.vue +0 -1053
  110. package/dev/components/DeviceInfo/index.vue +0 -32
  111. package/dev/components/Empty/empty.png +0 -0
  112. package/dev/components/Empty/index.vue +0 -28
  113. package/dev/components/FilterInput/index.vue +0 -86
  114. package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
  115. package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
  116. package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
  117. package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
  118. package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
  119. package/dev/components/JsonPretty/hooks/useError.ts +0 -21
  120. package/dev/components/JsonPretty/index.vue +0 -476
  121. package/dev/components/JsonPretty/type.ts +0 -125
  122. package/dev/components/JsonPretty/utils/index.ts +0 -172
  123. package/dev/components/NetworkList/NetworkDetail.vue +0 -194
  124. package/dev/components/NetworkList/NetworkItem.vue +0 -119
  125. package/dev/components/NetworkList/index.vue +0 -128
  126. package/dev/components/PiniaList/index.vue +0 -64
  127. package/dev/components/RouteList/index.vue +0 -121
  128. package/dev/components/RunJS/index.vue +0 -128
  129. package/dev/components/SettingList/index.vue +0 -222
  130. package/dev/components/SourceCode/index.vue +0 -231
  131. package/dev/components/StorageList/index.vue +0 -170
  132. package/dev/components/SystemInfo/index.vue +0 -34
  133. package/dev/components/Tabs/index.vue +0 -123
  134. package/dev/components/Tag/index.vue +0 -89
  135. package/dev/components/UniEvent/UniEventItem.vue +0 -126
  136. package/dev/components/UniEvent/index.vue +0 -98
  137. package/dev/components/UploadList/UploadDetail.vue +0 -204
  138. package/dev/components/UploadList/UploadItem.vue +0 -117
  139. package/dev/components/UploadList/index.vue +0 -117
  140. package/dev/components/VirtualList/index.vue +0 -112
  141. package/dev/components/VirtualListPro/AutoSize.vue +0 -43
  142. package/dev/components/VirtualListPro/index.vue +0 -238
  143. package/dev/components/VirtualListPro/readme.md +0 -40
  144. package/dev/components/VuexList/index.vue +0 -54
  145. package/dev/components/WebSocket/WebSocketItem.vue +0 -103
  146. package/dev/components/WebSocket/WebSocketList.vue +0 -173
  147. package/dev/components/WebSocket/index.vue +0 -124
  148. package/dev/components/WindowInfo/index.vue +0 -33
  149. package/dev/const.ts +0 -164
  150. package/dev/core.ts +0 -118
  151. package/dev/devConsole/index.ts +0 -350
  152. package/dev/devEvent/index.ts +0 -810
  153. package/dev/devEventBus/index.ts +0 -94
  154. package/dev/devIntercept/index.ts +0 -745
  155. package/dev/devRunJS/index.ts +0 -170
  156. package/dev/devStore/index.ts +0 -732
  157. package/dev/devToolInfo/index.ts +0 -26
  158. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  159. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  160. package/dev/plugins/utils/index.js +0 -1
  161. package/dev/shims-uni.d.ts +0 -43
  162. package/dev/type.ts +0 -291
  163. package/dev/utils/array.ts +0 -15
  164. package/dev/utils/date.ts +0 -75
  165. package/dev/utils/file.ts +0 -121
  166. package/dev/utils/function.ts +0 -192
  167. package/dev/utils/index.d.ts +0 -6
  168. package/dev/utils/index.ts +0 -51
  169. package/dev/utils/ip.ts +0 -79
  170. package/dev/utils/language.ts +0 -77
  171. package/dev/utils/object.ts +0 -306
  172. package/dev/utils/page.ts +0 -13
  173. package/dev/utils/platform.ts +0 -14
  174. package/dev/utils/string.ts +0 -133
  175. package/dev/utils/utils.ts +0 -198
  176. /package/{dev → dist}/index.d.ts +0 -0
  177. /package/{dev → dist}/index.d.ts.map +0 -0
  178. /package/{dev → dist}/index.js +0 -0
  179. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  180. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
  181. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
@@ -1,121 +0,0 @@
1
- <template>
2
- <view class="route-content">
3
- <view class="route-control">
4
- <FilterInput
5
- style="width: 100%"
6
- placeholder="搜索name/path"
7
- :modelValue="modelValue"
8
- @search="emit('search', $event)"
9
- @update:modelValue="emit('update:modelValue', $event)"
10
- />
11
- <Tag mode="clear" @click="onRefresh">刷新</Tag>
12
- </view>
13
-
14
- <VirtualListPro
15
- :data="routeList"
16
- :pageSize="15"
17
- :height="height"
18
- className="route-list"
19
- >
20
- <template v-slot="{ list, start }">
21
- <AutoSize
22
- v-for="(item, index) in list"
23
- :index="start + index"
24
- :key="start + index"
25
- >
26
- <view class="route-item">
27
- <view class="route-item-name">
28
- <view v-html="item.name" />
29
- <Tag v-if="item.type" mode="info">{{ item.type }}</Tag>
30
- <Tag mode="warn" v-if="item.index === 4 || item.index === 3">
31
- 当前页
32
- </Tag>
33
- <Tag mode="primary" v-if="item.index === 4 || item.index === 2">
34
- 启动页
35
- </Tag>
36
- </view>
37
- <view class="route-item-path">
38
- <view v-html="item.path" />
39
- <Tag mode="main" @click="onGoTo(item)">跳转</Tag>
40
- </view>
41
- </view>
42
- </AutoSize>
43
- <Empty v-if="!routeList || routeList.length === 0" />
44
- </template>
45
- </VirtualListPro>
46
- </view>
47
- </template>
48
- <script lang="ts" setup>
49
- import Tag from '../Tag/index.vue';
50
- import Empty from '../Empty/index.vue';
51
- import FilterInput from '../FilterInput/index.vue';
52
- import type { DevTool } from '../../type';
53
- import VirtualListPro from '../VirtualListPro/index.vue';
54
- import AutoSize from '../VirtualListPro/AutoSize.vue';
55
- import { onMounted, ref } from 'vue';
56
-
57
- defineProps<{ routeList: DevTool.Page[]; modelValue?: string }>();
58
- const emit = defineEmits<{
59
- (e: 'goTo', params: DevTool.Page): void;
60
- (e: 'search', value: string): void;
61
- (e: 'update:modelValue', value: string): void;
62
- (e: 'routeRefresh'): void;
63
- }>();
64
-
65
- function onGoTo(page: DevTool.Page) {
66
- emit('goTo', page);
67
- }
68
- function onRefresh() {
69
- emit('routeRefresh');
70
- }
71
- const height = ref(0);
72
- onMounted(() => {
73
- const { windowHeight } = uni.getWindowInfo();
74
- height.value = windowHeight - 32 - 32;
75
- });
76
- </script>
77
- <style scoped>
78
- .route-content {
79
- height: 100%;
80
-
81
- font-size: var(--dev-tool-base-font-size);
82
- }
83
-
84
- .route-control {
85
- display: flex;
86
- align-items: center;
87
- justify-content: flex-end;
88
- gap: 8px;
89
- padding: 0 16px;
90
- height: 32px;
91
- border-bottom: 1px solid var(--dev-tool-border-color);
92
- box-sizing: border-box;
93
- }
94
-
95
- .route-list {
96
- height: calc(100% - 32px);
97
- overflow: auto;
98
- }
99
- .route-content .route-item {
100
- padding: 16px;
101
- border-bottom: 1px solid var(--dev-tool-border-color);
102
- }
103
- .route-content .route-item .route-item-name {
104
- display: flex;
105
- align-items: center;
106
- margin-bottom: 8px;
107
- gap: 12px;
108
- }
109
-
110
- .route-content .route-item .route-item-path {
111
- display: flex;
112
- align-items: center;
113
- justify-content: space-between;
114
- word-break: break-all;
115
- }
116
- /* #ifdef APP-PLUS */
117
- .route-content .route-item .route-item-path :deep(.tag) {
118
- margin-left: 16px;
119
- }
120
- /* #endif */
121
- </style>
@@ -1,128 +0,0 @@
1
- <template>
2
- <view class="run-js">
3
- <view class="run-js-control">
4
- <FilterInput
5
- :modelValue="modelValue"
6
- placeholder="查询"
7
- @search="emit('search', $event)"
8
- @update:modelValue="emit('update:modelValue', $event)"
9
- />
10
- <Tag mode="clear" @click="emit('clear')">清空</Tag>
11
- </view>
12
- <view class="run-js-list">
13
- <view class="run-js-item" v-for="item in runJSList">
14
- <view :class="`run-js-item-icon run-js-item-${item.mode}`"></view>
15
- <view class="run-js-item-duration" v-if="item.mode === 'output'">
16
- {{ item.duration }}ms
17
- </view>
18
- <view
19
- class="run-js-item-content"
20
- v-html="item.mode === 'input' ? item.code : item.result"
21
- >
22
- </view>
23
- </view>
24
- <view class="run-js-item">
25
- <view class="run-js-item-icon run-js-item-input"> </view>
26
-
27
- <input v-model="code" class="run-js-input" @confirm="onConfirm" />
28
- </view>
29
- </view>
30
- </view>
31
- </template>
32
- <script lang="ts" setup>
33
- import { ref } from 'vue';
34
- import type { DevTool } from '../../type';
35
- import FilterInput from '../FilterInput/index.vue';
36
- import Tag from '../Tag/index.vue';
37
-
38
- defineProps<{ runJSList: DevTool.RunJSItem[]; modelValue: string }>();
39
-
40
- const emit = defineEmits<{
41
- (e: 'search', value: string): void;
42
- (e: 'update:modelValue', value: string): void;
43
- (e: 'clear'): void;
44
- (e: 'run', value: string): void;
45
- }>();
46
- const code = ref('');
47
- function onConfirm() {
48
- const value = code.value;
49
- if (!value) return;
50
- code.value = '';
51
- setTimeout(() => {
52
- emit('run', value);
53
- }, 100);
54
- }
55
- </script>
56
- <style scoped>
57
- .run-js {
58
- height: 100%;
59
- font-size: var(--dev-tool-base-font-size);
60
- }
61
- .run-js-control {
62
- display: flex;
63
- align-items: center;
64
- justify-content: space-between;
65
- gap: 8px;
66
- padding: 0 16px;
67
- height: 32px;
68
- border-bottom: 1px solid var(--dev-tool-border-color);
69
- box-sizing: border-box;
70
- }
71
-
72
- .run-js-list {
73
- height: calc(100% - 32px);
74
- overflow: auto;
75
- }
76
-
77
- .run-js-item {
78
- position: relative;
79
- display: flex;
80
- padding: 0 16px;
81
- min-height: 28px;
82
- border-bottom: 1px solid var(--dev-tool-border-color);
83
- overflow: hidden;
84
- }
85
-
86
- .run-js-item-icon {
87
- width: 8px;
88
- height: 8px;
89
- border: 1px solid #000;
90
- border-bottom-color: transparent;
91
- border-left-color: transparent;
92
- overflow: hidden;
93
- }
94
-
95
- .run-js-item-input {
96
- margin: 10px 0 10px -4px;
97
- transform: rotate(45deg);
98
- }
99
-
100
- .run-js-item-output {
101
- margin: 10px -4px 10px 0px;
102
- transform: rotate(-135deg);
103
- }
104
-
105
- .run-js-item-content {
106
- margin-left: 16px;
107
- min-height: 28px;
108
- line-height: 28px;
109
- white-space: pre-line;
110
- word-break: break-all;
111
- }
112
-
113
- .run-js-input {
114
- margin: 1px 0 1px 16px;
115
- min-height: 26px;
116
- width: 100%;
117
- border: 1px solid transparent;
118
- font-size: var(--dev-tool-base-font-size);
119
- }
120
-
121
- .run-js-item-duration {
122
- position: absolute;
123
- top: 2px;
124
- right: 16px;
125
- height: 24px;
126
- line-height: 24px;
127
- }
128
- </style>
@@ -1,222 +0,0 @@
1
- <template>
2
- <view class="setting-content">
3
- <view class="setting-item">
4
- <DevToolTitle>DevTool</DevToolTitle>
5
- <view class="setting-item-content">
6
- <view class="setting-row">
7
- <view>显示调试按钮:</view>
8
- <Checkbox
9
- :modelValue="devToolVisible"
10
- @change="onChangeShowDevButton"
11
- />
12
- </view>
13
- <view class="setting-tips"> 取消后将不在展示调试按钮 </view>
14
- <view class="setting-row">
15
- <view>重启调试器:</view>
16
- </view>
17
-
18
- <view class="setting-tips">点击后将会重启调试器</view>
19
- <DButton class="setting-button" @click="onRestartDevTool(true)">
20
- 重启调试器
21
- </DButton>
22
-
23
- <view class="setting-row">
24
- <view>销毁调试器:</view>
25
- </view>
26
-
27
- <view class="setting-tips">
28
- 点击后将会销毁调试器,销毁后不再接收调试信息,需要通过 createDevTool()
29
- 重新创建
30
- </view>
31
- <DButton class="setting-button" @click="onDestructionDevTool">
32
- 销毁调试器
33
- </DButton>
34
-
35
- <view class="setting-row">
36
- <view>重启APP:</view>
37
- </view>
38
- <view class="setting-tips">点击后将会重启APP</view>
39
- <DButton class="setting-button" @click="onRestartApp(true)">
40
- 重启APP
41
- </DButton>
42
- <view class="setting-row">
43
- <view>占用存储空间:{{ sizeFormat }}</view>
44
- </view>
45
- <view class="setting-tips">
46
- 当前所有信息占用的存储空间,只会清除 Console, Network, Upload,
47
- Websocket, UniEvent
48
- </view>
49
- <DButton class="setting-button" @click="onClearCache">
50
- 清除缓存
51
- </DButton>
52
- </view>
53
- </view>
54
- <view class="setting-item">
55
- <DevToolTitle>Log</DevToolTitle>
56
- <view class="setting-item-content">
57
- <view class="setting-row">
58
- <view>导出当前日志信息:</view>
59
- <Checkbox v-model="setting.exportLog" />
60
- </view>
61
- <view class="setting-tips">勾选后将会导出当前的Log</view>
62
- <view class="setting-row">
63
- <view>导出当前网络信息:</view>
64
- <Checkbox v-model="setting.exportNetwork" />
65
- </view>
66
- <view class="setting-tips">勾选后将会导出当前的Network</view>
67
- <view class="setting-row">
68
- <view>导出当前上传信息:</view>
69
- <Checkbox v-model="setting.exportUpload" />
70
- </view>
71
- <view class="setting-tips">勾选后将会导出当前的Upload</view>
72
- <view class="setting-row">
73
- <view>导出当前套接字信息:</view>
74
- <Checkbox v-model="setting.exportWebsocket" />
75
- </view>
76
- <view class="setting-tips">勾选后将会导出当前的Websocket</view>
77
- <view class="setting-row">
78
- <view>导出当前缓存信息:</view>
79
- <Checkbox v-model="setting.exportStorage" />
80
- </view>
81
- <view class="setting-tips">
82
- 勾选后将会导出当前的Storage, Vuex, Pinia
83
- </view>
84
- <view class="setting-row">
85
- <view>导出当前窗口信息:</view>
86
- <Checkbox v-model="setting.exportWindow" />
87
- </view>
88
- <view class="setting-tips">勾选后将会导出当前的Window</view>
89
-
90
- <view class="setting-row">
91
- <view>导出当前设备信息:</view>
92
- <Checkbox v-model="setting.exportDevice" />
93
- </view>
94
- <view class="setting-tips">勾选后将会导出当前的Device</view>
95
-
96
- <view class="setting-row">
97
- <view>导出当前系统信息:</view>
98
- <Checkbox v-model="setting.exportSystem" />
99
- </view>
100
- <view class="setting-tips">勾选后将会导出当前的System</view>
101
-
102
- <DButton class="setting-button" @click="onExportLog"> 导出 </DButton>
103
- </view>
104
- </view>
105
-
106
- <!--
107
- <view class="setting-item">
108
- <view class="setting-item-title">截图</view>
109
- <DButton
110
- class="setting-button"
111
-
112
- @click="onScreenshot"
113
- >
114
- 截图当前路由
115
- </DButton>
116
- </view>
117
- -->
118
- </view>
119
- </template>
120
- <script lang="ts" setup>
121
- import { reactive } from 'vue';
122
- import Checkbox from '../Checkbox/index.vue';
123
- import DButton from '../Button/index.vue';
124
- import DevToolTitle from '../DevToolTitle/index.vue';
125
- defineProps<{
126
- devToolVisible?: boolean;
127
- sizeFormat?: string;
128
- }>();
129
- const setting = reactive({
130
- restartDevTool: false,
131
- restartApp: false,
132
- exportLog: false,
133
- exportNetwork: false,
134
- exportUpload: false,
135
- exportStorage: false,
136
- exportWebsocket: false,
137
- exportWindow: false,
138
- exportDevice: false,
139
- exportSystem: false,
140
- });
141
- const emit = defineEmits<{
142
- (e: 'showDevButton', show: boolean): void;
143
- (e: 'restartDevTool', restart?: boolean): void;
144
- (e: 'restartApp', restart?: boolean): void;
145
- (
146
- e: 'exportLog',
147
- params: {
148
- exportLog: boolean;
149
- exportNetwork: boolean;
150
- exportStorage: boolean;
151
- exportWebsocket: boolean;
152
- exportUpload: boolean;
153
- exportWindow: boolean;
154
- exportDevice: boolean;
155
- exportSystem: boolean;
156
- },
157
- ): void;
158
- (e: 'screenshot'): void;
159
- (e: 'clearCache'): void;
160
- (e: 'destroyDevTool'): void;
161
- }>();
162
-
163
- function onChangeShowDevButton(show: boolean) {
164
- emit('showDevButton', show);
165
- }
166
- function onRestartDevTool(restart: boolean) {
167
- restart && emit('restartDevTool');
168
- }
169
-
170
- function onDestructionDevTool() {
171
- emit('destroyDevTool');
172
- }
173
-
174
- function onRestartApp(restart: boolean) {
175
- restart && emit('restartApp');
176
- }
177
- function onExportLog() {
178
- if (setting.exportLog || setting.exportNetwork || setting.exportStorage) {
179
- emit('exportLog', {
180
- exportLog: setting.exportLog,
181
- exportNetwork: setting.exportNetwork,
182
- exportStorage: setting.exportStorage,
183
- exportWebsocket: setting.exportWebsocket,
184
- exportUpload: setting.exportUpload,
185
- exportWindow: setting.exportWindow,
186
- exportDevice: setting.exportDevice,
187
- exportSystem: setting.exportSystem,
188
- });
189
- }
190
- }
191
- function onScreenshot() {
192
- emit('screenshot');
193
- }
194
-
195
- function onClearCache() {
196
- emit('clearCache');
197
- }
198
- </script>
199
- <style scoped>
200
- .setting-content {
201
- height: 100%;
202
- overflow: auto;
203
- font-size: var(--dev-tool-base-font-size);
204
- }
205
- .setting-item {
206
- padding: 16px 16px 0 16px;
207
- box-sizing: border-box;
208
- }
209
-
210
- .setting-row {
211
- display: flex;
212
- align-items: center;
213
- justify-content: space-between;
214
- margin: 8px 0;
215
- min-height: 18px;
216
- }
217
- .setting-tips {
218
- color: #616161;
219
- font-size: var(--dev-tool-tips-font-size);
220
- margin-bottom: 8px;
221
- }
222
- </style>
@@ -1,231 +0,0 @@
1
- <template>
2
- <view class="dev-tool-code" :style="{ zIndex: zIndex }">
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
- zIndex?: number;
48
- }>();
49
-
50
- const emit = defineEmits<{ (e: 'close'): void }>();
51
-
52
- const modelValue = ref('');
53
- const scrollTop = ref(0);
54
- const fileName = computed(() => {
55
- const name =
56
- props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
57
- return name;
58
- });
59
-
60
- const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
61
-
62
- let backupCodes: string[] = [];
63
-
64
- const codes = ref<string[]>([]);
65
-
66
- const scrollIntoView = ref('');
67
-
68
- const start = computed(() => {
69
- return activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
70
- });
71
-
72
- function onClose() {
73
- emit('close');
74
- }
75
-
76
- function onSearch(value: string) {
77
- codes.value = backupCodes.map((code) => {
78
- return hightLight(code, value);
79
- });
80
- }
81
-
82
- let index = 0;
83
- function getCode(url: string, i: number = 0) {
84
- let allUrl = url;
85
- // 平台判断
86
- if (isAndroid()) {
87
- if (!props.sourceFileServers?.[i]) {
88
- index = 0;
89
- return;
90
- }
91
-
92
- allUrl = props.sourceFileServers?.[i] + '/src/' + url;
93
- }
94
-
95
- uni.showLoading({ mask: true });
96
- uni.request({
97
- url: allUrl,
98
- success: (res) => {
99
- if (typeof res.data === 'string') {
100
- // 为什么要注释掉?
101
- // 在 Android 识别到标签后会进行重启,导致代码无法显示
102
- // TODO: 还有其它原因导致重启
103
- const str = res.data
104
- ?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
105
- ?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
106
- ?.replace(/<style/, '// [DevTool] 注释 <style')
107
- ?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
108
- backupCodes = escapeHTML(str ?? '')
109
- .toString()
110
- .split('\n');
111
-
112
- const start =
113
- activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
114
-
115
- const end =
116
- activeRowCol.value.row + 20 > backupCodes.length
117
- ? backupCodes.length
118
- : activeRowCol.value.row + 20;
119
-
120
- // backupCodes.slice(start, end);
121
-
122
- codes.value = backupCodes.slice(start, end);
123
-
124
- activeRowCol.value.activeRow = activeRowCol.value.row - start;
125
-
126
- nextTick(() => {
127
- scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
128
- });
129
- }
130
- },
131
- fail: (err) => {
132
- index++;
133
- getCode(url, index);
134
- uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
135
- },
136
- complete: () => {
137
- uni.hideLoading();
138
- },
139
- });
140
- }
141
-
142
- /** 开发环境获取源代码 */
143
- function getSourceCodeDev(url: string) {
144
- if (!url) {
145
- uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
146
- uni?.__dev__console?.log('[DevTool] url 处理异常');
147
- return;
148
- }
149
-
150
- getCode(url, index);
151
- }
152
-
153
- onMounted(() => {
154
- let url = props?.url;
155
-
156
- const { path, col, row } = parseStock(props?.url ?? '');
157
-
158
- if (path) {
159
- url = path;
160
- }
161
-
162
- activeRowCol.value.col = col;
163
- activeRowCol.value.row = row;
164
-
165
- if (props.mode === 'development') {
166
- // 开发环境查看源码
167
- getSourceCodeDev(url);
168
- } else if (props.mode === 'production') {
169
- // TODO 生产环境查看源码
170
- }
171
- });
172
- </script>
173
- <style scoped>
174
- .dev-tool-code {
175
- position: fixed;
176
- width: 100vw;
177
- height: 100vh;
178
- z-index: 1001;
179
- top: 0;
180
- left: 0;
181
- padding: 0 16px;
182
-
183
- background-color: rgba(255, 255, 255, 0.95);
184
- box-sizing: border-box;
185
- color: #000;
186
- }
187
-
188
- .dev-tool-code-control {
189
- display: flex;
190
- align-items: center;
191
- gap: 12px;
192
- height: 32px;
193
- border-bottom: 1px solid var(--dev-tool-border-color);
194
- box-sizing: border-box;
195
- }
196
-
197
- .dev-tool-code-title {
198
- height: 32px;
199
- line-height: 32px;
200
- margin-bottom: 4px;
201
- border-bottom: 1px solid var(--dev-tool-border-color);
202
- box-sizing: border-box;
203
- white-space: nowrap;
204
- overflow: auto;
205
- }
206
-
207
- .dev-tool-code-list {
208
- height: calc(100% - 68px);
209
- }
210
-
211
- .dev-tool-code-item {
212
- display: flex;
213
- align-items: center;
214
- height: 28px;
215
- }
216
- .dev-tool-code-item-active {
217
- color: #fff;
218
- background-color: var(--dev-tool-main-color);
219
- }
220
-
221
- .dev-tool-code-item-index {
222
- flex-shrink: 0;
223
- width: 20px;
224
- margin-right: 8px;
225
- text-align: right;
226
- }
227
-
228
- .dev-tool-code-item-content {
229
- white-space: pre;
230
- }
231
- </style>