-
Notifications
You must be signed in to change notification settings - Fork 1
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
23 changed files
with
2,089 additions
and
750 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 |
---|---|---|
@@ -1 +1 @@ | ||
VITE_APP_PREFIX_URL=/api | ||
RENDERER_VITE_APP_PREFIX_URL=/api |
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 +1 @@ | ||
VITE_APP_PREFIX_URL=/api | ||
RENDERER_VITE_APP_PREFIX_URL=/api |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.cs.allow-jit</key> | ||
<true/> | ||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key> | ||
<true/> | ||
<key>com.apple.security.cs.allow-dyld-environment-variables</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,40 @@ | ||
/** @format */ | ||
|
||
const { notarize } = require('@electron/notarize'); | ||
|
||
module.exports = async (context) => { | ||
if (process.platform !== 'darwin') return; | ||
|
||
console.log('aftersign hook triggered, start to notarize app.'); | ||
|
||
if (!process.env.CI) { | ||
console.log(`skipping notarizing, not in CI.`); | ||
return; | ||
} | ||
|
||
if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) { | ||
console.warn( | ||
'skipping notarizing, APPLE_ID and APPLE_ID_PASS env variables must be set.', | ||
); | ||
return; | ||
} | ||
|
||
const appId = 'com.electron.app'; | ||
|
||
const { appOutDir } = context; | ||
|
||
const appName = context.packager.appInfo.productFilename; | ||
|
||
try { | ||
await notarize({ | ||
appBundleId: appId, | ||
appPath: `${appOutDir}/${appName}.app`, | ||
appleId: process.env.APPLE_ID, | ||
appleIdPassword: process.env.APPLEIDPASS, | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
|
||
console.log(`done notarizing ${appId}.`); | ||
}; |
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,72 @@ | ||
/** @format */ | ||
|
||
import { app, shell, BrowserWindow, screen } from 'electron'; | ||
import { join } from 'path'; | ||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'; | ||
import icon from './public/refrain.png?asset'; | ||
|
||
function createWindow() { | ||
const primaryDisplay = screen.getPrimaryDisplay(); | ||
const { width, height } = primaryDisplay.workAreaSize; | ||
|
||
const mainWindow = new BrowserWindow({ | ||
x: 0, | ||
y: 0, | ||
width, | ||
height, | ||
show: true, | ||
fullscreenable: true, | ||
skipTaskbar: false, | ||
autoHideMenuBar: true, | ||
...(process.platform === 'linux' ? { icon } : { icon }), | ||
webPreferences: { | ||
preload: join(__dirname, '../preload/index.js'), | ||
sandbox: false, | ||
}, | ||
}); | ||
|
||
mainWindow.on('ready-to-show', () => { | ||
mainWindow.show(); | ||
}); | ||
|
||
mainWindow.webContents.setWindowOpenHandler((details) => { | ||
shell.openExternal(details.url); | ||
return { action: 'deny' }; | ||
}); | ||
|
||
// HMR for renderer base on electron-vite cli. | ||
// Load the remote URL for development or the local html file for production. | ||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { | ||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']); | ||
} else { | ||
mainWindow.loadFile(join(__dirname, '../renderer/index.html')); | ||
} | ||
} | ||
|
||
app.whenReady().then(() => { | ||
electronApp.setAppUserModelId('com.electron'); | ||
|
||
// Default open or close DevTools by F12 in development | ||
// and ignore CommandOrControl + R in production. | ||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils | ||
app.on('browser-window-created', (_, window) => { | ||
optimizer.watchWindowShortcuts(window); | ||
}); | ||
|
||
createWindow(); | ||
|
||
app.on('activate', function () { | ||
// 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. | ||
if (BrowserWindow.getAllWindows().length === 0) createWindow(); | ||
}); | ||
}); | ||
|
||
// 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(); | ||
} | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
/** @format */ | ||
|
||
import { ElectronAPI } from '@electron-toolkit/preload'; | ||
|
||
declare global { | ||
interface Window { | ||
electron: ElectronAPI; | ||
api: unknown; | ||
} | ||
} |
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,20 @@ | ||
/** @format */ | ||
|
||
import { contextBridge } from 'electron'; | ||
import { electronAPI } from '@electron-toolkit/preload'; | ||
|
||
const api = {}; | ||
|
||
if (process.contextIsolated) { | ||
try { | ||
contextBridge.exposeInMainWorld('electron', electronAPI); | ||
contextBridge.exposeInMainWorld('api', api); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} else { | ||
// @ts-ignore (define in dts) | ||
window.electron = electronAPI; | ||
// @ts-ignore (define in dts) | ||
window.api = api; | ||
} |
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,48 @@ | ||
# @format | ||
|
||
appId: com.electron.app | ||
productName: refrain-music | ||
directories: | ||
buildResources: build | ||
files: | ||
- '!**/.vscode/*' | ||
- '!src/*' | ||
- '!**/electron.vite.config.{js,ts,mjs,cjs}' | ||
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}' | ||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml,yarn.lock}' | ||
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}' | ||
asarUnpack: | ||
- client/main/public/** | ||
afterSign: build/notarize.js | ||
win: | ||
icon: build/icon.png | ||
executableName: refrain-music | ||
nsis: | ||
artifactName: ${name}-${version}-setup.${ext} | ||
shortcutName: ${productName} | ||
uninstallDisplayName: ${productName} | ||
createDesktopShortcut: always | ||
mac: | ||
icon: build/icon.png | ||
entitlementsInherit: build/entitlements.mac.plist | ||
extendInfo: | ||
- NSCameraUsageDescription: Application requests access to the device's camera. | ||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone. | ||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder. | ||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. | ||
dmg: | ||
artifactName: ${name}-${version}.${ext} | ||
linux: | ||
target: | ||
- AppImage | ||
- snap | ||
- deb | ||
maintainer: electronjs.org | ||
category: Utility | ||
icon: build/icon.png | ||
appImage: | ||
artifactName: ${name}-${version}.${ext} | ||
npmRebuild: false | ||
publish: | ||
provider: generic | ||
url: https://example.com/auto-updates |
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
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,21 +1,11 @@ | ||
/** @format */ | ||
|
||
import proxyConfig from './proxy'; | ||
import path from 'path'; | ||
|
||
const extend = Object.assign; | ||
|
||
const pathResolve = (dir: string) => path.resolve(`${__dirname}`, '../', dir); | ||
|
||
const hostname = '127.0.0.1'; | ||
const hostname = 'localhost'; | ||
const port = 2021; | ||
|
||
const viteConstants: ViteConstant = { | ||
pathResolve, | ||
hostname, | ||
port, | ||
extend, | ||
proxy: proxyConfig, | ||
}; | ||
|
||
export default viteConstants; |
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,36 @@ | ||
/** @format */ | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; | ||
import RenderViteConfig from './vite.config'; | ||
import path from 'path'; | ||
|
||
export default defineConfig({ | ||
main: { | ||
publicDir: path.join(process.cwd(), 'client/main/public'), | ||
build: { | ||
watch: {}, | ||
outDir: 'dist/main', | ||
rollupOptions: { | ||
input: { | ||
index: path.join(process.cwd(), 'client/main/index.ts'), | ||
}, | ||
}, | ||
minify: true, | ||
}, | ||
plugins: [externalizeDepsPlugin()], | ||
}, | ||
preload: { | ||
publicDir: path.join(process.cwd(), 'client/preload/public'), | ||
build: { | ||
outDir: 'dist/preload', | ||
rollupOptions: { | ||
watch: {}, | ||
input: { | ||
index: path.join(process.cwd(), 'client/preload/index.ts'), | ||
}, | ||
}, | ||
minify: true, | ||
}, | ||
plugins: [externalizeDepsPlugin()], | ||
}, | ||
renderer: RenderViteConfig, | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.