xplugin-nextcode
Version:
75 lines (73 loc) • 1.71 kB
JavaScript
const schema = {
"node": {
"title": "节点属性",
"type": "object",
"properties": {
"url": {
"title": "URL",
"type": "string"
},
"target": {
"title": "目标",
"type": "string",
"default": "blank"
},
},
},
"input": {
"type": "object",
"title": "节点入参",
"properties": {
"x": {
"title": "x",
"type": "number"
},
"y": {
"title": "y",
"type": "number"
},
}
},
"output": {
"type": "object",
"title": "节点出参",
"properties": {
"_json": {
"title": "内容",
"required": false,
"disabled": false,
"readOnly": false,
"hidden": false,
"props": {
"foldable": false
},
"type": "string",
}
}
}
}
/**
* 打开页面
* @param {*} node
* @param {*} input
* @param {*} engine
* @returns
*/
function open(node, input, engine) {
//非客户端,直接返回
if ("undefined" === typeof (window)) {
console.warn("client must run in client!")
return input;
}
if ("blank" === node.target || "_blank" === node.target || "new" === node.target) {
window.open(node.url);
} else {
window.location.href = node.url;
}
return input;
}
module.exports = {
"service": "open",
"implement": open,
"schema": schema,
}