disable the beep by default
This commit is contained in:
+6
-6
@@ -35,11 +35,11 @@ async function needToBook(contact, mongoManager) {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
async function startBook(contactPojo, device, selectedStore, audioAnalyse) {
|
||||
async function startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep) {
|
||||
console.log(`型号: ${device.model()}`);
|
||||
console.log(`序列号: ${device.serial()}`);
|
||||
if (await needToBook(contactPojo, mongoManager)) {
|
||||
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse);
|
||||
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse, alertBeep);
|
||||
//read contacts form excel
|
||||
return await commandor.loadPage();
|
||||
} else {
|
||||
@@ -47,18 +47,18 @@ async function startBook(contactPojo, device, selectedStore, audioAnalyse) {
|
||||
}
|
||||
}
|
||||
|
||||
async function startWithList(contacts, device, selectedStore, audioAnalyse) {
|
||||
async function startWithList(contacts, device, selectedStore, audioAnalyse, alertBeep) {
|
||||
await contacts.reduce(async (promise, contactPojo) => {
|
||||
// This line will wait for the last async function to finish.
|
||||
// The first iteration uses an already resolved Promise
|
||||
// so, it will immediately continue.
|
||||
await promise;
|
||||
const contents = await startBook(contactPojo, device, selectedStore, audioAnalyse);
|
||||
const contents = await startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep);
|
||||
console.log(contents);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false) {
|
||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) {
|
||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||
let contactList;
|
||||
if (endNumber <= allContactList.length) {
|
||||
@@ -80,7 +80,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
}
|
||||
let segmentNumber = listToBook.length / devices.length;
|
||||
for (let i = 0; i < devices.length; i++) {
|
||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse);
|
||||
startWithList(listToBook.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -57,7 +57,7 @@ function log(message) {
|
||||
}
|
||||
|
||||
class CommandorPage {
|
||||
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false) {
|
||||
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false) {
|
||||
this.contact = contact;
|
||||
this.device = device;
|
||||
this.mongoManager = mongoManager;
|
||||
@@ -66,6 +66,7 @@ class CommandorPage {
|
||||
this.isFillingFields = false;
|
||||
this.isTerminated = false;
|
||||
this.audioAnalyse = audioAnalyse;
|
||||
this.alertBeep = alertBeep;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,9 +299,11 @@ class CommandorPage {
|
||||
if (this.audioAnalyse) {
|
||||
await this.checkAudioBtn();
|
||||
}
|
||||
for (let i = 0; i < 15; i++) {
|
||||
await delay(1000)
|
||||
shell.beep()
|
||||
if (this.alertBeep) {
|
||||
for (let i = 0; i < 15; i++) {
|
||||
await delay(1000)
|
||||
shell.beep()
|
||||
}
|
||||
}
|
||||
log("发现datadome");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user