mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 09:27:34 +00:00
面板服务增加MiniGG-API,#喵喵设置
中可区分国服、B服、外服分别设置面板服务器
This commit is contained in:
parent
276dba9b7e
commit
25a7103321
@ -1,3 +1,10 @@
|
||||
# 2.3.2
|
||||
|
||||
* 面板服务增加国内专属面板服务 MiniGG-API
|
||||
* 由小灰灰大佬**@MiniGrayGay**与Enka官方合作部署
|
||||
* 国内节点,免费开放,请求速度会比Enka更快
|
||||
* `#喵喵设置`中可区分国服、B服、外服分别设置面板服务器,具体参见喵喵设置
|
||||
|
||||
# 2.3.1
|
||||
|
||||
* MiaoApi面板服务更新
|
||||
|
@ -68,13 +68,13 @@ export const cfgSchema = {
|
||||
input: (n) => Math.min(30, Math.max(5, (n * 1 || 15))),
|
||||
desc: '可选值5~30,建议15。设置高排名人数会提高图片的长度,图片较大可能会影响渲染与发送速度'
|
||||
},
|
||||
profileServ: {
|
||||
profileServer: {
|
||||
title: '面板服务',
|
||||
key: '面板服务',
|
||||
type: 'num',
|
||||
def: 1,
|
||||
input: (n) => n * 1 === 1 ? 1 : 2,
|
||||
desc: '面板服务优先选择:1:自动(具备有效Token时优先喵喵Api,否则Enka),2:Enka服务优先'
|
||||
def: 0,
|
||||
input: (n) => /[0-3]{1,3}/.test(n) ? n : 0,
|
||||
desc: '面板服务选择:0:自动,1:喵Api(需具备Token), 2:Enka-API, 3:MiniGG-Api。如设置三位数字则为分服务器设置,按顺序分别为 国服/B服/外服,例如112代表国服B服Miao,国外Enka'
|
||||
},
|
||||
costumeSplash: {
|
||||
title: '使用自定义面板插图',
|
||||
|
@ -4,16 +4,25 @@
|
||||
* */
|
||||
|
||||
export const miaoApi = {
|
||||
listApi: ({ uid, diyCfg }) => {
|
||||
listApi: ({ url, uid, diyCfg }) => {
|
||||
let qq = /\d{5,12}/.test(diyCfg.qq) ? diyCfg.qq : 'none'
|
||||
let token = diyCfg.token
|
||||
return `http://miaoapi.cn/profile/data?uid=${uid}&qq=${qq}&token=${token}&version=2`
|
||||
url = url || 'http://miaoapi.cn/'
|
||||
return `${url}profile/data?uid=${uid}&qq=${qq}&token=${token}&version=2`
|
||||
}
|
||||
}
|
||||
|
||||
export const enkaApi = {
|
||||
url: 'https://enka.network/',
|
||||
userAgent: 'Miao-Plugin/3.0',
|
||||
userAgent: 'Miao-Plugin/3.1',
|
||||
listApi: ({ url, uid, diyCfg }) => {
|
||||
return `${url}api/uid/${uid}/`
|
||||
}
|
||||
}
|
||||
|
||||
export const mggApi = {
|
||||
url: 'https://profile.microgg.cn/',
|
||||
userAgent: 'Miao-Plugin/3.1',
|
||||
listApi: ({ url, uid, diyCfg }) => {
|
||||
return `${url}api/uid/${uid}/`
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ export default class AvatarData extends Base {
|
||||
return {
|
||||
enka: 'Enka.Network',
|
||||
miao: '喵喵Api',
|
||||
mgg: 'MiniGG-API',
|
||||
mys: '米游社'
|
||||
}[this._source] || this._source
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import lodash from 'lodash'
|
||||
import { Data } from '../../components/index.js'
|
||||
import EnkaData from './EnkaData.js'
|
||||
import MiaoData from './MiaoData.js'
|
||||
|
||||
let HttpsProxyAgent = ''
|
||||
|
||||
@ -53,17 +52,6 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
profileData (data) {
|
||||
let ret = {}
|
||||
lodash.forEach(data.avatarInfoList, (ds) => {
|
||||
let profile = EnkaData.getProfile(ds)
|
||||
if (profile && profile.id) {
|
||||
ret[profile.id] = profile
|
||||
}
|
||||
})
|
||||
return ret
|
||||
},
|
||||
|
||||
// 获取冷却时间
|
||||
cdTime (data) {
|
||||
return data.ttl || 60
|
||||
|
@ -3,7 +3,7 @@ import { attrMap, idsMap, artisIdxMap } from './ProfileMeta.js'
|
||||
import { Character, ArtifactSet } from '../index.js'
|
||||
|
||||
let EnkaData = {
|
||||
setAvatar (player, data) {
|
||||
setAvatar (player, data, dataSource = 'enka') {
|
||||
let char = Character.get(data.avatarId)
|
||||
if (!char) {
|
||||
return
|
||||
@ -20,7 +20,7 @@ let EnkaData = {
|
||||
weapon: EnkaData.getWeapon(data.equipList),
|
||||
talent: talentRet.talent,
|
||||
artis: EnkaData.getArtifact(data.equipList)
|
||||
}, 'enka')
|
||||
}, dataSource)
|
||||
return avatar
|
||||
},
|
||||
|
||||
|
46
models/player/MggApi.js
Normal file
46
models/player/MggApi.js
Normal file
@ -0,0 +1,46 @@
|
||||
import lodash from 'lodash'
|
||||
import { Data } from '../../components/index.js'
|
||||
import EnkaData from './EnkaData.js'
|
||||
|
||||
export default {
|
||||
id: 'mgg',
|
||||
name: 'MiniGG-Api',
|
||||
cfgKey: 'mggApi',
|
||||
// 处理请求参数
|
||||
async request (api) {
|
||||
let params = {
|
||||
headers: { 'User-Agent': this.getCfg('userAgent') }
|
||||
}
|
||||
return { api, params }
|
||||
},
|
||||
|
||||
// 处理服务返回
|
||||
async response (data, req) {
|
||||
if (!data.playerInfo) {
|
||||
if (data.error) {
|
||||
console.log(`Enka ReqErr: ${data.error}`)
|
||||
}
|
||||
return req.err('error', 60)
|
||||
}
|
||||
let details = data.avatarInfoList
|
||||
if (!details || details.length === 0 || !details[0].propMap) {
|
||||
return req.err('empty', 5 * 60)
|
||||
}
|
||||
return data
|
||||
},
|
||||
|
||||
updatePlayer (player, data) {
|
||||
player.setBasicData(Data.getData(data, 'name:nickname,face:profilePicture.avatarID,card:nameCardID,level,word:worldLevel,sign:signature'))
|
||||
lodash.forEach(data.avatarInfoList, (ds) => {
|
||||
let ret = EnkaData.setAvatar(player, ds, 'mgg')
|
||||
if (ret) {
|
||||
player._update.push(ret.id)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 获取冷却时间
|
||||
cdTime (data) {
|
||||
return data.ttl || 60
|
||||
}
|
||||
}
|
@ -6,6 +6,10 @@ export default {
|
||||
key: 'miao',
|
||||
name: '喵喵Api',
|
||||
cfgKey: 'miaoApi',
|
||||
async request (api) {
|
||||
api = this.getCfg('api') || api
|
||||
return { api }
|
||||
},
|
||||
async response (data, req) {
|
||||
if (data.status !== 0) {
|
||||
return req.err(data.msg || 'error', 60)
|
||||
|
@ -2,12 +2,25 @@ import { ProfileReq, ProfileServ } from '../index.js'
|
||||
import { Cfg, Data } from '../../components/index.js'
|
||||
import MysAvatar from './MysAvatar.js'
|
||||
|
||||
import enkaCfg from './EnkaApi.js'
|
||||
import MiaoApi from './MiaoApi.js'
|
||||
import enkaApi from './EnkaApi.js'
|
||||
import miaoApi from './MiaoApi.js'
|
||||
import mggApi from './MggApi.js'
|
||||
|
||||
let { diyCfg } = await Data.importCfg('profile')
|
||||
|
||||
const Profile = {
|
||||
servs: {},
|
||||
serv (key) {
|
||||
if (!Profile.servs[key]) {
|
||||
Profile.servs[key] = new ProfileServ({
|
||||
miao: miaoApi,
|
||||
mgg: mggApi,
|
||||
enka: enkaApi
|
||||
}[key])
|
||||
}
|
||||
return Profile.servs[key]
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据UID分配请求服务器
|
||||
* @param uid
|
||||
@ -16,17 +29,24 @@ const Profile = {
|
||||
getServ (uid) {
|
||||
let token = diyCfg?.miaoApi?.token
|
||||
let qq = diyCfg?.miaoApi?.qq
|
||||
let hasToken = !!(qq && token && token.length === 32 && !/^test/.test(token))
|
||||
|
||||
if (qq && token && token.length === 32 && !/^test/.test(token) && Cfg.get('profileServ') === 1) {
|
||||
if (!Profile.Miao) {
|
||||
Profile.Miao = new ProfileServ(MiaoApi)
|
||||
// 判断国服、B服、外服,获取在配置中的idx
|
||||
let servIdx = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2 }[uid[0]]
|
||||
|
||||
// 获取对应服务选择的配置数字,0自动,1喵,2Enka,3Mgg
|
||||
let servCfg = Cfg.get('profileServer', '0').toString() || '0'
|
||||
servCfg = servCfg[servIdx] || servCfg[0] || '0'
|
||||
|
||||
if ((servCfg === '0' || servCfg === '1') && hasToken) {
|
||||
return Profile.serv('miao')
|
||||
}
|
||||
return Profile.Miao
|
||||
if (servCfg === '2') {
|
||||
return Profile.serv('enka')
|
||||
} else if (servCfg === '3') {
|
||||
return Profile.serv('mgg')
|
||||
}
|
||||
if (!Profile.Enka) {
|
||||
Profile.Enka = new ProfileServ(enkaCfg)
|
||||
}
|
||||
return Profile.Enka
|
||||
return Profile.serv(servIdx === 2 ? 'enka' : 'mgg')
|
||||
},
|
||||
|
||||
/**
|
||||
@ -64,7 +84,7 @@ const Profile = {
|
||||
|
||||
isProfile (avatar) {
|
||||
// 检查数据源
|
||||
if (!avatar._source || !['enka', 'change', 'miao'].includes(avatar._source)) {
|
||||
if (!avatar._source || !['enka', 'change', 'miao', 'mgg'].includes(avatar._source)) {
|
||||
return false
|
||||
}
|
||||
// 检查武器及天赋
|
||||
|
@ -78,7 +78,7 @@
|
||||
</div>
|
||||
|
||||
<div class="copyright data-source">
|
||||
数据源:{{ {miao:'喵喵API', 'enka':'Enka.Network', mys:'米游社'}[data.source]||data.source }} {{data.updateTime}}
|
||||
数据源:{{ {miao:'喵喵API', 'enka':'Enka.Network', 'mgg':'MiniGG-API', mys:'米游社'}[data.source]||data.source }} {{data.updateTime}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{if custom}}
|
||||
|
Loading…
Reference in New Issue
Block a user