mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
typo: 代码注释
This commit is contained in:
parent
51b3908afd
commit
4c90ca5354
12 changed files with 457 additions and 139 deletions
|
|
@ -11,7 +11,7 @@ import version from './version.js';
|
|||
* @param {object} cfg 配置
|
||||
* @returns
|
||||
*/
|
||||
function render(e, renderPath, renderData = {}, cfg = {}) {
|
||||
const render = (e, renderPath, renderData = {}, cfg = {}) => {
|
||||
// 判断是否存在e.runtime
|
||||
if (!e.runtime) {
|
||||
console.log('未找到e.runtime,请升级至最新版Yunzai');
|
||||
|
|
@ -30,31 +30,55 @@ function render(e, renderPath, renderData = {}, cfg = {}) {
|
|||
|
||||
// 调用e.runtime.render方法渲染
|
||||
return e.runtime.render(pluginName, renderPath, renderData, {
|
||||
// 合并传入的配置
|
||||
...cfg,
|
||||
beforeRender({ data }) {
|
||||
// 资源路径
|
||||
const resPath = data.pluResPath;
|
||||
// 布局路径
|
||||
const layoutPath = data.pluResPath + 'common/layout/';
|
||||
// 当前的渲染路径
|
||||
const renderPathFull = data.pluResPath + renderPath.split('/')[0] + '/';
|
||||
// 合并数据
|
||||
return {
|
||||
// 玩家信息
|
||||
player: e?.playerCard?.player,
|
||||
// 玩家头像
|
||||
avatar: e?.playerCard?.avatar,
|
||||
// 传入的数据
|
||||
...data,
|
||||
// 资源路径
|
||||
_res_path: resPath,
|
||||
// 布局路径
|
||||
_layout_path: layoutPath,
|
||||
// 默认布局路径
|
||||
defaultLayout: path.join(layoutPathFull, 'index.html'),
|
||||
// 系统配置
|
||||
sys: {
|
||||
// 缩放比例
|
||||
scale: pct,
|
||||
// 资源路径
|
||||
resourcesPath: resPath,
|
||||
// 当前渲染的路径
|
||||
currentPath: renderPathFull,
|
||||
/**
|
||||
* 下面两个模块的作用在于,你可以在你的布局文件中使用这两个模块,就可以显示用户信息和特殊标题,使用方法如下:
|
||||
* 1. 展示玩家信息:首先你要在查询的时候调用`this.getPlayerInfo()`,这样,玩家数据就会保存在`e.playerCard`中,然后你就可以在布局文件中使用`{{include sys.playerInfo}}`来展示玩家信息。
|
||||
* 2. 展示特殊标题:你可以在布局文件中使用`<% include(sys.specialTitle, {en: 'PROPERTY' , cn: '属性' , count: 6 }) %>`来展示特殊标题,其中`count`为可选参数,默认为9。
|
||||
*/
|
||||
// 玩家信息模块
|
||||
playerInfo: path.join(layoutPathFull, 'playerinfo.html'),
|
||||
// 特殊标题模块
|
||||
specialTitle: path.join(layoutPathFull, 'specialtitle.html'),
|
||||
// 版权信息
|
||||
copyright: `Created By ${version.name}<span class="version">${version.yunzai}</span> & ${pluginName}<span class="version">${version.version}</span>`,
|
||||
// 版权信息(简化版)
|
||||
createdby: `Created By <span class="highlight">${pluginName}</span> & Powered By <span class="highlight">ZZZure</span>`,
|
||||
},
|
||||
quality: 100,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default render;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue