@vnejs/desktop 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/desktop",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Tools to run desktop app of @vnejs",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/electron.js CHANGED
@@ -5,10 +5,15 @@ const createWindow = (options) => {
5
5
  mainWindow = new BrowserWindow({ autoHideMenuBar: options.isProd, fullscreen: true, frame: true });
6
6
 
7
7
  if (options.port) mainWindow.loadURL(`http://localhost:${options.port}/`);
8
- if (options.file) mainWindow.loadFile(options.file);
8
+ if (options.file) mainWindow.loadFile(options.file, { search: options.search });
9
9
 
10
10
  mainWindow.on("closed", () => (mainWindow = null));
11
11
  options.isProd ? mainWindow.removeMenu() : mainWindow.webContents.openDevTools();
12
+
13
+ mainWindow.webContents.on("before-input-event", (event, input) => {
14
+ if (input.key === "F5") return event.preventDefault();
15
+ if (input.key.toLowerCase() === "r" && (input.control || input.meta)) return event.preventDefault();
16
+ });
12
17
  };
13
18
 
14
19
  const runElectron = (options) => {
package/src/server.js CHANGED
@@ -28,6 +28,11 @@ const runServer = async ({ rootDir, oldApp } = {}) => {
28
28
  const app =
29
29
  oldApp ||
30
30
  express()
31
+ .use((req, res, next) => {
32
+ res.header("Access-Control-Allow-Origin", "*");
33
+
34
+ next();
35
+ })
31
36
  .use(bodyParser.json({ limit: "50mb" }))
32
37
  .use(express.static(path.join(rootDir, "dist")))
33
38
  .use("/state/save", onSaveState)
package/src/web.js CHANGED
@@ -1,4 +1,6 @@
1
1
  const open = require("open");
2
2
  const { runServer } = require("./server");
3
3
 
4
- module.exports = () => runServer({ rootDir: process.env.PWD }).then((port) => open(`http://localhost:${port}`));
4
+ const getRootDir = () => process.env.PWD || process.env.INIT_CWD;
5
+
6
+ module.exports = () => runServer({ rootDir: getRootDir() }).then((port) => open(`http://localhost:${port}`));