-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(desktop): initial desktop electron
- Loading branch information
Showing
13 changed files
with
1,394 additions
and
50 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,5 +1,6 @@ | ||
node_modules | ||
.DS_Store | ||
build | ||
dist | ||
dist-ssr | ||
*.local | ||
|
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,72 @@ | ||
const { app, BrowserWindow, protocol, globalShortcut } = require('electron') | ||
const { join } = require('path') | ||
|
||
const isDev = process.env.NODE_ENV === 'development' | ||
const WinURL = isDev | ||
? `http://localhost:3000` | ||
: 'file://' + join(__dirname, '../render/index.html') | ||
|
||
let mainWindow: any = null | ||
let willQuitApp = false | ||
|
||
protocol.registerSchemesAsPrivileged([ | ||
{ scheme: 'app', privileges: { secure: true, standard: true } } | ||
]) | ||
|
||
function createWindow () { | ||
mainWindow = new BrowserWindow({ | ||
minWidth: 1140, | ||
minHeight: 700, | ||
width: 1240, | ||
height: 700, | ||
center: true, | ||
titleBarStyle: 'hidden', | ||
webPreferences: { | ||
contextIsolation: false, | ||
enableRemoteModule: false, | ||
webSecurity: true, | ||
nodeIntegration: true | ||
}, | ||
}) | ||
|
||
mainWindow.webContents.openDevTools() | ||
// and load the index.html of the app. | ||
mainWindow.loadURL(WinURL) | ||
mainWindow.on('close', function (event: any) { | ||
if (!willQuitApp) { | ||
event.preventDefault() | ||
// mainWindow?.hide() | ||
} | ||
}) | ||
// Emitted when the window is closed. | ||
mainWindow.on('closed', function () { | ||
mainWindow = null | ||
}) | ||
mainWindow.once('ready-to-show', () => { | ||
mainWindow?.show() | ||
}) | ||
} | ||
|
||
|
||
app.on('ready', createWindow) | ||
|
||
app.on("ready", () => { | ||
globalShortcut.register("CmdOrCtrl+D", () => { | ||
mainWindow.webContents.openDevTools(); | ||
}); | ||
}); | ||
|
||
app.on('window-all-closed', function () { | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (!mainWindow) { | ||
createWindow() | ||
} else { | ||
mainWindow.show() | ||
} | ||
}) | ||
app.on('before-quit', () => willQuitApp = 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
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,15 +1,25 @@ | ||
import { createRouter, createWebHistory } from 'vue-router' | ||
import { | ||
createRouter, | ||
createWebHashHistory, | ||
createWebHistory, | ||
} from 'vue-router' | ||
import isElectron from 'is-electron' | ||
import Landing from '@/pages/Landing.vue' | ||
import Editor from '@/pages/Editor.vue' | ||
import ErrorPage from '@/pages/404.vue' | ||
|
||
const routes = [ | ||
const electronRoutes = [ | ||
{ path: '/', component: Editor }, | ||
{ path: '/:pathMatch(.*)*', redirect: '/' }, | ||
] | ||
|
||
const webRoutes = [ | ||
{ path: '/', component: Editor }, | ||
{ path: '/landing', component: Landing }, | ||
{ path: '/:pathMatch(.*)*', component: ErrorPage }, | ||
] | ||
|
||
export default createRouter({ | ||
history: createWebHistory(), | ||
routes, | ||
history: isElectron() ? createWebHashHistory() : createWebHistory(), | ||
routes: isElectron() ? electronRoutes : webRoutes, | ||
}) |
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
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
Oops, something went wrong.
cde7d76
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: