Skip to content

Commit bd37e3e

Browse files
committed
♻️ 战绩世界探索数据结构调整
1 parent 286c1e2 commit bd37e3e

File tree

6 files changed

+89
-20
lines changed

6 files changed

+89
-20
lines changed

src/components/userRecord/tur-world-sub.vue

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@
99
<div class="tur-ws-content">
1010
<div class="tur-ws-title">
1111
<span>{{ data.name }}</span>
12-
<span v-if="data.offering" class="tur-ws-sub">
13-
<img :src="data.offering.icon" alt="offer" />
14-
<span>{{ data.offering.name }}-</span>
15-
<span>{{ data.offering.level }}</span>
12+
<span v-if="data.offerings?.length === 1" class="tur-ws-sub">
13+
<img :src="data.offerings[0].icon" alt="offer" />
14+
<span>{{ data.offerings[0].name }}-</span>
15+
<span>{{ data.offerings[0].level }}</span>
16+
<span>级</span>
17+
</span>
18+
</div>
19+
<div class="tur-ws-offerings" v-if="data.offerings && data.offerings.length > 1">
20+
<span
21+
v-for="(offer, idx) in data.offerings"
22+
:key="idx"
23+
class="tur-ws-sub"
24+
:title="offer.name + '-' + offer.level + '级'"
25+
>
26+
<img :src="offer.icon" alt="offer" />
27+
<span>{{ offer.level }}</span>
1628
<span>级</span>
1729
</span>
1830
</div>
@@ -33,6 +45,24 @@
3345
<span>%</span>
3446
</div>
3547
</div>
48+
<div
49+
v-if="
50+
data.area_exploration_list &&
51+
data.area_exploration_list.length > 0 &&
52+
data.exploration < 1000
53+
"
54+
class="tur-ws-areas"
55+
>
56+
<span
57+
v-for="area in data.area_exploration_list.filter((i) => i.exploration_percentage < 1000)"
58+
:key="area.name"
59+
class="tur-ws-sub"
60+
>
61+
<span>{{ area.name }}:</span>
62+
<span>{{ Math.min(area.exploration_percentage / 10, 100) }}</span>
63+
<span>%</span>
64+
</span>
65+
</div>
3666
<div v-if="data.reputation" class="tur-ws-sub">
3767
<span>声望等级:</span>
3868
<span>{{ data.reputation }}</span>
@@ -84,6 +114,7 @@ const icon = computed<string>(() => {
84114
}
85115
86116
.tur-ws-icon {
117+
position: relative;
87118
z-index: 1;
88119
width: 64px;
89120
height: 64px;
@@ -96,6 +127,7 @@ const icon = computed<string>(() => {
96127
}
97128
98129
.tur-ws-content {
130+
position: relative;
99131
z-index: 1;
100132
width: calc(100% - 68px);
101133
height: 100%;
@@ -111,6 +143,21 @@ const icon = computed<string>(() => {
111143
font-size: 18px;
112144
}
113145
146+
.tur-ws-offerings {
147+
display: flex;
148+
align-items: center;
149+
justify-content: start;
150+
column-gap: 8px;
151+
}
152+
153+
.tur-ws-areas {
154+
display: flex;
155+
flex-wrap: wrap;
156+
align-items: center;
157+
justify-content: start;
158+
gap: 4px 8px;
159+
}
160+
114161
.tur-ws-sub {
115162
display: flex;
116163
align-items: center;

src/pages/User/Record.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ async function loadRecord(): Promise<void> {
113113
const record = await TSUserRecord.getRecord(uidCur.value);
114114
if (!record) return;
115115
recordData.value = record;
116+
console.log(recordData.value);
116117
}
117118
118119
async function refreshRecord(): Promise<void> {

src/plugins/Sqlite/utils/transUserRecord.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,12 @@ function transStat(data: TGApp.Game.Record.Stats): TGApp.Sqlite.Record.Stats {
124124
/**
125125
* @description 将探索信息转换为数据库中的数据
126126
* @since Beta v0.8.1
127-
* @param {TGApp.Game.Record.WorldExplore[]} data 城市探索信息
128-
* @returns {TGApp.Sqlite.Record.WorldExplore[]} 转换后的城市探索信息
127+
* @param {Array<TGApp.Game.Record.WorldExplore>} data 城市探索信息
128+
* @returns {Array<TGApp.Sqlite.Record.WorldExplore>} 转换后的城市探索信息
129129
*/
130-
function transWorld(data: TGApp.Game.Record.WorldExplore[]): TGApp.Sqlite.Record.WorldExplore[] {
130+
function transWorld(
131+
data: Array<TGApp.Game.Record.WorldExplore>,
132+
): Array<TGApp.Sqlite.Record.WorldExplore> {
131133
const areaParent = data.filter((i) => i.parent_id === 0);
132134
const areaChild = data.filter((i) => i.parent_id !== 0);
133135
const worlds: TGApp.Sqlite.Record.WorldExplore[] = [];
@@ -141,16 +143,11 @@ function transWorld(data: TGApp.Game.Record.WorldExplore[]): TGApp.Sqlite.Record
141143
bg: area.background_image,
142144
cover: area.cover,
143145
exploration: area.exploration_percentage,
146+
area_exploration_list: area.area_exploration_list,
144147
children: [],
145148
};
146149
if (area.type === "Reputation") world.reputation = area.level;
147-
if (area.offerings !== undefined && area.offerings.length > 0) {
148-
world.offering = {
149-
name: area.offerings[0].name,
150-
level: area.offerings[0].level,
151-
icon: area.offerings[0].icon,
152-
};
153-
}
150+
if (area.offerings !== undefined && area.offerings.length > 0) world.offerings = area.offerings;
154151
// 对纳塔的特殊处理
155152
if (area.name === "纳塔") {
156153
world.icon =

src/types/Game/Record.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ declare namespace TGApp.Game.Record {
175175
/**
176176
* @description 世界探索信息类型
177177
* @interface WorldExplore
178-
* @since Beta 0.7.2
178+
* @since Beta 0.8.1
179179
* @property {number} level - 声望等级
180180
* @property {number} exploration_percentage - 探索千分比
181181
* @property {string} icon - 图标
@@ -195,7 +195,7 @@ declare namespace TGApp.Game.Record {
195195
* @property {boolean} index_active - 索引激活
196196
* @property {boolean} detail_active - 详细激活
197197
* @property {number} seven_status_level - 七天神像等级
198-
* @property {NataReputation[] | null} nata_reputation - 纳塔声望
198+
* @property {NataReputation | null} nata_reputation - 纳塔声望
199199
* @property {number} world_type - 世界类型
200200
*/
201201
type WorldExplore = {
@@ -212,7 +212,7 @@ declare namespace TGApp.Game.Record {
212212
background_image: string;
213213
inner_icon: string;
214214
cover: string;
215-
area_exploration_list: Array<unknown>;
215+
area_exploration_list: Array<AreaExploration>;
216216
boss_list: Array<unknown>;
217217
is_hot: boolean;
218218
index_active: boolean;
@@ -232,6 +232,15 @@ declare namespace TGApp.Game.Record {
232232
*/
233233
type WorldOffering = { name: string; level: number; icon: string };
234234

235+
/**
236+
* @description 区域探索类型
237+
* @interface AreaExploration
238+
* @since Beta v0.8.1
239+
* @property {string} name - 名称
240+
* @property {number} exploration_percentage - 探索千分比
241+
*/
242+
type AreaExploration = { name: string; exploration_percentage: number };
243+
235244
/**
236245
* @description 纳塔声望类型
237246
* @interface NataReputation

src/types/Sqlite/Record.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@ declare namespace TGApp.Sqlite.Record {
137137
/**
138138
* @description 世界探索信息类型
139139
* @interface WorldExplore
140-
* @since Beta v0.7.2
140+
* @since Beta v0.8.1
141141
* @property {number} id - 地区 ID
142142
* @property {string} name - 地区名称
143143
* @property {string} iconLight - 地区图标(亮)
144144
* @property {string} bg - 背景
145145
* @property {string} cover - 封面
146146
* @property {number} reputation - 地区声望等级
147147
* @property {WorldOffering} offering - 地区供奉信息
148+
* @property {Array<WorldOffering>} offerings - 地区供奉列表
148149
* @property {number} exploration - 地区探索进度
149150
* @property {Array<WorldChild>} children - 子地区
150151
*/
@@ -156,8 +157,13 @@ declare namespace TGApp.Sqlite.Record {
156157
bg: string;
157158
cover: string;
158159
reputation?: number;
160+
/**
161+
* @deprecated 已弃用,建议使用 offerings
162+
*/
159163
offering?: WorldOffering;
164+
offerings?: Array<WorldOffering>;
160165
exploration: number;
166+
area_exploration_list?: Array<AreaExploration>;
161167
children: Array<WorldChild>;
162168
};
163169

@@ -171,6 +177,15 @@ declare namespace TGApp.Sqlite.Record {
171177
*/
172178
type WorldOffering = { name: string; level: number; icon: string };
173179

180+
/**
181+
* @description 区域探索类型
182+
* @interface AreaExploration
183+
* @since Beta v0.8.1
184+
* @property {string} name - 名称
185+
* @property {number} exploration_percentage - 探索千分比
186+
*/
187+
type AreaExploration = { name: string; exploration_percentage: number };
188+
174189
/**
175190
* @description 子地区类型
176191
* @interface WorldChild

src/utils/toolFunc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @file utils/toolFunc.ts
33
* @description 一些工具函数
4-
* @since Beta v0.8.0
4+
* @since Beta v0.8.1
55
*/
66

77
import { AvatarExtResTypeEnum, AvatarExtTypeEnum } from "@enum/bbs.js";
@@ -220,7 +220,7 @@ export function isColorSimilar(colorBg: string, colorText: string): boolean {
220220

221221
/**
222222
* @description 解析带样式的文本
223-
* @since Beta v0.8.0
223+
* @since Beta v0.8.1
224224
* @param {string} desc - 带样式的文本
225225
* @returns {string} 解析后的文本
226226
*/

0 commit comments

Comments
 (0)