-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
1e85459
commit 68ccf27
Showing
27 changed files
with
736 additions
and
0 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
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,4 @@ | ||
node_modules | ||
dist | ||
out | ||
.gitignore |
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,43 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es6: true, | ||
node: true | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true | ||
}, | ||
sourceType: 'module', | ||
ecmaVersion: 2021 | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:prettier/recommended' | ||
], | ||
rules: { | ||
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }], | ||
'@typescript-eslint/explicit-function-return-type': 'error', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }], | ||
'@typescript-eslint/no-explicit-any': 'error', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'@typescript-eslint/no-var-requires': 'off' | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.js'], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'off' | ||
} | ||
} | ||
] | ||
} |
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,2 @@ | ||
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ | ||
shamefully-hoist=true |
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 @@ | ||
out | ||
dist | ||
pnpm-lock.yaml | ||
LICENSE.md | ||
tsconfig.json | ||
tsconfig.*.json |
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,4 @@ | ||
singleQuote: true | ||
semi: false | ||
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 |
---|---|---|
@@ -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> |
Binary file not shown.
Binary file not shown.
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,36 @@ | ||
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,3 @@ | ||
provider: generic | ||
url: https://example.com/auto-updates | ||
updaterCacheDirName: luna-electron-updater |
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,43 @@ | ||
appId: com.electron.app | ||
productName: luna-electron | ||
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}' | ||
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}' | ||
asarUnpack: | ||
- resources/** | ||
afterSign: build/notarize.js | ||
win: | ||
executableName: luna-electron | ||
nsis: | ||
artifactName: ${name}-${version}-setup.${ext} | ||
shortcutName: ${productName} | ||
uninstallDisplayName: ${productName} | ||
createDesktopShortcut: always | ||
mac: | ||
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 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { resolve } from 'path' | ||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' | ||
import react from '@vitejs/plugin-react' | ||
import tailwindcss from 'tailwindcss' | ||
import autoprefixer from 'autoprefixer' | ||
|
||
export default defineConfig({ | ||
main: { | ||
plugins: [externalizeDepsPlugin()] | ||
}, | ||
preload: { | ||
plugins: [externalizeDepsPlugin()] | ||
}, | ||
renderer: { | ||
resolve: { | ||
alias: { | ||
'@renderer': resolve('src/renderer/src') | ||
} | ||
}, | ||
plugins: [react()], | ||
css: { | ||
postcss: { | ||
plugins: [tailwindcss, autoprefixer] | ||
} | ||
} | ||
} | ||
}) |
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,71 @@ | ||
import { app, shell, BrowserWindow } from 'electron' | ||
import { join } from 'path' | ||
import { electronApp, optimizer, is } from '@electron-toolkit/utils' | ||
import icon from '../../resources/icon.png?asset' | ||
|
||
function createWindow(): void { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 900, | ||
height: 670, | ||
show: false, | ||
autoHideMenuBar: true, | ||
...(process.platform === 'linux' ? { 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')) | ||
} | ||
} | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.whenReady().then(() => { | ||
// Set app user model id for windows | ||
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() | ||
} | ||
}) | ||
|
||
// In this file you can include the rest of your app"s specific main process | ||
// code. You can also put them in separate files and require them here. |
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 @@ | ||
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,22 @@ | ||
import { contextBridge } from 'electron' | ||
import { electronAPI } from '@electron-toolkit/preload' | ||
|
||
// Custom APIs for renderer | ||
const api = {} | ||
|
||
// Use `contextBridge` APIs to expose Electron APIs to | ||
// renderer only if context isolation is enabled, otherwise | ||
// just add to the DOM global. | ||
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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Electron</title> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | ||
<meta | ||
http-equiv="Content-Security-Policy" | ||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" | ||
/> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.