mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 06:16:27 +08:00
支持修改环境变量和 ALIAS
This commit is contained in:
parent
2dd7508911
commit
1ee35586c1
@ -570,11 +570,15 @@ window.runCodeInSandbox = (code, callback, addVars = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.runCodeFile = (cmd, option, terminal, callback) => {
|
window.runCodeFile = (cmd, option, terminal, callback) => {
|
||||||
var bin = option.bin,
|
let {
|
||||||
argv = option.argv,
|
bin,
|
||||||
ext = option.ext,
|
argv,
|
||||||
charset = option.charset,
|
ext,
|
||||||
scptarg = option.scptarg || "";
|
charset,
|
||||||
|
scptarg,
|
||||||
|
envPath,
|
||||||
|
alias
|
||||||
|
} = option
|
||||||
let script = getQuickcommandTempFile(ext, 'quickcommandTempScript');
|
let script = getQuickcommandTempFile(ext, 'quickcommandTempScript');
|
||||||
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
// 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
|
||||||
if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode);
|
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 {
|
} else {
|
||||||
cmdline = `${bin} ${argv} "${script}" ${scptarg}`
|
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)
|
if (terminal) cmdline = getCommandToLaunchTerminal(cmdline)
|
||||||
child = child_process.spawn(cmdline, {
|
child = child_process.spawn(cmdline, {
|
||||||
encoding: 'buffer',
|
encoding: 'buffer',
|
||||||
shell: true
|
shell: true,
|
||||||
|
env: processEnv
|
||||||
});
|
});
|
||||||
// var chunks = [],
|
// var chunks = [],
|
||||||
// err_chunks = [];
|
// err_chunks = [];
|
||||||
|
@ -175,6 +175,8 @@ export default {
|
|||||||
: this.$root.programs[command.program];
|
: this.$root.programs[command.program];
|
||||||
option.scptarg = command.scptarg || "";
|
option.scptarg = command.scptarg || "";
|
||||||
option.charset = command.charset || {};
|
option.charset = command.charset || {};
|
||||||
|
option.envPath = this.$root.nativeProfile.envPath.trim() || "";
|
||||||
|
option.alias = this.$root.nativeProfile.alias.trim() || "";
|
||||||
return option;
|
return option;
|
||||||
},
|
},
|
||||||
listenStopSign() {
|
listenStopSign() {
|
||||||
|
@ -184,20 +184,20 @@
|
|||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="keyboard_arrow_left" />
|
<q-icon name="keyboard_arrow_left" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>导入导出</q-item-section>
|
<q-item-section>命令管理</q-item-section>
|
||||||
<q-menu anchor="top end" self="top start">
|
<q-menu anchor="top end" self="top start">
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item clickable v-close-popup @click="importCommand">
|
<q-item clickable v-close-popup @click="importCommand">
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="text_snippet" />
|
<q-icon name="text_snippet" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>从文件导入</q-item-section>
|
<q-item-section>从文件导入命令</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable v-close-popup @click="importCommand(false)">
|
<q-item clickable v-close-popup @click="importCommand(false)">
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="content_paste" />
|
<q-icon name="content_paste" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>从剪贴板导入</q-item-section>
|
<q-item-section>从剪贴板导入命令</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<!-- 导出 -->
|
<!-- 导出 -->
|
||||||
<q-item clickable v-close-popup @click="exportAllCommands">
|
<q-item clickable v-close-popup @click="exportAllCommands">
|
||||||
@ -206,17 +206,6 @@
|
|||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>导出所有命令</q-item-section>
|
<q-item-section>导出所有命令</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
|
||||||
</q-menu>
|
|
||||||
</q-item>
|
|
||||||
<!-- 批处理 -->
|
|
||||||
<q-item clickable>
|
|
||||||
<q-item-section side>
|
|
||||||
<q-icon name="keyboard_arrow_left" />
|
|
||||||
</q-item-section>
|
|
||||||
<q-item-section>批处理</q-item-section>
|
|
||||||
<q-menu anchor="top end" self="top start">
|
|
||||||
<q-list>
|
|
||||||
<q-item clickable v-close-popup @click="enableAllCommands">
|
<q-item clickable v-close-popup @click="enableAllCommands">
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="checklist_rtl" />
|
<q-icon name="checklist_rtl" />
|
||||||
@ -244,7 +233,68 @@
|
|||||||
</q-list>
|
</q-list>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
</q-item>
|
</q-item>
|
||||||
<!-- 选项 -->
|
<q-item clickable>
|
||||||
|
<q-item-section side>
|
||||||
|
<q-icon name="keyboard_arrow_left" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>环境配置</q-item-section>
|
||||||
|
<q-menu anchor="bottom end" self="bottom start">
|
||||||
|
<q-list>
|
||||||
|
<q-item clickable @click="showUserDara = true">
|
||||||
|
<q-item-section side>
|
||||||
|
<q-icon name="manage_accounts" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>用户特殊变量</q-item-section>
|
||||||
|
<q-tooltip
|
||||||
|
>用户设置的变量,类似一个全局配置项<br />
|
||||||
|
配置好后可选择特殊变量中的「usr:」插入<br />
|
||||||
|
也可直接在特殊变量中配置</q-tooltip
|
||||||
|
>
|
||||||
|
</q-item>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section side>
|
||||||
|
<q-icon name="dvr" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
autogrow
|
||||||
|
style="width: 280px"
|
||||||
|
autofocus
|
||||||
|
v-model="$root.nativeProfile.envPath"
|
||||||
|
type="text"
|
||||||
|
label="环境变量 PATH"
|
||||||
|
>
|
||||||
|
<q-tooltip
|
||||||
|
>修改本插件环境变量中的 PATH,直接覆盖而非追加
|
||||||
|
<br />将会影响到除 quickcommand、html
|
||||||
|
以外的所有环境</q-tooltip
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
</q-item>
|
||||||
|
<q-item v-if="showAlias">
|
||||||
|
<q-item-section side>
|
||||||
|
<q-icon name="code" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-input
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
autogrow
|
||||||
|
style="width: 280px"
|
||||||
|
v-model="$root.nativeProfile.alias"
|
||||||
|
type="text"
|
||||||
|
label="Alias"
|
||||||
|
>
|
||||||
|
<q-tooltip
|
||||||
|
>一行一条,配置方法和 shell 的语法一样<br />如 alias
|
||||||
|
python="/home/user/.bin/python"<br />将会影响到除
|
||||||
|
quickcommand、html 以外的所有环境</q-tooltip
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="keyboard_arrow_left" />
|
<q-icon name="keyboard_arrow_left" />
|
||||||
@ -387,6 +437,9 @@
|
|||||||
<q-dialog v-model="showPanelConf">
|
<q-dialog v-model="showPanelConf">
|
||||||
<PanelSetting :isTagStared="isTagStared" :currentTag="currentTag" />
|
<PanelSetting :isTagStared="isTagStared" :currentTag="currentTag" />
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
<q-dialog v-model="showUserDara">
|
||||||
|
<UserData :showInsertBtn="false" />
|
||||||
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -397,12 +450,14 @@ import AboutThis from "components/popup/AboutThis";
|
|||||||
import PanelSetting from "components/popup/PanelSetting";
|
import PanelSetting from "components/popup/PanelSetting";
|
||||||
import UserInfo from "components/popup/UserInfo";
|
import UserInfo from "components/popup/UserInfo";
|
||||||
import features from "../js/options/quickFeatures.js";
|
import features from "../js/options/quickFeatures.js";
|
||||||
|
import UserData from "components/popup/UserData";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
AboutThis,
|
AboutThis,
|
||||||
PanelSetting,
|
PanelSetting,
|
||||||
UserInfo,
|
UserInfo,
|
||||||
|
UserData,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -410,8 +465,10 @@ export default {
|
|||||||
selectFile: ref(null),
|
selectFile: ref(null),
|
||||||
showAbout: false,
|
showAbout: false,
|
||||||
showPanelConf: false,
|
showPanelConf: false,
|
||||||
|
showUserDara: false,
|
||||||
features: features,
|
features: features,
|
||||||
redirect: utools.redirect,
|
redirect: utools.redirect,
|
||||||
|
showAlias: this.$q.platform.is.mac || this.$q.platform.is.linux,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -21,13 +21,18 @@
|
|||||||
<q-chip color="primary" dense>{{ item.id }}</q-chip>
|
<q-chip color="primary" dense>{{ item.id }}</q-chip>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-toggle dense class="q-mr-sm" v-model="item.isNative" color="primary" />
|
<q-toggle
|
||||||
|
dense
|
||||||
|
class="q-mr-sm"
|
||||||
|
v-model="item.isNative"
|
||||||
|
color="primary" />
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="send"
|
icon="send"
|
||||||
@click="insertText(`{{usr:${item.id}}}`)" />
|
@click="insertText(`{{usr:${item.id}}}`)"
|
||||||
|
v-if="showInsertBtn" />
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
@ -57,6 +62,9 @@ export default {
|
|||||||
allUserData: [],
|
allUserData: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
props: {
|
||||||
|
showInsertBtn: Boolean,
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.allUserData = this.$root.utools.userData.all();
|
this.allUserData = this.$root.utools.userData.all();
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,8 @@ export default {
|
|||||||
native: {
|
native: {
|
||||||
crontabs: {},
|
crontabs: {},
|
||||||
serverPort: 33442,
|
serverPort: 33442,
|
||||||
serverStatus: false
|
serverStatus: false,
|
||||||
|
envPath: '',
|
||||||
|
alias: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user