2
0
Gitea 3 жил өмнө
parent
commit
a2b7b880e0

+ 76 - 0
express/electron-starter.js

@@ -0,0 +1,76 @@
+const electron = require('electron');
+require('./dist/app');
+
+// Module to control application life.
+const app = electron.app;
+// Module to create native browser window.
+const BrowserWindow = electron.BrowserWindow;
+
+const path = require('path');
+const url = require('url');
+
+// 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 createWindow() {
+  // Create the browser window.
+  mainWindow = new BrowserWindow({
+    width: 1200,
+    height: 800,
+    webPreferences: {
+      devTools: true,
+      webSecurity: false,
+      nodeIntegration: true,
+      enableRemoteModule: true,
+    },
+  });
+  // mainWindow.maximize();
+  // mainWindow.show();
+  // and load the index.html of the app.
+
+  const startUrl =
+    process.env.ELECTRON_START_URL ||
+    url.format({
+      pathname: path.join(__dirname, './build/index.html'),
+      protocol: 'file:',
+      slashes: true,
+    });
+  console.log(startUrl);
+  mainWindow.loadURL(startUrl);
+  // mainWindow.loadURL('http://127.0.0.1:3000');
+  mainWindow.focus();
+
+  // Open the DevTools.
+  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;
+  });
+}
+
+// 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 OS X 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 OS X 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();
+  }
+});

+ 40 - 3
express/package.json

@@ -1,7 +1,6 @@
 {
 {
   "name": "express",
   "name": "express",
   "version": "1.0.0",
   "version": "1.0.0",
-  "main": "dist/app.js",
   "license": "MIT",
   "license": "MIT",
   "dependencies": {
   "dependencies": {
     "@zilliz/milvus2-sdk-node": "^1.0.19",
     "@zilliz/milvus2-sdk-node": "^1.0.19",
@@ -50,6 +49,8 @@
     "@types/swagger-jsdoc": "^6.0.1",
     "@types/swagger-jsdoc": "^6.0.1",
     "@types/swagger-ui-express": "^4.1.3",
     "@types/swagger-ui-express": "^4.1.3",
     "@types/ws": "^8.2.0",
     "@types/ws": "^8.2.0",
+    "electron": "^16.0.2",
+    "electron-builder": "^22.14.5",
     "jest": "^27.3.1",
     "jest": "^27.3.1",
     "nodemon": "^2.0.14",
     "nodemon": "^2.0.14",
     "prettier": "^2.4.1",
     "prettier": "^2.4.1",
@@ -60,6 +61,7 @@
     "typescript": "^4.4.4"
     "typescript": "^4.4.4"
   },
   },
   "scripts": {
   "scripts": {
+    "electron": "ELECTRON_START_URL=http://localhost:3001 electron .",
     "prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
     "prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
     "build": "yarn clean && tsc",
     "build": "yarn clean && tsc",
     "prestart": "rm -rf dist && yarn build",
     "prestart": "rm -rf dist && yarn build",
@@ -71,7 +73,8 @@
     "test:cov": "cross-env NODE_ENV=test jest --passWithNoTests --coverage",
     "test:cov": "cross-env NODE_ENV=test jest --passWithNoTests --coverage",
     "test:report": "cross-env NODE_ENV=test jest --watchAll=false --coverage --coverageReporters='text-summary'",
     "test:report": "cross-env NODE_ENV=test jest --watchAll=false --coverage --coverageReporters='text-summary'",
     "clean": "rimraf dist",
     "clean": "rimraf dist",
-    "format": "prettier --write '**/*.{ts,js}'"
+    "format": "prettier --write '**/*.{ts,js}'",
+    "mac": "rm -rf electron-app && electron-builder --mac"
   },
   },
   "nodemonConfig": {
   "nodemonConfig": {
     "ignore": [
     "ignore": [
@@ -85,5 +88,39 @@
       "src"
       "src"
     ],
     ],
     "ext": "ts yml"
     "ext": "ts yml"
+  },
+  "homepage": "./",
+  "main": "electron-starter.js",
+  "build": {
+    "appId": "milvus",
+    "directories": {
+      "output": "electron-app"
+    },
+    "files": [
+      "build/**/*",
+      "dist/**/*",
+      "node_modules/**/*",
+      "electron-starter.js",
+      "package.json",
+      "preload.js"
+    ],
+    "linux": {
+      "icon": "./build/milvus-icon.icns",
+      "target": [
+        "deb"
+      ]
+    },
+    "mac": {
+      "icon": "./build/milvus-icon.icns",
+      "target": "dmg"
+    },
+    "win": {
+      "icon": "./build/milvus-icon.png",
+      "target": [
+        {
+          "target": "nsis"
+        }
+      ]
+    }
   }
   }
-}
+}

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 621 - 10
express/yarn.lock


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно