sequel-ice/src/main.js

73 lines
1.7 KiB
JavaScript

/**
* 主入口
* @author yutent<yutent.io@gmail.com>
* @date 2020/11/18 09:27:09
*/
const { app, session, protocol, globalShortcut, ipcMain } = require('electron')
const path = require('path')
const fs = require('iofs')
require('./tools/init.js')
const { createMainWindow } = require('./tools/windows.js')
const MIME_TYPES = {
'.js': 'text/javascript',
'.html': 'text/html',
'.htm': 'text/plain',
'.css': 'text/css',
'.jpg': 'image/jpg',
'.png': 'image/png',
'.gif': 'image/gif',
'.svg': 'image/svg+xml',
'.ico': 'image/ico',
'.mp3': 'audio/mpeg',
'.m4a': 'audio/m4a',
'.aac': 'audio/x-aac',
'.ogg': 'audio/ogg',
'.wav': 'audio/x-wav',
'.flac': 'audio/flac',
all: 'audio/*'
}
/* ----------------------------------------------------- */
app.commandLine.appendSwitch('--lang', 'zh-CN')
app.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required')
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
])
/* ----------------------------------------------------- */
// 初始化应用
app.once('ready', () => {
// 注册协议
protocol.registerStreamProtocol('app', function (req, cb) {
let file = decodeURIComponent(req.url.replace(/^app:\/\/local\//, ''))
let ext = path.extname(req.url)
file = path.resolve(__dirname, 'dist/', file)
cb({
data: fs.origin.createReadStream(file),
mimeType: MIME_TYPES[ext],
headers: {
'Cache-Control': 'max-age=144000000'
}
})
})
let win = createMainWindow(path.resolve(__dirname, './images/app.png'))
ipcMain.on('app', (ev, conn) => {
switch (conn.type) {
case '':
break
default:
break
}
})
})
MySQL/MariaDB database management for Linux
JavaScript 64.4%
Vue 28.5%
HTML 7.1%