ed-safari/src/renderer.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-05-08 12:25:13 -07:00
/**
* This file will automatically be loaded by vite and run in the "renderer" context.
* To learn more about the differences between the "main" and the "renderer" context in
* Electron, visit:
*
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
*
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
* in a renderer process, please be aware of potential security implications. You can read
* more about security risks here:
*
* https://electronjs.org/docs/tutorial/security
*
* To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`
* flag:
*
* ```
* // Create the browser window.
* mainWindow = new BrowserWindow({
* width: 800,
* height: 600,
* webPreferences: {
* nodeIntegration: true
* }
* });
* ```
*/
import './index.css'
2023-05-08 17:42:09 -07:00
import './icons/flaticon.css'
2023-05-08 12:25:13 -07:00
2023-05-08 17:42:09 -07:00
const { app } = require('electron')
2023-05-08 12:25:13 -07:00
import { createApp, ref } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
import { JournalInterface } from './interfaces/JournalInterface'
2023-05-08 17:42:09 -07:00
// Grab app.isPackaged from main process
let isPackaged = false
window.process.argv.forEach((item) => {
if (item.includes('EDS-ENV')) {
isPackaged = (item.split('=').pop() === 'true')
}
})
2023-05-08 12:25:13 -07:00
createApp({
setup() {
2023-05-08 17:42:09 -07:00
const journal = new JournalInterface(isPackaged)
2023-05-08 12:25:13 -07:00
2023-05-08 13:10:38 -07:00
// TODO: show warning to user
if (journal.journalDir === null) {
return
}
2023-05-08 12:25:13 -07:00
journal.watchDirectory()
2023-05-08 13:10:38 -07:00
journal.watchJournal()
2023-05-08 12:25:13 -07:00
const currentLocation = ref('Unknown')
2023-05-08 19:13:30 -07:00
const currentLocationBodies = ref([])
2023-05-08 12:25:13 -07:00
journal.on('FSDJump', () => currentLocation.value = journal.currentLocation)
2023-05-08 19:13:30 -07:00
journal.on('SCANNED_BODIES_FOUND', () => currentLocationBodies.value = journal.currentLocation.bodies)
2023-05-08 17:42:09 -07:00
2023-05-08 12:25:13 -07:00
return {
2023-05-08 13:10:38 -07:00
currentLocation,
2023-05-08 19:13:30 -07:00
currentLocationBodies,
2023-05-08 12:25:13 -07:00
}
}
}).mount('#app')