2023-03-08 21:29:30 +00:00
|
|
|
|
import { Version, Cfg } from '#miao'
|
2022-09-17 09:48:24 +00:00
|
|
|
|
|
2023-03-08 21:29:30 +00:00
|
|
|
|
const Render = {
|
|
|
|
|
async render (path, params, cfg) {
|
|
|
|
|
let { e } = cfg
|
|
|
|
|
if (!e.runtime) {
|
|
|
|
|
console.log('未找到e.runtime,请升级至最新版Yunzai')
|
|
|
|
|
}
|
2023-11-06 19:52:55 +00:00
|
|
|
|
return e.runtime.render(cfg.plugin || 'miao-plugin', path, params, {
|
2023-12-22 16:03:58 +00:00
|
|
|
|
retType: cfg.retType || (cfg.retMsgId ? 'msgId' : 'default'),
|
2023-03-08 21:29:30 +00:00
|
|
|
|
beforeRender ({ data }) {
|
2023-03-09 20:34:25 +00:00
|
|
|
|
let pluginName = ''
|
|
|
|
|
if (data.pluginName !== false) {
|
|
|
|
|
pluginName = ` & ${data.pluginName || 'Miao-Plugin'}`
|
|
|
|
|
if (data.pluginVersion !== false) {
|
|
|
|
|
pluginName += `<span class="version">${data.pluginVersion || Version.version}`
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-08 21:29:30 +00:00
|
|
|
|
let resPath = data.pluResPath
|
|
|
|
|
const layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/'
|
|
|
|
|
return {
|
2023-11-07 21:06:13 +00:00
|
|
|
|
_miao_path: resPath,
|
2023-03-08 21:29:30 +00:00
|
|
|
|
...data,
|
|
|
|
|
_res_path: resPath,
|
|
|
|
|
_layout_path: layoutPath,
|
|
|
|
|
_tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/',
|
|
|
|
|
defaultLayout: layoutPath + 'default.html',
|
|
|
|
|
elemLayout: layoutPath + 'elem.html',
|
|
|
|
|
sys: {
|
|
|
|
|
scale: Cfg.scale(cfg.scale || 1)
|
|
|
|
|
},
|
2023-07-20 00:31:09 +00:00
|
|
|
|
copyright: `Created By ${Version.name}<span class="version">${Version.yunzai}</span>${pluginName}</span>`,
|
2023-03-08 21:29:30 +00:00
|
|
|
|
pageGotoParams: {
|
|
|
|
|
waitUntil: 'networkidle2'
|
|
|
|
|
}
|
2022-10-26 20:28:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-08 21:29:30 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
2022-10-26 20:28:44 +00:00
|
|
|
|
}
|
2023-03-08 21:29:30 +00:00
|
|
|
|
|
2023-12-22 16:03:58 +00:00
|
|
|
|
export default Render
|