Skip to content

Commit

Permalink
📝 (fixed sid translate)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreedzt committed Mar 24, 2022
1 parent 803af28 commit 39923ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/pages/admin/CodeQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const CodeQuery: FC<CodeQueryProps> = ({ loading, onQuery }) => {
<p>xp: number; // XP</p>
<p>rp: number; // RP</p>
<p>squad_tag: string; // 小队名称</p>
<p>sid: string; // Steam ID</p>
<p>sid: string; // sid</p>
<p>time_played: number; // 游玩时间</p>
<p>kills: number; // 击杀数</p>
<p>deaths: number; // 死亡数</p>
Expand Down
26 changes: 13 additions & 13 deletions src/pages/admin/PersonList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
personList: [],
});
/**
映射关系: [steamId, [profile_id]]
映射关系: [sid, [profile_id]]
*/
const steamIdMapRef = useRef<Map<string, number[]>>(new Map());
const sidMapRef = useRef<Map<string, number[]>>(new Map());
const allProfileIdMapRef = useRef<Map<number, PersonListItem>>(new Map());

useImperativeHandle(
Expand All @@ -62,7 +62,7 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
try {
const personListRes = await PersonService.queryAll();

steamIdMapRef.current.clear();
sidMapRef.current.clear();
allProfileIdMapRef.current.clear();

personListRes.forEach((info) => {
Expand All @@ -80,13 +80,13 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
associated_count: 1,
};

const steamIdMapValue = steamIdMapRef.current.get(resInfo.sid);
const sidMapValue = sidMapRef.current.get(resInfo.sid);

if (steamIdMapValue === undefined) {
steamIdMapRef.current.set(resInfo.sid, [resInfo.profile_id]);
if (sidMapValue === undefined) {
sidMapRef.current.set(resInfo.sid, [resInfo.profile_id]);
} else {
steamIdMapRef.current.set(resInfo.sid, [
...steamIdMapValue,
sidMapRef.current.set(resInfo.sid, [
...sidMapValue,
resInfo.profile_id,
]);
}
Expand All @@ -95,9 +95,9 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
});

allProfileIdMapRef.current.forEach((info) => {
const steamIdMapValue = steamIdMapRef.current.get(info.sid);
const sidMapValue = sidMapRef.current.get(info.sid);

info.associated_count = steamIdMapValue?.length ?? 1;
info.associated_count = sidMapValue?.length ?? 1;
});

const extractedRes: PersonListItem[] = Array.from(
Expand All @@ -123,7 +123,7 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {

const onQueryUniqueBySid = useCallback(() => {
/**
steamId 唯一, 大号优先
* sid 唯一, 大号优先
*/
const tempMap = new Map<string, PersonListItem>();

Expand Down Expand Up @@ -168,7 +168,7 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
);

const onQueryAssociatedModal = useCallback((targetSid: string) => {
const profileIdList = steamIdMapRef.current.get(targetSid) ?? [];
const profileIdList = sidMapRef.current.get(targetSid) ?? [];

const modalPersonList: PersonListItem[] = [];

Expand Down Expand Up @@ -209,7 +209,7 @@ const PersonList = forwardRef<PersonListRef>((_props, ref) => {
过滤出所有五星人形
</Button>
<Button loading={queryLoading} onClick={onQueryUniqueBySid}>
Steam ID 唯一过滤(游玩时间优先)
sid 唯一过滤(游玩时间优先)
</Button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const PersonListItemMapper: Record<keyof PersonListItem, string> = {
xp: "XP",
rp: "RP",
squad_tag: "小队名称",
sid: "Steam ID",
sid: "sid",
time_played: "游玩时间",
kills: "击杀数",
deaths: "死亡数",
Expand Down

0 comments on commit 39923ed

Please sign in to comment.