Electron support
This commit is contained in:
+2
-2
@@ -4,5 +4,5 @@
|
|||||||
yarn-error.log
|
yarn-error.log
|
||||||
/__sapper__/
|
/__sapper__/
|
||||||
.env
|
.env
|
||||||
# Local Netlify folder
|
package-lock.json
|
||||||
.netlify
|
/dist/
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
// Modules to control application life and create native browser window
|
||||||
|
const { app, BrowserWindow, dialog } = require('electron');
|
||||||
|
const path = require('path');
|
||||||
|
const serve = require('electron-serve');
|
||||||
|
const loadURL = serve({ directory: '__sapper__/export' });
|
||||||
|
|
||||||
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
|
let mainWindow;
|
||||||
|
|
||||||
|
function isDev() {
|
||||||
|
return !app.isPackaged;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
// Create the browser window.
|
||||||
|
mainWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
},
|
||||||
|
// Use this in development mode.
|
||||||
|
icon: isDev()
|
||||||
|
? path.join(process.cwd(), 'static/logo-512.png')
|
||||||
|
: path.join(__dirname, '__sapper__/export/logo-512.png'),
|
||||||
|
// Use this in production mode.
|
||||||
|
// icon: path.join(__dirname, '__sapper__/export/logo-512.png'),
|
||||||
|
show: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
// This block of code is intended for development purpose only.
|
||||||
|
// Delete this entire block of code when you are ready to package the application.
|
||||||
|
if (isDev()) {
|
||||||
|
mainWindow.loadURL('http://localhost:3000/');
|
||||||
|
} else {
|
||||||
|
loadURL(mainWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncomment the following line of code when app is ready to be packaged.
|
||||||
|
// loadURL(mainWindow);
|
||||||
|
|
||||||
|
// Open the DevTools and also disable Electron Security Warning.
|
||||||
|
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = true;
|
||||||
|
// mainWindow.webContents.openDevTools();
|
||||||
|
|
||||||
|
// Emitted when the window is closed.
|
||||||
|
mainWindow.on('closed', function () {
|
||||||
|
// Dereference the window object, usually you would store windows
|
||||||
|
// in an array if your app supports multi windows, this is the time
|
||||||
|
// when you should delete the corresponding element.
|
||||||
|
mainWindow = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Emitted when the window is ready to be shown
|
||||||
|
// This helps in showing the window gracefully.
|
||||||
|
mainWindow.once('ready-to-show', () => {
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.on('ready', createWindow);
|
||||||
|
|
||||||
|
// Quit when all windows are closed.
|
||||||
|
app.on('window-all-closed', function () {
|
||||||
|
// On macOS it is common for applications and their menu bar
|
||||||
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
|
if (process.platform !== 'darwin') app.quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
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 (mainWindow === null) createWindow();
|
||||||
|
});
|
||||||
|
// 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.
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
const { NetlifyAPI } = require('netlify');
|
|
||||||
|
|
||||||
exports.handler = async function (event) {
|
|
||||||
// your server-side functionality
|
|
||||||
// const { siteName } = JSON.parse(event.body);
|
|
||||||
console.log(
|
|
||||||
'process.env.SVELTE_APP_NETLIFY_API_KEY',
|
|
||||||
process.env.SVELTE_APP_NETLIFY_API_KEY
|
|
||||||
);
|
|
||||||
const client = new NetlifyAPI(process.env.SVELTE_APP_NETLIFY_API_KEY);
|
|
||||||
const sites = await client.listSites();
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
body: JSON.stringify({ sites }),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
Generated
-5581
File diff suppressed because it is too large
Load Diff
+23
-2
@@ -2,12 +2,17 @@
|
|||||||
"name": "classroomio",
|
"name": "classroomio",
|
||||||
"description": "classroomio",
|
"description": "classroomio",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "sapper dev",
|
"dev": "sapper dev",
|
||||||
"build": "sapper build --legacy",
|
"build": "sapper build --legacy",
|
||||||
"export": "sapper export --legacy --entry \"/ /404 login signup forgot onboarding courses dashboard people profile course\"",
|
"export": "sapper export --legacy --entry \"/ /404 login signup forgot onboarding courses dashboard people profile course\"",
|
||||||
"postexport": "mv __sapper__/export/404/index.html __sapper__/export/404.html",
|
"postexport": "mv __sapper__/export/404/index.html __sapper__/export/404.html",
|
||||||
"start": "node __sapper__/build"
|
"start": "node __sapper__/build",
|
||||||
|
"electron": "wait-on http://localhost:3000 && electron .",
|
||||||
|
"electron-dev": "concurrently \"npm run dev\" \"npm run electron\"",
|
||||||
|
"preelectron-pack": "npm run export",
|
||||||
|
"electron-pack": "electron-builder"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
@@ -21,8 +26,10 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"canvas-confetti": "^1.4.0",
|
"canvas-confetti": "^1.4.0",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
|
"concurrently": "^8.1.0",
|
||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"copy-to-clipboard": "^3.3.1",
|
"copy-to-clipboard": "^3.3.1",
|
||||||
|
"electron-serve": "^1.1.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"hotkeys-js": "^3.8.5",
|
"hotkeys-js": "^3.8.5",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
@@ -37,6 +44,7 @@
|
|||||||
"sapper-environment": "^1.0.1",
|
"sapper-environment": "^1.0.1",
|
||||||
"sirv": "^1.0.0",
|
"sirv": "^1.0.0",
|
||||||
"svelte-easy-crop": "^1.0.4",
|
"svelte-easy-crop": "^1.0.4",
|
||||||
|
"wait-on": "^7.0.1",
|
||||||
"zod": "^3.19.1"
|
"zod": "^3.19.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -57,6 +65,8 @@
|
|||||||
"carbon-components-svelte": "^0.70.13",
|
"carbon-components-svelte": "^0.70.13",
|
||||||
"carbon-icons-svelte": "^10.21.0",
|
"carbon-icons-svelte": "^10.21.0",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
|
"electron": "^25.0.1",
|
||||||
|
"electron-builder": "^23.6.0",
|
||||||
"postcss": "^8.0.9",
|
"postcss": "^8.0.9",
|
||||||
"postcss-load-config": "^2.1.0",
|
"postcss-load-config": "^2.1.0",
|
||||||
"rollup": "^2.3.4",
|
"rollup": "^2.3.4",
|
||||||
@@ -73,5 +83,16 @@
|
|||||||
"tailwindcss": "^2.1.2",
|
"tailwindcss": "^2.1.2",
|
||||||
"tslib": "^2.3.1",
|
"tslib": "^2.3.1",
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"icon": "static/logo-512.png",
|
||||||
|
"productName": "ClassroomIO",
|
||||||
|
"files": [
|
||||||
|
"__sapper__/export/**/*",
|
||||||
|
"main.js"
|
||||||
|
],
|
||||||
|
"win": {},
|
||||||
|
"linux": {},
|
||||||
|
"mac": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user