mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2024-12-26 03:38:24 +00:00
使用终端窗口的方式运行解析psd
This commit is contained in:
parent
9174aea6e1
commit
40ee90491e
11
ccc-tnt-psd2ui-v2.4.x/libs/psd2ui/command.bat
Normal file
11
ccc-tnt-psd2ui-v2.4.x/libs/psd2ui/command.bat
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
set input1=%1%
|
||||||
|
set input2=%2%
|
||||||
|
|
||||||
|
cd /d %~dp0
|
||||||
|
|
||||||
|
%~dp0../../bin/node.exe ./index.js %input1% %input2%
|
||||||
|
|
||||||
|
pause
|
||||||
|
exit
|
10
ccc-tnt-psd2ui-v2.4.x/libs/psd2ui/command.sh
Executable file
10
ccc-tnt-psd2ui-v2.4.x/libs/psd2ui/command.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
# exec /bin/bash
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# node_dir=$(dirname $(dirname $(dirname $(realpath $0))))
|
||||||
|
|
||||||
|
cur_dir=$(dirname $0)
|
||||||
|
$(dirname $(dirname $cur_dir))/bin/node $cur_dir/index.js $1 $2
|
||||||
|
|
||||||
|
# echo 请按任意键继续..
|
||||||
|
# read -n 1
|
@ -18,6 +18,7 @@ const configFile = path.join(`${packagePath}/config/psd.config.json`);
|
|||||||
|
|
||||||
|
|
||||||
const nodejsFile = path.join(packagePath, "bin", `node${Os.platform() == 'darwin' ? "" : ".exe"}`);
|
const nodejsFile = path.join(packagePath, "bin", `node${Os.platform() == 'darwin' ? "" : ".exe"}`);
|
||||||
|
const commandFile = path.join(packagePath, "libs", "psd2ui", `command.${Os.platform() == 'darwin' ? "sh" : "bat"}`);
|
||||||
const psd = path.join(packagePath, "libs", "psd2ui", "index.js");
|
const psd = path.join(packagePath, "libs", "psd2ui", "index.js");
|
||||||
|
|
||||||
let uuid2md5 = new Map();
|
let uuid2md5 = new Map();
|
||||||
@ -35,9 +36,13 @@ function _exec(options, tasks) {
|
|||||||
// 处理权限问题
|
// 处理权限问题
|
||||||
if (Os.platform() === 'darwin') {
|
if (Os.platform() === 'darwin') {
|
||||||
if (fs.statSync(nodejsFile).mode != 33261) {
|
if (fs.statSync(nodejsFile).mode != 33261) {
|
||||||
Editor.log(`[ccc-tnt-psd2ui] 设置权限`);
|
Editor.log(`[ccc-tnt-psd2ui] nodejsFile 设置权限`);
|
||||||
fs.chmodSync(nodejsFile, 33261);
|
fs.chmodSync(nodejsFile, 33261);
|
||||||
}
|
}
|
||||||
|
if (fs.statSync(commandFile).mode != 33261) {
|
||||||
|
Editor.log(`[ccc-tnt-psd2ui] commandFile 设置权限`);
|
||||||
|
fs.chmodSync(commandFile, 33261);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor.log("[ccc-tnt-psd2ui] 命令参数:" + jsonContent);
|
Editor.log("[ccc-tnt-psd2ui] 命令参数:" + jsonContent);
|
||||||
@ -46,13 +51,29 @@ function _exec(options, tasks) {
|
|||||||
let base64 = Buffer.from(jsonContent).toString("base64");
|
let base64 = Buffer.from(jsonContent).toString("base64");
|
||||||
tasks.push(new Promise((rs) => {
|
tasks.push(new Promise((rs) => {
|
||||||
// Editor.log(`[ccc-tnt-psd2ui] `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
// Editor.log(`[ccc-tnt-psd2ui] `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
||||||
exec(`${nodejsFile} ${psd}` + ' ' + `--json ${base64}`, { windowsHide: false }, (err, stdout, stderr) => {
|
// exec(`${nodejsFile} ${psd}` + ' ' + `--json ${base64}`, { windowsHide: false }, (err, stdout, stderr) => {
|
||||||
|
// Editor.log("[ccc-tnt-psd2ui]:\n", stdout);
|
||||||
|
// if (stderr) {
|
||||||
|
// Editor.log(stderr);
|
||||||
|
// }
|
||||||
|
// rs();
|
||||||
|
// })
|
||||||
|
|
||||||
|
let shellScript = commandFile; // 你的脚本路径
|
||||||
|
let scriptArgs = `--json ${base64}`; // 你的脚本参数
|
||||||
|
|
||||||
|
let command =
|
||||||
|
Os.platform() == 'darwin' ? `osascript -e 'tell app "Terminal" to do script "cd ${process.cwd()}; ${shellScript} ${scriptArgs}"'`
|
||||||
|
: `start ${commandFile} ${scriptArgs}`;
|
||||||
|
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
Editor.log("[ccc-tnt-psd2ui]:\n", stdout);
|
Editor.log("[ccc-tnt-psd2ui]:\n", stdout);
|
||||||
|
Editor.log("[ccc-tnt-psd2ui]: 程序执行完后请手动关闭终端窗口", );
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
Editor.log(stderr);
|
Editor.log(stderr);
|
||||||
}
|
}
|
||||||
rs();
|
rs();
|
||||||
})
|
});
|
||||||
}));
|
}));
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
11
ccc-tnt-psd2ui-v3.4.+/libs/psd2ui/command.bat
Normal file
11
ccc-tnt-psd2ui-v3.4.+/libs/psd2ui/command.bat
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
set input1=%1%
|
||||||
|
set input2=%2%
|
||||||
|
|
||||||
|
cd /d %~dp0
|
||||||
|
|
||||||
|
%~dp0../../bin/node.exe ./index.js %input1% %input2%
|
||||||
|
|
||||||
|
pause
|
||||||
|
exit
|
10
ccc-tnt-psd2ui-v3.4.+/libs/psd2ui/command.sh
Executable file
10
ccc-tnt-psd2ui-v3.4.+/libs/psd2ui/command.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
# exec /bin/bash
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# node_dir=$(dirname $(dirname $(dirname $(realpath $0))))
|
||||||
|
|
||||||
|
cur_dir=$(dirname $0)
|
||||||
|
$(dirname $(dirname $cur_dir))/bin/node $cur_dir/index.js $1 $2
|
||||||
|
|
||||||
|
# echo 请按任意键继续..
|
||||||
|
# read -n 1
|
@ -15,6 +15,7 @@ const cacheFile = path.join(Editor.Project.path, "local", "psd-to-prefab-cache.j
|
|||||||
const configFile = path.join(`${packagePath}/config/psd.config.json`);
|
const configFile = path.join(`${packagePath}/config/psd.config.json`);
|
||||||
|
|
||||||
const nodejsFile = path.join(packagePath, "bin", `node${Os.platform() == 'darwin' ? "" : ".exe"}`);
|
const nodejsFile = path.join(packagePath, "bin", `node${Os.platform() == 'darwin' ? "" : ".exe"}`);
|
||||||
|
const commandFile = path.join(packagePath, "libs", "psd2ui", `command.${Os.platform() == 'darwin' ? "sh" : "bat"}`);
|
||||||
const psd = path.join(packagePath, "libs", "psd2ui", "index.js");
|
const psd = path.join(packagePath, "libs", "psd2ui", "index.js");
|
||||||
|
|
||||||
let uuid2md5: Map<string, string> = new Map();
|
let uuid2md5: Map<string, string> = new Map();
|
||||||
@ -116,6 +117,11 @@ function _exec(options: any, tasks: any) {
|
|||||||
console.log(`[ccc-tnt-psd2ui] 设置权限`);
|
console.log(`[ccc-tnt-psd2ui] 设置权限`);
|
||||||
fs.chmodSync(nodejsFile, 33261);
|
fs.chmodSync(nodejsFile, 33261);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fs.statSync(commandFile).mode != 33261) {
|
||||||
|
console.log(`[ccc-tnt-psd2ui] commandFile 设置权限`);
|
||||||
|
fs.chmodSync(commandFile, 33261);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("[ccc-tnt-psd2ui] 命令参数:" + jsonContent);
|
console.log("[ccc-tnt-psd2ui] 命令参数:" + jsonContent);
|
||||||
@ -124,13 +130,29 @@ function _exec(options: any, tasks: any) {
|
|||||||
let base64 = Buffer.from(jsonContent).toString("base64");
|
let base64 = Buffer.from(jsonContent).toString("base64");
|
||||||
tasks.push(new Promise<void>((rs) => {
|
tasks.push(new Promise<void>((rs) => {
|
||||||
// console.log(`[ccc-tnt-psd2ui] `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
// console.log(`[ccc-tnt-psd2ui] `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
||||||
exec(`${nodejsFile} ${psd}` + ' ' + `--json ${base64}`, { windowsHide: false }, (err, stdout, stderr) => {
|
// exec(`${nodejsFile} ${psd}` + ' ' + `--json ${base64}`, { windowsHide: false }, (err, stdout, stderr) => {
|
||||||
|
// console.log("[ccc-tnt-psd2ui]:\n", stdout);
|
||||||
|
// if (stderr) {
|
||||||
|
// console.log(stderr);
|
||||||
|
// }
|
||||||
|
// rs();
|
||||||
|
// })
|
||||||
|
|
||||||
|
let shellScript = commandFile; // 你的脚本路径
|
||||||
|
let scriptArgs = `--json ${base64}`; // 你的脚本参数
|
||||||
|
|
||||||
|
let command =
|
||||||
|
Os.platform() == 'darwin' ? `osascript -e 'tell app "Terminal" to do script "cd ${process.cwd()}; ${shellScript} ${scriptArgs}"'`
|
||||||
|
: `start ${commandFile} ${scriptArgs}`;
|
||||||
|
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
console.log("[ccc-tnt-psd2ui]:\n", stdout);
|
console.log("[ccc-tnt-psd2ui]:\n", stdout);
|
||||||
|
console.log("[ccc-tnt-psd2ui]: 程序执行完后请手动关闭终端窗口", );
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
console.log(stderr);
|
console.log(stderr);
|
||||||
}
|
}
|
||||||
rs();
|
rs();
|
||||||
})
|
});
|
||||||
}));
|
}));
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release24x": "",
|
"release24x": "",
|
||||||
"release34x": ""
|
"release34x": "",
|
||||||
|
"testsh": "node src/test.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
Loading…
Reference in New Issue
Block a user