vite-uni-dev-tool 0.0.13 → 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.
Files changed (109) hide show
  1. package/dist/v2/AppInfo/index.vue +41 -0
  2. package/dist/v2/AutoSizer/index.vue +189 -0
  3. package/dist/v2/AutoSizer/index1.vue +193 -0
  4. package/dist/v2/AutoSizer/utils.ts +49 -0
  5. package/dist/v2/CaptureScreen/index.vue +78 -0
  6. package/dist/v2/CloseButton/index.vue +32 -0
  7. package/dist/v2/Connection/index.vue +94 -0
  8. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  9. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  10. package/dist/v2/ConsoleList/index.vue +164 -0
  11. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  12. package/dist/v2/DevTool/index.vue +162 -0
  13. package/dist/v2/DevToolButton/index.vue +228 -0
  14. package/dist/v2/DevToolTitle/index.vue +28 -0
  15. package/dist/v2/DevToolWindow/index.vue +1051 -0
  16. package/dist/v2/DeviceInfo/index.vue +48 -0
  17. package/dist/v2/Empty/empty.png +0 -0
  18. package/dist/v2/Empty/index.vue +40 -0
  19. package/dist/v2/FilterInput/index.vue +100 -0
  20. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  21. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  22. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  23. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  24. package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
  25. package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
  26. package/dist/v2/JsonPretty/index.vue +531 -0
  27. package/dist/v2/JsonPretty/type.ts +125 -0
  28. package/dist/v2/JsonPretty/utils/index.js +211 -0
  29. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  30. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  31. package/dist/v2/NetworkList/index.vue +148 -0
  32. package/dist/v2/PiniaList/index.vue +79 -0
  33. package/dist/v2/RouteList/index.vue +137 -0
  34. package/dist/v2/RunJS/index.vue +128 -0
  35. package/dist/v2/SettingList/index.vue +318 -0
  36. package/dist/v2/SourceCode/index.vue +237 -0
  37. package/dist/v2/StorageList/index.vue +165 -0
  38. package/dist/v2/SystemInfo/index.vue +49 -0
  39. package/dist/v2/Tabs/index.vue +127 -0
  40. package/dist/v2/Tag/index.vue +91 -0
  41. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  42. package/dist/v2/UniEvent/index.vue +127 -0
  43. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  44. package/dist/v2/UploadList/UploadItem.vue +134 -0
  45. package/dist/v2/UploadList/index.vue +143 -0
  46. package/dist/v2/VirtualList/index.vue +140 -0
  47. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  48. package/dist/v2/VirtualListPro/index.vue +255 -0
  49. package/dist/v2/VirtualListPro/readme.md +40 -0
  50. package/dist/v2/VuexList/index.vue +80 -0
  51. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  52. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  53. package/dist/v2/WebSocket/index.vue +155 -0
  54. package/dist/v2/WindowInfo/index.vue +49 -0
  55. package/dist/v3/AppInfo/index.vue +35 -0
  56. package/dist/v3/AutoSizer/index.vue +193 -0
  57. package/dist/v3/AutoSizer/index1.vue +186 -0
  58. package/dist/v3/AutoSizer/utils.ts +49 -0
  59. package/dist/v3/CaptureScreen/index.vue +62 -0
  60. package/dist/v3/CloseButton/index.vue +29 -0
  61. package/dist/v3/Connection/index.vue +88 -0
  62. package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
  63. package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
  64. package/dist/v3/ConsoleList/index.vue +139 -0
  65. package/dist/v3/ConsoleList/staticTips.ts +1145 -0
  66. package/dist/v3/DevTool/index.vue +217 -0
  67. package/dist/v3/DevToolButton/index.vue +210 -0
  68. package/dist/v3/DevToolTitle/index.vue +21 -0
  69. package/dist/v3/DevToolWindow/index.vue +1116 -0
  70. package/dist/v3/DeviceInfo/index.vue +32 -0
  71. package/dist/v3/Empty/empty.png +0 -0
  72. package/dist/v3/Empty/index.vue +28 -0
  73. package/dist/v3/FilterInput/index.vue +87 -0
  74. package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
  75. package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
  76. package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
  77. package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
  78. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  79. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  80. package/dist/v3/JsonPretty/index.vue +476 -0
  81. package/dist/v3/JsonPretty/type.ts +125 -0
  82. package/dist/v3/JsonPretty/utils/index.ts +172 -0
  83. package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
  84. package/dist/v3/NetworkList/NetworkItem.vue +120 -0
  85. package/dist/v3/NetworkList/index.vue +128 -0
  86. package/dist/v3/PiniaList/index.vue +64 -0
  87. package/dist/v3/RouteList/index.vue +121 -0
  88. package/dist/v3/RunJS/index.vue +128 -0
  89. package/dist/v3/SettingList/index.vue +313 -0
  90. package/dist/v3/SourceCode/index.vue +231 -0
  91. package/dist/v3/StorageList/index.vue +170 -0
  92. package/dist/v3/SystemInfo/index.vue +34 -0
  93. package/dist/v3/Tabs/index.vue +123 -0
  94. package/dist/v3/Tag/index.vue +89 -0
  95. package/dist/v3/UniEvent/UniEventItem.vue +126 -0
  96. package/dist/v3/UniEvent/index.vue +98 -0
  97. package/dist/v3/UploadList/UploadDetail.vue +192 -0
  98. package/dist/v3/UploadList/UploadItem.vue +117 -0
  99. package/dist/v3/UploadList/index.vue +117 -0
  100. package/dist/v3/VirtualList/index.vue +112 -0
  101. package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
  102. package/dist/v3/VirtualListPro/index.vue +238 -0
  103. package/dist/v3/VirtualListPro/readme.md +40 -0
  104. package/dist/v3/VuexList/index.vue +54 -0
  105. package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
  106. package/dist/v3/WebSocket/WebSocketList.vue +161 -0
  107. package/dist/v3/WebSocket/index.vue +124 -0
  108. package/dist/v3/WindowInfo/index.vue +33 -0
  109. package/package.json +1 -1
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <view class="app-info-content">
3
+ <JsonPretty v-if="showJson" :data="appInfo" />
4
+ <Empty v-else />
5
+ </view>
6
+ </template>
7
+ <script>
8
+ import JsonPretty from '../JsonPretty/index.vue';
9
+ import Empty from '../Empty/index.vue';
10
+ export default {
11
+ components: { JsonPretty, Empty },
12
+ props: {
13
+ appInfo: {
14
+ type: Object,
15
+ default: () => ({}),
16
+ },
17
+ },
18
+ computed: {
19
+ showJson: () => {
20
+ try {
21
+ const str = JSON.stringify(props.appInfo);
22
+ if (typeof props.appInfo === 'object' && (str === '' || str === '{}')) {
23
+ return false;
24
+ }
25
+ return true;
26
+ } catch (error) {
27
+ return false;
28
+ }
29
+ },
30
+ },
31
+ };
32
+ </script>
33
+ <style scoped>
34
+ .app-info-content {
35
+ padding: 16px;
36
+ font-size: var(--dev-tool-base-font-size);
37
+
38
+ height: calc(100% - 32px);
39
+ overflow: auto;
40
+ }
41
+ </style>
@@ -0,0 +1,189 @@
1
+ <template>
2
+ <view class="auto-sizer">
3
+ <!-- 大小和slot 内容宽度一致 -->
4
+ <view class="listener-slot">
5
+ <slot></slot>
6
+ </view>
7
+
8
+ <!-- 变大监听固定在 listener-slot 右下角大1px位置 变大时 相交触发监听 -->
9
+ <view
10
+ class="anchor-height-add"
11
+ :style="{
12
+ top: listenerSlot.height + 1 + 'px',
13
+ }"
14
+ >
15
+ </view>
16
+
17
+ <!-- 变小监听固定在 listener-slot 右下角小1px位置 减小时 离开触发监听 -->
18
+ <view
19
+ class="anchor-height-sub"
20
+ :style="{
21
+ top: listenerSlot.height - 1 + 'px',
22
+ }"
23
+ >
24
+ </view>
25
+
26
+ <!-- 变大监听固定在 listener-slot 右下角大1px位置 变大时 相交触发监听 -->
27
+ <view
28
+ class="anchor-width-add"
29
+ :style="{
30
+ left: listenerSlot.width + 1 + 'px',
31
+ top: '0px',
32
+ }"
33
+ >
34
+ </view>
35
+
36
+ <!-- 变小监听固定在 listener-slot 右下角小1px位置 减小时 离开触发监听 -->
37
+ <view
38
+ class="anchor-width-sub"
39
+ :style="{
40
+ left: listenerSlot.width - 1 + 'px',
41
+ top: '0px',
42
+ }"
43
+ >
44
+ </view>
45
+ </view>
46
+ </template>
47
+
48
+ <script>
49
+ import { debounce } from '../../utils';
50
+
51
+ export default {
52
+ inject: ['onSizeChange', 'itemsHeight'],
53
+ props: {
54
+ index: {
55
+ type: Number,
56
+ required: true,
57
+ },
58
+ immediate: {
59
+ type: Boolean,
60
+ default: false,
61
+ },
62
+ },
63
+
64
+ data() {
65
+ return {
66
+ isMounted: false,
67
+ listenerSlot: {
68
+ width: 0,
69
+ height: 0,
70
+ },
71
+ size: {
72
+ width: 0,
73
+ height: 0,
74
+ top: 0,
75
+ left: 0,
76
+ right: 0,
77
+ bottom: 0,
78
+ },
79
+ observer: null,
80
+ };
81
+ },
82
+
83
+ created() {
84
+ this.debounceReact = debounce(
85
+ (rect) => {
86
+ if (Array.isArray(rect)) return;
87
+
88
+ // 获取屏幕尺寸
89
+ const { windowWidth, windowHeight } = uni.getSystemInfoSync();
90
+
91
+ // 在尺寸更新时限制最大值
92
+ this.listenerSlot.height = Math.min(rect.height ?? 0, windowHeight);
93
+ this.listenerSlot.width = Math.min(rect.width ?? 0, windowWidth);
94
+
95
+ this?.onSizeChange?.(this.index, rect.height ?? 0);
96
+
97
+ this.size.width = rect.width ?? 0;
98
+ this.size.height = rect.height ?? 0;
99
+ this.size.top = rect.top ?? 0;
100
+ this.size.left = rect.left ?? 0;
101
+ this.size.right = rect.right ?? 0;
102
+ this.size.bottom = rect.bottom ?? 0;
103
+
104
+ if (this.immediate && !this.isMounted) {
105
+ this.$emit('resize', this.size);
106
+ }
107
+
108
+ if (this.isMounted) {
109
+ this.$emit('resize', this.size);
110
+ }
111
+
112
+ this.isMounted = true;
113
+ },
114
+ 100,
115
+ true,
116
+ );
117
+
118
+ this.debounceGetSize = debounce(this.getSize, 100, true);
119
+ },
120
+
121
+ mounted() {
122
+ // 防止重复获取
123
+ // TODO
124
+ // if (this.itemsHeight && this.itemsHeight?.[this.index]) return;
125
+
126
+ // 初始大小
127
+ this.debounceGetSize();
128
+
129
+ // TODO 只有可视范围之内才获取大小
130
+ this.observer = uni.createIntersectionObserver(this, {
131
+ thresholds: [0, 1],
132
+ });
133
+ // 变大监听
134
+ this.observer
135
+ .relativeTo('.auto-sizer')
136
+ .observe('.anchor-height-add', this.debounceGetSize);
137
+ // 变小监听
138
+ this.observer
139
+ .relativeTo('.auto-sizer')
140
+ .observe('.anchor-height-sub', this.debounceGetSize);
141
+
142
+ // 变大监听
143
+ this.observer
144
+ .relativeTo('.auto-sizer')
145
+ .observe('.anchor-width-add', this.debounceGetSize);
146
+ // 变小监听
147
+ this.observer
148
+ .relativeTo('.auto-sizer')
149
+ .observe('.anchor-width-sub', this.debounceGetSize);
150
+ },
151
+
152
+ beforeDestroy() {
153
+ // 销毁监听
154
+ this.observer.disconnect();
155
+ },
156
+
157
+ methods: {
158
+ getSize() {
159
+ uni
160
+ .createSelectorQuery()
161
+ .in(this)
162
+ .select('.listener-slot')
163
+ .boundingClientRect(this.debounceReact)
164
+ .exec();
165
+ },
166
+ },
167
+ };
168
+ </script>
169
+
170
+ <style scoped>
171
+ .auto-sizer {
172
+ position: relative;
173
+ overflow: hidden;
174
+ width: min-content;
175
+ height: min-content;
176
+ }
177
+
178
+ .anchor-height-add,
179
+ .anchor-height-sub,
180
+ .anchor-width-add,
181
+ .anchor-width-sub {
182
+ position: absolute;
183
+ width: 1px;
184
+ height: 1px;
185
+
186
+ background-color: skyblue;
187
+ visibility: hidden;
188
+ }
189
+ </style>
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <view
3
+ class="l-resize l-class"
4
+ :class="{ 'l-resize-target': hasNoDefaultSlot }"
5
+ :style="[styles, lStyle]"
6
+ >
7
+ <!-- 插槽需要脱离父容器文档流,防止父容器固宽固高导致插槽大小被限制 -->
8
+ <view
9
+ ref="lResizeContainer"
10
+ class="l-resize__container l-container-class"
11
+ :style="[lStyle]"
12
+ >
13
+ <!-- 被监听的插槽 -->
14
+ <slot></slot>
15
+ <!-- 监听插槽变大 -->
16
+ <scroll-view
17
+ class="l-resize__wrapper"
18
+ :scroll-y="true"
19
+ :scroll-x="true"
20
+ :scroll-top="expandScrollTop"
21
+ :scroll-left="expandScrollLeft"
22
+ @scroll="onScrollHandler"
23
+ >
24
+ <view
25
+ class="l-resize__wrapper--placeholder"
26
+ style="height: 100000px; width: 100000px"
27
+ ></view>
28
+ </scroll-view>
29
+ <!-- 监听插槽变小 -->
30
+ <scroll-view
31
+ class="l-resize__wrapper"
32
+ :scroll-y="true"
33
+ :scroll-x="true"
34
+ :scroll-top="shrinkScrollTop"
35
+ :scroll-left="shrinkScrollLeft"
36
+ @scroll="onScrollHandler"
37
+ >
38
+ <view
39
+ class="l-resize__wrapper--placeholder"
40
+ style="height: 250%; width: 250%"
41
+ ></view>
42
+ </scroll-view>
43
+ </view>
44
+ </view>
45
+ </template>
46
+
47
+ <script>
48
+ import { getRect, addUnit } from './utils';
49
+
50
+ export default {
51
+ props: {
52
+ lStyle: {
53
+ type: [String, Object],
54
+ default: () => ({}),
55
+ },
56
+ },
57
+
58
+ data() {
59
+ return {
60
+ width: 0,
61
+ height: 0,
62
+ hasNoDefaultSlot: false,
63
+ expandScrollTop: 0,
64
+ expandScrollLeft: 0,
65
+ shrinkScrollTop: 0,
66
+ shrinkScrollLeft: 0,
67
+ scrollEventCount: 0,
68
+ lastHeight: 0,
69
+ lastWidth: 0,
70
+ querySelector: '.l-resize__container',
71
+ };
72
+ },
73
+
74
+ computed: {
75
+ styles() {
76
+ // Vue2 中通过 this.$slots 访问插槽
77
+ if (this.$slots.default && (this.width || this.height)) {
78
+ return {
79
+ width: addUnit(this.width),
80
+ height: addUnit(this.height),
81
+ };
82
+ }
83
+ return {};
84
+ },
85
+ },
86
+
87
+ mounted() {
88
+ // 检查是否有默认插槽
89
+ this.hasNoDefaultSlot = !this.$slots.default;
90
+
91
+ // 初始获取尺寸
92
+ getRect(this.querySelector, this).then((res) => {
93
+ this.lastHeight = res.height || 0;
94
+ this.lastWidth = res.width || 0;
95
+ this.width = this.lastWidth;
96
+ this.height = this.lastHeight;
97
+ this.scrollToBottom({
98
+ width: this.lastWidth,
99
+ height: this.lastHeight,
100
+ });
101
+ });
102
+ },
103
+
104
+ methods: {
105
+ onScrollHandler() {
106
+ getRect(this.querySelector, this).then((res) => {
107
+ // 前两次滚动事件触发时通知尺寸变化
108
+ if (this.scrollEventCount++ === 0) {
109
+ this.resizeEvent(res);
110
+ }
111
+ // 屏蔽滚动条拉到底部的多余事件
112
+ if (this.scrollEventCount < 3) return;
113
+
114
+ const newHeight = res.height || 0;
115
+ const newWidth = res.width || 0;
116
+
117
+ // 更新容器尺寸
118
+ this.height = newHeight;
119
+ this.width = newWidth;
120
+
121
+ // 检查尺寸变化并触发事件
122
+ const emitStack = [];
123
+ if (newHeight !== this.lastHeight) {
124
+ this.lastHeight = newHeight;
125
+ emitStack.push(1);
126
+ }
127
+ if (newWidth !== this.lastWidth) {
128
+ this.lastWidth = newWidth;
129
+ emitStack.push(1);
130
+ }
131
+ if (emitStack.length > 0) {
132
+ this.resizeEvent(res);
133
+ }
134
+
135
+ // 滚动到底部
136
+ this.scrollToBottom({
137
+ width: this.lastWidth,
138
+ height: this.lastHeight,
139
+ });
140
+ });
141
+ },
142
+
143
+ scrollToBottom(res) {
144
+ this.expandScrollTop = 100000 + res.height;
145
+ this.shrinkScrollTop = 3 * this.height + res.height;
146
+ this.expandScrollLeft = 100000 + res.width;
147
+ this.shrinkScrollLeft = 3 * this.width + res.width;
148
+ },
149
+
150
+ resizeEvent(res) {
151
+ const result = {};
152
+ ['bottom', 'top', 'left', 'right', 'height', 'width'].forEach((prop) => {
153
+ result[prop] = res[prop];
154
+ });
155
+ this.$emit('resize', result);
156
+ },
157
+ },
158
+ };
159
+ </script>
160
+
161
+ <style lang="scss" scoped>
162
+ .l-resize {
163
+ &__container {
164
+ position: absolute;
165
+ min-width: 1px;
166
+ min-height: 1px;
167
+ }
168
+ &-target,
169
+ &__wrapper {
170
+ background-color: aqua;
171
+ position: absolute;
172
+ top: 0;
173
+ bottom: 0;
174
+ left: 0;
175
+ right: 0;
176
+ z-index: -9999;
177
+ overflow: hidden;
178
+ visibility: hidden;
179
+ }
180
+ &-target {
181
+ .l-resize__container {
182
+ width: 100%;
183
+ height: 100%;
184
+ }
185
+ }
186
+ &__wrapper {
187
+ &--placeholder {
188
+ transition: 0s;
189
+ animation: none;
190
+ }
191
+ }
192
+ }
193
+ </style>
@@ -0,0 +1,49 @@
1
+ import type { ComponentInternalInstance, ComponentPublicInstance } from 'vue';
2
+
3
+ export function getRect(
4
+ selector: string,
5
+ context: ComponentInternalInstance | null | any,
6
+ node: boolean = false,
7
+ ) {
8
+ // 之前是个对象,现在改成实例,防止旧版会报错
9
+ if (context == null) {
10
+ return Promise.reject('context is null');
11
+ }
12
+ if (context?.context) {
13
+ context = context.context;
14
+ }
15
+
16
+ return new Promise<UniNamespace.NodeInfo>((resolve, reject) => {
17
+ const dom = uni.createSelectorQuery().in(context).select(selector);
18
+ const result: any = (rect: UniNamespace.NodeInfo) => {
19
+ if (rect) {
20
+ resolve(rect);
21
+ } else {
22
+ reject('no rect');
23
+ }
24
+ };
25
+
26
+ if (!node) {
27
+ dom.boundingClientRect(result).exec();
28
+ } else {
29
+ dom
30
+ .fields(
31
+ {
32
+ node: true,
33
+ size: true,
34
+ rect: true,
35
+ },
36
+ result,
37
+ )
38
+ .exec();
39
+ }
40
+ });
41
+ }
42
+
43
+ export function addUnit(value?: string | number): string {
44
+ if (!value) {
45
+ return '0px';
46
+ }
47
+
48
+ return typeof value === 'number' ? `${value}px` : value;
49
+ }
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <view class="capture-screen-content">
3
+ <view class="capture-screen-control">
4
+ <Tag style="margin-left: auto" mode="clear" @click="handleClear">
5
+ 清空
6
+ </Tag>
7
+ </view>
8
+
9
+ <view class="capture-screen-list">
10
+ <view
11
+ class="capture-screen-item"
12
+ v-for="item in captureScreenList"
13
+ :key="item.timer + item.position"
14
+ >
15
+ <view class="info-row">时间:{{ item.timer }} </view>
16
+ <view class="info-row">页面:{{ item.position }}</view>
17
+ </view>
18
+
19
+ <Empty v-if="!captureScreenList || captureScreenList.length === 0" />
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import Empty from '../Empty/index.vue';
26
+ import Tag from '../Tag/index.vue';
27
+
28
+ export default {
29
+ components: {
30
+ Empty,
31
+ Tag,
32
+ },
33
+ props: {
34
+ /** @type {{position: string, time: string}[]} */
35
+ captureScreenList: {
36
+ type: Array,
37
+ default: () => [],
38
+ },
39
+ },
40
+ methods: {
41
+ handleClear() {
42
+ this.$emit('clear');
43
+ },
44
+ },
45
+ };
46
+ </script>
47
+
48
+ <style scoped>
49
+ .capture-screen-content {
50
+ height: 100%;
51
+ font-size: var(--dev-tool-base-font-size);
52
+ }
53
+
54
+ .capture-screen-list {
55
+ height: calc(100% - 32px);
56
+ overflow: auto;
57
+ }
58
+
59
+ .capture-screen-control {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: space-between;
63
+ gap: 8px;
64
+ padding: 0 16px;
65
+ height: 32px;
66
+ border-bottom: 1px solid var(--dev-tool-border-color);
67
+ box-sizing: border-box;
68
+ }
69
+
70
+ .capture-screen-item {
71
+ padding: 16px;
72
+ border-bottom: 1px solid var(--dev-tool-border-color);
73
+ }
74
+ .info-row {
75
+ height: 28px;
76
+ line-height: 28px;
77
+ }
78
+ </style>
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <view class="close-button" @click="onClick"> × </view>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ methods: {
8
+ onClick() {
9
+ this.$emit('click');
10
+ },
11
+ },
12
+ };
13
+ </script>
14
+
15
+ <style scoped>
16
+ .close-button {
17
+ flex-shrink: 0;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ width: 24px;
22
+ height: 24px;
23
+ margin-left: auto;
24
+ border-radius: 50%;
25
+ border: 1px solid var(--dev-tool-text-color);
26
+ box-sizing: border-box;
27
+ color: var(--dev-tool-text-color);
28
+ transition:
29
+ border,
30
+ color 0.3s;
31
+ }
32
+ </style>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <view class="connection-content">
3
+ <view class="connection-item">
4
+ <DevToolTitle>网络连接</DevToolTitle>
5
+ <view class="connection-item-content">
6
+ <view class="connection-row">
7
+ <view>IP地址:</view>
8
+ <Tag
9
+ :mode="
10
+ netWorkStatus.isConnected === undefined || netWorkStatus.ip
11
+ ? 'info'
12
+ : netWorkStatus.isConnected && netWorkStatus.ip
13
+ ? 'success'
14
+ : 'error'
15
+ "
16
+ >
17
+ {{
18
+ netWorkStatus.isConnected === undefined
19
+ ? '未获取'
20
+ : netWorkStatus.ip || '未获取'
21
+ }}
22
+ </Tag>
23
+ </view>
24
+ <view class="connection-row">
25
+ <view>连接状态:</view>
26
+ <Tag
27
+ :mode="
28
+ netWorkStatus.isConnected === undefined
29
+ ? 'info'
30
+ : netWorkStatus.isConnected
31
+ ? 'success'
32
+ : 'error'
33
+ "
34
+ >
35
+ {{
36
+ netWorkStatus.isConnected === undefined
37
+ ? '未获取'
38
+ : netWorkStatus.isConnected
39
+ ? '已连接'
40
+ : '已断开'
41
+ }}
42
+ </Tag>
43
+ </view>
44
+ <view class="connection-row">
45
+ <view>网络类型:</view>
46
+ <Tag mode="info">{{ netWorkStatus.networkType || '未获取' }}</Tag>
47
+ </view>
48
+ </view>
49
+ </view>
50
+ </view>
51
+ </template>
52
+
53
+ <script>
54
+ import Tag from '../Tag/index.vue';
55
+ import DevToolTitle from '../DevToolTitle/index.vue';
56
+
57
+ export default {
58
+ components: {
59
+ Tag,
60
+ DevToolTitle,
61
+ },
62
+ props: {
63
+ netWorkStatus: {
64
+ type: Object,
65
+ default() {
66
+ return {
67
+ isConnected: undefined,
68
+ networkType: undefined,
69
+ ip: undefined,
70
+ };
71
+ },
72
+ },
73
+ },
74
+ };
75
+ </script>
76
+
77
+ <style scoped>
78
+ .connection-content {
79
+ height: 100%;
80
+ overflow: auto;
81
+ font-size: var(--dev-tool-base-font-size);
82
+ }
83
+ .connection-item {
84
+ padding: 16px 16px 0 16px;
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ .connection-row {
89
+ display: flex;
90
+ align-items: center;
91
+ justify-content: space-between;
92
+ margin: 8px 0;
93
+ }
94
+ </style>