diff --git a/plugin/preload.js b/plugin/preload.js index 8e552f9..ff6539f 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -570,11 +570,15 @@ window.runCodeInSandbox = (code, callback, addVars = {}) => { } window.runCodeFile = (cmd, option, terminal, callback) => { - var bin = option.bin, - argv = option.argv, - ext = option.ext, - charset = option.charset, - scptarg = option.scptarg || ""; + let { + bin, + argv, + ext, + charset, + scptarg, + envPath, + alias + } = option let script = getQuickcommandTempFile(ext, 'quickcommandTempScript'); // 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题 if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode); @@ -598,11 +602,15 @@ window.runCodeFile = (cmd, option, terminal, callback) => { } else { cmdline = `${bin} ${argv} "${script}" ${scptarg}` } + let processEnv = _.cloneDeep(process.env); + if (envPath) processEnv.PATH = envPath; + if (alias) cmdline = alias + '\n' + cmdline; // 在终端中输出 if (terminal) cmdline = getCommandToLaunchTerminal(cmdline) child = child_process.spawn(cmdline, { encoding: 'buffer', - shell: true + shell: true, + env: processEnv }); // var chunks = [], // err_chunks = []; diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index 548ba61..7552c44 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -175,6 +175,8 @@ export default { : this.$root.programs[command.program]; option.scptarg = command.scptarg || ""; option.charset = command.charset || {}; + option.envPath = this.$root.nativeProfile.envPath.trim() || ""; + option.alias = this.$root.nativeProfile.alias.trim() || ""; return option; }, listenStopSign() { diff --git a/src/components/ConfigurationMenu.vue b/src/components/ConfigurationMenu.vue index 1d9ca45..b45e218 100644 --- a/src/components/ConfigurationMenu.vue +++ b/src/components/ConfigurationMenu.vue @@ -184,20 +184,20 @@ - 导入导出 + 命令管理 - 从文件导入 + 从文件导入命令 - 从剪贴板导入 + 从剪贴板导入命令 @@ -206,17 +206,6 @@ 导出所有命令 - - - - - - - - - 批处理 - - @@ -244,7 +233,68 @@ - + + + + + 环境配置 + + + + + + + 用户特殊变量 + 用户设置的变量,类似一个全局配置项
+ 配置好后可选择特殊变量中的「usr:」插入
+ 也可直接在特殊变量中配置
+
+ + + + + + 修改本插件环境变量中的 PATH,直接覆盖而非追加 +
将会影响到除 quickcommand、html + 以外的所有环境
+
+
+ + + + + + 一行一条,配置方法和 shell 的语法一样
如 alias + python="/home/user/.bin/python"
将会影响到除 + quickcommand、html 以外的所有环境
+
+
+
+
+
@@ -387,6 +437,9 @@ + + + @@ -397,12 +450,14 @@ import AboutThis from "components/popup/AboutThis"; import PanelSetting from "components/popup/PanelSetting"; import UserInfo from "components/popup/UserInfo"; import features from "../js/options/quickFeatures.js"; +import UserData from "components/popup/UserData"; export default { components: { AboutThis, PanelSetting, UserInfo, + UserData, }, data() { return { @@ -410,8 +465,10 @@ export default { selectFile: ref(null), showAbout: false, showPanelConf: false, + showUserDara: false, features: features, redirect: utools.redirect, + showAlias: this.$q.platform.is.mac || this.$q.platform.is.linux, }; }, computed: { diff --git a/src/components/popup/UserData.vue b/src/components/popup/UserData.vue index 924ae0b..edbb7dc 100644 --- a/src/components/popup/UserData.vue +++ b/src/components/popup/UserData.vue @@ -21,13 +21,18 @@ {{ item.id }}