云崽名从package读取

This commit is contained in:
小花花花儿 2024-01-25 00:56:49 +08:00
parent 08b2773a9f
commit 12e280b38c
12 changed files with 37 additions and 16 deletions

View File

@ -1,22 +1,23 @@
import fs from 'node:fs' import fs from 'node:fs'
import _ from 'lodash' import _ from 'lodash'
import cfg from '../../../lib/config/config.js'
import { Common, Version } from '#miao' import { Common, Version } from '#miao'
import { Character } from '#miao.models' import { Character } from '#miao.models'
export default class base { export default class base {
constructor (e = {}) { constructor(e = {}) {
this.e = e this.e = e
this.userId = e?.user_id this.userId = e?.user_id
this.model = 'genshin' this.model = 'genshin'
this._path = process.cwd().replace(/\\/g, '/') this._path = process.cwd().replace(/\\/g, '/')
} }
get prefix () { get prefix() {
return `Yz:genshin:${this.model}:` return `Yz:genshin:${this.model}:`
} }
// 统一封装渲染 // 统一封装渲染
async renderImg (tpl, data, cfg = {}) { async renderImg(tpl, data, cfg = {}) {
return Common.render('genshin', `html/${tpl}`, data, { return Common.render('genshin', `html/${tpl}`, data, {
...cfg, ...cfg,
e: this.e e: this.e
@ -29,12 +30,23 @@ export default class base {
* @param tplFile 模板html路径 * @param tplFile 模板html路径
* @param pluResPath 插件资源路径 * @param pluResPath 插件资源路径
*/ */
get screenData () { get screenData() {
const layoutPath = process.cwd() + '/plugins/genshin/resources/html/layout/' const layoutPath = process.cwd() + '/plugins/genshin/resources/html/layout/'
let yunzaiName = cfg.package.name
if (yunzaiName == 'miao-yunzai') {
yunzaiName = 'Miao-Yunzai'
} else if (yunzaiName == 'yunzai') {
yunzaiName = 'Yunzai-Bot'
} else if (yunzaiName == 'trss-yunzai') {
yunzaiName = 'TRSS-Yunzai'
} else {
yunzaiName = _.capitalize(yunzaiName)
}
let data = { let data = {
saveId: this.userId, saveId: this.userId,
cwd: this._path, cwd: this._path,
yzVersion: `v${Version.yunzai}`, yzVersion: `v${Version.yunzai}`,
yzName: yunzaiName,
genshinLayout: layoutPath + 'genshin.html', genshinLayout: layoutPath + 'genshin.html',
defaultLayout: layoutPath + 'default.html' defaultLayout: layoutPath + 'default.html'
} }

View File

@ -63,14 +63,23 @@ export default class ExportLog extends base {
if (!this.uid) return false if (!this.uid) return false
let list = this.getAllList().list let list = this.getAllList().list
let yunzaiName = cfg.package.name
if (yunzaiName == 'miao-yunzai') {
yunzaiName = 'Miao-Yunzai'
} else if (yunzaiName == 'yunzai') {
yunzaiName = 'Yunzai-Bot'
} else if (yunzaiName == 'trss-yunzai') {
yunzaiName = 'TRSS-Yunzai'
} else {
yunzaiName = _.capitalize(yunzaiName)
}
let data = { let data = {
info: { info: {
uid: this.uid, uid: this.uid,
lang: list[0].lang, lang: list[0].lang,
export_time: moment().format('YYYY-MM-DD HH:mm:ss'), export_time: moment().format('YYYY-MM-DD HH:mm:ss'),
export_timestamp: moment().format('X'), export_timestamp: moment().format('X'),
export_app: 'Miao-Yunzai', export_app: yunzaiName,
export_app_version: cfg.package.version, export_app_version: cfg.package.version,
}, },
list list

View File

@ -42,7 +42,7 @@
</div> </div>
</div> </div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div> <div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -120,7 +120,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="logo">Created By Miao-Yunzai</div> --> <!-- <div class="logo">Created By {{yzName}}</div> -->
</div> </div>
</body> </body>
<script type="text/javascript" src="{{pluResPath.replace('StarRail/', '')}}script/qrcode.min.js"></script> <script type="text/javascript" src="{{pluResPath.replace('StarRail/', '')}}script/qrcode.min.js"></script>

View File

@ -77,7 +77,7 @@
<li><span>#删除无效用户</span>: 删除当前所有请求失效的用户的CK数据暂不会删除公共CK</li> <li><span>#删除无效用户</span>: 删除当前所有请求失效的用户的CK数据暂不会删除公共CK</li>
</ul> </ul>
</div> </div>
<div class="copyright">Created By Miao-Yunzai</div> <div class="copyright">Created By {{yzName}}</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -77,7 +77,7 @@
</div> </div>
</div> </div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -115,7 +115,7 @@
<div class="logo">左下角为使用次数,仅展示已有行动牌</div> <div class="logo">左下角为使用次数,仅展示已有行动牌</div>
</div> </div>
{{/if}} {{/if}}
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -50,7 +50,7 @@
</div> </div>
</div> </div>
{{/each}} {{/each}}
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -18,7 +18,7 @@
<body class="body_box"> <body class="body_box">
<div class="container" id="container"> <div class="container" id="container">
{{block 'main'}}{{/block}} {{block 'main'}}{{/block}}
<div class="logo">Created By Miao-Yunzai {{yzVersion}}</div> <div class="logo">Created By {{yzName}} {{yzVersion}}</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -42,7 +42,7 @@
</div> </div>
</div> </div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div> <div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -120,7 +120,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="logo">Created By Miao-Yunzai</div> --> <!-- <div class="logo">Created By {{yzName}}</div> -->
</div> </div>
</body> </body>
<script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script> <script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script>

View File

@ -52,7 +52,7 @@
<div class="tab_lable">详细统计</div> <div class="tab_lable">详细统计</div>
<div id="chartContainer2"></div> <div id="chartContainer2"></div>
</div> </div>
<div class="logo">Created By Miao-Yunzai & seven-plugin</div> <div class="logo">Created By {{yzName}} & seven-plugin</div>
</div> </div>
</body> </body>