mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
优化更新面板异常回复
This commit is contained in:
parent
a5c6ee4a37
commit
1bbfb8cf0f
2 changed files with 20 additions and 15 deletions
|
|
@ -66,7 +66,6 @@ export class Panel extends ZZZPlugin {
|
||||||
const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e))
|
const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e))
|
||||||
let result
|
let result
|
||||||
if (isEnka) {
|
if (isEnka) {
|
||||||
await this.reply('正在更新面板列表,请稍候...');
|
|
||||||
const data = await refreshPanelFromEnka(uid)
|
const data = await refreshPanelFromEnka(uid)
|
||||||
.catch(err => err)
|
.catch(err => err)
|
||||||
if (data instanceof Error) {
|
if (data instanceof Error) {
|
||||||
|
|
@ -82,22 +81,28 @@ export class Panel extends ZZZPlugin {
|
||||||
result = await mergePanel(uid, panelList)
|
result = await mergePanel(uid, panelList)
|
||||||
await this.getPlayerInfo(playerInfo)
|
await this.getPlayerInfo(playerInfo)
|
||||||
} else if (typeof data === 'number') {
|
} else if (typeof data === 'number') {
|
||||||
return this.reply(`Enka服务调用失败,状态码:${data}${data === 424 ? '\n版本更新后,须等待一段时间才可正常使用enka服务' : ''}`);
|
return this.reply(`Enka服务调用失败,状态码:${data}`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const { api, deviceFp } = await this.getAPI();
|
const oriReply = this.reply.bind(this);
|
||||||
await this.reply('正在更新面板列表,请稍候...\n账号异常时,可尝试%更新展柜面板(所更新角色数据与实际不一致时,请提issue)');
|
let errorMsg = '';
|
||||||
await this.getPlayerInfo();
|
this.reply = (msg) => errorMsg += '\n' + msg;
|
||||||
await redis.set(`ZZZ:PANEL:${uid}:LASTTIME`, Date.now());
|
try {
|
||||||
result = await refreshPanelFunction(api, deviceFp).catch(e => {
|
const { api, deviceFp } = await this.getAPI();
|
||||||
this.reply(e.message);
|
await oriReply('正在更新面板列表,请稍候...');
|
||||||
throw e;
|
await this.getPlayerInfo();
|
||||||
});
|
await redis.set(`ZZZ:PANEL:${uid}:LASTTIME`, Date.now());
|
||||||
}
|
result = await refreshPanelFunction(api, deviceFp);
|
||||||
if (!result) {
|
} catch (err) {
|
||||||
await this.reply('面板列表更新失败,请稍后再试');
|
logger.error('面板列表更新失败:', err);
|
||||||
return false;
|
errorMsg = (err.message || '') + errorMsg;
|
||||||
|
}
|
||||||
|
this.reply = oriReply;
|
||||||
|
if (errorMsg && !result) {
|
||||||
|
return this.reply(`面板列表更新失败,请稍后再试或尝试%更新展柜面板:\n${errorMsg.trim()}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!result) return false;
|
||||||
const newChar = result.filter(item => item.isNew);
|
const newChar = result.filter(item => item.isNew);
|
||||||
const finalData = {
|
const finalData = {
|
||||||
newChar: newChar.length,
|
newChar: newChar.length,
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@
|
||||||
<div class="properties">
|
<div class="properties">
|
||||||
<div class="prop-icon {{prop.classname}}"></div>
|
<div class="prop-icon {{prop.classname}}"></div>
|
||||||
{{if prop.score !== false}}
|
{{if prop.score !== false}}
|
||||||
<div class="label yellow hit{{prop.base_score * 100}}">
|
<div class="label yellow hit{{prop.base_score * 100 - (prop.base_score * 100 % 25)}}">
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="label yellow">
|
<div class="label yellow">
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue