From 9f190530d861674e0fda80521a954a2c785ccd93 Mon Sep 17 00:00:00 2001 From: TomyJan Date: Thu, 30 May 2024 22:28:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=B8=A3=E6=BD=AE=E5=8D=A1=E7=89=87[WI?= =?UTF-8?q?P]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/gameCard.js | 47 ++++- model/bbsActivityTask.js | 2 +- model/gameCard.js | 7 +- model/userConfig.js | 2 +- resources/html/gameCardMc/index.css | 259 ++++++++++++++++++++++++++ resources/html/gameCardMc/index.html | 69 +++++++ resources/html/gameCardPns/index.html | 4 +- 7 files changed, 381 insertions(+), 9 deletions(-) create mode 100644 resources/html/gameCardMc/index.css create mode 100644 resources/html/gameCardMc/index.html diff --git a/apps/gameCard.js b/apps/gameCard.js index 286137f..884a283 100644 --- a/apps/gameCard.js +++ b/apps/gameCard.js @@ -21,6 +21,10 @@ export class gameCard extends plugin { reg: '^#?战双(帕弥什)?(卡片|面板)(.*)$', fnc: 'gameCardPns', }, + { + reg: '^#?鸣潮?(卡片|面板)(.*)$', + fnc: 'gameCardMc', + }, ], }) } @@ -37,15 +41,15 @@ export class gameCard extends plugin { let user = new userConfig() if (await user.saveCurGameUidByIndex(this.e.user_id, index - 1, 2)) await this.reply(`已切换至第 ${index} 个账号, UID: ${(await user.getCurGameUidLocal(this.e.user_id, 2))?.gameUid}`) - else await this.reply(`切换账号失败`) + else await this.reply(`切换账号失败, 请检查索引是否正确`) } let data = await gameCardData.get(this.e, 'gameCardPns', this.e.user_id) if (!data) return false - let img = await this.cache(data) + let img = await this.cachePns(data) await this.reply(img) } - async cache(data) { + async cachePns(data) { let tmp = md5(JSON.stringify(data)) if (gameCard.pnsCardData.md5 === tmp) { return gameCard.pnsCardData.img @@ -61,4 +65,41 @@ export class gameCard extends plugin { md5: '', img: '', } + + async gameCardMc(e) { + kuroLogger.debug('鸣潮卡片:', e.msg) + // 提取消息文本末尾的数字 + let index = this.e.msg + .replace(/鸣潮|卡片|面板|:|:/g, '') + .replace(/,|,/g, ',') + .replace(/#| /g, '') + kuroLogger.debug('鸣潮卡片索引:', index) + if (index) { + let user = new userConfig() + if (await user.saveCurGameUidByIndex(this.e.user_id, index - 1, 3)) + await this.reply(`已切换至第 ${index} 个账号, UID: ${await user.getCurGameUidLocal(this.e.user_id, 3)?.gameUid}`) + else await this.reply(`切换账号失败, 请检查索引是否正确`) + } + let data = await gameCardData.get(this.e, 'gameCardMc', this.e.user_id) + if (!data) return false + let img = await this.cacheMc(data) + await this.reply(img) + } + + async cacheMc(data) { + let tmp = md5(JSON.stringify(data)) + if (gameCard.mcCardData.md5 === tmp) { + return gameCard.mcCardData.img + } + + gameCard.mcCardData.img = await puppeteer.screenshot('gameCardMc', data) + gameCard.mcCardData.md5 = tmp + + return gameCard.mcCardData.img + } + + static mcCardData = { + md5: '', + img: '', + } } diff --git a/model/bbsActivityTask.js b/model/bbsActivityTask.js index 0457c3e..32b324c 100644 --- a/model/bbsActivityTask.js +++ b/model/bbsActivityTask.js @@ -10,7 +10,7 @@ export default class bbsActivityTask { async bbsActivityTask() { const tokenData = await getToken(this.e.user_id) - console.log(tokenData) + kuroLogger.debug(`QQ ${this.e.user_id} 的 tokenData: ${tokenData}`) if (tokenData && Object.keys(tokenData).length > 0) { const accNum = Object.keys(tokenData).length diff --git a/model/gameCard.js b/model/gameCard.js index 8d7d65c..43a00f7 100644 --- a/model/gameCard.js +++ b/model/gameCard.js @@ -19,6 +19,9 @@ export default class gameCard { const tokenData = await getToken(e.user_id) if (tokenData && Object.keys(tokenData).length > 0) { + let gameId = 2 + if (model === 'gameCardMc') gameId = 3 + for (const kuro_uid in tokenData) { if (tokenData.hasOwnProperty(kuro_uid)) { let kuroapi = new kuroApi(e.user_id) @@ -26,7 +29,7 @@ export default class gameCard { let rsp_mineV2 = await kuroapi.mineV2(kuro_uid) let accName = rsp_mineV2?.data?.mine?.userName || '未知昵称' accName += ` (${kuro_uid})` - let rsp_roleList = await kuroapi.roleList(kuro_uid, { gameId: 2 }) + let rsp_roleList = await kuroapi.roleList(kuro_uid, { gameId }) let acc = { account: accName, msg: '', data: null } if (typeof rsp_roleList !== 'string') { if (rsp_roleList.data.length > 0) { @@ -52,7 +55,7 @@ export default class gameCard { let ret = { tplFile: `${resPath}/html/${model}/index.html`, accArr, - accCurPnsUidIndex: (await user.getCurGameUidIndex(e.user_id, 2)) + 1, + curGameUidIndex: (await user.getCurGameUidIndex(e.user_id, gameId)) + 1, pluResPath: _ResPath, pluginName, pluginVer, diff --git a/model/userConfig.js b/model/userConfig.js index 0718c9f..43e106e 100644 --- a/model/userConfig.js +++ b/model/userConfig.js @@ -171,7 +171,7 @@ export default class userConfig { * @param {number} uin QQ * @param {number} uidIndex uid 索引 * @param {number} gameId 游戏 id, 战双=2, 鸣潮=3 - * @returns {boolean} 是否成功 + * @returns {boolean} 是否成功, 失败一般原因是索引不存在 */ async saveCurGameUidByIndex(qq, uidIndex, gameId) { kuroLogger.debug(`保存用户 ${qq} 使用的游戏 ${gameId} 的 uid 索引 ${uidIndex}...`) diff --git a/resources/html/gameCardMc/index.css b/resources/html/gameCardMc/index.css new file mode 100644 index 0000000..0bad2c7 --- /dev/null +++ b/resources/html/gameCardMc/index.css @@ -0,0 +1,259 @@ +@font-face { + font-family: "MiSans-Normal"; + src: url("../../font/MiSans-Normal.ttf"); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "HYWenHei-55W"; + src: url("../../font/HYWenHei-55W.ttf"); + font-weight: normal; + font-style: normal; +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; + user-select: none; + font-family: MiSans-Normal +} + +body { + transform: scale(1); + width: 725px; + background: url(../../img/help/background/0.jpg) no-repeat; + background-size: cover; +} + +.container { + width: 745px; + padding: 20px 15px 10px 15px; +} + +.head-box { + margin: 60px 0 0 0; + padding-bottom: 0; +} + +.head-box .title { + font-size: 50px; + font-family: HYWenHei-55W +} + +.head-box .label { + font-family: HYWenHei-55W +} + +.cont-box { + margin-top: 20px; + margin-bottom: 30px; + overflow: hidden; + position: relative; + font-size: 20px; + background: rgba(62, 62, 62, 0.3); + + -webkit-backdrop-filter: blur(10px); + backdrop-filter: blur(10px); + border-radius: 30px; +} + +.help-group { + font-size: 20px; + font-weight: bold; + padding: 15px 15px 10px 20px; + display: inline-block; +} + +.list { + display: flex; + + flex-wrap: wrap; +} + + + +.mr-4 { + margin-right: 8px +} + +.mr-12 { + margin-right: 24px; +} + +.pd-16 { + padding: 32px +} + +.mb-16 { + margin-bottom: 32px +} + +div, +body { + box-sizing: border-box; + list-style: none; + margin: 0; + padding: 0 +} + +span, +div { + word-break: break-word; + vertical-align: middle + /*英文和中文竖直居中*/ +} + +.text-12 { + font-size: 24px; + line-height: 40px +} + +.text-14 { + font-size: 28px; + line-height: 44px +} + +.flex { + display: flex +} + +.flex-vertical-center { + display: flex; + align-items: center +} + +.game-box-container[data-v-08c4bfda] { + display: flex; + justify-content: center; + align-items: center; + width: 710px; + height: 304px +} + +.pns .game-box[data-v-08c4bfda] { + width: 662px; + height: 256px; + background: url(https://web-static.kurobbs.com/resource/prod/assets/game-box-pns-02781a5b.png); + background-size: 100% 100% +} + +.game-box[data-v-08c4bfda] { + position: absolute; + font-size: 32px; + color: #fff; + flex: 1 +} + +.game-box-header .icon[data-v-08c4bfda] { + width: 80px; + height: 80px; + border-radius: 8px +} + +.game-box-header .role-info[data-v-08c4bfda] { + flex: 1 +} + +.game-box-header .role-info .name[data-v-08c4bfda] { + font-weight: 700 +} + +.game-box-header .role-info .level[data-v-08c4bfda] { + height: 32px; + font-size: 24px; + line-height: 24px; + padding: 4px 8px; + color: #fff; + background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .32) 100%); + border: .8px solid rgba(255, 255, 255, .5); + border-radius: 4px +} + +.game-box-header .role-info .show[data-v-08c4bfda] { + margin-left: auto; + display: flex; + align-items: center; +} + +.game-box-header .sub-info[data-v-08c4bfda] { + color: #aeb6c2; + font-weight: 400; + opacity: .5 +} + +.game-box-footer[data-v-08c4bfda] { + + display: flex; + justify-content: space-between +} + +.game-box-footer .item[data-v-08c4bfda] { + flex: 1; + font-size: 24px; + line-height: 40px; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: flex-start; + color: #8c95a3 +} + +.game-box-footer .item .number[data-v-08c4bfda] { + display: flex; + align-items: center; + font-size: 32px; + line-height: 48px; + font-weight: 700; + color: #fff +} + +.game-box-footer .item .title[data-v-08c4bfda] { + width: 100%; + color: #8c95a3; + font-weight: 400; + text-align: center +} + +.game-box-footer .item .icon[data-v-08c4bfda] { + cursor: pointer +} + +.better-checkbox:checked { + border: none; + background: #1673ff +} + +.better-checkbox { + width: 32px; + height: 32px; + border: solid 3px #dddddd; + border-radius: 50%; + vertical-align: top; + margin-right: 8px; + position: relative; + appearance: none +} + +.better-checkbox:checked::after { + content: ''; + top: 9px; + left: 8px; + position: absolute; + background: transparent; + border: #fff solid 3px; + border-top: none; + border-right: none; + height: 8px; + width: 14px; + transform: rotate(-45deg) +} + +.copyright { + text-align: center; + font-size: 14px; + color: white; + font-family: HYWenHei-55W +} diff --git a/resources/html/gameCardMc/index.html b/resources/html/gameCardMc/index.html new file mode 100644 index 0000000..c31d091 --- /dev/null +++ b/resources/html/gameCardMc/index.html @@ -0,0 +1,69 @@ + + + + + + + + + + + +
+
+
鸣潮卡片 - 库洛插件
+
Handmade With ❤️ by TomyJan.
+
+ + + {{each accArr acc}} +
+
+ {{acc.account}}{{acc.data ? '' : acc.msg}} +
+
+ {{each acc.data item}} + +
+
+
+ +
+
+
{{@item.roleName}}
+
{{@item.gameLevel}}级
+
+ {{@countIndex === curGameUidIndex ? ' 当前' : 'No.' + countIndex}} +
+
+
+ {{@item.serverName}} | ID: {{@item.roleId}} +
+
+
+ +
+
+ {{/each}} +
+
+ {{/each}} + +
+ + + diff --git a/resources/html/gameCardPns/index.html b/resources/html/gameCardPns/index.html index bfea0fb..03721c3 100644 --- a/resources/html/gameCardPns/index.html +++ b/resources/html/gameCardPns/index.html @@ -32,8 +32,8 @@
{{@item.roleName}}
{{@item.gameLevel}}级
- {{@countIndex === accCurPnsUidIndex ? ' 当前' : 'No.' + countIndex}} + {{@countIndex === curGameUidIndex ? ' 当前' : 'No.' + countIndex}}