优化electron命令
This commit is contained in:
parent
cb792cbb26
commit
32c2d60f7e
25
cmd
25
cmd
@ -86,6 +86,24 @@ run_compile() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_electron() {
|
||||||
|
local type=$1
|
||||||
|
check_node
|
||||||
|
if [ ! -d "./electron/node_modules" ]; then
|
||||||
|
pushd electron
|
||||||
|
npm install
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
if [ -d "./electron/dist" ]; then
|
||||||
|
rm -rf "./electron/dist"
|
||||||
|
fi
|
||||||
|
if [ "$type" = "prod" ]; then
|
||||||
|
node ./electron/build.js --build
|
||||||
|
else
|
||||||
|
node ./electron/build.js
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
run_exec() {
|
run_exec() {
|
||||||
local container=$1
|
local container=$1
|
||||||
local cmd=$2
|
local cmd=$2
|
||||||
@ -240,6 +258,13 @@ if [ $# -gt 0 ]; then
|
|||||||
elif [[ "$1" == "prod" ]] || [[ "$1" == "production" ]]; then
|
elif [[ "$1" == "prod" ]] || [[ "$1" == "production" ]]; then
|
||||||
shift 1
|
shift 1
|
||||||
run_compile prod
|
run_compile prod
|
||||||
|
elif [[ "$1" == "electron" ]]; then
|
||||||
|
shift 1
|
||||||
|
if [[ "$@" == "dev" ]]; then
|
||||||
|
run_electron dev
|
||||||
|
else
|
||||||
|
run_electron prod
|
||||||
|
fi
|
||||||
elif [[ "$1" == "doc" ]]; then
|
elif [[ "$1" == "doc" ]]; then
|
||||||
shift 1
|
shift 1
|
||||||
run_exec php "php app/Http/Controllers/Api/apidoc.php"
|
run_exec php "php app/Http/Controllers/Api/apidoc.php"
|
||||||
|
1
electron/.gitignore
vendored
1
electron/.gitignore
vendored
@ -2,6 +2,7 @@ node_modules/
|
|||||||
public/
|
public/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
|
||||||
|
build/
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
.devload
|
.devload
|
||||||
|
29
electron/build.js
vendored
29
electron/build.js
vendored
@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const fse = require('fs-extra')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const inquirer = require('inquirer');
|
const inquirer = require('inquirer');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
@ -72,11 +73,21 @@ function formatUrl(str) {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正则提取域名
|
||||||
|
* @param weburl
|
||||||
|
* @returns {string|string}
|
||||||
|
*/
|
||||||
|
function getDomain(weburl) {
|
||||||
|
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||||
|
let domain = weburl.match(urlReg);
|
||||||
|
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 右边是否包含
|
* 右边是否包含
|
||||||
* @param string
|
* @param string
|
||||||
* @param find
|
* @param find
|
||||||
* @param lower
|
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
function rightExists(string, find) {
|
function rightExists(string, find) {
|
||||||
@ -157,7 +168,21 @@ if (argv[2] === "--build") {
|
|||||||
//
|
//
|
||||||
child_process.spawnSync("mix", ["--production", "--", "--env", "--electron"], {stdio: "inherit"});
|
child_process.spawnSync("mix", ["--production", "--", "--env", "--electron"], {stdio: "inherit"});
|
||||||
answers.platform.forEach(arg => {
|
answers.platform.forEach(arg => {
|
||||||
child_process.spawn("npm", ["run", arg], {stdio: "inherit", cwd: "electron"});
|
child_process.spawnSync("npm", ["run", arg], {stdio: "inherit", cwd: "electron"});
|
||||||
|
let name = ""
|
||||||
|
if (arg == "build-mac-intel") {
|
||||||
|
name = config.name + "-" + config.version + ".dmg"
|
||||||
|
} else if (arg == "build-mac-m1") {
|
||||||
|
name = config.name + "-" + config.version + "-arm64.dmg"
|
||||||
|
} else if (arg == "build-win") {
|
||||||
|
name = config.name + " Setup " + config.version + ".exe"
|
||||||
|
}
|
||||||
|
if (name != "") {
|
||||||
|
fse.copySync(
|
||||||
|
path.resolve(__dirname, "dist", name),
|
||||||
|
path.resolve(__dirname, "build", getDomain(answers.targetUrl), config.version, name)
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,13 +21,14 @@
|
|||||||
"@electron-forge/maker-rpm": "^6.0.0-beta.61",
|
"@electron-forge/maker-rpm": "^6.0.0-beta.61",
|
||||||
"@electron-forge/maker-squirrel": "^6.0.0-beta.61",
|
"@electron-forge/maker-squirrel": "^6.0.0-beta.61",
|
||||||
"@electron-forge/maker-zip": "^6.0.0-beta.61",
|
"@electron-forge/maker-zip": "^6.0.0-beta.61",
|
||||||
"dmg-license": "^1.0.9",
|
"dmg-license": "^1.0.10",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"electron": "^15.0.0",
|
"electron": "^16.0.4",
|
||||||
"electron-builder": "^22.11.7"
|
"electron-builder": "^22.14.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
|
"fs-extra": "^10.0.0",
|
||||||
"xlsx": "^0.17.2"
|
"xlsx": "^0.17.2"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "./cmd dev",
|
"start": "./cmd dev",
|
||||||
"build": "./cmd prod",
|
"build": "./cmd prod",
|
||||||
"electron-start": "node ./electron/build.js",
|
|
||||||
"electron-build": "node ./electron/build.js --build",
|
|
||||||
"version": "node ./version.js"
|
"version": "node ./version.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user