解决 frame 内变量问题

This commit is contained in:
fofolee 2022-04-23 00:09:33 +08:00
parent 0f9f003c0a
commit f99123518a
3 changed files with 34 additions and 40 deletions

View File

@ -65,16 +65,9 @@ export default {
},
},
methods: {
frameInit() {
if (!this.showFrame) return;
let ctx = {
quickcommand,
utools,
parent: undefined,
};
Object.assign(this.cfw, _.cloneDeep(ctx));
},
frameLoad() {
this.cfw.quickcommand = _.cloneDeep(quickcommand);
this.cfw.utools = _.cloneDeep(utools);
this.frameHeight = Math.min(
this.cfw.document.documentElement.getBoundingClientRect().height,
this.maxHeight
@ -82,9 +75,6 @@ export default {
this.$emit("frameLoad");
},
},
mounted() {
this.frameInit();
},
};
</script>

View File

@ -21,8 +21,8 @@ const quickcommand = {
hints: [],
title: title
}
if (!(options instanceof Object)) return reject(new TypeError(`应为 Object, 而非 ${typeof options}`))
if (options instanceof Array) props.labels = options
if (!_.isObject(options)) return reject(new TypeError(`应为 Object, 而非 ${typeof options}`))
if (_.isArray(options)) props.labels = options
else Object.assign(props, options)
Dialog.create({
component: inputBox,
@ -35,7 +35,7 @@ const quickcommand = {
}),
showButtonBox: (labels = ["确定"], title = "") => new Promise((reslove, reject) => {
if (!(labels instanceof Array)) return reject(new TypeError(`应为 Array, 而非 ${typeof labels}`))
if (!_.isArray(labels)) return reject(new TypeError(`应为 Array, 而非 ${typeof labels}`))
let props = {
labels: labels,
title: title
@ -91,7 +91,7 @@ const quickcommand = {
}),
showSelectList: (selects, options = {}) => new Promise((reslove, reject) => {
if (!(selects instanceof Array)) return reject(new TypeError(`应为 Array, 而非 ${typeof selects}`))
if (!_.isArray(selects)) return reject(new TypeError(`应为 Array, 而非 ${typeof selects}`))
let defaultOptions = {
placeholder: "输入进行筛选,支持拼音",
optionType: "plaintext",

View File

@ -1,4 +1,11 @@
{
"program": "shell",
"cmd": "echo \"<script>function actionWithSelectedFile(file) { quickcommand.showButtonBox(['打开文件', '在文件管理器中定位', '复制文件路径']).then(x => { switch (x.id) { case 0: utools.shellOpenItem(file); break; case 1: utools.shellShowItemInFolder(file); break; case 2: utools.copyText(file); break; default: break; } }) }</script> <style> body li { list-style: none; padding: 5px 20px; margin: 10px 0; transition: .2s; height: 60px; font-size: 15px; border-radius: 6px; background: #9e9e9e26; line-height: 60px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} body li:hover { background: #009688; color: white; transition: .5s; } </style>\" \n\necho \"find / -name \\\"{{subinput}}\\\" 2>/dev/null\"\nfind / -name \"{{subinput}}\" -exec echo -n \"<li onclick=actionWithSelectedFile(this.innerText)>\"{}\"</li>\" \\; 2>/dev/null",
"scptarg": "",
"charset": {
"scriptCode": "",
"outputCode": ""
},
"features": {
"code": "default_findGui",
"explain": "通过 find 查找文件",
@ -12,11 +19,8 @@
"linux"
]
},
"program": "shell",
"cmd": "echo \"<script>function actionWithSelectedFile(file) { quickcommand.showButtonBox(['打开文件', '在文件管理器中定位', '复制文件路径']).then(x => { switch (x.id) { case 0: utools.shellOpenItem(file); break; case 1: utools.shellShowItemInFolder(file); break; case 2: utools.copyText(file); break; default: break; } }) }</script> <style> #out li { list-style: none; padding: 5px 20px; margin: 10px 0; transition: .2s; height: 60px; font-size: 15px; border-radius: 6px; background: #9e9e9e26; line-height: 60px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} #out li:hover { background: #009688; color: white; transition: .5s; } </style>\" \n\necho \"find / -name \\\"{{subinput}}\\\" 2>/dev/null\"\nfind / -name \"{{subinput}}\" -exec echo -n \"<li onclick=actionWithSelectedFile(this.innerText)>\"{}\"</li>\" \\; 2>/dev/null",
"output": "html",
"hasSubInput": true,
"scptarg": "",
"tags": [
"默认"
]