-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
91 changed files
with
34,984 additions
and
43,326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/prettierrc", | ||
"semi": false, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
// @see - https://www.electron.build/configuration/configuration | ||
{ | ||
$schema: 'https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json', | ||
appId: 'com.hotsea.coss', | ||
asar: true, | ||
productName: 'coss', | ||
directories: { | ||
output: 'release/${version}' | ||
}, | ||
files: ['dist', 'dist-electron'], | ||
mac: { | ||
target: ['dmg'], | ||
artifactName: '${productName}-Mac-${version}-Installer.${ext}' | ||
}, | ||
win: { | ||
requestedExecutionLevel: 'highestAvailable', | ||
target: [ | ||
{ | ||
target: 'nsis', | ||
arch: ['x64', 'ia32'] | ||
} | ||
], | ||
artifactName: '${productName}-Windows-${version}-Setup.${ext}' | ||
}, | ||
nsis: { | ||
oneClick: false, | ||
perMachine: false, | ||
allowToChangeInstallationDirectory: true, | ||
deleteAppDataOnUninstall: false | ||
}, | ||
linux: { | ||
target: ['AppImage'], | ||
artifactName: '${productName}-Linux-${version}.${ext}' | ||
} | ||
$schema: 'https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json', | ||
appId: 'YourAppID', | ||
asar: true, | ||
productName: 'COSS', | ||
directories: { | ||
output: 'release/${version}' | ||
}, | ||
files: ['dist', 'dist-electron'], | ||
mac: { | ||
target: ['dmg'], | ||
artifactName: '${productName}-Mac-${version}-Installer.${ext}' | ||
}, | ||
win: { | ||
target: [ | ||
{ | ||
target: 'nsis', | ||
arch: ['x64'] | ||
} | ||
], | ||
artifactName: '${productName}-Windows-${version}-Setup.${ext}' | ||
}, | ||
nsis: { | ||
oneClick: false, | ||
perMachine: false, | ||
allowToChangeInstallationDirectory: true, | ||
deleteAppDataOnUninstall: false | ||
}, | ||
linux: { | ||
target: ['AppImage'], | ||
artifactName: '${productName}-Linux-${version}.${ext}' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,65 +15,68 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) | |
// │ │ ├── main.js | ||
// │ │ └── preload.mjs | ||
// │ | ||
process.env.APP_ROOT = path.join(__dirname, '../..') | ||
process.env.APP_ROOT = path.join(__dirname, '..') | ||
|
||
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin - [email protected] | ||
export const VITE_DEV_SERVER_URL = process.env['VITE_DEV_SERVER_URL'] | ||
export const MAIN_DIST = path.join(process.env.APP_ROOT, 'dist-electron') | ||
export const RENDERER_DIST = path.join(process.env.APP_ROOT, 'dist') | ||
|
||
process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL ? path.join(process.env.APP_ROOT, 'public') : RENDERER_DIST | ||
process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL | ||
? path.join(process.env.APP_ROOT, 'public') | ||
: RENDERER_DIST | ||
|
||
let win: BrowserWindow | null | ||
|
||
function createWindow() { | ||
win = new BrowserWindow({ | ||
icon: path.join(process.env.VITE_PUBLIC, 'electron-vite.svg'), | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.mjs') | ||
// webSecurity: false | ||
// nodeIntegration: true, | ||
// contextIsolation: false | ||
}, | ||
width: 1000, | ||
height: 600 | ||
// titleBarStyle: 'hidden', | ||
// titleBarOverlay: true, | ||
// show: false | ||
}) | ||
win = new BrowserWindow({ | ||
icon: path.join(process.env.VITE_PUBLIC, 'electron-vite.svg'), | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.mjs') | ||
// webSecurity: false | ||
// nodeIntegration: true, | ||
// contextIsolation: false | ||
}, | ||
width: 1000, | ||
height: 600 | ||
// titleBarStyle: 'hidden', | ||
// titleBarOverlay: true, | ||
// show: false | ||
}) | ||
|
||
// Test active push message to Renderer-process. | ||
win.webContents.on('did-finish-load', () => { | ||
win?.webContents.send('main-process-message', new Date().toLocaleString()) | ||
}) | ||
// Test active push message to Renderer-process. | ||
win.webContents.on('did-finish-load', () => { | ||
win?.webContents.send('main-process-message', new Date().toLocaleString()) | ||
}) | ||
|
||
if (VITE_DEV_SERVER_URL) { | ||
// 开发环境下打开控制台 | ||
win.webContents.openDevTools() | ||
win.loadURL(VITE_DEV_SERVER_URL) | ||
// win.loadURL('http://localhost:8081') | ||
} else { | ||
// win.loadFile('dist/index.html') | ||
win.loadFile(path.join(RENDERER_DIST, 'index.html')) | ||
} | ||
if (VITE_DEV_SERVER_URL) { | ||
// 开发环境下打开控制台 | ||
win.loadURL(VITE_DEV_SERVER_URL) | ||
// win.loadURL('http://localhost:8081') | ||
} else { | ||
// win.loadFile('dist/index.html') | ||
win.loadFile(path.join(RENDERER_DIST, 'index.html')) | ||
} | ||
|
||
win.webContents.openDevTools() | ||
} | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
win = null | ||
} | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
win = null | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
// 在 OS X 上,当出现以下情况时,通常会在应用程序中重新创建一个窗口: | ||
// 单击停靠图标,并且没有打开其他窗口。 | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow() | ||
} | ||
// 在 OS X 上,当出现以下情况时,通常会在应用程序中重新创建一个窗口: | ||
// 单击停靠图标,并且没有打开其他窗口。 | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
app.whenReady().then(createWindow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
// import initSqlJs from 'sql.js' | ||
// const SQL = await initSqlJs({ locateFile: (file: any) => `/assets/${file}` }) | ||
// const db = new SQL.Database() | ||
// 创建表 | ||
// const createTable = () => { | ||
// const createTableSQL = ` | ||
// CREATE TABLE IF NOT EXISTS items ( | ||
// id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
// name TEXT, | ||
// quantity INTEGER | ||
// ); | ||
// ` | ||
// db.run(createTableSQL) | ||
// } | ||
// const insertItem = (name, quantity) => { | ||
// const insertSQL = `INSERT INTO items (name, quantity) VALUES (?, ?)` | ||
// const statement = db.prepare(insertSQL) | ||
// statement.run([name, quantity]) | ||
// statement.free() | ||
// } | ||
// const getItems = () => { | ||
// const selectSQL = `SELECT * FROM items` | ||
// const results = db.exec(selectSQL) | ||
// return results.length ? results[0].values : [] | ||
// } | ||
// // createTable() | ||
// export const sqlTest = () => { | ||
// console.log('SQL', SQL) | ||
// // insertItem('apple', 10) | ||
// // insertItem('banana', 5) | ||
// console.log(getItems()) | ||
// } |
Oops, something went wrong.