Skip to content

Commit

Permalink
fix(filter):Fixed the Palu list data search and filtering bug (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
lozyHao authored Feb 27, 2024
1 parent 8ccfeb3 commit 3e3f22d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
14 changes: 12 additions & 2 deletions web/src/views/MobileHome/MobileHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NTag, NButton, useMessage, useDialog } from "naive-ui";
import { useI18n } from "vue-i18n";
import ApiService from "@/service/api";
import dayjs from "dayjs";
import palMap from "@/assets/pal.json";
import skillMap from "@/assets/skill.json";
import PlayerList from "./component/PlayerList.vue";
import GuildList from "./component/GuildList.vue";
Expand Down Expand Up @@ -126,8 +127,17 @@ const clickSearch = (searchValue) => {
if (searchValue && !pattern.test(searchValue)) {
playerPalsList.value = playerInfo.value.pals.filter((item) => {
return (
item.skills.some((skill) => skill.includes(searchValue)) ||
item.typeName.includes(searchValue)
item.skills.some((skill) => {
return (
skillMap[locale.value][skill]
? skillMap[locale.value][skill].name
: skill
).includes(searchValue);
}) ||
(palMap[locale.value][item.type]
? palMap[locale.value][item.type]
: item.type
).includes(searchValue)
);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/MobileHome/component/PlayerDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const finished = computed(() => props.finished);
const emits = defineEmits(["onSearch"]);
const handelPlayerAction = async (type) => {
if (!isLogin) {
if (!isLogin.value) {
message.error($t("message.requireauth"));
showLoginModal.value = true;
return;
Expand Down
1 change: 1 addition & 0 deletions web/src/views/PcHome/PcHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ const putWhiteList = async () => {
);
if (statusCode.value === 200) {
message.success(t("message.addwhitesuccess"));
getWhiteList();
showWhiteListModal.value = false;
} else {
message.error(t("message.addwhitefail", { err: data.value?.error }));
Expand Down
27 changes: 21 additions & 6 deletions web/src/views/PcHome/component/PlayerDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ const createPlayerPalsColumns = () => {
value,
})),
filter(value, row) {
return ~row.skills.indexOf(value);
return row.skills.some((skill) => {
return (
skillMap[locale.value][skill]
? skillMap[locale.value][skill].name
: skill
).includes(value);
});
},
},
{
Expand Down Expand Up @@ -175,8 +181,17 @@ const clickSearch = () => {
if (searchValue.value && !pattern.test(searchValue.value)) {
currentPalsList.value = playerInfo?.value.pals.filter((item) => {
return (
item.skills.some((skill) => skill.includes(searchValue.value)) ||
item.typeName.includes(searchValue.value)
item.skills.some((skill) => {
return (
skillMap[locale.value][skill]
? skillMap[locale.value][skill].name
: skill
).includes(searchValue.value);
}) ||
(palMap[locale.value][item.type]
? palMap[locale.value][item.type]
: item.type
).includes(searchValue.value)
);
});
} else {
Expand Down Expand Up @@ -242,7 +257,7 @@ const addWhiteList = async () => {
}
};
const handleAddWhiteList = () => {
if (isLogin) {
if (isLogin.value) {
addWhiteData.value.name = playerInfo.value.nickname;
addWhiteData.value.player_uid = playerInfo.value.player_uid;
addWhiteData.value.steam_id = playerInfo.value.steam_id;
Expand All @@ -267,7 +282,7 @@ const removeWhitelist = async (player) => {
// 封禁、踢出
const handelPlayerAction = async (type) => {
if (!isLogin) {
if (!isLogin.value) {
message.error($t("message.requireauth"));
showLoginModal.value = true;
return;
Expand Down Expand Up @@ -304,7 +319,7 @@ const handelPlayerAction = async (type) => {
// 获取白名单列表
const whiteList = computed(() => whitelistStore().getWhitelist());
const getWhiteList = async () => {
if (isLogin) {
if (isLogin.value) {
const { data, statusCode } = await new ApiService().getWhitelist();
if (statusCode.value === 200) {
if (data.value) {
Expand Down

0 comments on commit 3e3f22d

Please sign in to comment.