diff --git a/service/guild.go b/service/guild.go
index ab84754..6f818b4 100644
--- a/service/guild.go
+++ b/service/guild.go
@@ -42,18 +42,28 @@ func ListGuilds(db *bbolt.DB) ([]database.Guild, error) {
return guilds, nil
}
-func GetGuild(db *bbolt.DB, adminPlayerUid string) (database.Guild, error) {
+func GetGuild(db *bbolt.DB, playerUID string) (database.Guild, error) {
var guild database.Guild
err := db.View(func(tx *bbolt.Tx) error {
b := tx.Bucket([]byte("guilds"))
- v := b.Get([]byte(adminPlayerUid))
- if v == nil {
- return ErrNoRecord
- }
- if err := json.Unmarshal(v, &guild); err != nil {
- return err
+
+ // 遍历bucket中的所有guild
+ c := b.Cursor()
+ for k, v := c.First(); k != nil; k, v = c.Next() {
+ var g database.Guild
+ if err := json.Unmarshal(v, &g); err != nil {
+ return err
+ }
+
+ // 检查当前guild的players是否包含指定的player_uid
+ for _, player := range g.Players {
+ if player.PlayerUid == playerUID {
+ guild = g
+ return nil
+ }
+ }
}
- return nil
+ return ErrNoRecord
})
if err != nil {
return database.Guild{}, err
diff --git a/web/src/assets/i18n.js b/web/src/assets/i18n.js
index bbbc067..e6dee63 100644
--- a/web/src/assets/i18n.js
+++ b/web/src/assets/i18n.js
@@ -55,6 +55,8 @@ const messages = {
detail: "Detail",
confirm: "Confirm",
cancel: "Cancel",
+ viewGuild: "View Guild",
+ viewPlayer: "View Player",
},
pal: {
type: "Type",
@@ -121,6 +123,8 @@ const messages = {
detail: "详情",
confirm: "确认",
cancel: "取消",
+ viewGuild: "查看公会",
+ viewPlayer: "查看玩家",
},
pal: {
type: "类型",
diff --git a/web/src/views/PcHome.vue b/web/src/views/PcHome.vue
index af4d7b3..0959610 100644
--- a/web/src/views/PcHome.vue
+++ b/web/src/views/PcHome.vue
@@ -5,6 +5,7 @@ import {
GroupWorkRound,
ContentCopyFilled,
SettingsPowerRound,
+ PersonSearchSharp
} from "@vicons/material";
import { GameController, LogOut, Ban, LanguageSharp } from "@vicons/ionicons5";
import { BroadcastTower } from "@vicons/fa";
@@ -102,11 +103,12 @@ const getPlayerList = async (is_update_info = true) => {
getPlayerInfo(playerList.value[0].player_uid);
}
};
-const getGuildList = async () => {
+const getGuildList = async (player_uid = '') => {
const { data } = await new ApiService().getGuildList();
guildList.value = data.value;
if (guildList.value.length > 0) {
- getGuildInfo(guildList.value[0].admin_player_uid);
+ let uid = player_uid ? player_uid : guildList.value[0].admin_player_uid;
+ getGuildInfo(uid);
}
};
@@ -414,20 +416,27 @@ const handleShutdown = () => {
}
};
-const toPlayers = async () => {
+const toPlayers = async (uid = '') => {
if (currentDisplay.value === "players") {
return;
}
await getPlayerList();
currentDisplay.value = "players";
};
-const toGuilds = async () => {
+const toGuilds = async (uid = '') => {
if (currentDisplay.value === "guilds") {
return;
}
- await getGuildList();
+ await getGuildList(uid);
currentDisplay.value = "guilds";
};
+const guildToPlayers = async (uid) => {
+ if (currentDisplay.value === "players") {
+ return;
+ }
+ await getPlayerInfo(uid);
+ currentDisplay.value = "players";
+};
/**
* check auth token
@@ -546,7 +555,7 @@ onMounted(async () => {
{{ $t("button.players") }}
{
+
+ {{ $t("button.viewGuild") }}
+
+
+
+
@@ -940,6 +962,19 @@ onMounted(async () => {
>
{{ $t("status.master") }}
+
+ {{ $t("button.viewPlayer") }}
+
+
+
+