初步增加Meta数据管理

This commit is contained in:
Kokomi 2023-10-20 04:18:30 +08:00
parent 4eae5af34e
commit dc7cb7a9bb
10 changed files with 1564 additions and 8 deletions

98
components/Meta.js Normal file
View File

@ -0,0 +1,98 @@
import lodash from 'lodash'
const Store = {}
const Meta = {
// 获取存储
getStore (game, dataType) {
Store[game] = Store[game] || {}
Store[game][dataType] = Store[game][dataType] || {
meta: {},
alias: {},
abbr: {}
}
return Store[game][dataType]
},
// 添加数据
addMeta (game, dataType, data, pk = 'id') {
let { meta, alias } = Meta.getStore(game, dataType)
lodash.forEach(data, (ds, id) => {
id = ds[pk] || id
meta[id] = ds
alias[id] = id
if (ds.name) {
alias[ds.name] = id
}
})
},
// 添加简写
addAbbr (game, dataType, data) {
let { abbr, alias } = Meta.getStore(game, dataType)
lodash.forEach(data, (abbr, id) => {
abbr[id] = abbr
alias[abbr] = alias[id] || id
})
},
// 添加别名
addAlias (game, dataType, data) {
let { alias } = Meta.getStore(game, dataType)
lodash.forEach(data, (txt, id) => {
lodash.forEach(txt.split(','), (t) => {
alias[lodash.trim(t.toLowerCase())] = alias[id] || id
})
})
},
// 注册别名Fn
addAliasFn (game, dataType, fn) {
let store = Meta.getStore(game, dataType)
if (fn) {
store.aliasFn = fn
}
},
// 根据别名获取数据ID
getId (game, dataType, txt) {
txt = lodash.trim(txt.toLowerCase())
let { alias, aliasFn } = Meta.getStore(game, dataType)
if (alias[txt]) {
return alias[txt]
}
if (aliasFn) {
let id = aliasFn(txt)
if (alias[id]) {
return alias
}
}
return false
},
// 在各个游戏内匹配以传入的game优先
matchGame (game = 'gs', dataType, txt) {
txt = lodash.trim(txt.toLowerCase())
let games = game === 'gs' ? ['gs', 'sr'] : ['sr', 'gs']
for (let currGame of games) {
let id = Meta.getId(currGame, dataType, txt)
if (id) {
let meta = Meta.getMeta(currGame, dataType, id)
return { game, id, meta }
}
}
return false
},
// 根据别名获取数据
getMeta (game, dataType, txt) {
txt = lodash.trim(txt.toLowerCase())
let id = Meta.getId(game, dataType, txt)
let { meta } = Meta.getStore(game, dataType)
return meta[id]
}
}
export default Meta

View File

@ -5,5 +5,6 @@ import Cfg from './Cfg.js'
import Version from './Version.js'
import App from './App.js'
import MiaoError from './MiaoError.js'
import Meta from './Meta.js'
export { Data, Cfg, Format, Common, Version, App, MiaoError }
export { Data, Cfg, Format, Common, Version, App, MiaoError, Meta }

View File

@ -6,7 +6,7 @@
* */
import lodash from 'lodash'
import Base from './Base.js'
import { Data, Format, Cfg } from '#miao'
import { Data, Format, Cfg, Meta } from '#miao'
import CharImg from './character/CharImg.js'
import CharTalent from './character/CharTalent.js'
import CharId from './character/CharId.js'

View File

@ -11,6 +11,7 @@ import { Avatar, ProfileRank, Character } from './index.js'
import MysAvatar from './avatar/MysAvatar.js'
import ProfileAvatar from './avatar/ProfileAvatar.js'
import Trans from './player/PlayerTrans.js'
Data.createDir('/data/UserData', 'root')
Data.createDir('/data/PlayerData/gs', 'root')
@ -407,3 +408,7 @@ export default class Player extends Base {
return avatarRet
}
}
setTimeout(() => {
Trans.init()
}, 500)

View File

@ -154,10 +154,6 @@ const CharId = {
return false
},
getTravelerId (id, game = 'gs') {
return id * 1 === 10000005 ? 10000005 : 10000007
},
getSrMeta (name) {
return srData?.[aliasMap[name]] || {}
}

View File

@ -12,7 +12,7 @@ let Trans = {
if (uids.length === 0) {
return
}
console.log('准备将面板数据迁移至data/PlayerData/gs...')
console.log('miao-plugin: 准备将面板数据迁移至data/PlayerData/gs...')
lodash.forEach(uids, (uid) => {
uid = uid.replace('.json', '')
let ret = Trans.trans(uid)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
import { Data, Meta } from '#miao'
import { alias } from './meta.js'
let data = Data.readJSON('resources/meta/character/data.json', 'miao')
Meta.addMeta('gs', 'char', data)
Meta.addAlias('gs', 'char', alias)
export const game = 'gs'
export const dataType = 'char'

View File

@ -0,0 +1,88 @@
import lodash from 'lodash'
export const alias = {
// 1.0
: 'Jean,团长,代理团长,琴团长,蒲公英骑士',
丽莎: 'Lisa,图书管理员,图书馆管理员,蔷薇魔女,阿姨',
: '男主,男主角,龙哥,空哥,男爷',
: '女主,女主角,莹,萤,黄毛阿姨,荧妹,女爷,包包,宴宁',
旅行者: '主角,卑鄙的外乡人,荣誉骑士,爷,主,履刑者,抽卡不歪真君',
芭芭拉: 'Barbara,巴巴拉,内鬼,加湿器,肉身解咒,肉身解咒真君,闪耀偶像,偶像',
凯亚: 'Kaeya,盖亚,凯子哥,凯鸭,矿工,矿工头子,骑兵队长,凯子,凝冰渡海真君',
迪卢克: 'Diluc,卢姥爷,姥爷,卢老爷,卢锅巴,正义人,正e人,正E人,卢本伟,暗夜英雄,卢卢伯爵,落魄了,落魄了家人们',
雷泽: 'Razor,狼少年,狼崽子,狼崽,卢皮卡,小狼,小狼狗,狼孩',
安柏: 'Amber,安伯,兔兔伯爵,飞行冠军,侦查骑士,点火姬,点火机,打火机,打火姬',
温迪: 'Venti,温蒂,风神,卖唱的,巴巴托斯,巴巴脱丝,芭芭托斯,芭芭脱丝,干点正事,不干正事,吟游诗人,诶嘿,唉嘿,摸鱼',
香菱: 'Xiangling,香玲,锅巴,厨师,万民堂厨师,香师傅',
北斗: 'Beidou,大姐头,大姐,无冕的龙王',
行秋: 'Xingqiu,秋秋人,秋妹妹,书呆子,枕玉,飞云商会二少爷',
: 'Xiao,打桩机,插秧,三眼五显仙人,三眼五显真人,降魔大圣,护法夜叉,快乐风男,无聊,靖妖傩舞,矮子仙人,三点五尺仙人,跳跳虎,风夜叉',
凝光: 'Ningguang,富婆,天权星,天权',
可莉: '逃跑的太阳,Klee,嘟嘟可,火花骑士,蹦蹦炸弹,炸鱼,放火烧山,放火烧山真君,蒙德最强战力,逃跑的太阳,啦啦啦,哒哒哒,炸弹人,禁闭室,太阳,小太阳',
钟离: 'Zhongli,摩拉克斯,岩王爷,岩神,钟师傅,天动万象,岩王帝君,未来可期,帝君,拒收病婿',
菲谢尔: 'Fischl,皇女,小艾米,小艾咪,奥兹,断罪皇女,中二病,中二少女,中二皇女,奥兹发射器',
班尼特: 'Bennett,点赞哥,点赞,倒霉少年,倒霉蛋,霹雳闪雷真君,班神,班爷,倒霉,火神,六星真神',
达达利亚: 'Tartaglia,Childe,Ajax,达达鸭,达达利鸭,公子,玩具销售员,玩具推销员,钱包,鸭鸭,愚人众末席',
诺艾尔: 'Noelle,女仆,高达,岩王帝姬',
七七: 'Qiqi,僵尸,肚饿真君,度厄真君,77',
重云: 'Chongyun,纯阳之体,冰棍',
甘雨: 'Ganyu,椰羊,椰奶,王小美',
阿贝多: 'Albedo,可莉哥哥,升降机,升降台,电梯,白垩之子,贝爷,白垩,阿贝少,花呗多,阿贝夕,阿师傅',
迪奥娜: 'Diona,迪欧娜,dio娜,冰猫,猫猫,猫娘,喵喵,调酒师',
莫娜: 'Mona,穷鬼,穷光蛋,穷,莫纳,占星术士,占星师,讨龙真君,半部讨龙真君,阿斯托洛吉斯·莫娜·梅姬斯图斯,梅姬斯图斯,梅姬斯图斯姬',
刻晴: 'Keqing,刻情,氪晴,刻师傅,刻师父,牛杂,牛杂师傅,斩尽牛杂,免疫,免疫免疫,屁斜剑法,玉衡星,阿晴,啊晴,璃月雷神',
砂糖: 'Sucrose,sucrose',
辛焱: 'Xinyan,辛炎,黑妹,摇滚',
罗莎莉亚: 'Rosaria,罗莎莉娅,白色史莱姆,白史莱姆,修女,罗莎利亚,罗莎利娅,罗沙莉亚,罗沙莉娅,罗沙利亚,罗沙利娅,萝莎莉亚,萝莎莉娅,萝莎利亚,萝莎利娅,萝沙莉亚,萝沙莉娅,萝沙利亚,萝沙利娅',
胡桃: 'Hu Tao,HuTao,Hutao,胡淘,往生堂堂主,火化,抬棺的,蝴蝶,核桃,堂主,胡堂主,雪霁梅香,桃子,桃',
枫原万叶: 'Kaedehara Kazuha,Kazuha,万叶,叶天帝,天帝,叶师傅',
烟绯: 'Yanfei,烟老师,律师,罗翔',
优菈: 'Eula,优拉,尤拉,尤菈,浪花骑士,记仇,劳伦斯',
// 2.0
神里绫华: 'Kamisato Ayaka,Ayaka,神里,绫华,神里凌华,凌华,白鹭公主,神里大小姐,龟,龟龟,乌龟',
宵宫: 'Yoimiya,霄宫,烟花,肖宫,肖工,绷带女孩',
雷电将军: 'Raiden Shogun,Raiden,雷神,将军,雷军,巴尔,阿影,影,巴尔泽布,煮饭婆,奶香一刀,无想一刀,宅女',
早柚: 'Sayu,小狸猫,狸猫,忍者,貉',
珊瑚宫心海: 'Sangonomiya Kokomi,Kokomi,心海,军师,珊瑚宫,书记,观赏鱼,水母,鱼,美人鱼',
九条裟罗: 'Kujou Sara,Sara,九条,九条沙罗,裟罗,沙罗,天狗',
埃洛伊: 'Aloy',
托马: 'Thoma,家政官,太郎丸,地头蛇,男仆,拖马',
五郎: 'Gorou,柴犬,土狗,希娜,希娜小姐',
荒泷一斗: 'Arataki Itto,Itto,荒龙一斗,荒泷天下第一斗,一斗,一抖,荒泷,1斗,牛牛,斗子哥,牛子哥,牛子,孩子王,斗虫,巧乐兹,放牛的',
八重神子: 'Yae Miko,Miko,八重,神子,狐狸,想得美哦,巫女,屑狐狸,骚狐狸,八重宫司,婶子,小八,八重寄子,寄子,八神虫子,八神重子',
鹿野院平藏: 'shikanoin heizou,Heizou,鹿野苑,鹿野院,平藏,鹿野苑平藏,小鹿',
夜兰: 'Yelan,夜阑,叶澜,腋兰,夜天后',
申鹤: 'Shenhe,神鹤,小姨,小姨子,审鹤',
云堇: 'Yun Jin,yun jin,云瑾,云先生,云锦,神女劈观',
久岐忍: 'Kuki Shinobu,Kuki,Shinobu,97忍,小忍,久歧忍,97,茄忍,茄子,紫茄子,阿忍,忍姐',
神里绫人: 'Kamisato Ayato,Ayato,绫人,神里凌人,凌人,0人,神人,零人,大舅哥',
// 3.0
绮良良: 'Kirara,大猫猫,大喵喵,稻妻猫猫,绮娘娘,琦良良,良良,快递员,草猫,草猫猫,草喵,草喵喵,猫又',
提纳里: 'Tighnari,提那里,小提,驴',
柯莱: 'Collei,柯来,科莱,科来,小天使,须弥安柏,草安柏,须弥飞行冠军',
多莉: 'Dori,多利,多力,奸商',
妮露: 'Nilou,尼露,妮璐,舞娘,红牛',
赛诺: 'Cyno,塞诺,胡狼,大风纪官,大风机关',
坎蒂丝: 'Candace,坎迪斯',
纳西妲: 'Nahida,草神,小吉祥,大吉祥,小草神,大慈树王,小吉祥草王,草萝莉,羽毛球,摩诃善法大吉祥智慧主,智慧主,智慧之神,布耶尔',
莱依拉: 'Layla,莱依菈,来依菈,来依拉',
流浪者: 'Wanderer,散兵,国崩,雷电国崩,大炮,雷电大炮,雷大炮,伞兵,斯卡拉姆齐',
珐露珊: 'Faruzan,法露珊,法璐珊,法露姗,法璐姗,珐露姗,珐璐姗,百岁珊,百岁山,前辈,仙贝',
瑶瑶: 'Yaoyao,遥遥,萝卜,月桂',
艾尔海森: 'Alhaitham,海哥,埃尔海森,海森,海参,书记官',
迪希雅: 'Dehya,迪希亚,迪希娅,迪西雅,迪西亚',
米卡: 'Mika,鹦鹉,凤头,凤头鹦鹉',
卡维: 'Kaveh,艾尔海森室友',
白术: 'Baizhu,长生',
// 4.0
琳妮特: 'Lynette,林妮特,林尼特,琳尼特,女魔术师,魔术猫,魔术喵,登登',
林尼: 'Lyney,林妮,琳尼,琳妮,男魔术师,魔术师',
菲米尼: 'Freminet,非米尼,潜水员',
莱欧斯利: 'Wriothesley,莱欧,枫丹桑博',
那维莱特: 'Neuvillette,那维,水龙王,水龙,审判官,海獭',
夏洛蒂: 'Charlotte,夏洛,夏洛帝,记者,小记者',
芙宁娜: 'Furina,Focalors,水神,芙芙,芙卡洛斯',
}

View File

@ -1274,7 +1274,7 @@
"star": 4
},
"": {
"id": "n113056",
"id": "n113054",
"name": "",
"type": "weekly",
"star": 5