vite-uni-dev-tool 0.0.19 → 0.0.21

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.
@@ -134,13 +134,13 @@ export declare class DevStore {
134
134
  clearWsList(): void;
135
135
  updateWsList(item: DevTool.WS): DevTool.WS[] | undefined;
136
136
  clearWsMessage(url: string): void;
137
- clearStorageList(): DevTool.StorageItem[];
137
+ clearStorageList(local?: boolean): DevTool.StorageItem[];
138
138
  setStorageList(items: DevTool.StorageItem[]): DevTool.StorageItem[] | undefined;
139
- removeStorage(key: string): DevTool.StorageItem[];
139
+ removeStorage(key: string, local?: boolean): DevTool.StorageItem[];
140
140
  addStorage(data: {
141
141
  key: string;
142
142
  value: any;
143
- }): DevTool.StorageItem[] | undefined;
143
+ }, local?: boolean): DevTool.StorageItem[] | undefined;
144
144
  refreshStore(): DevTool.StorageItem[];
145
145
  updateStoreList(addItems: DevTool.StorageItem[]): DevTool.StorageItem[] | undefined;
146
146
  setRouteList(pages: DevTool.Page[], currentPath?: string): DevTool.Page[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../dev/devStore/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAgBvC,cAAc;AACd,qBAAa,QAAQ;IACnB,WAAW;IACX,OAAO,CAAC,KAAK,CAsBX;IAEF,WAAW;IACX,OAAO,CAAC,cAAc,CAAqC;IAC3D,YAAY;IACZ,OAAO,CAAC,aAAa,CAAQ;IAC7B,YAAY;IACZ,OAAO,CAAC,cAAc,CAAQ;IAC9B,YAAY;IACZ,OAAO,CAAC,cAAc,CAAQ;IAC9B,cAAc;IACd,OAAO,CAAC,aAAa,CAAQ;IAC7B,cAAc;IACd,OAAO,CAAC,gBAAgB,CAAQ;IAChC,YAAY;IACZ,OAAO,CAAC,oBAAoB,CAAQ;IAEpC,YAAY;IACZ,YAAY,SAAwB;IAE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AC,EAAE,MAAM;IAqBjE,gBAAgB;IAIhB,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;IAW3C,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM;IAiBjE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM;IAmB/D,eAAe;IAIf,iBAAiB,CAAC,OAAO,EAAE,OAAO;IAQlC,iBAAiB;IAMjB,kBAAkB;IASlB;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS;IAOrC;;;;;OAKG;IACH,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa;IAY/C,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE;IAYhD,aAAa;IAUb,uBAAuB,CAAC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE;IActE,sBAAsB;CAGvB"}
@@ -219,25 +219,25 @@ class V {
219
219
  const e = ((o = (s = this.state) == null ? void 0 : s.wsList) == null ? void 0 : o.findIndex((a) => a.url === t)) ?? -1;
220
220
  e !== -1 && (i = this.state.wsList) != null && i[e] && (this.state.wsList[e].message = []);
221
221
  }
222
- clearStorageList() {
223
- return this.state.storageList = [], uni.clearStorage(), this.state.storageList;
222
+ clearStorageList(t) {
223
+ return this.state.storageList = [], t && uni.clearStorage(), this.state.storageList;
224
224
  }
225
225
  setStorageList(t) {
226
226
  if (this.getDevToolVisible())
227
227
  return this.state.storageList = t, this.state.storageList;
228
228
  }
229
- removeStorage(t) {
230
- var e;
231
- return this.state.storageList = ((e = this.state.storageList) == null ? void 0 : e.filter((s) => s.key !== t)) ?? [], uni.removeStorageSync(t), this.state.storageList;
229
+ removeStorage(t, e) {
230
+ var s;
231
+ return this.state.storageList = ((s = this.state.storageList) == null ? void 0 : s.filter((o) => o.key !== t)) ?? [], e && uni.removeStorageSync(t), this.state.storageList;
232
232
  }
233
- addStorage(t) {
234
- var o;
235
- const { key: e, value: s } = t;
236
- return (o = this.state.storageList) == null || o.unshift({
237
- key: e,
238
- _oldKey: e,
239
- value: s
240
- }), uni.setStorageSync(e, s), this.state.storageList;
233
+ addStorage(t, e) {
234
+ var i;
235
+ const { key: s, value: o } = t;
236
+ return (i = this.state.storageList) == null || i.unshift({
237
+ key: s,
238
+ _oldKey: s,
239
+ value: o
240
+ }), e && uni.setStorageSync(s, o), this.state.storageList;
241
241
  }
242
242
  refreshStore() {
243
243
  const { keys: t } = uni.getStorageInfoSync();
@@ -140,14 +140,14 @@ export default {
140
140
 
141
141
  // 向上滚动时加载前面的数据
142
142
  if (
143
- this.current > 1 &&
143
+ this.current > 0 &&
144
144
  this.currentHeight > 0 &&
145
145
  scrollTop - this.preLodeHeight < this.currentHeight
146
146
  ) {
147
147
  this.start = this.current * this.pageSize;
148
148
  this.current--;
149
149
 
150
- this.updateVisitableData('up');
150
+ this.updateVisitableData();
151
151
  this.updateCurrentHeight();
152
152
  }
153
153
  },
@@ -159,7 +159,7 @@ export default {
159
159
 
160
160
  this.updateCurrentHeight();
161
161
  this.$nextTick(() => {
162
- this.updateVisitableData('down');
162
+ this.updateVisitableData();
163
163
  });
164
164
  }
165
165
  },
@@ -183,8 +183,12 @@ export default {
183
183
  },
184
184
  // 更新总高度(累加已加载项的高度)
185
185
  updateCurrentHeight() {
186
+ const pageSize = this.pageSize;
187
+ const current = this.current;
188
+ const currentSub1 = current - 1 < 0 ? 0 : current - 1;
189
+
186
190
  const total = this.itemsHeight
187
- .slice(0, (this.current - 1) * this.pageSize)
191
+ .slice(0, currentSub1 * pageSize)
188
192
  .reduce((acc, height) => acc + (height || 0), 0);
189
193
  this.currentHeight = total;
190
194
  },
@@ -1230,6 +1230,16 @@ function onOpenCode(value?: string) {
1230
1230
  --dev-tool-symbol-color: bisque;
1231
1231
  --dev-tool-active-bg-color: #f0f0f0;
1232
1232
  --dev-tool-time-line-color: #9254de;
1233
+
1234
+ --dev-tool-note-color: #9c9c9c;
1235
+
1236
+ --dev-tool-keyword-color: #9254de;
1237
+ --dev-tool-bracket-color: #ffa940;
1238
+ --dev-tool-quotation-color: #91e76a;
1239
+ --dev-tool-string-color: #91e76a;
1240
+ --dev-tool-function-color: #1d8ce0;
1241
+ --dev-tool-attribute-color: #ef66ba;
1242
+ --dev-tool-operator-color: #50d3eb;
1233
1243
  }
1234
1244
  .dev-tool-window-dark {
1235
1245
  --dev-tool-bg-color: rgba(0, 0, 0, 0.8);
@@ -1243,6 +1253,16 @@ function onOpenCode(value?: string) {
1243
1253
  --dev-tool-active-bg-color: #3d3d3d;
1244
1254
 
1245
1255
  --dev-tool-time-line-color: #f9f9f9;
1256
+
1257
+ --dev-tool-note-color: #9c9c9c;
1258
+
1259
+ --dev-tool-keyword-color: #9254de;
1260
+ --dev-tool-bracket-color: #ffa940;
1261
+ --dev-tool-quotation-color: #91e76a;
1262
+ --dev-tool-string-color: #91e76a;
1263
+ --dev-tool-function-color: #1d8ce0;
1264
+ --dev-tool-attribute-color: #ef66ba;
1265
+ --dev-tool-operator-color: #50d3eb;
1246
1266
  }
1247
1267
 
1248
1268
  .dev-tool-window-bg {
@@ -16,7 +16,7 @@
16
16
  <view class="network-detail-header" v-if="currentSelect === 'header'">
17
17
  <DevToolTitle>常规</DevToolTitle>
18
18
  <view class="net-detail-item">
19
- <view>请求url:</view>
19
+ <view>请求地址:</view>
20
20
  <view>{{ network.url }}</view>
21
21
  </view>
22
22
  <view class="net-detail-item">
@@ -27,31 +27,65 @@
27
27
  <view>状态代码:</view>
28
28
  {{ network.status }}
29
29
  </view>
30
+ <view class="net-detail-item">
31
+ <view>开始时间:</view>
32
+ {{
33
+ network.startTime
34
+ ? formatDate(network.startTime, 'HH:mm:ss:SS')
35
+ : '--:--:--'
36
+ }}
37
+ </view>
38
+ <view class="net-detail-item">
39
+ <view>结束时间:</view>
40
+ {{
41
+ network.endTime
42
+ ? formatDate(network.endTime, 'HH:mm:ss:SS')
43
+ : '--:--:--'
44
+ }}
45
+ </view>
46
+ <view class="net-detail-item">
47
+ <view>请求耗时:</view>
48
+ {{ network.time ?? '--' }}
49
+ </view>
50
+ <view class="net-detail-item">
51
+ <view>请求大小:</view>
52
+ {{ network.size ?? '--' }}
53
+ </view>
30
54
 
31
55
  <DevToolTitle>请求头</DevToolTitle>
32
- <view
33
- class="net-detail-item"
34
- v-for="item in network.headers.requestHeader"
35
- :key="item.key"
36
- >
37
- <view>{{ item.key }}:</view>
38
- {{ item.value }}
56
+ <template v-if="network.headers.requestHeader.length > 0">
57
+ <view
58
+ class="net-detail-item"
59
+ v-for="item in network.headers.requestHeader"
60
+ :key="item.key"
61
+ >
62
+ <view>{{ item.key }}:</view>
63
+ {{ item.value }}
64
+ </view>
65
+ </template>
66
+ <view v-else>
67
+ <Empty text="暂无请求头" />
39
68
  </view>
40
69
 
41
70
  <DevToolTitle>响应头</DevToolTitle>
42
- <view
43
- class="net-detail-item"
44
- v-for="item in network.headers.responseHeader"
45
- :key="item.key"
46
- >
47
- <view>{{ item.key }}:</view>
48
- {{ item.value }}
71
+ <template v-if="network.headers.responseHeader.length > 0">
72
+ <view
73
+ class="net-detail-item"
74
+ v-for="item in network.headers.responseHeader"
75
+ :key="item.key"
76
+ >
77
+ <view>{{ item.key }}:</view>
78
+ {{ item.value }}
79
+ </view>
80
+ </template>
81
+ <view v-else>
82
+ <Empty text="暂无响应头" />
49
83
  </view>
50
84
  </view>
51
85
 
52
86
  <template v-if="currentSelect === 'payload'">
53
87
  <template v-if="payload?.type === 'object'">
54
- <JsonPretty :data="payload.value" />
88
+ <JsonPretty :data="payload.value" virtual :height="height" />
55
89
  </template>
56
90
  <view
57
91
  v-else-if="payload?.type === 'string'"
@@ -64,7 +98,7 @@
64
98
 
65
99
  <template v-if="currentSelect === 'response'">
66
100
  <template v-if="response?.type === 'object'">
67
- <JsonPretty :data="response.value" virtual />
101
+ <JsonPretty :data="response.value" virtual :height="height" />
68
102
  </template>
69
103
  <view
70
104
  v-else-if="response?.type === 'string'"
@@ -77,13 +111,14 @@
77
111
  </view>
78
112
  </template>
79
113
  <script lang="ts" setup>
80
- import { ref, computed } from 'vue';
114
+ import { ref, computed, onMounted } from 'vue';
81
115
  import JsonPretty from '../JsonPretty/index.vue';
82
116
  import Tag from '../Tag/index.vue';
83
117
  import Empty from '../Empty/index.vue';
84
118
  import CircularButton from '../CircularButton/index.vue';
85
119
  import DevToolTitle from '../DevToolTitle/index.vue';
86
120
  import type { DevTool } from '../../type';
121
+ import { formatDate } from '../../utils';
87
122
  const props = defineProps<{ network: DevTool.NetworkItem; zIndex?: number }>();
88
123
  const emit = defineEmits<{ (e: 'close'): void }>();
89
124
  const selectItems = [
@@ -100,6 +135,9 @@ const selectItems = [
100
135
  value: 'response',
101
136
  },
102
137
  ];
138
+
139
+ const height = ref(0);
140
+
103
141
  const currentSelect = ref('header');
104
142
 
105
143
  const payload = computed(() => {
@@ -148,6 +186,12 @@ function onSelect(item: { label: string; value: string }) {
148
186
  function onClose() {
149
187
  emit('close');
150
188
  }
189
+
190
+ onMounted(() => {
191
+ const { windowHeight } = uni.getWindowInfo();
192
+
193
+ height.value = windowHeight - 32 - 32 - 2;
194
+ });
151
195
  </script>
152
196
  <style scoped>
153
197
  .network-detail {
@@ -166,7 +210,7 @@ function onClose() {
166
210
  .network-detail .network-detail-control {
167
211
  display: flex;
168
212
  align-items: center;
169
- margin-bottom: 4px;
213
+ /* margin-bottom: 4px; */
170
214
  gap: 12px;
171
215
  height: 32px;
172
216
  border-bottom: 1px solid transparent;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view class="setting-content">
3
3
  <view class="setting-item">
4
- <DevToolTitle>DevTool(v0.0.19-vue3)</DevToolTitle>
4
+ <DevToolTitle>DevTool(v0.0.21-vue3)</DevToolTitle>
5
5
  <view class="setting-item-content">
6
6
  <view class="setting-row">
7
7
  <view>显示调试按钮:</view>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <view
3
+ :class="['source-code-line', active ? 'source-code-line-active' : '']"
4
+ :id="id"
5
+ >
6
+ <view class="source-code-line-num" v-if="showNum">{{ num }}</view>
7
+ <view :class="['source-code-line-content', line.class]">
8
+ <view
9
+ v-for="item in line.words"
10
+ :class="['source-code-line-word', item.class]"
11
+ >
12
+ {{ item.word }}
13
+ </view>
14
+ </view>
15
+ </view>
16
+ </template>
17
+ <script lang="ts" setup>
18
+ import type { LineInfo } from './parseCode';
19
+
20
+ const props = withDefaults(
21
+ defineProps<{
22
+ line: LineInfo;
23
+
24
+ id: string;
25
+ active?: boolean;
26
+ num?: number;
27
+ showNum?: boolean;
28
+ }>(),
29
+ {
30
+ showNum: true,
31
+ },
32
+ );
33
+ </script>
34
+ <style lang="scss" scoped>
35
+ .source-code-line {
36
+ display: flex;
37
+ align-items: center;
38
+ height: 24px;
39
+ }
40
+
41
+ .source-code-line-active {
42
+ color: #fff;
43
+ background-color: var(--dev-tool-main-color);
44
+ }
45
+
46
+ .source-code-line-num {
47
+ flex-shrink: 0;
48
+ width: 30px;
49
+ padding: 0 6px;
50
+ margin-right: 6px;
51
+ text-align: right;
52
+ height: 24px;
53
+ border-right: 1px solid var(--dev-tool-border-color);
54
+ }
55
+
56
+ .source-code-line-content {
57
+ display: flex;
58
+ white-space: nowrap;
59
+ height: 24px;
60
+ }
61
+
62
+ .source-code-line-word {
63
+ white-space: nowrap;
64
+ }
65
+
66
+ .source-code-pre-note {
67
+ color: var(--dev-tool-note-color);
68
+ }
69
+
70
+ .source-code-pre-space {
71
+ width: 8px;
72
+ }
73
+
74
+ .source-code-pre-keyword {
75
+ color: var(--dev-tool-keyword-color);
76
+ }
77
+
78
+ .source-code-pre-bracket {
79
+ color: var(--dev-tool-bracket-color);
80
+ }
81
+
82
+ .source-code-pre-quotation {
83
+ color: var(--dev-tool-quotation-color);
84
+ }
85
+
86
+ .source-code-pre-string {
87
+ color: var(--dev-tool-string-color);
88
+ }
89
+
90
+ .source-code-pre-function {
91
+ color: var(--dev-tool-function-color);
92
+ }
93
+
94
+ .source-code-pre-attribute {
95
+ color: var(--dev-tool-attribute-color);
96
+ }
97
+
98
+ .source-code-pre-operator {
99
+ color: var(--dev-tool-operator-color);
100
+ }
101
+ </style>
@@ -1,45 +1,51 @@
1
1
  <template>
2
2
  <view class="dev-tool-code" :style="{ zIndex: zIndex }">
3
3
  <view class="dev-tool-code-control">
4
- <FilterInput
4
+ <!-- <FilterInput
5
5
  v-model="modelValue"
6
6
  style="width: 100%"
7
7
  @search="onSearch"
8
- />
8
+ /> -->
9
+ <view class="dev-tool-code-title">{{ fileName }}</view>
9
10
  <CircularButton style="margin-left: auto" text="×" @click="onClose" />
10
11
  </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"
12
+
13
+ <VirtualListPro
14
+ v-if="codes.length > 0"
15
+ scrollX
16
+ :pageSize="pageSize"
17
+ :height="height"
18
+ :data="codes"
19
+ :scrollWithAnimation="true"
19
20
  >
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>
21
+ <template #default="{ list, current, start }">
22
+ <AutoSize
23
+ v-for="(code, index) in list"
24
+ :key="start + index"
25
+ :index="start + index"
26
+ >
27
+ <Line
28
+ :line="code"
29
+ :id="`dev-code-${start + index}`"
30
+ :num="start + index + 1"
31
+ :active="start + index === activeRowCol.row"
32
+ />
33
+ </AutoSize>
34
+ </template>
35
+ </VirtualListPro>
36
+ <Empty v-if="!codes || codes.length === 0" />
34
37
  </view>
35
38
  </template>
36
39
  <script lang="ts" setup>
37
- import { computed, ref, nextTick, onMounted } from 'vue';
38
- import FilterInput from '../FilterInput/index.vue';
40
+ import { computed, ref, onMounted } from 'vue';
41
+ // import FilterInput from '../FilterInput/index.vue';
39
42
  import CircularButton from '../CircularButton/index.vue';
43
+ import VirtualListPro from '../VirtualListPro/index.vue';
40
44
  import Empty from '../Empty/index.vue';
41
- import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
42
-
45
+ import AutoSize from '../VirtualListPro/AutoSize.vue';
46
+ import Line from './Line.vue';
47
+ import { isAndroid, parseStock } from '../../utils';
48
+ import { parseCode, type LineInfo } from './parseCode';
43
49
  const props = defineProps<{
44
50
  url: string;
45
51
  sourceFileServers?: string[];
@@ -49,8 +55,8 @@ const props = defineProps<{
49
55
 
50
56
  const emit = defineEmits<{ (e: 'close'): void }>();
51
57
 
52
- const modelValue = ref('');
53
- const scrollTop = ref(0);
58
+ // const modelValue = ref('');
59
+ const height = ref(0);
54
60
  const fileName = computed(() => {
55
61
  const name =
56
62
  props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
@@ -58,25 +64,51 @@ const fileName = computed(() => {
58
64
  });
59
65
 
60
66
  const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
61
-
62
- let backupCodes: string[] = [];
63
-
64
- const codes = ref<string[]>([]);
65
-
66
67
  const scrollIntoView = ref('');
67
68
 
68
- const start = computed(() => {
69
- return activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
70
- });
69
+ // let backupCodes: string[] = [];
70
+
71
+ const codes = ref<LineInfo[]>([]);
72
+ // const defaultCurrent = ref(1);
73
+ const pageSize = 50;
71
74
 
72
75
  function onClose() {
73
76
  emit('close');
74
77
  }
75
78
 
76
79
  function onSearch(value: string) {
77
- codes.value = backupCodes.map((code) => {
78
- return hightLight(code, value);
79
- });
80
+ // codes.value = backupCodes.map((code) => {
81
+ // return hightLight(code, value);
82
+ // });
83
+ }
84
+
85
+ let timer: number;
86
+ function startCounter({
87
+ start,
88
+ target,
89
+ duration,
90
+ onExecute,
91
+ onSuccess,
92
+ }: {
93
+ start: number;
94
+ target: number;
95
+ duration: number;
96
+ onExecute: (current: number) => void;
97
+ onSuccess: () => void;
98
+ }) {
99
+ if (timer) return;
100
+
101
+ let s = start;
102
+ timer = setInterval(() => {
103
+ if (s >= target) {
104
+ clearInterval(timer);
105
+ console.log('停止');
106
+ onSuccess();
107
+ return;
108
+ }
109
+ s++;
110
+ onExecute(s);
111
+ }, duration);
80
112
  }
81
113
 
82
114
  let index = 0;
@@ -100,35 +132,26 @@ function getCode(url: string, i: number = 0) {
100
132
  url: allUrl,
101
133
  success: (res) => {
102
134
  if (typeof res.data === 'string') {
103
- // 为什么要注释掉?
104
- // 在 Android 识别到标签后会进行重启,导致代码无法显示
105
- // TODO: 还有其它原因导致重启
106
- const str = res.data
107
- ?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
108
- ?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
109
- ?.replace(/<style/, '// [DevTool] 注释 <style')
110
- ?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
111
- backupCodes = escapeHTML(str ?? '')
112
- .toString()
113
- .split('\n');
114
-
115
- const start =
116
- activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
117
-
118
- const end =
119
- activeRowCol.value.row + 20 > backupCodes.length
120
- ? backupCodes.length
121
- : activeRowCol.value.row + 20;
122
-
123
- // backupCodes.slice(start, end);
124
-
125
- codes.value = backupCodes.slice(start, end);
126
-
127
- activeRowCol.value.activeRow = activeRowCol.value.row - start;
128
-
129
- nextTick(() => {
130
- scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
131
- });
135
+ codes.value = parseCode(res.data ?? '');
136
+
137
+ // res.data?.split('\n') ?? [];
138
+
139
+ // 缓慢显示
140
+ const row = activeRowCol.value.row;
141
+ // defaultCurrent.value = Math.ceil(activeRowCol.value.row / pageSize);
142
+ const targetCurrent = Math.ceil(row / pageSize);
143
+
144
+ // startCounter({
145
+ // start: 1,
146
+ // target: targetCurrent,
147
+ // duration: 500,
148
+ // onExecute(current) {
149
+ // scrollIntoView.value = `dev-code-${current * pageSize - 1}`;
150
+ // },
151
+ // onSuccess() {
152
+ // // scrollIntoView.value = `dev-code-${row}`;
153
+ // },
154
+ // });
132
155
  }
133
156
  },
134
157
  fail: (err) => {
@@ -155,6 +178,10 @@ function getSourceCodeDev(url: string) {
155
178
  }
156
179
 
157
180
  onMounted(() => {
181
+ const { windowHeight } = uni.getWindowInfo();
182
+
183
+ height.value = windowHeight - 32 - 32;
184
+
158
185
  let url = props?.url;
159
186
 
160
187
  const { path, col, row } = parseStock(props?.url ?? '');
@@ -221,25 +248,4 @@ onMounted(() => {
221
248
  .dev-tool-code-list {
222
249
  height: calc(100% - 68px);
223
250
  }
224
-
225
- .dev-tool-code-item {
226
- display: flex;
227
- align-items: center;
228
- height: 28px;
229
- }
230
- .dev-tool-code-item-active {
231
- color: #fff;
232
- background-color: var(--dev-tool-main-color);
233
- }
234
-
235
- .dev-tool-code-item-index {
236
- flex-shrink: 0;
237
- width: 20px;
238
- margin-right: 8px;
239
- text-align: right;
240
- }
241
-
242
- .dev-tool-code-item-content {
243
- white-space: pre;
244
- }
245
251
  </style>
@@ -0,0 +1,27 @@
1
+ type Word = {
2
+ /** 字符 */
3
+ word: string;
4
+ /** css 样式 */
5
+ class: string;
6
+ /** 分类
7
+ * - space: 空格
8
+ * - bracket: 括号
9
+ * - quotation: 引号
10
+ * - string: 字符串
11
+ * - function: 函数
12
+ * - attribute: 属性
13
+ * - operator: 操作符
14
+ * - symbol: 符号
15
+ * - keyword: 关键字
16
+ * - other: 其他
17
+ */
18
+ type: 'space' | 'bracket' | 'quotation' | 'string' | 'function' | 'attribute' | 'operator' | 'symbol' | 'keyword' | 'other';
19
+ };
20
+ export type LineInfo = {
21
+ type: 'empty' | 'tag' | 'script' | 'style' | 'note';
22
+ class: string;
23
+ words: Word[];
24
+ };
25
+ export declare function parseCode(code: string): LineInfo[];
26
+ export {};
27
+ //# sourceMappingURL=parseCode.d.ts.map