断线重连
This commit is contained in:
parent
bc6936def1
commit
f10fe2843e
47
index.ts
47
index.ts
@ -138,28 +138,37 @@ async function connectAPI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getDHCPList(addr: string | null) {
|
async function getDHCPList(addr: string | null) {
|
||||||
const result = await api.write('/ip/dhcp-server/lease/print');
|
|
||||||
list = [];
|
list = [];
|
||||||
for (let eq in result) {
|
try {
|
||||||
let format = {
|
const result = await api.write('/ip/dhcp-server/lease/print');
|
||||||
id: result[eq]['.id'],
|
for (let eq in result) {
|
||||||
address: result[eq]['address'],
|
let format = {
|
||||||
mac: result[eq]['mac-address'],
|
id: result[eq]['.id'],
|
||||||
status: result[eq]['status'],
|
address: result[eq]['address'],
|
||||||
host: result[eq]['host-name'],
|
mac: result[eq]['mac-address'],
|
||||||
comment: result[eq]['comment'],
|
status: result[eq]['status'],
|
||||||
device: false,
|
host: result[eq]['host-name'],
|
||||||
};
|
comment: result[eq]['comment'],
|
||||||
if (addr !== null || addr !== undefined || addr !== '') {
|
device: false,
|
||||||
if (addr === format.address) {
|
};
|
||||||
format.device = true;
|
if (addr !== null || addr !== undefined || addr !== '') {
|
||||||
list.unshift(format);
|
if (addr === format.address) {
|
||||||
} else {
|
format.device = true;
|
||||||
list.push(format);
|
list.unshift(format);
|
||||||
|
} else {
|
||||||
|
list.push(format);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
list.push(format);
|
||||||
}
|
}
|
||||||
list.push(format);
|
} catch (e) {
|
||||||
|
api = new RouterOSAPI({
|
||||||
|
host: cfg.host,
|
||||||
|
user: cfg.user,
|
||||||
|
password: cfg.password,
|
||||||
|
});
|
||||||
|
api.connect();
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user