2023-08-29 21:02:57 +08:00
|
|
|
import fs from 'node:fs'
|
|
|
|
import _ from 'lodash'
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
export default class base {
|
2023-06-12 20:35:53 +08:00
|
|
|
constructor(e = {}) {
|
2023-03-04 14:30:13 +08:00
|
|
|
this.e = e
|
|
|
|
this.userId = e?.user_id
|
|
|
|
this.model = 'genshin'
|
|
|
|
this._path = process.cwd().replace(/\\/g, '/')
|
|
|
|
}
|
|
|
|
|
2023-06-12 20:35:53 +08:00
|
|
|
get prefix() {
|
2023-03-04 14:30:13 +08:00
|
|
|
return `Yz:genshin:${this.model}:`
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 截图默认数据
|
|
|
|
* @param saveId html保存id
|
|
|
|
* @param tplFile 模板html路径
|
|
|
|
* @param pluResPath 插件资源路径
|
|
|
|
*/
|
2023-06-12 20:35:53 +08:00
|
|
|
get screenData() {
|
2023-08-29 21:02:57 +08:00
|
|
|
if (this.e?.isSr) {
|
|
|
|
let headImg = _.sample(fs.readdirSync(`${this._path}/plugins/genshin/resources/StarRail/img/worldcard`).filter(file => file.endsWith('.png')))
|
2023-08-18 10:19:48 +08:00
|
|
|
return {
|
|
|
|
saveId: this.userId,
|
|
|
|
cwd: this._path,
|
|
|
|
tplFile: `./plugins/genshin/resources/StarRail/html/${this.model}/${this.model}.html`,
|
|
|
|
/** 绝对路径 */
|
|
|
|
pluResPath: `${this._path}/plugins/genshin/resources/StarRail/`,
|
2023-08-29 21:02:57 +08:00
|
|
|
headStyle: `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/StarRail/img/worldcard/${headImg}) #fff; background-position-x: -10px; background-repeat: no-repeat; background-size: 540px; background-position-y: -100px; </style>`,
|
2023-08-19 19:48:02 +08:00
|
|
|
srtempFile: 'StarRail/'
|
2023-08-18 10:19:48 +08:00
|
|
|
}
|
2023-08-29 21:02:57 +08:00
|
|
|
}
|
2023-10-07 19:33:25 +08:00
|
|
|
|
2023-08-29 21:02:57 +08:00
|
|
|
let headImg = _.sample(fs.readdirSync(`${this._path}/plugins/genshin/resources/img/namecard`).filter(file => file.endsWith('.png')))
|
2023-03-04 14:30:13 +08:00
|
|
|
return {
|
|
|
|
saveId: this.userId,
|
|
|
|
cwd: this._path,
|
|
|
|
tplFile: `./plugins/genshin/resources/html/${this.model}/${this.model}.html`,
|
|
|
|
/** 绝对路径 */
|
|
|
|
pluResPath: `${this._path}/plugins/genshin/resources/`,
|
2023-08-29 21:02:57 +08:00
|
|
|
headStyle: `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/img/namecard/${headImg}) #fff; background-position-x: 42px; background-repeat: no-repeat; background-size: auto 101%; }</style>`,
|
2023-08-19 19:48:02 +08:00
|
|
|
srtempFile: ''
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|