vite-uni-dev-tool 1.0.0 → 1.1.0

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 (168) hide show
  1. package/README.md +46 -0
  2. package/dist/const.cjs +1 -1
  3. package/dist/const.d.ts +12 -0
  4. package/dist/const.d.ts.map +1 -1
  5. package/dist/const.js +1 -1
  6. package/dist/core-shared.d.ts +1 -1
  7. package/dist/core-shared.d.ts.map +1 -1
  8. package/dist/core-shared.js +1 -1
  9. package/dist/core.d.ts +10 -3
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +2 -2
  12. package/dist/i18n/locales/en.cjs +1 -1
  13. package/dist/i18n/locales/en.d.ts +81 -0
  14. package/dist/i18n/locales/en.d.ts.map +1 -1
  15. package/dist/i18n/locales/en.js +1 -1
  16. package/dist/i18n/locales/zh-Hans.cjs +1 -1
  17. package/dist/i18n/locales/zh-Hans.d.ts +82 -1
  18. package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
  19. package/dist/i18n/locales/zh-Hans.js +1 -1
  20. package/dist/modules/devConsole/index.cjs +1 -1
  21. package/dist/modules/devConsole/index.js +3 -3
  22. package/dist/modules/devEvent/index.cjs +3 -3
  23. package/dist/modules/devEvent/index.d.ts +1 -0
  24. package/dist/modules/devEvent/index.d.ts.map +1 -1
  25. package/dist/modules/devEvent/index.js +3 -3
  26. package/dist/modules/devIntercept/index.cjs +14 -13
  27. package/dist/modules/devIntercept/index.d.ts +19 -0
  28. package/dist/modules/devIntercept/index.d.ts.map +1 -1
  29. package/dist/modules/devIntercept/index.js +14 -13
  30. package/dist/modules/devStore/index.cjs +1 -1
  31. package/dist/modules/devStore/index.d.ts +21 -0
  32. package/dist/modules/devStore/index.d.ts.map +1 -1
  33. package/dist/modules/devStore/index.js +1 -1
  34. package/dist/plugins/uniDevTool/transform/transformMain.cjs +1 -1
  35. package/dist/plugins/uniDevTool/transform/transformMain.js +1 -1
  36. package/dist/type.d.ts +47 -2
  37. package/dist/type.d.ts.map +1 -1
  38. package/dist/utils/language.cjs +1 -1
  39. package/dist/utils/language.d.ts.map +1 -1
  40. package/dist/utils/language.js +1 -1
  41. package/dist/utils/object.cjs +1 -1
  42. package/dist/utils/object.d.ts.map +1 -1
  43. package/dist/utils/object.js +1 -1
  44. package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -0
  45. package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -0
  46. package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -0
  47. package/dist/v3/{CaptureScreen → DevTool/components/CaptureScreen}/index.vue +109 -109
  48. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/ConsoleItem.vue +225 -224
  49. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/RunJSInput.vue +247 -249
  50. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/index.vue +171 -160
  51. package/dist/v3/{ConsoleList → DevTool/components/ConsoleList}/staticTips.ts +1145 -1145
  52. package/dist/v3/{DevToolButton → DevTool/components/DevToolButton}/index.vue +7 -4
  53. package/dist/v3/{DevToolTitle → DevTool/components/DevToolTitle}/index.vue +24 -24
  54. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/DevToolOverlay.vue +197 -182
  55. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/const.ts +28 -5
  56. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/dataUtils.ts +48 -48
  57. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolData.ts +387 -338
  58. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolHandlers.ts +629 -549
  59. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/hooks/useDevToolOverlay.ts +197 -184
  60. package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.vue +67 -16
  61. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/ElEventItem.vue +105 -105
  62. package/dist/v3/{ElEvent → DevTool/components/ElEvent}/index.vue +106 -109
  63. package/dist/v3/{Instance → DevTool/components/Instance}/components/InstanceTreeNode.vue +265 -265
  64. package/dist/v3/{Instance → DevTool/components/Instance}/flatten.ts +226 -226
  65. package/dist/v3/{Instance → DevTool/components/Instance}/index.vue +94 -94
  66. package/dist/v3/{Instance → DevTool/components/Instance}/registry.ts +49 -49
  67. package/dist/v3/{Instance → DevTool/components/Instance}/transformTree.ts +375 -375
  68. package/dist/v3/{Instance → DevTool/components/Instance}/transformTreeCtx.ts +268 -268
  69. package/dist/v3/{Instance → DevTool/components/Instance}/typing.d.ts +43 -43
  70. package/dist/v3/{InstanceDetail → DevTool/components/InstanceDetail}/index.vue +485 -485
  71. package/dist/v3/{JsonDetail → DevTool/components/JsonDetail}/index.vue +70 -70
  72. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCItem.vue +112 -113
  73. package/dist/v3/{NFCList → DevTool/components/NFCList}/NFCTool.vue +454 -478
  74. package/dist/v3/{NFCList → DevTool/components/NFCList}/const.ts +56 -56
  75. package/dist/v3/{NFCList → DevTool/components/NFCList}/index.vue +94 -98
  76. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptConfig.vue +624 -608
  77. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/InterceptItem.vue +140 -140
  78. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkDetail.vue +287 -296
  79. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkIntercept.vue +88 -93
  80. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkItem.vue +163 -167
  81. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/NetworkSend.vue +589 -556
  82. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/const.ts +4 -4
  83. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/hooks/useNetworkForm.ts +86 -86
  84. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/index.vue +160 -160
  85. package/dist/v3/{NetworkList → DevTool/components/NetworkList}/utils.ts +101 -101
  86. package/dist/v3/{Performance → DevTool/components/Performance}/index.vue +498 -495
  87. package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceMetrics.vue +153 -153
  88. package/dist/v3/{Performance → DevTool/components/Performance}/modules/PerformanceWidget.vue +12 -9
  89. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceChart.ts +460 -460
  90. package/dist/v3/{Performance → DevTool/components/Performance}/modules/usePerformanceData.ts +258 -258
  91. package/dist/v3/{PiniaList → DevTool/components/PiniaList}/index.vue +93 -94
  92. package/dist/v3/{RouteList → DevTool/components/RouteList}/index.vue +21 -24
  93. package/dist/v3/{RunJS → DevTool/components/RunJS}/index.vue +148 -148
  94. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/ScanCodeItem.vue +97 -98
  95. package/dist/v3/{ScanCodeList → DevTool/components/ScanCodeList}/index.vue +100 -104
  96. package/dist/v3/{SettingButton → DevTool/components/SettingButton}/index.vue +45 -45
  97. package/dist/v3/{SettingList → DevTool/components/SettingList}/index.vue +218 -150
  98. package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -0
  99. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingDevTool.vue +212 -208
  100. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingInfo.vue +157 -119
  101. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLanguage.vue +74 -74
  102. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingLog.vue +230 -230
  103. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingNetwork.vue +3 -3
  104. package/dist/v3/{SettingList → DevTool/components/SettingList}/modules/SettingTheme.vue +37 -7
  105. package/dist/v3/{SettingList → DevTool/components/SettingList}/typing.d.ts +2 -2
  106. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/Line.vue +127 -116
  107. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/index.vue +8 -8
  108. package/dist/v3/{SourceCode → DevTool/components/SourceCode}/parseCode.ts +609 -701
  109. package/dist/v3/{StorageList → DevTool/components/StorageList}/index.vue +174 -174
  110. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferDetail.vue +268 -268
  111. package/dist/v3/{TransferList → DevTool/components/TransferList}/TransferItem.vue +4 -4
  112. package/dist/v3/{TransferList → DevTool/components/TransferList}/index.vue +8 -8
  113. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/UniEventItem.vue +6 -7
  114. package/dist/v3/{UniEvent → DevTool/components/UniEvent}/index.vue +6 -6
  115. package/dist/v3/{VuexList → DevTool/components/VuexList}/index.vue +84 -84
  116. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketDetail.vue +8 -8
  117. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/WebSocketItem.vue +4 -4
  118. package/dist/v3/{WebSocket → DevTool/components/WebSocket}/index.vue +8 -8
  119. package/dist/v3/DevTool/index.vue +179 -5
  120. package/dist/v3/{AppTransition → components/AppTransition}/index.vue +176 -170
  121. package/dist/v3/{AutoSizer → components/AutoSizer}/index.vue +192 -192
  122. package/dist/v3/{AutoSizer → components/AutoSizer}/index1.vue +184 -184
  123. package/dist/v3/{AutoSizer → components/AutoSizer}/utils.ts +49 -49
  124. package/dist/v3/components/Barrage/BarrageItem.vue +137 -0
  125. package/dist/v3/components/Barrage/index.vue +202 -0
  126. package/dist/v3/{CircularButton → components/CircularButton}/index.vue +84 -84
  127. package/dist/v3/{CustomSwiper → components/CustomSwiper}/CustomSwiperItem.vue +49 -49
  128. package/dist/v3/{CustomSwiper → components/CustomSwiper}/index.vue +104 -104
  129. package/dist/v3/{DraggableContainer → components/DraggableContainer}/index.vue +1 -1
  130. package/dist/v3/{Empty → components/Empty}/index.vue +29 -29
  131. package/dist/v3/{FilterInput → components/FilterInput}/index.vue +1 -1
  132. package/dist/v3/{FilterSelect → components/FilterSelect}/index.vue +179 -179
  133. package/dist/v3/{JsonPretty → components/JsonPretty}/components/Brackets/index.vue +27 -27
  134. package/dist/v3/{JsonPretty → components/JsonPretty}/components/Carets/index.vue +59 -59
  135. package/dist/v3/{JsonPretty → components/JsonPretty}/components/CheckController/index.vue +136 -136
  136. package/dist/v3/{JsonPretty → components/JsonPretty}/components/TreeNode/index.vue +387 -381
  137. package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useClipboard.ts +21 -21
  138. package/dist/v3/{JsonPretty → components/JsonPretty}/hooks/useError.ts +21 -21
  139. package/dist/v3/{JsonPretty → components/JsonPretty}/index.vue +16 -13
  140. package/dist/v3/{JsonPretty → components/JsonPretty}/type.ts +127 -126
  141. package/dist/v3/{JsonPretty → components/JsonPretty}/utils/index.ts +169 -169
  142. package/dist/v3/{MovableContainer → components/MovableContainer}/index.vue +1 -1
  143. package/dist/v3/{Pick → components/Pick}/index.vue +322 -322
  144. package/dist/v3/{Tabs → components/Tabs}/index.vue +30 -4
  145. package/dist/v3/{Tag → components/Tag}/index.vue +113 -113
  146. package/dist/v3/{VirtualList → components/VirtualList}/AutoSize.vue +40 -40
  147. package/dist/v3/{VirtualList → components/VirtualList}/index.vue +416 -412
  148. package/dist/v3/hooks/useBluetooth/index.ts +561 -0
  149. package/dist/v3/hooks/useContainerStyle.ts +153 -153
  150. package/dist/v3/hooks/useNFC/index.ts +107 -107
  151. package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
  152. package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
  153. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
  154. package/dist/v3/hooks/useNFC/utils.ts +754 -754
  155. package/dist/v3/hooks/useRequest/index.ts +586 -573
  156. package/dist/v3/hooks/useRequest/utils.ts +267 -267
  157. package/dist/v3/hooks/useScanCode/index.ts +206 -206
  158. package/dist/v3/hooks/useWebsocket/README.md +79 -0
  159. package/dist/v3/hooks/useWebsocket/index.ts +253 -0
  160. package/dist/v3/styles/theme.css +17 -10
  161. package/dist/v3/styles/theme.ts +12 -12
  162. package/package.json +59 -64
  163. package/dist/plugins/uniParseStock/index.d.ts +0 -10
  164. package/dist/plugins/uniParseStock/index.d.ts.map +0 -1
  165. /package/dist/v3/{DevToolWindow → DevTool/components/DevToolWindow}/index.css +0 -0
  166. /package/dist/v3/{SettingList → DevTool/components/SettingList}/index.css +0 -0
  167. /package/dist/v3/{Empty → components/Empty}/empty.png +0 -0
  168. /package/dist/v3/{VirtualList → components/VirtualList}/readme.md +0 -0
@@ -1,478 +1,454 @@
1
- <template>
2
- <view class="nfc-tool" :style="customStyle">
3
- <view class="nfc-tool-control">
4
- <DevToolTitle>{{ t('nfc.toolTitle') }}</DevToolTitle>
5
-
6
- <Tag
7
- mode="info"
8
- v-for="item in translatedSelectItems"
9
- :active="item.value === currentSelect"
10
- :key="item.value"
11
- customStyle="margin-left: 16px"
12
- @click="onSelect(item)"
13
- >
14
- {{ item.label }}
15
- </Tag>
16
-
17
- <CircularButton
18
- style="margin-left: auto"
19
- text="×"
20
- @click="emit('close')"
21
- />
22
- </view>
23
- <scroll-view scroll-y style="height: calc(100% - 32px)">
24
- <view class="nfc-tool-base">
25
- <view class="nfc-tool-tips">
26
- {{ t('nfc.tipsTool') }}
27
- </view>
28
- <DevToolTitle>{{ t('nfc.status') }}</DevToolTitle>
29
- <view class="nfc-tool-status">
30
- <view class="nfc-tool-status-key">{{ t('nfc.deviceSupport') }}</view>
31
- <Tag mode="success" v-if="isSupportNFC">{{ t('nfc.support') }}</Tag>
32
- <Tag mode="error" v-else>{{ t('nfc.notSupport') }}</Tag>
33
- </view>
34
- <view class="nfc-tool-status">
35
- <view class="nfc-tool-status-key">{{ t('nfc.enabledStatus') }}</view>
36
- <Tag mode="success" v-if="isListening">{{ t('nfc.enabled') }}</Tag>
37
- <Tag mode="error" v-else>{{ t('nfc.disabled') }}</Tag>
38
- </view>
39
- <view class="nfc-tool-status">
40
- <view class="nfc-tool-status-key">{{ t('nfc.connectStatus') }}</view>
41
- <Tag mode="success" v-if="isConnected">{{ t('nfc.connected') }}</Tag>
42
- <Tag mode="error" v-else>{{ t('nfc.disconnected') }}</Tag>
43
- </view>
44
-
45
- <DevToolTitle>{{ t('nfc.operation') }}</DevToolTitle>
46
- <SettingButton class="nfc-tool-button" @click="startHCE">
47
- {{ t('nfc.startScan') }}
48
- </SettingButton>
49
- <SettingButton class="nfc-tool-button" @click="stopHCE">
50
- {{ t('nfc.stopScan') }}
51
- </SettingButton>
52
- </view>
53
-
54
- <view class="nfc-tool-read" v-if="currentSelect === 'read'">
55
- <DevToolTitle>{{ t('nfc.result') }}</DevToolTitle>
56
- <JsonPretty
57
- virtual
58
- v-if="showJson"
59
- :data="data"
60
- :pageSize="20"
61
- :nodeSelectable="() => false"
62
- :pathCollapsible="() => false"
63
- :height="contentHeight - 32 * 5 - 28 * 3 - 16 - 20"
64
- />
65
- <Empty v-else :text="t('nfc.noResult')" />
66
- </view>
67
- <view class="nfc-tool-write" v-if="currentSelect === 'write'">
68
- <DevToolTitle>{{ t('nfc.write') }}</DevToolTitle>
69
- <radio-group
70
- class="radio-group"
71
- @change="onChangeFormData('writeMethod', $event)"
72
- >
73
- <label
74
- class="radio-group-item"
75
- v-for="item in translatedWriteMethods"
76
- :key="item.value"
77
- >
78
- <radio
79
- size
80
- style="transform: scale(0.8)"
81
- color="#9254de"
82
- :value="item.value"
83
- :checked="item.value === formData.writeMethod"
84
- />
85
-
86
- <view>{{ item.label }}</view>
87
- </label>
88
- </radio-group>
89
-
90
- <view
91
- class="nfc-tool-write-form"
92
- v-if="formData.writeMethod === 'text'"
93
- >
94
- <DevToolTitle>{{ t('nfc.textContent') }}</DevToolTitle>
95
- <textarea
96
- class="textarea"
97
- :value="formData.text"
98
- :placeholder="t('nfc.placeholderText')"
99
- @input="onChangeFormData('text', $event)"
100
- />
101
- </view>
102
-
103
- <view class="nfc-tool-write-form" v-if="formData.writeMethod === 'uri'">
104
- <DevToolTitle>{{ t('nfc.link') }}</DevToolTitle>
105
- <textarea
106
- class="textarea"
107
- :placeholder="t('nfc.placeholderLink')"
108
- :value="formData.uri"
109
- @input="onChangeFormData('uri', $event)"
110
- />
111
- </view>
112
-
113
- <view
114
- class="nfc-tool-write-form"
115
- v-if="formData.writeMethod === 'wifi'"
116
- >
117
- <DevToolTitle>{{ t('nfc.wifiConfig') }}</DevToolTitle>
118
- <input
119
- class="input"
120
- :placeholder="t('nfc.placeholderSsid')"
121
- :value="formData.ssid"
122
- @input="onChangeFormData('ssid', $event)"
123
- />
124
- <input
125
- class="input"
126
- :placeholder="t('nfc.placeholderPassword')"
127
- type="password"
128
- :value="formData.password"
129
- @input="onChangeFormData('password', $event)"
130
- />
131
- <view class="sub-title">{{ t('nfc.encryption') }}</view>
132
- <radio-group
133
- class="radio-group"
134
- @change="onChangeFormData('authType', $event)"
135
- >
136
- <label
137
- class="radio-group-item"
138
- v-for="item in translatedEncryptionMethods"
139
- :key="item.value"
140
- >
141
- <radio
142
- size
143
- style="transform: scale(0.8)"
144
- color="#9254de"
145
- :value="item.value"
146
- :checked="item.value === formData.authType"
147
- />
148
- <view>{{ item.label }}</view>
149
- </label>
150
- </radio-group>
151
- </view>
152
-
153
- <view
154
- class="nfc-tool-write-form"
155
- v-if="formData.writeMethod === 'card'"
156
- >
157
- <DevToolTitle>{{ t('nfc.cardInfo') }}</DevToolTitle>
158
- <input
159
- class="input"
160
- :placeholder="t('nfc.placeholderName')"
161
- :value="formData.name"
162
- @input="onChangeFormData('name', $event)"
163
- />
164
- <input
165
- class="input"
166
- :placeholder="t('nfc.placeholderOrg')"
167
- :value="formData.organization"
168
- @input="onChangeFormData('organization', $event)"
169
- />
170
- <input
171
- class="input"
172
- :placeholder="t('nfc.placeholderTel')"
173
- :value="formData.tel"
174
- @input="onChangeFormData('tel', $event)"
175
- />
176
- <input
177
- class="input"
178
- :placeholder="t('nfc.placeholderAddress')"
179
- :value="formData.address"
180
- @input="onChangeFormData('address', $event)"
181
- />
182
- <input
183
- class="input"
184
- :placeholder="t('nfc.placeholderWeb')"
185
- :value="formData.uri"
186
- @input="onChangeFormData('uri', $event)"
187
- />
188
- </view>
189
- <view class="nfc-tool-write-form" v-if="formData.writeMethod === 'tel'">
190
- <DevToolTitle>{{ t('nfc.tel') }}</DevToolTitle>
191
- <input
192
- class="input"
193
- :placeholder="t('nfc.placeholderTelInput')"
194
- :value="formData.tel"
195
- @input="onChangeFormData('tel', $event)"
196
- />
197
- </view>
198
- <view
199
- class="nfc-tool-write-form"
200
- v-if="formData.writeMethod === 'packageName'"
201
- >
202
- <DevToolTitle>{{ t('nfc.appLaunch') }}</DevToolTitle>
203
- <input
204
- class="input"
205
- :placeholder="t('nfc.placeholderPkg')"
206
- :value="formData.packageName"
207
- @input="onChangeFormData('packageName', $event)"
208
- />
209
- </view>
210
- <SettingButton @click="onWrite">{{
211
- t('nfc.startWrite')
212
- }}</SettingButton>
213
- <view class="nfc-tool-tips">
214
- {{ t('nfc.tipsWriting') }}
215
- </view>
216
- </view>
217
- <view class="nfc-tool-copy" v-if="currentSelect === 'copy'">
218
- <DevToolTitle>{{ t('nfc.copy') }}</DevToolTitle>
219
- <DevToolTitle>{{ t('nfc.step1') }}</DevToolTitle>
220
- <DevToolTitle>{{ t('nfc.step2') }}</DevToolTitle>
221
- <SettingButton @click="onCopy">{{ t('nfc.toCopy') }}</SettingButton>
222
- <view class="nfc-tool-tips">
223
- {{ t('nfc.tipsCopying') }}
224
- </view>
225
- <DevToolTitle>{{ t('nfc.step3') }}</DevToolTitle>
226
- <SettingButton @click="stopHCE">{{ t('nfc.stopScan') }}</SettingButton>
227
- </view>
228
- </scroll-view>
229
- </view>
230
- </template>
231
- <script lang="ts" setup>
232
- import { ref, reactive, computed } from 'vue';
233
- import Tag from '../Tag/index.vue';
234
- import CircularButton from '../CircularButton/index.vue';
235
- import DevToolTitle from '../DevToolTitle/index.vue';
236
- import JsonPretty from '../JsonPretty/index.vue';
237
- import Empty from '../Empty/index.vue';
238
- import useNFC from '../hooks/useNFC';
239
- import SettingButton from '../SettingButton/index.vue';
240
- import { selectItems, writeMethods, encryptionMethods } from './const';
241
- import { useI18n } from '../../i18n';
242
-
243
- const { t } = useI18n();
244
-
245
- const translatedSelectItems = computed(() => {
246
- return selectItems.map((item) => ({
247
- ...item,
248
- label: item.value === 'read' ? t('nfc.read') : t('nfc.writeLabel'),
249
- }));
250
- });
251
-
252
- const translatedWriteMethods = computed(() => {
253
- return writeMethods.map((item) => ({
254
- ...item,
255
- label: t(`nfc.writeMethods.${item.value}`),
256
- }));
257
- });
258
-
259
- const translatedEncryptionMethods = computed(() => {
260
- return encryptionMethods.map((item) => ({
261
- ...item,
262
- label:
263
- t(`nfc.authTypes.${item.value}`) !== `nfc.authTypes.${item.value}`
264
- ? t(`nfc.authTypes.${item.value}`)
265
- : item.label,
266
- }));
267
- });
268
- const _props = defineProps<{
269
- contentHeight: number;
270
- customStyle?: Record<string, any>;
271
- }>();
272
-
273
- const emit = defineEmits<{
274
- (e: 'close'): void;
275
- }>();
276
-
277
- const data = ref({});
278
- const formData = reactive({
279
- writeMethod: 'text',
280
-
281
- text: '',
282
- uri: 'https://gitee.com/cloud_l/vite-uni-dev-tool',
283
-
284
- authType: 'WPA2-Personal',
285
- ssid: '',
286
- password: '',
287
-
288
- name: '',
289
- organization: '',
290
- tel: '188888888888',
291
- address: '',
292
-
293
- packageName: 'io.dcloud.HBuilder',
294
- });
295
-
296
- const showJson = computed(() => {
297
- return JSON.stringify(data.value) !== '{}';
298
- });
299
- const {
300
- isConnected,
301
- isSupportNFC,
302
- isListening,
303
- startHCE,
304
- stopHCE,
305
- writeNdefText,
306
- writeNdefUri,
307
- writeNdefAndroidApp,
308
- writeNdefWifi,
309
- writeNdefVcard,
310
- } = useNFC((nfcInfo) => {
311
- console.log('nfcInfo: ', nfcInfo);
312
- data.value = nfcInfo;
313
- });
314
-
315
- const currentSelect = ref('read');
316
-
317
- function onSelect(item: { label: string; value: string }) {
318
- currentSelect.value = item.value;
319
- }
320
-
321
- function onChangeFormData(key: keyof typeof formData, e: any) {
322
- formData[key] = e.detail.value;
323
- }
324
-
325
- function onWrite() {
326
- switch (formData.writeMethod) {
327
- case 'text':
328
- writeNdefText(formData.text);
329
- break;
330
- case 'uri':
331
- writeNdefUri(formData.uri);
332
- break;
333
- case 'tel':
334
- writeNdefUri(`tel:${formData.tel}`);
335
- break;
336
- case 'packageName':
337
- writeNdefAndroidApp(formData.packageName);
338
- break;
339
- case 'wifi':
340
- writeNdefWifi({
341
- ssid: formData.ssid,
342
- password: formData.password,
343
- authType: formData.authType,
344
- });
345
- break;
346
- case 'card':
347
- if (!formData.name) {
348
- uni.showToast({
349
- title: t('nfc.toast.enterName'),
350
- icon: 'none',
351
- });
352
- return;
353
- }
354
- if (!formData.tel) {
355
- uni.showToast({
356
- title: t('nfc.toast.enterTel'),
357
- icon: 'none',
358
- });
359
- return;
360
- }
361
- writeNdefVcard({
362
- fullName: formData.name,
363
- address: formData.address,
364
- telephone: formData.tel,
365
- url: formData.uri,
366
- version: 'V3.0',
367
- organization: formData.organization,
368
- });
369
- break;
370
- default:
371
- break;
372
- }
373
- }
374
-
375
- function onCopy() {
376
- // 存储源标签信息
377
- // 复制到目标标签
378
- // 断开连接
379
- uni.showToast({
380
- title: t('nfc.copying'),
381
- icon: 'none',
382
- });
383
- }
384
- </script>
385
- <style scoped>
386
- .nfc-tool {
387
- position: fixed;
388
- width: 100vw;
389
- height: 100%;
390
- top: 0;
391
- left: 0;
392
- background-color: var(--dev-tool-bg3-color);
393
- box-sizing: border-box;
394
- }
395
-
396
- .nfc-tool-control {
397
- padding: 0 16px;
398
- display: flex;
399
- align-items: center;
400
-
401
- /* gap: 12px; */
402
- height: 32px;
403
- border-bottom: 1px solid var(--dev-tool-border-color);
404
- box-sizing: border-box;
405
- }
406
-
407
- .nfc-tool-tips {
408
- font-size: var(--dev-tool-tips-font-size);
409
- line-height: 20px;
410
- color: #616161;
411
- }
412
-
413
- .nfc-tool-base {
414
- padding: 0 16px;
415
- }
416
-
417
- .nfc-tool-status {
418
- display: flex;
419
- align-items: center;
420
- justify-content: space-between;
421
- min-height: 28px;
422
- word-break: break-all;
423
- }
424
-
425
- .nfc-tool-status-key {
426
- white-space: nowrap;
427
- margin-right: 8px;
428
- color: var(--dev-tool-info-color);
429
- }
430
-
431
- .nfc-tool-read,
432
- .nfc-tool-write,
433
- .nfc-tool-copy {
434
- padding: 0 16px;
435
- }
436
-
437
- .nfc-tool-button + .nfc-tool-button {
438
- margin-top: 8px;
439
- }
440
-
441
- .radio-group {
442
- display: flex;
443
- flex-wrap: wrap;
444
- }
445
-
446
- .radio-group-item {
447
- display: flex;
448
- align-items: center;
449
- justify-content: center;
450
- width: 33.33%;
451
- margin-bottom: 6px;
452
- }
453
-
454
- .textarea {
455
- padding: 6px;
456
- width: 100%;
457
- box-sizing: border-box;
458
- border: 1px solid var(--dev-tool-border-color);
459
- }
460
-
461
- .input {
462
- padding: 0 6px;
463
- height: 24px;
464
- border: 1px solid var(--dev-tool-border-color);
465
- }
466
-
467
- .input + .input {
468
- margin-top: 8px;
469
- }
470
-
471
- .sub-title {
472
- line-height: 20px;
473
- }
474
-
475
- .nfc-tool-write-form {
476
- height: 200px;
477
- }
478
- </style>
1
+ <template>
2
+ <view class="nfc-tool" :style="customStyle">
3
+ <view class="nfc-tool-control">
4
+ <DevToolTitle>{{ t('nfc.toolTitle') }}</DevToolTitle>
5
+
6
+ <Tag
7
+ mode="info"
8
+ v-for="item in translatedSelectItems"
9
+ :active="item.value === currentSelect"
10
+ :key="item.value"
11
+ customStyle="margin-left: 16px"
12
+ @click="onSelect(item)">
13
+ {{ item.label }}
14
+ </Tag>
15
+
16
+ <CircularButton
17
+ style="margin-left: auto"
18
+ text="×"
19
+ @click="emit('close')" />
20
+ </view>
21
+ <scroll-view scroll-y style="height: calc(100% - 32px)">
22
+ <view class="nfc-tool-base">
23
+ <view class="nfc-tool-tips">
24
+ {{ t('nfc.tipsTool') }}
25
+ </view>
26
+ <DevToolTitle>{{ t('nfc.status') }}</DevToolTitle>
27
+ <view class="nfc-tool-status">
28
+ <view class="nfc-tool-status-key">{{ t('nfc.deviceSupport') }}</view>
29
+ <Tag mode="success" v-if="isSupportNFC">{{ t('nfc.support') }}</Tag>
30
+ <Tag mode="error" v-else>{{ t('nfc.notSupport') }}</Tag>
31
+ </view>
32
+ <view class="nfc-tool-status">
33
+ <view class="nfc-tool-status-key">{{ t('nfc.enabledStatus') }}</view>
34
+ <Tag mode="success" v-if="isListening">{{ t('nfc.enabled') }}</Tag>
35
+ <Tag mode="error" v-else>{{ t('nfc.disabled') }}</Tag>
36
+ </view>
37
+ <view class="nfc-tool-status">
38
+ <view class="nfc-tool-status-key">{{ t('nfc.connectStatus') }}</view>
39
+ <Tag mode="success" v-if="isConnected">{{ t('nfc.connected') }}</Tag>
40
+ <Tag mode="error" v-else>{{ t('nfc.disconnected') }}</Tag>
41
+ </view>
42
+
43
+ <DevToolTitle>{{ t('nfc.operation') }}</DevToolTitle>
44
+ <SettingButton class="nfc-tool-button" @click="startHCE">
45
+ {{ t('nfc.startScan') }}
46
+ </SettingButton>
47
+ <SettingButton class="nfc-tool-button" @click="stopHCE">
48
+ {{ t('nfc.stopScan') }}
49
+ </SettingButton>
50
+ </view>
51
+
52
+ <view class="nfc-tool-read" v-if="currentSelect === 'read'">
53
+ <DevToolTitle>{{ t('nfc.result') }}</DevToolTitle>
54
+ <JsonPretty
55
+ virtual
56
+ v-if="showJson"
57
+ :data="data"
58
+ :pageSize="20"
59
+ :nodeSelectable="() => false"
60
+ :pathCollapsible="() => false"
61
+ :height="contentHeight - 32 * 5 - 28 * 3 - 16 - 20" />
62
+ <Empty v-else :text="t('nfc.noResult')" />
63
+ </view>
64
+ <view class="nfc-tool-write" v-if="currentSelect === 'write'">
65
+ <DevToolTitle>{{ t('nfc.write') }}</DevToolTitle>
66
+ <radio-group
67
+ class="radio-group"
68
+ @change="onChangeFormData('writeMethod', $event)">
69
+ <label
70
+ class="radio-group-item"
71
+ v-for="item in translatedWriteMethods"
72
+ :key="item.value">
73
+ <radio
74
+ size
75
+ style="transform: scale(0.8)"
76
+ color="#9254de"
77
+ :value="item.value"
78
+ :checked="item.value === formData.writeMethod" />
79
+
80
+ <view>{{ item.label }}</view>
81
+ </label>
82
+ </radio-group>
83
+
84
+ <view
85
+ class="nfc-tool-write-form"
86
+ v-if="formData.writeMethod === 'text'">
87
+ <DevToolTitle>{{ t('nfc.textContent') }}</DevToolTitle>
88
+ <textarea
89
+ class="textarea"
90
+ :value="formData.text"
91
+ :placeholder="t('nfc.placeholderText')"
92
+ @input="onChangeFormData('text', $event)" />
93
+ </view>
94
+
95
+ <view class="nfc-tool-write-form" v-if="formData.writeMethod === 'uri'">
96
+ <DevToolTitle>{{ t('nfc.link') }}</DevToolTitle>
97
+ <textarea
98
+ class="textarea"
99
+ :placeholder="t('nfc.placeholderLink')"
100
+ :value="formData.uri"
101
+ @input="onChangeFormData('uri', $event)" />
102
+ </view>
103
+
104
+ <view
105
+ class="nfc-tool-write-form"
106
+ v-if="formData.writeMethod === 'wifi'">
107
+ <DevToolTitle>{{ t('nfc.wifiConfig') }}</DevToolTitle>
108
+ <input
109
+ class="input"
110
+ :placeholder="t('nfc.placeholderSsid')"
111
+ :value="formData.ssid"
112
+ @input="onChangeFormData('ssid', $event)" />
113
+ <input
114
+ class="input"
115
+ :placeholder="t('nfc.placeholderPassword')"
116
+ type="password"
117
+ :value="formData.password"
118
+ @input="onChangeFormData('password', $event)" />
119
+ <view class="sub-title">{{ t('nfc.encryption') }}</view>
120
+ <radio-group
121
+ class="radio-group"
122
+ @change="onChangeFormData('authType', $event)">
123
+ <label
124
+ class="radio-group-item"
125
+ v-for="item in translatedEncryptionMethods"
126
+ :key="item.value">
127
+ <radio
128
+ size
129
+ style="transform: scale(0.8)"
130
+ color="#9254de"
131
+ :value="item.value"
132
+ :checked="item.value === formData.authType" />
133
+ <view>{{ item.label }}</view>
134
+ </label>
135
+ </radio-group>
136
+ </view>
137
+
138
+ <view
139
+ class="nfc-tool-write-form"
140
+ v-if="formData.writeMethod === 'card'">
141
+ <DevToolTitle>{{ t('nfc.cardInfo') }}</DevToolTitle>
142
+ <input
143
+ class="input"
144
+ :placeholder="t('nfc.placeholderName')"
145
+ :value="formData.name"
146
+ @input="onChangeFormData('name', $event)" />
147
+ <input
148
+ class="input"
149
+ :placeholder="t('nfc.placeholderOrg')"
150
+ :value="formData.organization"
151
+ @input="onChangeFormData('organization', $event)" />
152
+ <input
153
+ class="input"
154
+ :placeholder="t('nfc.placeholderTel')"
155
+ :value="formData.tel"
156
+ @input="onChangeFormData('tel', $event)" />
157
+ <input
158
+ class="input"
159
+ :placeholder="t('nfc.placeholderAddress')"
160
+ :value="formData.address"
161
+ @input="onChangeFormData('address', $event)" />
162
+ <input
163
+ class="input"
164
+ :placeholder="t('nfc.placeholderWeb')"
165
+ :value="formData.uri"
166
+ @input="onChangeFormData('uri', $event)" />
167
+ </view>
168
+ <view class="nfc-tool-write-form" v-if="formData.writeMethod === 'tel'">
169
+ <DevToolTitle>{{ t('nfc.tel') }}</DevToolTitle>
170
+ <input
171
+ class="input"
172
+ :placeholder="t('nfc.placeholderTelInput')"
173
+ :value="formData.tel"
174
+ @input="onChangeFormData('tel', $event)" />
175
+ </view>
176
+ <view
177
+ class="nfc-tool-write-form"
178
+ v-if="formData.writeMethod === 'packageName'">
179
+ <DevToolTitle>{{ t('nfc.appLaunch') }}</DevToolTitle>
180
+ <input
181
+ class="input"
182
+ :placeholder="t('nfc.placeholderPkg')"
183
+ :value="formData.packageName"
184
+ @input="onChangeFormData('packageName', $event)" />
185
+ </view>
186
+ <SettingButton @click="onWrite">
187
+ {{ t('nfc.startWrite') }}
188
+ </SettingButton>
189
+ <view class="nfc-tool-tips">
190
+ {{ t('nfc.tipsWriting') }}
191
+ </view>
192
+ </view>
193
+ <view class="nfc-tool-copy" v-if="currentSelect === 'copy'">
194
+ <DevToolTitle>{{ t('nfc.copy') }}</DevToolTitle>
195
+ <DevToolTitle>{{ t('nfc.step1') }}</DevToolTitle>
196
+ <DevToolTitle>{{ t('nfc.step2') }}</DevToolTitle>
197
+ <SettingButton @click="onCopy">{{ t('nfc.toCopy') }}</SettingButton>
198
+ <view class="nfc-tool-tips">
199
+ {{ t('nfc.tipsCopying') }}
200
+ </view>
201
+ <DevToolTitle>{{ t('nfc.step3') }}</DevToolTitle>
202
+ <SettingButton @click="stopHCE">{{ t('nfc.stopScan') }}</SettingButton>
203
+ </view>
204
+ </scroll-view>
205
+ </view>
206
+ </template>
207
+ <script lang="ts" setup>
208
+ import { ref, reactive, computed } from 'vue';
209
+ import Tag from '../../../components/Tag/index.vue';
210
+ import CircularButton from '../../../components/CircularButton/index.vue';
211
+ import DevToolTitle from '../DevToolTitle/index.vue';
212
+ import JsonPretty from '../../../components/JsonPretty/index.vue';
213
+ import Empty from '../../../components/Empty/index.vue';
214
+ import useNFC from '../../../hooks/useNFC';
215
+ import SettingButton from '../SettingButton/index.vue';
216
+ import { selectItems, writeMethods, encryptionMethods } from './const';
217
+ import { useI18n } from '../../../../i18n';
218
+
219
+ const { t } = useI18n();
220
+
221
+ const translatedSelectItems = computed(() => {
222
+ return selectItems.map((item) => ({
223
+ ...item,
224
+ label: item.value === 'read' ? t('nfc.read') : t('nfc.writeLabel'),
225
+ }));
226
+ });
227
+
228
+ const translatedWriteMethods = computed(() => {
229
+ return writeMethods.map((item) => ({
230
+ ...item,
231
+ label: t(`nfc.writeMethods.${item.value}`),
232
+ }));
233
+ });
234
+
235
+ const translatedEncryptionMethods = computed(() => {
236
+ return encryptionMethods.map((item) => ({
237
+ ...item,
238
+ label:
239
+ t(`nfc.authTypes.${item.value}`) !== `nfc.authTypes.${item.value}`
240
+ ? t(`nfc.authTypes.${item.value}`)
241
+ : item.label,
242
+ }));
243
+ });
244
+ const _props = defineProps<{
245
+ contentHeight: number;
246
+ customStyle?: Record<string, any>;
247
+ }>();
248
+
249
+ const emit = defineEmits<{
250
+ (e: 'close'): void;
251
+ }>();
252
+
253
+ const data = ref({});
254
+ const formData = reactive({
255
+ writeMethod: 'text',
256
+
257
+ text: '',
258
+ uri: 'https://gitee.com/cloud_l/vite-uni-dev-tool',
259
+
260
+ authType: 'WPA2-Personal',
261
+ ssid: '',
262
+ password: '',
263
+
264
+ name: '',
265
+ organization: '',
266
+ tel: '188888888888',
267
+ address: '',
268
+
269
+ packageName: 'io.dcloud.HBuilder',
270
+ });
271
+
272
+ const showJson = computed(() => {
273
+ return JSON.stringify(data.value) !== '{}';
274
+ });
275
+ const {
276
+ isConnected,
277
+ isSupportNFC,
278
+ isListening,
279
+ startHCE,
280
+ stopHCE,
281
+ writeNdefText,
282
+ writeNdefUri,
283
+ writeNdefAndroidApp,
284
+ writeNdefWifi,
285
+ writeNdefVcard,
286
+ } = useNFC((nfcInfo) => {
287
+ console.log('nfcInfo: ', nfcInfo);
288
+ data.value = nfcInfo;
289
+ });
290
+
291
+ const currentSelect = ref('read');
292
+
293
+ function onSelect(item: { label: string; value: string }) {
294
+ currentSelect.value = item.value;
295
+ }
296
+
297
+ function onChangeFormData(key: keyof typeof formData, e: any) {
298
+ formData[key] = e.detail.value;
299
+ }
300
+
301
+ function onWrite() {
302
+ switch (formData.writeMethod) {
303
+ case 'text':
304
+ writeNdefText(formData.text);
305
+ break;
306
+ case 'uri':
307
+ writeNdefUri(formData.uri);
308
+ break;
309
+ case 'tel':
310
+ writeNdefUri(`tel:${formData.tel}`);
311
+ break;
312
+ case 'packageName':
313
+ writeNdefAndroidApp(formData.packageName);
314
+ break;
315
+ case 'wifi':
316
+ writeNdefWifi({
317
+ ssid: formData.ssid,
318
+ password: formData.password,
319
+ authType: formData.authType,
320
+ });
321
+ break;
322
+ case 'card':
323
+ if (!formData.name) {
324
+ uni.showToast({
325
+ title: t('nfc.toast.enterName'),
326
+ icon: 'none',
327
+ });
328
+ return;
329
+ }
330
+ if (!formData.tel) {
331
+ uni.showToast({
332
+ title: t('nfc.toast.enterTel'),
333
+ icon: 'none',
334
+ });
335
+ return;
336
+ }
337
+ writeNdefVcard({
338
+ fullName: formData.name,
339
+ address: formData.address,
340
+ telephone: formData.tel,
341
+ url: formData.uri,
342
+ version: 'V3.0',
343
+ organization: formData.organization,
344
+ });
345
+ break;
346
+ default:
347
+ break;
348
+ }
349
+ }
350
+
351
+ function onCopy() {
352
+ // 存储源标签信息
353
+ // 复制到目标标签
354
+ // 断开连接
355
+ uni.showToast({
356
+ title: t('nfc.copying'),
357
+ icon: 'none',
358
+ });
359
+ }
360
+ </script>
361
+ <style scoped>
362
+ .nfc-tool {
363
+ position: fixed;
364
+ width: 100vw;
365
+ height: 100%;
366
+ top: 0;
367
+ left: 0;
368
+ background-color: var(--dev-tool-bg3-color);
369
+ box-sizing: border-box;
370
+ }
371
+
372
+ .nfc-tool-control {
373
+ padding: 0 16px;
374
+ display: flex;
375
+ align-items: center;
376
+
377
+ /* gap: 12px; */
378
+ height: 32px;
379
+ border-bottom: 1px solid var(--dev-tool-border-color);
380
+ box-sizing: border-box;
381
+ }
382
+
383
+ .nfc-tool-tips {
384
+ font-size: var(--dev-tool-tips-font-size);
385
+ line-height: 20px;
386
+ color: #616161;
387
+ }
388
+
389
+ .nfc-tool-base {
390
+ padding: 0 16px;
391
+ }
392
+
393
+ .nfc-tool-status {
394
+ display: flex;
395
+ align-items: center;
396
+ justify-content: space-between;
397
+ min-height: 28px;
398
+ word-break: break-all;
399
+ }
400
+
401
+ .nfc-tool-status-key {
402
+ white-space: nowrap;
403
+ margin-right: 8px;
404
+ color: var(--dev-tool-info-color);
405
+ }
406
+
407
+ .nfc-tool-read,
408
+ .nfc-tool-write,
409
+ .nfc-tool-copy {
410
+ padding: 0 16px;
411
+ }
412
+
413
+ .nfc-tool-button + .nfc-tool-button {
414
+ margin-top: 8px;
415
+ }
416
+
417
+ .radio-group {
418
+ display: flex;
419
+ flex-wrap: wrap;
420
+ }
421
+
422
+ .radio-group-item {
423
+ display: flex;
424
+ align-items: center;
425
+ justify-content: center;
426
+ width: 33.33%;
427
+ margin-bottom: 6px;
428
+ }
429
+
430
+ .textarea {
431
+ padding: 6px;
432
+ width: 100%;
433
+ box-sizing: border-box;
434
+ border: 1px solid var(--dev-tool-border-color);
435
+ }
436
+
437
+ .input {
438
+ padding: 0 6px;
439
+ height: 24px;
440
+ border: 1px solid var(--dev-tool-border-color);
441
+ }
442
+
443
+ .input + .input {
444
+ margin-top: 8px;
445
+ }
446
+
447
+ .sub-title {
448
+ line-height: 20px;
449
+ }
450
+
451
+ .nfc-tool-write-form {
452
+ height: 200px;
453
+ }
454
+ </style>