mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
feat: 设置默认设备
This commit is contained in:
parent
8425503797
commit
c6a41ab210
5 changed files with 76 additions and 7 deletions
53
apps/manage/device.js
Normal file
53
apps/manage/device.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import settings from '../../lib/settings.js';
|
||||
|
||||
export async function setDefaultDevice() {
|
||||
this.setContext('toSetDefaultDevice');
|
||||
await this.reply(
|
||||
`请发送默认设备信息,或者发送“取消”取消设置默认设备信息`,
|
||||
false,
|
||||
{ at: true, recallMsg: 100 }
|
||||
);
|
||||
}
|
||||
export async function toSetDefaultDevice() {
|
||||
const msg = this.e.msg.trim();
|
||||
if (!msg) {
|
||||
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
}
|
||||
if (msg.includes('取消')) {
|
||||
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||
this.finish('toSetDefaultDevice');
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const info = JSON.parse(msg);
|
||||
if (!info) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!info?.deviceName ||
|
||||
!info?.deviceBoard ||
|
||||
!info?.deviceModel ||
|
||||
!info?.oaid ||
|
||||
!info?.deviceFingerprint ||
|
||||
!info?.deviceProduct
|
||||
) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
}
|
||||
settings.setConfig('device', {
|
||||
productName: info.deviceProduct,
|
||||
productType: info.deviceName,
|
||||
modelName: info.deviceModel,
|
||||
oaid: info.oaid,
|
||||
deviceInfo: info.deviceFingerprint,
|
||||
board: info.deviceBoard,
|
||||
});
|
||||
this.reply('默认设备信息设置成功', false, { at: true, recallMsg: 100 });
|
||||
} catch (error) {
|
||||
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
|
||||
} finally {
|
||||
this.finish('toSetDefaultDevice');
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ import * as panel from './panel.js';
|
|||
|
||||
import * as version from './version.js';
|
||||
|
||||
import * as device from './device.js';
|
||||
|
||||
export default {
|
||||
assets,
|
||||
guides,
|
||||
|
|
@ -17,4 +19,5 @@ export default {
|
|||
alias,
|
||||
panel,
|
||||
version,
|
||||
device,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue