Merge branch 'master' of bitbucket.org:panleicim/appointment_tool_js
This commit is contained in:
@@ -36,6 +36,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<input name="audio_analyse" id="audio_analyse" type="checkbox" checked>自动语音分析</input>
|
<input name="audio_analyse" id="audio_analyse" type="checkbox" checked>自动语音分析</input>
|
||||||
<br/>
|
<br/>
|
||||||
|
<input name="alert_beep" id="alert_beep" type="checkbox">警报声音</input>
|
||||||
|
<br/>
|
||||||
<button id="clear_all_browsers" type="button" class="btn btn-primary">重置浏览器
|
<button id="clear_all_browsers" type="button" class="btn btn-primary">重置浏览器
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ const createWindow = () => {
|
|||||||
win.loadFile('index.html').then((r) => {
|
win.loadFile('index.html').then((r) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore, audioAnalyse) => {
|
ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => {
|
||||||
startBook(startNumber, endNumber, selectedStore, audioAnalyse)
|
startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep)
|
||||||
})
|
})
|
||||||
ipcMain.on('clearAllBrowsers', (event) => {
|
ipcMain.on('clearAllBrowsers', (event) => {
|
||||||
clearAllBrowsers()
|
clearAllBrowsers()
|
||||||
@@ -69,7 +69,7 @@ function clearAllBrowsers() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startBook(startNumber, endNumber, selectedStore, audioAnalyse) {
|
function startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) {
|
||||||
console.log("startNumber: " + startNumber);
|
console.log("startNumber: " + startNumber);
|
||||||
console.log("endNumber: " + endNumber);
|
console.log("endNumber: " + endNumber);
|
||||||
console.log("selectedStore: " + selectedStore);
|
console.log("selectedStore: " + selectedStore);
|
||||||
@@ -78,7 +78,7 @@ function startBook(startNumber, endNumber, selectedStore, audioAnalyse) {
|
|||||||
let config = loadIniFile.sync(configFilePath);
|
let config = loadIniFile.sync(configFilePath);
|
||||||
console.log(config);
|
console.log(config);
|
||||||
let contactExcelFilePath = config.DEFAULT.contact_list_file;
|
let contactExcelFilePath = config.DEFAULT.contact_list_file;
|
||||||
startBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath, audioAnalyse).then(() => {
|
startBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath, audioAnalyse, alertBeep).then(() => {
|
||||||
console.log("stop")
|
console.log("stop")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
const {contextBridge, ipcRenderer} = require('electron')
|
const {contextBridge, ipcRenderer} = require('electron')
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('appointment', {
|
contextBridge.exposeInMainWorld('appointment', {
|
||||||
startBook: (startNumber, endNumber, selectedStore, audioAnalyse) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore, audioAnalyse),
|
startBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep),
|
||||||
clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'),
|
clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'),
|
||||||
scanDevices: () => ipcRenderer.invoke('scan-devices')
|
scanDevices: () => ipcRenderer.invoke('scan-devices')
|
||||||
})
|
})
|
||||||
+3
-1
@@ -17,7 +17,9 @@ window.addEventListener('load', () => {
|
|||||||
})
|
})
|
||||||
document.getElementById("start_book_btn").addEventListener('click', () => {
|
document.getElementById("start_book_btn").addEventListener('click', () => {
|
||||||
let audioAnalyse = document.getElementById("audio_analyse").checked;
|
let audioAnalyse = document.getElementById("audio_analyse").checked;
|
||||||
window.appointment.startBook(startNumber, endNumber, selectedStore, audioAnalyse);
|
let alertBeep = document.getElementById("alert_beep").checked;
|
||||||
|
alert("alertBeep is "+alertBeep)
|
||||||
|
window.appointment.startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep);
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById("clear_all_browsers").addEventListener('click', () => {
|
document.getElementById("clear_all_browsers").addEventListener('click', () => {
|
||||||
|
|||||||
+6
-6
@@ -35,11 +35,11 @@ async function needToBook(contact, mongoManager) {
|
|||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, selectedStore, audioAnalyse) {
|
async function startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep) {
|
||||||
console.log(`型号: ${device.model()}`);
|
console.log(`型号: ${device.model()}`);
|
||||||
console.log(`序列号: ${device.serial()}`);
|
console.log(`序列号: ${device.serial()}`);
|
||||||
if (await needToBook(contactPojo, mongoManager)) {
|
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
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} 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) => {
|
await contacts.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
// so, it will immediately continue.
|
// so, it will immediately continue.
|
||||||
await promise;
|
await promise;
|
||||||
const contents = await startBook(contactPojo, device, selectedStore, audioAnalyse);
|
const contents = await startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, 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 allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||||
let contactList;
|
let contactList;
|
||||||
if (endNumber <= allContactList.length) {
|
if (endNumber <= allContactList.length) {
|
||||||
@@ -80,7 +80,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
}
|
}
|
||||||
let segmentNumber = listToBook.length / devices.length;
|
let segmentNumber = listToBook.length / devices.length;
|
||||||
for (let i = 0; i < devices.length; i++) {
|
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 {
|
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.contact = contact;
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.mongoManager = mongoManager;
|
this.mongoManager = mongoManager;
|
||||||
@@ -66,6 +66,7 @@ class CommandorPage {
|
|||||||
this.isFillingFields = false;
|
this.isFillingFields = false;
|
||||||
this.isTerminated = false;
|
this.isTerminated = false;
|
||||||
this.audioAnalyse = audioAnalyse;
|
this.audioAnalyse = audioAnalyse;
|
||||||
|
this.alertBeep = alertBeep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -298,9 +299,11 @@ class CommandorPage {
|
|||||||
if (this.audioAnalyse) {
|
if (this.audioAnalyse) {
|
||||||
await this.checkAudioBtn();
|
await this.checkAudioBtn();
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 15; i++) {
|
if (this.alertBeep) {
|
||||||
await delay(1000)
|
for (let i = 0; i < 15; i++) {
|
||||||
shell.beep()
|
await delay(1000)
|
||||||
|
shell.beep()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log("发现datadome");
|
log("发现datadome");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user