-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
Signed-off-by: Kevin Cui <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,ts,.mjs}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{json,yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# See: https://github.com/electron-userland/electron-builder/issues/6289#issuecomment-1042620422 | ||
shamefully-hoist = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,50 @@ | ||
{ | ||
"cSpell.words": [ | ||
"antd", | ||
"iife", | ||
"refreshable", | ||
"tsup", | ||
"Vals", | ||
"wavesurfer" | ||
], | ||
"editor.tabSize": 2 | ||
} | ||
// Disable the default formatter, use eslint instead | ||
"prettier.enable": false, | ||
"editor.formatOnSave": false, | ||
|
||
// Auto fix | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
|
||
// Silent the stylistic rules in you IDE, but still auto fix them | ||
"eslint.rules.customizations": [ | ||
{ "rule": "style/*", "severity": "off", "fixable": true }, | ||
{ "rule": "format/*", "severity": "off", "fixable": true }, | ||
{ "rule": "*-indent", "severity": "off", "fixable": true }, | ||
{ "rule": "*-spacing", "severity": "off", "fixable": true }, | ||
{ "rule": "*-spaces", "severity": "off", "fixable": true }, | ||
{ "rule": "*-order", "severity": "off", "fixable": true }, | ||
{ "rule": "*-dangle", "severity": "off", "fixable": true }, | ||
{ "rule": "*-newline", "severity": "off", "fixable": true }, | ||
{ "rule": "*quotes", "severity": "off", "fixable": true }, | ||
{ "rule": "*semi", "severity": "off", "fixable": true } | ||
], | ||
|
||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml", | ||
"toml", | ||
"xml", | ||
"gql", | ||
"graphql", | ||
"astro", | ||
"svelte", | ||
"css", | ||
"less", | ||
"scss", | ||
"pcss", | ||
"postcss" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
words: | ||
- antd | ||
- iife | ||
- refreshable | ||
- tsup | ||
- Vals | ||
- wavesurfer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist | ||
dist-dev | ||
node_modules | ||
index.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "subtitle-editor", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./dist/index.mjs", | ||
"scripts": { | ||
"build": "vite build", | ||
"start": "vite dev", | ||
"ts-check": "tsc --noEmit" | ||
}, | ||
"license": "MIT", | ||
"type": "module", | ||
"devDependencies": { | ||
"@antfu/eslint-config": "overridden", | ||
"electron": "^32.0.1", | ||
"eslint": "overridden", | ||
"vite": "^5.4.2", | ||
"vite-plugin-electron": "^0.28.8" | ||
}, | ||
"dependencies": { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import path, { join } from "node:path"; | ||
import { app, BrowserWindow } from "electron"; | ||
import { registerIpcHandlers } from "./ipc"; | ||
|
||
const __filename = new URL(import.meta.url).pathname; | ||
const __dirname = path.dirname(__filename); | ||
|
||
async function createWindow() { | ||
const mainWindow = new BrowserWindow({ | ||
width: 1600, | ||
height: 1500, | ||
show: false, | ||
webPreferences: { | ||
preload: path.join(__dirname, "preload.mjs"), | ||
nodeIntegration: false, | ||
}, | ||
}); | ||
|
||
mainWindow.once("ready-to-show", () => { | ||
mainWindow.show(); | ||
}); | ||
|
||
if (__DEV__) { | ||
await mainWindow.loadURL(RENDERER_URL); | ||
mainWindow.webContents.openDevTools(); | ||
} | ||
else { | ||
await mainWindow.loadFile(join(__dirname, "..", "renderer", "index.html")); | ||
} | ||
} | ||
|
||
app.whenReady().then(async () => { | ||
registerIpcHandlers(); | ||
await createWindow(); | ||
}); | ||
|
||
app.on("window-all-closed", () => { | ||
app.quit(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { IpcMainInvokeEvent } from "electron"; | ||
import { readFile, writeFile } from "node:fs/promises"; | ||
import { ipcMain } from "electron"; | ||
|
||
type ElectronAPI = Omit<typeof electronAPI, "getPathOfFile">; | ||
type HandleAPI = { | ||
[k in keyof ElectronAPI]: (event: IpcMainInvokeEvent, ...args: Parameters<ElectronAPI[k]>) => ReturnType<ElectronAPI[k]> | ||
}; | ||
|
||
const handle: HandleAPI = { | ||
async getContentOfFile(_: IpcMainInvokeEvent, filePath: string): Promise<string> { | ||
return await readFile(filePath, "utf-8"); | ||
}, | ||
async setFileContent(_: IpcMainInvokeEvent, filePath: string, fileContent: string): Promise<void> { | ||
return await writeFile(filePath, fileContent, "utf-8"); | ||
}, | ||
}; | ||
|
||
export const registerIpcHandlers = () => { | ||
Object.keys(handle).forEach((key) => { | ||
ipcMain.handle(key, handle[key as keyof ElectronAPI]); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { contextBridge, ipcRenderer, webUtils } from "electron"; | ||
|
||
const prefix = __DEV__ ? "/@fs" : ""; | ||
|
||
contextBridge.exposeInMainWorld("electronAPI", { | ||
async getContentOfFile(filePath: string) { | ||
return await ipcRenderer.invoke("getContentOfFile", filePath.slice(prefix.length)); | ||
}, | ||
async setFileContent(filePath: string, fileContent: string) { | ||
return await ipcRenderer.invoke("setFileContent", filePath.slice(prefix.length), fileContent); | ||
}, | ||
getPathOfFile(file: File) { | ||
return `${prefix}${webUtils.getPathForFile(file)}`; | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"include": [ | ||
"src/**/*", | ||
"typings/**/*", | ||
"../editor/typings/**/*", | ||
"../typings/**/*.d.ts", | ||
], | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const __DEV__: boolean; | ||
declare const RENDERER_URL: string; |