mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
html 监听错误和重定向 console
This commit is contained in:
parent
3e3248162f
commit
de01de24bb
@ -58,6 +58,7 @@ export default {
|
|||||||
enableHtml: Boolean,
|
enableHtml: Boolean,
|
||||||
runResultStatus: Boolean,
|
runResultStatus: Boolean,
|
||||||
runResult: Object,
|
runResult: Object,
|
||||||
|
maxHeight: Number,
|
||||||
frameInitHeight: Number,
|
frameInitHeight: Number,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -67,7 +68,7 @@ export default {
|
|||||||
src() {
|
src() {
|
||||||
return this.showFrame
|
return this.showFrame
|
||||||
? window.URL.createObjectURL(
|
? window.URL.createObjectURL(
|
||||||
new Blob([this.frameStyle].concat(this.runResult), {
|
new Blob([this.frameStyle, this.runResult], {
|
||||||
type: "text/html",
|
type: "text/html",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -82,16 +83,30 @@ export default {
|
|||||||
frameInit() {
|
frameInit() {
|
||||||
let cfw = this.$refs?.iframe?.contentWindow;
|
let cfw = this.$refs?.iframe?.contentWindow;
|
||||||
if (!cfw) return;
|
if (!cfw) return;
|
||||||
|
let showError = (...args) => {
|
||||||
|
quickcommand.showMessageBox(args.join(" "), "error", 0);
|
||||||
|
};
|
||||||
|
let showLog = (...args) => {
|
||||||
|
quickcommand.showMessageBox(args.join(" "), "success", 0);
|
||||||
|
};
|
||||||
let ctx = {
|
let ctx = {
|
||||||
quickcommand: _.cloneDeep(quickcommand),
|
quickcommand: _.cloneDeep(quickcommand),
|
||||||
utools: _.cloneDeep(utools),
|
utools: _.cloneDeep(utools),
|
||||||
parent: undefined,
|
parent: undefined,
|
||||||
|
console: {
|
||||||
|
log: showLog,
|
||||||
|
error: showError,
|
||||||
|
},
|
||||||
|
onerror: (e) => showError(e),
|
||||||
};
|
};
|
||||||
Object.assign(cfw, ctx);
|
Object.assign(cfw, ctx);
|
||||||
cfw.onload = () => {
|
cfw.onload = () => {
|
||||||
let clientHeight =
|
this.frameHeight = Math.min(
|
||||||
cfw.document.documentElement.getBoundingClientRect().height;
|
cfw.document.body.innerText
|
||||||
this.frameHeight = clientHeight === 20 ? 0 : clientHeight;
|
? cfw.document.documentElement.getBoundingClientRect().height
|
||||||
|
: 0,
|
||||||
|
this.maxHeight
|
||||||
|
);
|
||||||
this.$emit("frameLoad", this.frameHeight);
|
this.$emit("frameLoad", this.frameHeight);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -92,6 +92,15 @@ export default {
|
|||||||
message: message,
|
message: message,
|
||||||
timeout: time,
|
timeout: time,
|
||||||
position: "top",
|
position: "top",
|
||||||
|
actions:
|
||||||
|
time === 0
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
label: "确定",
|
||||||
|
color: "white",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
14
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
14
src/plugins/monaco/types/quickcommand.api.d.ts
vendored
@ -138,7 +138,7 @@ interface quickcommandApi {
|
|||||||
* ```
|
* ```
|
||||||
* @param message 显示的消息内容
|
* @param message 显示的消息内容
|
||||||
* @param icon 图标,默认为 success
|
* @param icon 图标,默认为 success
|
||||||
* @param time 多少毫秒后消失,默认为 3000
|
* @param time 多少毫秒后消失,默认为 3000,当设为 0 时则需要手动点击关闭
|
||||||
*/
|
*/
|
||||||
showMessageBox(
|
showMessageBox(
|
||||||
message: string,
|
message: string,
|
||||||
@ -352,18 +352,6 @@ interface quickcommandApi {
|
|||||||
*/
|
*/
|
||||||
simulatePaste();
|
simulatePaste();
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取剪贴板
|
|
||||||
*/
|
|
||||||
readClipboard(): text<string>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 写入剪贴板
|
|
||||||
*
|
|
||||||
* @param text 要写入的文本
|
|
||||||
*/
|
|
||||||
writeClipboard(text: string);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 唤醒 uTools
|
* 唤醒 uTools
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user