// | ------------------------------------------------------------ // | @版本: version 0.1 // | @创建人: 【Nie-nie】 // | @E-mail: x71291@outlook.com // | @所在项目: js-ii-pad-linux // | @文件描述: systemConfig.js - // | @创建时间: 2024-11-11 17:29 // | @更新时间: 2024-11-11 17:29 // | @修改记录: // | -*-*-*- (时间--修改人--修改说明) -*-*-*- // | = // | ------------------------------------------------------------ export async function setServerHost(msg) { // 查找是否存在ServerHost const SQL = `SELECT * FROM SystemConfigs WHERE key = ?` const data = await global.DB.prepare(SQL).get('ServerHost') if (data === undefined) { const createSQL = `INSERT INTO SystemConfigs (key, value) VALUES (?,?)` await global.DB.prepare(createSQL).run('ServerHost', msg.data.host) } else { const updateSQL = `UPDATE SystemConfigs SET value = ? WHERE key = ?` await global.DB.prepare(updateSQL).run('ServerHost', msg.data.host) } } export async function setDeviceBinding(data) { // 查找是否存在ServerHost console.log('DD', data) const SQL = `SELECT * FROM SystemConfigs WHERE key = ?;` const result = await global.DB.prepare(SQL).get('DeviceBinding') console.log(result) if (result === undefined) { const createSQL = `INSERT INTO SystemConfigs (key, value) VALUES (?,?)` await global.DB.prepare(createSQL).run('DeviceBinding', JSON.stringify(data)) } else { const updateSQL = `UPDATE SystemConfigs SET value = ? WHERE key = ?` await global.DB.prepare(updateSQL).run('DeviceBinding', JSON.stringify(data)) } }