同步 Miao-Yunzai 更新

This commit is contained in:
🌌 2023-06-01 15:02:01 +08:00
parent f4f3a1580f
commit 9e9073971e
3 changed files with 46 additions and 14 deletions

View File

@ -67,9 +67,47 @@ export default class Runtime {
}
static async init (e) {
e.runtime = new Runtime(e)
e.user = await MysInfo.getNoteUser(e)
return e.runtime
await MysInfo.initCache()
let runtime = new Runtime(e)
e.runtime = runtime
e.game = e.isSr ? 'sr' : 'gs'
await runtime.initUser()
return runtime
}
async initUser () {
let e = this.e
let user = await NoteUser.create(e)
if (user) {
e.user = new Proxy(user, {
get (self, key, receiver) {
let game = e.isSr ? 'sr' : 'gs'
let fnMap = {
uid: 'getUid',
uidList: 'getUidList',
mysUser: 'getMysUser',
ckUidList: 'getCkUidList'
}
if (fnMap[key]) {
return self[fnMap[key]](game)
}
if (key === 'uidData') {
return self.getUidData('', game)
}
if (['getUid', 'getUidList', 'getMysUser', 'getCkUidList', 'getUidMapList', 'getGameDs'].includes(key)) {
return (_game, arg2) => {
return self[key](_game || game, arg2)
}
}
if (['getUidData', 'hasUid', 'addRegUid', 'delRegUid', 'setMainUid'].includes(key)) {
return (uid, _game = '') => {
return self[key](uid, _game || game)
}
}
return self[key]
}
})
}
}
/**
@ -89,10 +127,6 @@ export default class Runtime {
return await MysInfo.getUid(this.e)
}
async getSelfUid () {
return await MysInfo.getSelfUid(this.e)
}
/**
* 获取MysApi实例
*

View File

@ -46,7 +46,8 @@ app.get('/', function (req, res) {
})
app.get('/:page', function (req, res) {
let [plugin, app, page] = req.params.page.split('_')
let [plugin, app, ...page] = req.params.page.split('_')
page = page.join('_')
if (plugin == 'favicon.ico') {
return res.send('')
}
@ -60,12 +61,9 @@ app.get('/:page', function (req, res) {
data.pluResPath = data._res_path
}
let htmlPath = ''
if (data._plugin === 'genshin') {
htmlPath = 'html/'
}
let tplPath = `${app}/${htmlPath}${page}/${page}.html`
if (data._plugin) {
tplPath = `../plugins/${data._plugin}/resources/${htmlPath}/${app}/${page}.html`
tplPath = `../plugins/${data._plugin}/resources/${htmlPath}/${app}/${page.split('_').join('/')}.html`
} else if (data._no_type_path) {
tplPath = `${app}/${page}.html`
}

View File

@ -30,8 +30,8 @@
"node-schedule": "^2.1.1",
"node-xlsx": "^0.23.0",
"pm2": "^5.3.0",
"puppeteer": "^20.4.0",
"redis": "^4.6.6",
"puppeteer": "^20.5.0",
"redis": "^4.6.7",
"sequelize": "^6.31.1",
"sqlite3": "^5.1.6",
"ws": "^8.13.0",