Skip to content

Commit 9dc89e0

Browse files
committed
fix:99烟花成就
1 parent 28dd64c commit 9dc89e0

6 files changed

Lines changed: 29 additions & 14 deletions

File tree

docs/project/achievement-statistics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ v2 points 的业务数据是 `ID -> [point, general, visible]` 映射。当前
128128

129129
## 6. 99 烟花口径
130130

131-
当前后端没有“99 烟花”专门分类字段,前端在 `FIREWORK_ACHIEVEMENT_IDS` 中维护 65 项正向 ID 白名单:
131+
当前后端没有“99 烟花”专门分类字段,65 项正向 ID 白名单统一维护在公共库的
132+
`@jx3box/jx3box-common/data/firework_achievement_ids.json` 中,PVX 通过 `FIREWORK_ACHIEVEMENT_IDS` 引用:
132133

133134
- 当前上限为 `65 项 / 13,000 资历`
134135
- 它是常规可见成就的专题子集,分类卡标注“已计入常规”。

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"dependencies": {
3434
"@element-plus/icons-vue": "^2.3.2",
35-
"@jx3box/jx3box-common": "^9.2.9",
35+
"@jx3box/jx3box-common": "^9.5.3",
3636
"@jx3box/jx3box-data": "^3.9.6",
3737
"@jx3box/jx3box-editor": "^3.2.13",
3838
"@jx3box/jx3box-emotion": "^1.3.0",

scripts/test-achievement-statistics.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const assert = require("assert");
22
const path = require("path");
33
const babel = require("@babel/core");
4+
const fireworkAchievementIds = require("@jx3box/jx3box-common/data/firework_achievement_ids.json");
45

56
function loadModule(file) {
67
const result = babel.transformFileSync(file, {
@@ -27,6 +28,7 @@ const {
2728

2829
assert.strictEqual(FIREWORK_ACHIEVEMENT_IDS.length, 65);
2930
assert.strictEqual(new Set(FIREWORK_ACHIEVEMENT_IDS).size, 65);
31+
assert.deepStrictEqual(FIREWORK_ACHIEVEMENT_IDS, fireworkAchievementIds);
3032
assert.strictEqual(FIREWORK_ACHIEVEMENT_IDS.includes(1573), true);
3133
assert.strictEqual(FIREWORK_ACHIEVEMENT_IDS.includes(1707), false);
3234
assert.strictEqual(FIREWORK_ACHIEVEMENT_IDS.includes(4493), false);

src/utils/achievementStatistics.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
export const FIREWORK_ACHIEVEMENT_IDS = Object.freeze([
2-
1573, 4444, 4495, 4649, 5077, 5079, 5295, 5304, 5342, 5688, 5828, 5841, 6046, 6192, 6274, 6826, 6829, 6846, 6878,
3-
7130, 7288, 7291, 7488, 7492, 7613, 7617, 8469, 8473, 8476, 8480, 9092, 9107, 9411, 9414, 9450, 9453, 9456, 9531,
4-
10030, 10036, 10165, 10169, 10210, 10292, 10827, 10835, 11021, 11024, 11077, 11082, 11457, 11460, 11473, 11595,
5-
11598, 11642, 11646, 11650, 12099, 12106, 12327, 12331, 12544, 12624, 12631,
6-
]);
1+
import fireworkAchievementIds from "@jx3box/jx3box-common/data/firework_achievement_ids.json";
2+
3+
export const FIREWORK_ACHIEVEMENT_IDS = Object.freeze([...fireworkAchievementIds]);
74

85
function appendAchievementIds(value, target) {
96
if (Array.isArray(value)) {

src/views/wiki/overview.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,20 @@ import {
363363
UserFilled,
364364
WarningFilled,
365365
} from "@element-plus/icons-vue";
366+
367+
function createImageAssetMap(context) {
368+
return context.keys().reduce((assets, path) => {
369+
const name = path.replace(/^\.\//, "").replace(/\.png$/, "");
370+
assets[name] = context(path);
371+
return assets;
372+
}, {});
373+
}
374+
375+
const CATEGORY_TITLE_IMAGES = createImageAssetMap(
376+
require.context("@/assets/img/wiki/overview/title", false, /\.png$/)
377+
);
378+
const CATEGORY_ITEM_IMAGES = createImageAssetMap(require.context("@/assets/img/wiki/overview/item", false, /\.png$/));
379+
366380
export default {
367381
name: "wiki-achievement-overview",
368382
props: [],
@@ -418,7 +432,8 @@ export default {
418432
},
419433
categoryTitleImage() {
420434
if (!this.viewAchievementsName) return "";
421-
return require(`@/assets/img/wiki/overview/title/${this.viewAchievementsName}.png`);
435+
const rootCategoryName = this.categoryPath[0]?.name || this.viewAchievementsName;
436+
return CATEGORY_TITLE_IMAGES[rootCategoryName] || "";
422437
},
423438
avatar_frame() {
424439
if (this.userInfo) {
@@ -729,7 +744,7 @@ export default {
729744
window.scrollTo({ top: 0, behavior: "smooth" });
730745
},
731746
getCategoryImage(name) {
732-
return require(`@/assets/img/wiki/overview/item/${name}.png`);
747+
return CATEGORY_ITEM_IMAGES[name] || "";
733748
},
734749
onEnterCategory(data) {
735750
if (data.children) {

0 commit comments

Comments
 (0)