Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,26 @@ const unicorn = [
"unicorn/prefer-spread": "off",
"unicorn/no-array-reduce": "warn",
"unicorn/number-literal-case": "off",
"unicorn/no-array-for-each": "warn",
"unicorn/no-for-each": "warn",
"unicorn/prefer-global-this": "off",
"unicorn/no-array-reverse": "off",
"unicorn/no-array-sort": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/name-replacements": "off",
"unicorn/consistent-boolean-name": "off",
"unicorn/prefer-split-limit": "off",
"unicorn/prefer-dom-node-html-methods": "off",
"unicorn/prefer-simple-condition-first": "off",
"unicorn/no-computed-property-existence-check": "off",
"unicorn/better-dom-traversing": "off",
"unicorn/prefer-await": "off",
"unicorn/no-global-object-property-assignment": "off",
"unicorn/prefer-https": "off",
"unicorn/no-break-in-nested-loop": "off",
"unicorn/consistent-compound-words": "off",
"unicorn/no-unreadable-for-of-expression": "off",
"unicorn/no-declarations-before-early-exit": "off",
"unicorn/max-nested-calls": "off",
},
},
];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-prettier": "^5.5.6",
"eslint-plugin-unicorn": "^64.0.0",
"eslint-plugin-unicorn": "^72.0.0",
"eslint-plugin-vue": "^10.10.0",
"globals": "^17.8.0",
"prettier": "^3.9.6",
Expand Down
240 changes: 158 additions & 82 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ async function request({
let requestBody: BodyInit | undefined;

if (body && method === "POST") {
const formData = new URLSearchParams();
for (const [key, value] of Object.entries(body)) {
formData.append(key, value);
}
const formData = new URLSearchParams(body);
requestBody = formData;
headers["Content-Type"] = "application/x-www-form-urlencoded";
}

const response = await fetch(url.toString(), {
const response = await fetch(url.href, {
method,
headers,
body: requestBody,
Expand Down
2 changes: 1 addition & 1 deletion scripts/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));

async function main(): Promise<void> {
if (process.argv[2] === "-h" || process.argv.length < 4) {
console.log(String.raw`tsx scripts/update.ts username password`);
console.log("tsx scripts/update.ts username password");
return;
}

Expand Down
9 changes: 4 additions & 5 deletions src/components/CheckboxGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ function setState(value: string, state: boolean) {
if (stateMap.value[value] && !state) return;

if (!stateMap.value[value] && state) {
Object.keys(stateMap.value).find((key) => {
if (stateMap.value[key]) {
for (const [key, checked] of Object.entries(stateMap.value)) {
if (checked) {
stateMap.value[key] = false;
return true;
break;
}
return false;
});
}
stateMap.value[value] = true;
emit("update:modelValue", value);
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/OptionsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ const selectedOptions = useVModel(props, "modelValue", emit, {
deep: true,
});
const onTagClick = (option: string) => {
return selectedOptions.value.includes(option)
? selectedOptions.value.splice(selectedOptions.value.indexOf(option), 1)
: selectedOptions.value.push(option);
const index = selectedOptions.value.indexOf(option);
if (index === -1) selectedOptions.value.push(option);
else selectedOptions.value.splice(index, 1);
};
const selectAll = () => {
for (const option of props.options)
if (!selectedOptions.value.includes(option))
selectedOptions.value.push(option);
};
const selectNone = () => selectedOptions.value.splice(0);
const selectNone = () => {
selectedOptions.value = [];
};
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const checkboxCount = computed(() => {

const cur = computed({
get() {
return `${props.index}`;
return String(props.index);
},
set(v) {
emit("update:index", Number.parseInt(v));
Expand Down
2 changes: 1 addition & 1 deletion src/entries/AudioPlayerV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for (const element of Array.from(players)) {
lowSource: element.dataset?.low || "",
highSource: element.dataset?.high || "",
title: element.innerHTML,
p: Number.parseFloat(element.dataset?.p || "0"),
p: Number(element.dataset?.p || "0"),
};

createApp(AudioPlayerV2, props).mount(element);
Expand Down
9 changes: 5 additions & 4 deletions src/entries/ISEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for (const eventEle of Array.from(eventEles)) {
return {
etype: data.etype,
efloor: data.efloor?.split(",") || [],
edesc: scene.querySelectorAll(".edesc")[0]?.innerHTML,
edesc: scene.querySelector(".edesc")?.innerHTML,
name: data.name,
ename: data.ename,
nav: data.nav,
Expand All @@ -45,11 +45,11 @@ for (const eventEle of Array.from(eventEles)) {
type: chooseData.type,
icon: chooseData.icon,
iconId: chooseData.iconid,
desc1: choose.querySelectorAll(".desc1")[0]?.innerHTML,
desc2: choose.querySelectorAll(".desc2")[0]?.innerHTML,
desc1: choose.querySelector(".desc1")?.innerHTML,
desc2: choose.querySelector(".desc2")?.innerHTML,
dest: Number.parseInt(chooseData.dest || "0"),
customBadgeText:
choose.querySelectorAll(".customBadgeText")[0]?.innerHTML,
choose.querySelector(".customBadgeText")?.innerHTML,
subChoose: chooseData.subchoose,
index,
};
Expand All @@ -66,6 +66,7 @@ for (const eventEle of Array.from(eventEles)) {
if (scenes[0].efloor) {
sceneFloorList.push(...scenes[0].efloor);
sceneFloorList = Array.from(new Set(sceneFloorList));
// eslint-disable-next-line unicorn/require-array-sort-compare
sceneFloorList.sort();
}
sceneCategoryData.at(-1)?.push(scenes[0].ename || scenes[0].name || "???");
Expand Down
3 changes: 1 addition & 2 deletions src/entries/ItemList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ function readItemsFromDOM(): ItemData[] {
return iconId === ""
? getImagePath("无图片占位符.png")
: `${TORAPPU_ENDPOINT}/assets/item_icon/${iconId}.png`;
} else {
return filename;
}
return filename;
})();

items.push({
Expand Down
8 changes: 5 additions & 3 deletions src/entries/VoiceTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ const parseDetail = (children: HTMLCollection) => {
const detail: Record<string, string> = {};
const childrenArray = Array.from(children) as Array<HTMLElement>;
for (const child of childrenArray) {
if (child.dataset?.kindName !== undefined) {
detail[child.dataset.kindName || ""] = child.innerHTML;
langSet.add(child.dataset.kindName || "");
if (child.dataset?.kindName === undefined) {
continue;
}

detail[child.dataset.kindName || ""] = child.innerHTML;
langSet.add(child.dataset.kindName || "");
}

return detail;
Expand Down
2 changes: 1 addition & 1 deletion src/entries/XbMapViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const data = document.querySelector("#MAPDATA")?.textContent;
if (!ele && !data) {
console.error("data or ele not found", ele, data);
} else {
(window.RLQ = window.RLQ || []).push([
(window.RLQ ||= []).push([
"ext.gadget.tippy",
() => {
createApp(XbMapViewer, {
Expand Down
2 changes: 1 addition & 1 deletion src/entries/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ window.Sentry = {
captureException: Sentry.captureException,
};

(window.RLQ = window.RLQ || []).push([
(window.RLQ ||= []).push([
"mediawiki.user",
function () {
if (window.mw.user.isAnon()) {
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/ArkSign/getUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ export function skill(skillId: string) {
// No default
}
return `${TORAPPU_ENDPOINT}/assets/skill_icon/skill_icon_${skillId}.png`;
} else {
return `${STATIC_ENDPOINT}/charinfo/img/skland/skill_icon_none.png`;
}
return `${STATIC_ENDPOINT}/charinfo/img/skland/skill_icon_none.png`;
}

export function specialized(skills: Char["skills"], skillId: string) {
Expand Down
12 changes: 5 additions & 7 deletions src/widgets/ArkSign/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ const charList = ref<Char[]>([]);
function order() {
const selectedList: Char[] = [];
const result: Char[] = [];
for (const charId of Object.keys(charData.value)) {
for (const [charId, char] of Object.entries(charData.value)) {
const index = selected.value.indexOf(charId);
if (index !== -1) {
selectedList[index] = charData.value[charId];
selectedList[index] = char;
continue;
}
if (
Expand All @@ -130,7 +130,7 @@ function order() {
) {
continue;
}
result.push(charData.value[charId]);
result.push(char);
}
switch (selectSort.value) {
case "level": {
Expand Down Expand Up @@ -334,18 +334,16 @@ function calcEquipStyle(char: Char) {
return equipmentInfoMap.value[char.defaultEquipId].typeIcon === "original"
? "height:80%"
: "transform:translateY(-4%);height:100%;";
} else {
return "height:100%";
}
return "height:100%";
}
function calcAvatar(avatar: PlayerInfo["status"]["avatar"]) {
if (avatar.id) {
return avatar.type === "ICON"
? docAvatar(avatar.id)
: charAvatar(avatar.id);
} else {
return docAvatar("avatar_def_01");
}
return docAvatar("avatar_def_01");
}
function calcServerColor(id: string) {
if (id === "1") {
Expand Down
42 changes: 17 additions & 25 deletions src/widgets/CharList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ const oridata = computed(() => {
const o =
classes.indexOf(a.profession) - classes.indexOf(b.profession);
return o === 0 ? a.zh.localeCompare(b.zh, "zh") : o;
} else {
return r;
}
return r;
});
break;
}
Expand All @@ -239,9 +238,8 @@ const oridata = computed(() => {
const o =
classes.indexOf(a.profession) - classes.indexOf(b.profession);
return o === 0 ? a.zh.localeCompare(b.zh, "zh") : o;
} else {
return r;
}
return r;
});
break;
}
Expand Down Expand Up @@ -276,7 +274,7 @@ watch(states, () => {
}
});
watch(sortMethod, () => {
hash._o = `${sortMethods.value.indexOf(sortMethod.value)}`;
hash._o = String(sortMethods.value.indexOf(sortMethod.value));
});
watch(
currDataTypes,
Expand All @@ -291,46 +289,40 @@ watch(
{ deep: true },
);
watch(currDisplayMode, () => {
hash._d = `${displayModes.value.indexOf(currDisplayMode.value)}`;
hash._d = String(displayModes.value.indexOf(currDisplayMode.value));
});
onBeforeMount(() => {
// too hard to refactor
// eslint-disable-next-line unicorn/no-array-for-each
Object.entries(hash).forEach(([k, v]) => {
for (const [k, v] of Object.entries(hash)) {
if (k === "_s") {
searchText.value = v as string;
return;
continue;
}
if (k === "_o") {
sortMethod.value = sortMethods.value[Number.parseInt(v as string)];
return;
continue;
}
if (k === "_f") {
if (v.includes("p")) currDataTypes.value["满潜能"] = true;
if (v.includes("t")) currDataTypes.value["满信赖"] = true;
return;
continue;
}
if (k === "_d") {
currDisplayMode.value = displayModes.value[Number.parseInt(v as string)];
return;
continue;
}

const both = v[0] === "0";
const selected = (v as string).slice(2).split(";");
for (const state of states) {
for (const element of state) {
if (element.meta.field === k) {
element.both = both;
for (let f of selected) {
if (k === "rarity") f = `★${f}`;
const element = states.flat().find((element) => element.meta.field === k);
if (!element) continue;

element.selected[f] = true;
}
return;
}
}
element.both = both;
for (let f of selected) {
if (k === "rarity") f = `★${f}`;

element.selected[f] = true;
}
});
}
});

function hasSelected(states: State[]) {
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/CharList/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ const getLast = (str: string) => {
if (str.includes("→")) {
const arr = str.split("→");
return Number.parseInt(arr.at(-1)!);
} else {
return Number.parseInt(str);
}
return Number.parseInt(str);
};

export class Char {
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/EnemiesListV2/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ const filteredEnemyData = computed(() => {
if (filters[key].length > 0) {
if (
filterConfig.groups[0].filters.includes(key) &&
!filters[key].some(
filters[key].every(
(filter) =>
!!~enemy[key as keyof EnemyData].toString().indexOf(filter),
!~enemy[key as keyof EnemyData].toString().indexOf(filter),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这地方能不能改成includes啊

)
)
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/EquipList/components/EquipGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const groupedEquipData = computed<Record<string, CharEquips[]>>(() => {
}
}
}
for (const key of Object.keys(result)) {
result[key].sort((a, b) => {
for (const value of Object.values(result)) {
value.sort((a, b) => {
return a.char.rarity === b.char.rarity
? b.char.id - a.char.id
: Number.parseInt(b.char.rarity as string) -
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/EquipList/components/SubAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ const showEquips = inject("showEquips") as Ref<string[]>;
const toggleShow = (c: CharEquips) => {
if (c.equips.some((e) => !!e.name && showEquips.value.includes(e.name))) {
for (const equip of props.char.equips) {
if (!!equip.name && showEquips.value.includes(equip.name)) {
const ind = showEquips.value.indexOf(equip.name);
showEquips.value.splice(ind, 1);
if (!equip.name || !showEquips.value.includes(equip.name)) {
continue;
}

const ind = showEquips.value.indexOf(equip.name);
showEquips.value.splice(ind, 1);
}
showInfo.value = false;
} else {
Expand Down
Loading
Loading