vite-uni-dev-tool 1.1.0 → 1.2.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.
- package/README.md +8 -0
- package/dist/const.cjs +1 -1
- package/dist/const.d.ts +1 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2 -2
- package/dist/i18n/locales/en.cjs +1 -1
- package/dist/i18n/locales/en.d.ts +5 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.cjs +1 -1
- package/dist/i18n/locales/zh-Hans.d.ts +5 -0
- package/dist/i18n/locales/zh-Hans.d.ts.map +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/modules/devIntercept/index.cjs +9 -9
- package/dist/modules/devIntercept/index.d.ts +1 -1
- package/dist/modules/devIntercept/index.d.ts.map +1 -1
- package/dist/modules/devIntercept/index.js +9 -9
- package/dist/modules/devStore/index.cjs +1 -1
- package/dist/modules/devStore/index.d.ts.map +1 -1
- package/dist/modules/devStore/index.js +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -3
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts +2 -1
- package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
- package/dist/plugins/uniDevTool/transform/transformVue.cjs +31 -25
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts +2 -1
- package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/transform/transformVue.js +30 -24
- package/dist/plugins/uniDevTool/uniDevTool.cjs +3 -3
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
- package/dist/type.d.ts +3 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/v3/DevTool/components/BluetoothList/BluetoothItem.vue +199 -199
- package/dist/v3/DevTool/components/BluetoothList/BluetoothTool.vue +730 -730
- package/dist/v3/DevTool/components/BluetoothList/index.vue +167 -167
- package/dist/v3/DevTool/components/CaptureScreen/index.vue +109 -109
- package/dist/v3/DevTool/components/ConsoleList/ConsoleItem.vue +230 -225
- package/dist/v3/DevTool/components/ConsoleList/RunJSInput.vue +247 -247
- package/dist/v3/DevTool/components/ConsoleList/index.vue +171 -171
- package/dist/v3/DevTool/components/ConsoleList/staticTips.ts +1145 -1145
- package/dist/v3/DevTool/components/DevToolTitle/index.vue +24 -24
- package/dist/v3/DevTool/components/DevToolWindow/DevToolOverlay.vue +197 -197
- package/dist/v3/DevTool/components/DevToolWindow/hooks/dataUtils.ts +48 -48
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolData.ts +387 -387
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolHandlers.ts +629 -629
- package/dist/v3/DevTool/components/DevToolWindow/hooks/useDevToolOverlay.ts +201 -197
- package/dist/v3/DevTool/components/ElEvent/ElEventItem.vue +105 -105
- package/dist/v3/DevTool/components/ElEvent/index.vue +106 -106
- package/dist/v3/DevTool/components/Instance/components/InstanceTreeNode.vue +265 -265
- package/dist/v3/DevTool/components/Instance/flatten.ts +226 -226
- package/dist/v3/DevTool/components/Instance/index.vue +94 -94
- package/dist/v3/DevTool/components/Instance/registry.ts +49 -49
- package/dist/v3/DevTool/components/Instance/transformTree.ts +375 -375
- package/dist/v3/DevTool/components/Instance/transformTreeCtx.ts +268 -268
- package/dist/v3/DevTool/components/Instance/typing.d.ts +43 -43
- package/dist/v3/DevTool/components/InstanceDetail/index.vue +485 -485
- package/dist/v3/DevTool/components/JsonDetail/index.vue +70 -70
- package/dist/v3/DevTool/components/NFCList/NFCItem.vue +112 -112
- package/dist/v3/DevTool/components/NFCList/NFCTool.vue +454 -454
- package/dist/v3/DevTool/components/NFCList/const.ts +56 -56
- package/dist/v3/DevTool/components/NFCList/index.vue +94 -94
- package/dist/v3/DevTool/components/NetworkList/InterceptConfig.vue +624 -624
- package/dist/v3/DevTool/components/NetworkList/InterceptItem.vue +140 -140
- package/dist/v3/DevTool/components/NetworkList/NetworkDetail.vue +287 -287
- package/dist/v3/DevTool/components/NetworkList/NetworkIntercept.vue +88 -88
- package/dist/v3/DevTool/components/NetworkList/NetworkItem.vue +163 -163
- package/dist/v3/DevTool/components/NetworkList/NetworkSend.vue +589 -589
- package/dist/v3/DevTool/components/NetworkList/const.ts +4 -4
- package/dist/v3/DevTool/components/NetworkList/hooks/useNetworkForm.ts +86 -86
- package/dist/v3/DevTool/components/NetworkList/index.vue +160 -160
- package/dist/v3/DevTool/components/NetworkList/utils.ts +101 -101
- package/dist/v3/DevTool/components/Performance/index.vue +498 -498
- package/dist/v3/DevTool/components/Performance/modules/PerformanceMetrics.vue +153 -153
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceChart.ts +460 -460
- package/dist/v3/DevTool/components/Performance/modules/usePerformanceData.ts +258 -258
- package/dist/v3/DevTool/components/PiniaList/index.vue +93 -93
- package/dist/v3/DevTool/components/RunJS/index.vue +148 -148
- package/dist/v3/DevTool/components/ScanCodeList/ScanCodeItem.vue +97 -97
- package/dist/v3/DevTool/components/ScanCodeList/index.vue +100 -100
- package/dist/v3/DevTool/components/SettingButton/index.vue +45 -45
- package/dist/v3/DevTool/components/SettingList/index.vue +218 -218
- package/dist/v3/DevTool/components/SettingList/modules/SettingBarrage.vue +304 -304
- package/dist/v3/DevTool/components/SettingList/modules/SettingDevTool.vue +212 -212
- package/dist/v3/DevTool/components/SettingList/modules/SettingInfo.vue +157 -157
- package/dist/v3/DevTool/components/SettingList/modules/SettingLanguage.vue +74 -74
- package/dist/v3/DevTool/components/SettingList/modules/SettingLog.vue +230 -230
- package/dist/v3/DevTool/components/SettingList/typing.d.ts +2 -2
- package/dist/v3/DevTool/components/SourceCode/Line.vue +127 -127
- package/dist/v3/DevTool/components/SourceCode/parseCode.ts +609 -609
- package/dist/v3/DevTool/components/StorageList/index.vue +174 -174
- package/dist/v3/DevTool/components/TransferList/TransferDetail.vue +268 -268
- package/dist/v3/DevTool/components/VuexList/index.vue +84 -84
- package/dist/v3/DevTool/index.vue +1 -0
- package/dist/v3/components/AppTransition/index.vue +176 -176
- package/dist/v3/components/AutoSizer/index.vue +192 -192
- package/dist/v3/components/AutoSizer/index1.vue +184 -184
- package/dist/v3/components/AutoSizer/utils.ts +49 -49
- package/dist/v3/components/Barrage/BarrageItem.vue +137 -137
- package/dist/v3/components/Barrage/index.vue +202 -202
- package/dist/v3/components/CircularButton/index.vue +84 -84
- package/dist/v3/components/CustomSwiper/CustomSwiperItem.vue +49 -49
- package/dist/v3/components/CustomSwiper/index.vue +104 -104
- package/dist/v3/components/DevErrorBoundary/index.vue +380 -0
- package/dist/v3/components/Empty/index.vue +29 -29
- package/dist/v3/components/FilterSelect/index.vue +179 -179
- package/dist/v3/components/JsonPretty/components/Brackets/index.vue +27 -27
- package/dist/v3/components/JsonPretty/components/Carets/index.vue +59 -59
- package/dist/v3/components/JsonPretty/components/CheckController/index.vue +136 -136
- package/dist/v3/components/JsonPretty/components/TreeNode/index.vue +387 -387
- package/dist/v3/components/JsonPretty/hooks/useClipboard.ts +21 -21
- package/dist/v3/components/JsonPretty/hooks/useError.ts +21 -21
- package/dist/v3/components/JsonPretty/type.ts +127 -127
- package/dist/v3/components/JsonPretty/utils/index.ts +169 -169
- package/dist/v3/components/MovableContainer/index.vue +8 -4
- package/dist/v3/components/Pick/index.vue +322 -322
- package/dist/v3/components/Tag/index.vue +113 -113
- package/dist/v3/components/VirtualList/AutoSize.vue +40 -40
- package/dist/v3/components/VirtualList/index.vue +416 -416
- package/dist/v3/hooks/useBluetooth/index.ts +561 -561
- package/dist/v3/hooks/useContainerStyle.ts +153 -153
- package/dist/v3/hooks/useNFC/index.ts +107 -107
- package/dist/v3/hooks/useNFC/typing.d.ts +396 -396
- package/dist/v3/hooks/useNFC/useNFCAndroid.ts +966 -966
- package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +812 -812
- package/dist/v3/hooks/useNFC/utils.ts +754 -754
- package/dist/v3/hooks/useRequest/index.ts +586 -586
- package/dist/v3/hooks/useRequest/utils.ts +267 -267
- package/dist/v3/hooks/useScanCode/index.ts +206 -206
- package/dist/v3/hooks/useWebsocket/index.ts +253 -253
- package/dist/v3/styles/theme.ts +12 -12
- package/package.json +9 -1
|
@@ -1,454 +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
|
-
{{ 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>
|
|
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>
|