General clean up, updates, and prep for new version of launcher using Svelte.

This commit is contained in:
Scott Idem
2022-03-01 17:59:48 -05:00
parent 382e98baf1
commit cbb0dc6a82
47 changed files with 7269 additions and 8732 deletions

194
index.js
View File

@@ -16,54 +16,56 @@ console.log(process.getSystemVersion());
if (os.type == 'Darwin') {
if (systemPreferences.getMediaAccessStatus('microphone') != 'granted') {
systemPreferences.askForMediaAccess('microphone');
} else {
console.log(systemPreferences.getMediaAccessStatus('microphone'));
}
if (systemPreferences.getMediaAccessStatus('camera') != 'granted') {
systemPreferences.askForMediaAccess('camera');
} else {
console.log(systemPreferences.getMediaAccessStatus('camera'));
}
if (systemPreferences.getMediaAccessStatus('microphone') != 'granted') {
systemPreferences.askForMediaAccess('microphone');
} else {
console.log(systemPreferences.getMediaAccessStatus('microphone'));
}
if (systemPreferences.getMediaAccessStatus('camera') != 'granted') {
systemPreferences.askForMediaAccess('camera');
} else {
console.log(systemPreferences.getMediaAccessStatus('camera'));
}
}
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 1500, // 1500 1280
height: 1024, // 1024
backgroundColor: '#fff',
icon: './app/img/favicon.ico',
webPreferences: {
nodeIntegration: true
}
})
win.setMinimumSize(1024, 768);
//win.setFullScreenable(false)
win.FullScreenable = false;
// and load the index.html of the app.
win.loadFile('app/index.html');
// Open the DevTools.
win.webContents.openDevTools();
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
})
win.on('minimize', () => {
//win.restore();
})
// Create the browser window.
win = new BrowserWindow({
width: 1500, // 1500 1280
height: 1024, // 1024
backgroundColor: '#fff',
icon: './app/img/favicon.ico',
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true
}
})
win.setMinimumSize(1024, 768);
//win.setFullScreenable(false)
win.FullScreenable = false;
// and load the index.html of the app.
win.loadFile('app/index.html');
// Open the DevTools.
win.webContents.openDevTools();
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
})
win.on('minimize', () => {
//win.restore();
})
}
@@ -75,68 +77,70 @@ app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.location_files
if (win === null) {
createWindow();
}
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.location_files
if (win === null) {
createWindow();
}
})
ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_token, save_path) => {
console.log('ipcMain on download_file: api_base_url='+api_base_url+' | api_temporary_token='+api_temporary_token);
console.log(api_temporary_token);
console.log('ipcMain download and save file: '+api_endpoint+' -> '+save_path);
axios.defaults.baseURL = api_base_url;
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
axios.defaults.headers.common['Authorization'] = `Token ${api_temporary_token}`;
const url = api_endpoint;
axios({
method: 'get',
url: url,
responseType: 'stream' /* responseType must be stream */
}).then(function (response) {
response.data.pipe(fs.createWriteStream(save_path));
});
console.log('ipcMain on download_file: api_base_url='+api_base_url+' | api_temporary_token='+api_temporary_token);
console.log(api_temporary_token);
console.log('ipcMain download and save file: '+api_endpoint+' -> '+save_path);
axios.defaults.baseURL = api_base_url;
axios.defaults.headers.common['Access-Control-Allow-Origin'] = access_control_allow_origin;
axios.defaults.headers.common['content-type'] = 'application/json';
axios.defaults.headers.common['x-aether-api-key'] = api_secret_key;
axios.defaults.headers.common['x-account-id'] = account_id;
const url = api_endpoint;
axios({
method: 'get',
url: url,
responseType: 'stream' /* responseType must be stream */
}).then(function (response) {
response.data.pipe(fs.createWriteStream(save_path));
});
});
ipcMain.on('open_local_file', (event, file_path, filename) => {
console.log('ipcMain open local file: '+file_path+' -> '+filename);
cache_file_path = path.join(process.cwd(), file_path);
console.log(cache_file_path);
open_file_path = path.join(process.cwd(), 'temp/', filename);
console.log(open_file_path);
if (fs.existsSync(open_file_path)) {
//console.log('File link already exists: '+open_file_path);
// NOTE: Should the file be checked to see if it has changed from the hashed cache version???
// NOTE: What if they made changes to the file locally in temp? The changed file would be used since a new copy is not being made.
// NOTE: It might make sense for this to be a configurable option depending on the group. Some do not allow changes. This helps enforce that.
console.log('File copy already exists: '+open_file_path);
} else {
//console.log('Creating file link: '+open_file_path);
//fs.linkSync(cache_file_path, open_file_path);
console.log('Copying file to temp: '+open_file_path);
fs.copyFileSync(cache_file_path, open_file_path);
}
shell.openItem(open_file_path);
//fs.open(open_file_path);
console.log('ipcMain open local file: '+file_path+' -> '+filename);
cache_file_path = path.join(process.cwd(), file_path);
console.log(cache_file_path);
open_file_path = path.join(process.cwd(), 'temp/', filename);
console.log(open_file_path);
if (fs.existsSync(open_file_path)) {
//console.log('File link already exists: '+open_file_path);
// NOTE: Should the file be checked to see if it has changed from the hashed cache version???
// NOTE: What if they made changes to the file locally in temp? The changed file would be used since a new copy is not being made.
// NOTE: It might make sense for this to be a configurable option depending on the group. Some do not allow changes. This helps enforce that.
console.log('File copy already exists: '+open_file_path);
} else {
//console.log('Creating file link: '+open_file_path);
//fs.linkSync(cache_file_path, open_file_path);
console.log('Copying file to temp: '+open_file_path);
fs.copyFileSync(cache_file_path, open_file_path);
}
shell.openItem(open_file_path);
//fs.open(open_file_path);
});