mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-20 04:39:45 +08:00
✨ 存储分区信息
This commit is contained in:
@@ -25,19 +25,21 @@ import { storeToRefs } from "pinia";
|
||||
import { onMounted, shallowRef } from "vue";
|
||||
|
||||
import { type NewsType, useAppStore } from "@/store/modules/app.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
|
||||
type ChannelItem = { icon: string; title: string; gid: number };
|
||||
type ToChannelProps = { gid?: string; curType?: string };
|
||||
|
||||
const bbsStore = useBBSStore();
|
||||
const { recentNewsType } = storeToRefs(useAppStore());
|
||||
const { gameList } = storeToRefs(bbsStore);
|
||||
const channelList = shallowRef<Array<ChannelItem>>();
|
||||
const props = defineProps<ToChannelProps>();
|
||||
const visible = defineModel<boolean>({ default: false });
|
||||
|
||||
onMounted(async () => {
|
||||
const allGames = await apiHubReq.game();
|
||||
channelList.value = allGames.map((i) => ({ icon: i.app_icon, title: i.name, gid: i.id }));
|
||||
if (gameList.value.length === 0) await bbsStore.refreshGameList();
|
||||
channelList.value = gameList.value.map((i) => ({ icon: i.app_icon, title: i.name, gid: i.id }));
|
||||
});
|
||||
|
||||
async function toChannel(item: ChannelItem): Promise<void> {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="tops-box">
|
||||
<div class="tops-top">查找:{{ search }}</div>
|
||||
<div class="tops-act">
|
||||
<span>分区:{{ gameName }}</span>
|
||||
<span>分区:{{ label }}</span>
|
||||
<v-btn :loading="load" size="small" class="tops-btn" @click="searchPosts()" rounded>
|
||||
加载更多({{ results.length }})
|
||||
</v-btn>
|
||||
@@ -24,27 +24,33 @@
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import TPostCard from "@comp/app/t-postcard.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type ToPostSearchProps = { gid: string; keyword?: string };
|
||||
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
|
||||
const props = defineProps<ToPostSearchProps>();
|
||||
const visible = defineModel<boolean>();
|
||||
|
||||
const search = ref<string>();
|
||||
const lastId = ref<string>("");
|
||||
const game = ref<string>("2");
|
||||
const gameId = ref<string>("2");
|
||||
const isLast = ref<boolean>(false);
|
||||
const load = ref<boolean>(false);
|
||||
const results = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
|
||||
const gameName = computed<string>(
|
||||
() => TGBbs.channels.find((v) => v.gid.toString() === game.value)?.title || "未知分区",
|
||||
);
|
||||
const label = computed<string>(() => {
|
||||
const gameFind = gameList.value.find((v) => v.id.toString() === gameId.value);
|
||||
if (gameFind === undefined) return "未知分区";
|
||||
return gameFind.name;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
game.value = props.gid;
|
||||
gameId.value = props.gid;
|
||||
if (props.keyword && props.keyword !== "") search.value = props.keyword;
|
||||
if (visible.value) await searchPosts();
|
||||
});
|
||||
@@ -79,8 +85,8 @@ watch(
|
||||
watch(
|
||||
() => props.gid,
|
||||
async () => {
|
||||
if (game.value !== props.gid) {
|
||||
game.value = props.gid;
|
||||
if (gameId.value !== props.gid) {
|
||||
gameId.value = props.gid;
|
||||
results.value = [];
|
||||
lastId.value = "";
|
||||
isLast.value = false;
|
||||
@@ -106,7 +112,7 @@ async function searchPosts(): Promise<void> {
|
||||
load.value = false;
|
||||
return;
|
||||
}
|
||||
const res = await postReq.search(game.value, search.value, lastId.value);
|
||||
const res = await postReq.search(gameId.value, search.value, lastId.value);
|
||||
if (lastId.value === "") results.value = res.posts;
|
||||
else results.value = results.value.concat(res.posts);
|
||||
lastId.value = res.last_id;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<v-select
|
||||
v-model="curGid"
|
||||
class="home-tool-select"
|
||||
:items="gameList"
|
||||
:items="games"
|
||||
:hide-details="true"
|
||||
item-value="gid"
|
||||
variant="outlined"
|
||||
@@ -72,9 +72,9 @@ import { storeToRefs } from "pinia";
|
||||
import { type Component, computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import { useHomeStore } from "@/store/modules/home.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
|
||||
type SFComp = Component & {
|
||||
__file?: string;
|
||||
@@ -84,14 +84,16 @@ type SFComp = Component & {
|
||||
};
|
||||
type SelectItem = { icon: string; title: string; gid: number };
|
||||
|
||||
const bbsStore = useBBSStore();
|
||||
const { devMode, isLogin } = storeToRefs(useAppStore());
|
||||
const { gameList } = storeToRefs(bbsStore);
|
||||
const homeStore = useHomeStore();
|
||||
|
||||
const showItemsAll: Array<string> = ["素材日历", "限时祈愿", "近期活动"];
|
||||
|
||||
const curGid = ref<number>(2);
|
||||
const gameList = shallowRef<Array<SelectItem>>();
|
||||
|
||||
const games = shallowRef<Array<SelectItem>>();
|
||||
const loadItems = shallowRef<Array<string>>([]);
|
||||
const components = shallowRef<Array<SFComp>>([]);
|
||||
const showItems = computed<Array<string>>({
|
||||
@@ -100,13 +102,13 @@ const showItems = computed<Array<string>>({
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await bbsStore.refreshGameList();
|
||||
// @ts-expect-error-next-line The import.meta meta-property is not allowed in files which will build into CommonJS output.
|
||||
const isProdEnv = import.meta.env.MODE === "production";
|
||||
if (isProdEnv && devMode.value) devMode.value = false;
|
||||
if (isLogin.value) {
|
||||
await showLoading.start("正在加载首页小部件");
|
||||
const allGames = await apiHubReq.game();
|
||||
gameList.value = allGames.map((i) => ({ icon: i.app_icon, title: i.name, gid: i.id }));
|
||||
games.value = gameList.value.map((i) => ({ icon: i.app_icon, title: i.name, gid: i.id }));
|
||||
}
|
||||
await loadComp();
|
||||
});
|
||||
|
||||
@@ -132,9 +132,11 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import VpOverlayUser from "@comp/viewPost/vp-overlay-user.vue";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, nextTick, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import ApiHubReq from "@/web/request/apiHubReq.js";
|
||||
@@ -162,6 +164,7 @@ const showSearch = ref<boolean>(false);
|
||||
const curUid = ref<string>("");
|
||||
const showUser = ref<boolean>(false);
|
||||
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
const selectedForum = shallowRef<SortSelect>();
|
||||
const sortGameList = shallowRef<Array<SortSelectGame>>([]);
|
||||
const postRaw = shallowRef<PostRaw>({ isLast: false, lastId: "", total: 0 });
|
||||
@@ -176,6 +179,7 @@ const curForums = computed<Array<SortSelect>>(() => {
|
||||
onMounted(async () => {
|
||||
await showLoading.start("正在加载帖子数据");
|
||||
await loadForums();
|
||||
await nextTick();
|
||||
let { gid, forum } = route.query;
|
||||
if (!gid) gid = route.params.gid;
|
||||
if (!forum) forum = route.params.forum;
|
||||
@@ -219,11 +223,10 @@ watch(
|
||||
|
||||
// 初始化
|
||||
async function loadForums(): Promise<void> {
|
||||
const allGames = await ApiHubReq.game();
|
||||
const allForums = await ApiHubReq.forum();
|
||||
const gameList: Array<SortSelectGame> = [];
|
||||
const list: Array<SortSelectGame> = [];
|
||||
for (const gameForum of allForums) {
|
||||
const gameFind = allGames.find((i) => i.id === gameForum.game_id);
|
||||
const gameFind = gameList.value.find((i) => i.id === gameForum.game_id);
|
||||
if (!gameFind) continue;
|
||||
const gameItem: SortSelectGame = {
|
||||
gid: gameForum.game_id,
|
||||
@@ -233,9 +236,9 @@ async function loadForums(): Promise<void> {
|
||||
.map((i) => ({ text: i.name, value: i.id, icon: i.icon_pure })),
|
||||
text: gameFind.name,
|
||||
};
|
||||
gameList.push(gameItem);
|
||||
list.push(gameItem);
|
||||
}
|
||||
sortGameList.value = gameList;
|
||||
sortGameList.value = list;
|
||||
}
|
||||
|
||||
function getForum(forum: number): SortSelect {
|
||||
|
||||
@@ -68,12 +68,11 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import ToChannel from "@comp/pageNews/to-channel.vue";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import type { Ref } from "vue";
|
||||
import { computed, onMounted, reactive, ref, shallowRef } from "vue";
|
||||
import { computed, onMounted, reactive, Ref, ref, shallowRef } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { type NewsType, useAppStore } from "@/store/modules/app.js";
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import painterReq from "@/web/request/painterReq.js";
|
||||
@@ -84,11 +83,15 @@ type RawData = { [key in NewsType]: Ref<RawItem> };
|
||||
|
||||
const router = useRouter();
|
||||
const { recentNewsType } = storeToRefs(useAppStore());
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
const { gid } = <{ gid: string }>useRoute().params;
|
||||
|
||||
const tabValues: Readonly<Array<NewsType>> = ["notice", "activity", "news"];
|
||||
const tabMap: Readonly<Record<NewsType, string>> = { notice: "1", activity: "2", news: "3" };
|
||||
const gameName = TGBbs.channels.find((v) => v.gid.toString() === gid)?.title || "未知分区";
|
||||
const label = computed<string>(() => {
|
||||
const game = gameList.value.find((v) => v.id.toString() === gid);
|
||||
return game?.name || "未知分区";
|
||||
});
|
||||
|
||||
const loading = ref<boolean>(false);
|
||||
const showList = ref<boolean>(false);
|
||||
@@ -117,20 +120,22 @@ async function firstLoad(key: NewsType, refresh: boolean = false): Promise<void>
|
||||
if (rawData[key].lastId !== 0) {
|
||||
if (!refresh) {
|
||||
loading.value = false;
|
||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||
return;
|
||||
}
|
||||
postData[key] = [];
|
||||
rawData[key].lastId = 0;
|
||||
}
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
document.documentElement.scrollTo({ top: 0, behavior: "smooth" });
|
||||
await showLoading.start(`正在获取${label.value}${rawData[key].name}数据`);
|
||||
const getData = await painterReq.news(gid, tabMap[key]);
|
||||
await showLoading.update(`数量:${getData.list.length},是否最后一页:${getData.is_last}`);
|
||||
rawData[key] = { isLast: getData.is_last, name: rawData[key].name, lastId: getData.list.length };
|
||||
postData[key] = getData.list;
|
||||
await showLoading.end();
|
||||
await TGLogger.Info(`[News][${gid}][firstLoad] 获取${rawData[key].name}数据成功`);
|
||||
showSnackbar.success(`获取${gameName}${rawData[key].name}数据成功,共 ${getData.list.length} 条`);
|
||||
showSnackbar.success(
|
||||
`获取${label.value}${rawData[key].name}数据成功,共 ${getData.list.length} 条`,
|
||||
);
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -148,7 +153,7 @@ async function loadMore(key: NewsType): Promise<void> {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
await showLoading.start(`正在获取${gameName}${rawData[key].name}数据`);
|
||||
await showLoading.start(`正在获取${label.value}${rawData[key].name}数据`);
|
||||
const mod = rawData[key].lastId % 20;
|
||||
const pageSize = mod === 0 ? 20 : 20 - mod;
|
||||
const getData = await painterReq.news(gid, tabMap[key], pageSize, rawData[key].lastId);
|
||||
|
||||
@@ -69,9 +69,14 @@
|
||||
@click:append="searchPost"
|
||||
@keyup.enter="searchPost"
|
||||
/>
|
||||
<v-btn :loading="isReq" class="post-topic-btn" @click="firstLoad()" prepend-icon="mdi-refresh"
|
||||
>刷新</v-btn
|
||||
<v-btn
|
||||
:loading="isReq"
|
||||
class="post-topic-btn"
|
||||
@click="firstLoad()"
|
||||
prepend-icon="mdi-refresh"
|
||||
>
|
||||
刷新
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-app-bar>
|
||||
<div class="post-topic-grid">
|
||||
@@ -96,11 +101,12 @@ import showLoading from "@comp/func/loading.js";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import VpOverlaySearch from "@comp/viewPost/vp-overlay-search.vue";
|
||||
import VpOverlayUser from "@comp/viewPost/vp-overlay-user.vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
import topicReq from "@/web/request/topicReq.js";
|
||||
|
||||
@@ -121,7 +127,7 @@ const curUid = ref<string>("");
|
||||
const showUser = ref<boolean>(false);
|
||||
|
||||
const isReq = ref<boolean>(false);
|
||||
const allGames = shallowRef<Array<TGApp.BBS.Game.Item>>([]);
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
const postRaw = shallowRef<PostMiniData>({ isLast: false, lastId: "", total: 0 });
|
||||
const topicInfo = shallowRef<TGApp.BBS.Topic.InfoRes>();
|
||||
const posts = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
|
||||
@@ -150,7 +156,6 @@ onMounted(async () => {
|
||||
curGid.value = Number(gid);
|
||||
curTopic.value = topic;
|
||||
await showLoading.start(`正在加载话题${topic}信息`);
|
||||
allGames.value = await apiHubReq.game();
|
||||
const info = await topicReq.info(gid, topic);
|
||||
if ("retcode" in info) {
|
||||
await showLoading.end();
|
||||
@@ -163,7 +168,7 @@ onMounted(async () => {
|
||||
tmpGame = info.game_info_list.find((i) => i.id === curGid.value);
|
||||
}
|
||||
if (tmpGame === undefined) tmpGame = info.game_info_list[0];
|
||||
const gameFind = allGames.value.find((i) => i.id === tmpGame?.id);
|
||||
const gameFind = gameList.value.find((i) => i.id === tmpGame?.id);
|
||||
curGame.value = { ...tmpGame, icon: gameFind?.app_icon };
|
||||
await firstLoad();
|
||||
});
|
||||
@@ -257,10 +262,10 @@ function searchPost(): void {
|
||||
} else createPost(search.value);
|
||||
}
|
||||
|
||||
function getGameList(gameList: Array<TGApp.BBS.Topic.GameInfo> | undefined): Array<GameList> {
|
||||
if (!gameList) return [];
|
||||
return gameList.map((item) => {
|
||||
const game = allGames.value.find((i) => i.id === item.id);
|
||||
function getGameList(list: Array<TGApp.BBS.Topic.GameInfo> | undefined): Array<GameList> {
|
||||
if (!list) return [];
|
||||
return list.map((item) => {
|
||||
const game = gameList.value.find((i) => i.id === item.id);
|
||||
return { ...item, icon: game?.app_icon };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file store/modules/app.ts
|
||||
* @description App store module
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
|
||||
import { path } from "@tauri-apps/api";
|
||||
@@ -131,13 +131,9 @@ export const useAppStore = defineStore(
|
||||
"shareDefaultFile",
|
||||
"imageQualityPercent",
|
||||
"incognito",
|
||||
"sidebar",
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "sidebar",
|
||||
storage: window.localStorage,
|
||||
pick: ["sidebar"],
|
||||
},
|
||||
{
|
||||
key: "theme",
|
||||
storage: window.localStorage,
|
||||
|
||||
27
src/store/modules/bbs.ts
Normal file
27
src/store/modules/bbs.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @file store/modules/bbs.ts
|
||||
* @description BBS 模块状态管理
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
import { defineStore } from "pinia";
|
||||
import { shallowRef } from "vue";
|
||||
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
|
||||
const useBBSStore = defineStore(
|
||||
"bbs",
|
||||
() => {
|
||||
// 游戏列表
|
||||
const gameList = shallowRef<Array<TGApp.BBS.Game.Item>>([]);
|
||||
|
||||
// 刷新游戏列表
|
||||
async function refreshGameList(): Promise<void> {
|
||||
gameList.value = await apiHubReq.game();
|
||||
}
|
||||
|
||||
return { gameList, refreshGameList };
|
||||
},
|
||||
{ persist: true },
|
||||
);
|
||||
|
||||
export default useBBSStore;
|
||||
@@ -4,35 +4,29 @@
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description salt 类型
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
export type SaltKey = "K2" | "LK2" | "X4" | "X6" | "PROD";
|
||||
|
||||
const BBS_VERSION: Readonly<string> = "2.85.1";
|
||||
const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
|
||||
const BBS_UA_PC: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
|
||||
|
||||
/**
|
||||
* @description 频道列表
|
||||
* @since Beta v0.6.8
|
||||
* @interface ChannelItem
|
||||
* @property {string} title - 频道名称
|
||||
* @property {number} gid - 频道 gid
|
||||
* @property {string} mini - 频道简称
|
||||
* @return ToChannelItem
|
||||
* @description salt 值
|
||||
* @version 2.85.1
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
type ChannelItem = { title: string; gid: number; mini: string };
|
||||
const BBS_SALT: Readonly<Record<SaltKey, string>> = {
|
||||
K2: "ss6ZUzUlaWv6iDe0SHPSdCZYr0RSKPdi",
|
||||
LK2: "gW20AtTxpc0V5GR3SmsytCLhVBgXtW6I",
|
||||
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
|
||||
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 渠道列表
|
||||
* @since Beta v0.6.8
|
||||
* @type {Array<ChannelItem>}
|
||||
*/
|
||||
const CHANNEL_LIST: Readonly<Array<ChannelItem>> = [
|
||||
{ title: "原神", gid: 2, mini: "ys" },
|
||||
{ title: "崩坏:星穹铁道", gid: 6, mini: "sr" },
|
||||
{ title: "绝区零", gid: 8, mini: "zzz" },
|
||||
{ title: "崩坏3", gid: 1, mini: "bh3" },
|
||||
{ title: "崩坏2", gid: 3, mini: "bh2" },
|
||||
{ title: "未定事件簿", gid: 4, mini: "wd" },
|
||||
{ title: "大别野", gid: 5, mini: "dby" },
|
||||
];
|
||||
|
||||
const TGBbs = { version: BBS_VERSION, ua: BBS_UA_MOBILE, channels: CHANNEL_LIST };
|
||||
const TGBbs = { version: BBS_VERSION, ua: BBS_UA_MOBILE, uap: BBS_UA_PC, salt: BBS_SALT };
|
||||
|
||||
export default TGBbs;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/utils/linkParser.ts
|
||||
* @description 处理链接
|
||||
* @since Beta v0.7.2
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
|
||||
import showDialog from "@comp/func/dialog.js";
|
||||
@@ -11,8 +11,6 @@ import { emit } from "@tauri-apps/api/event";
|
||||
import TGClient from "./TGClient.js";
|
||||
import { createPost } from "./TGWindow.js";
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
|
||||
/**
|
||||
* @function parsePost
|
||||
* @since Beta v0.6.9
|
||||
@@ -114,17 +112,19 @@ export async function parseLink(
|
||||
if (url.pathname.includes("/article/")) {
|
||||
const postId = url.pathname.split("/").pop();
|
||||
if (typeof postId !== "string") return false;
|
||||
if (!useInner) {
|
||||
return "post";
|
||||
}
|
||||
if (!useInner) return "post";
|
||||
await createPost(postId);
|
||||
return true;
|
||||
} else if (url.pathname.includes("/topicDetail/")) {
|
||||
}
|
||||
if (url.pathname.includes("/topicDetail/")) {
|
||||
const regex = /\/(\w+)\/topicDetail\/(\d+)/;
|
||||
const result = url.pathname.match(regex);
|
||||
if (!result) return false;
|
||||
const [, game, topicId] = result;
|
||||
const id = TGBbs.channels.find((item) => item.mini === game)?.gid;
|
||||
const bbsStore = localStorage.getItem("bbs");
|
||||
if (!bbsStore) return false;
|
||||
const gameList: Array<TGApp.BBS.Game.Item> = JSON.parse(bbsStore)["gameList"];
|
||||
const id = gameList.find((item) => item.en_name === game)?.id;
|
||||
await emit("active_deep_link", `router?path=/posts/topic/${id}/${topicId}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<div class="tp-post-meta">
|
||||
<div class="mpm-forum" v-if="postData.forum" @click="toForum(postData.forum)">
|
||||
<img :src="getGameIcon(postData.forum.game_id)" alt="gameIcon" />
|
||||
<TMiImg :src="getGameIcon(postData.forum.game_id)" alt="gameIcon" />
|
||||
<TMiImg :src="postData.forum.icon" alt="forumIcon" :ori="true" />
|
||||
<span>{{ postData.forum.name }}</span>
|
||||
</div>
|
||||
@@ -125,16 +125,18 @@ import { onBeforeMount, onMounted, onUnmounted, ref, shallowRef } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import { useAppStore } from "@/store/modules/app.js";
|
||||
import useBBSStore from "@/store/modules/bbs.js";
|
||||
import { useUserStore } from "@/store/modules/user.js";
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import TGClient from "@/utils/TGClient.js";
|
||||
import TGLogger from "@/utils/TGLogger.js";
|
||||
import { createTGWindow } from "@/utils/TGWindow.js";
|
||||
import apiHubReq from "@/web/request/apiHubReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
const { cookie } = storeToRefs(useUserStore());
|
||||
const { incognito } = storeToRefs(useAppStore());
|
||||
const { gameList } = storeToRefs(useBBSStore());
|
||||
const { cookie } = storeToRefs(useUserStore());
|
||||
|
||||
const appVersion = ref<string>();
|
||||
const postId = Number(useRoute().params.post_id);
|
||||
const showCollection = ref<boolean>(false);
|
||||
@@ -151,8 +153,8 @@ let incognitoListener: UnlistenFn | null = null;
|
||||
let userListener: UnlistenFn | null = null;
|
||||
|
||||
function getGameIcon(gameId: number): string {
|
||||
const find = TGBbs.channels.find((item) => item.gid === gameId);
|
||||
if (find) return `/platforms/mhy/${find.mini}.webp`;
|
||||
const find = gameList.value.find((item) => item.id === gameId);
|
||||
if (find) return find.app_icon;
|
||||
return "/platforms/mhy/mys.webp";
|
||||
}
|
||||
|
||||
@@ -332,9 +334,9 @@ async function tryLike(): Promise<void> {
|
||||
}
|
||||
|
||||
async function toPost(): Promise<void> {
|
||||
const channel = TGBbs.channels.find((item) => item.gid === postData.value?.post.game_id);
|
||||
const channel = gameList.value.find((item) => item.id === postData.value?.post.game_id);
|
||||
const link = channel
|
||||
? `https://m.miyoushe.com/${channel.mini}/#/article/${postId}`
|
||||
? `https://m.miyoushe.com/${channel.en_name}/#/article/${postId}`
|
||||
: `https://m.miyoushe.com/ys/#/article/${postId}`;
|
||||
await TGClient.open("web_thin", link);
|
||||
}
|
||||
|
||||
@@ -6,29 +6,9 @@
|
||||
|
||||
import Md5 from "js-md5";
|
||||
|
||||
import TGBbs from "@/utils/TGBbs.js";
|
||||
import TGBbs, { type SaltKey } from "@/utils/TGBbs.js";
|
||||
import { getDeviceInfo, getRandomString } from "@/utils/toolFunc.js";
|
||||
|
||||
/**
|
||||
* @description salt 类型
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
type SaltKey = "K2" | "LK2" | "X4" | "X6" | "PROD";
|
||||
|
||||
/**
|
||||
* @description salt 值
|
||||
* @version 2.85.1
|
||||
* @since Beta v0.7.3
|
||||
*/
|
||||
const Salt: Readonly<Record<SaltKey, string>> = {
|
||||
K2: "ss6ZUzUlaWv6iDe0SHPSdCZYr0RSKPdi",
|
||||
LK2: "gW20AtTxpc0V5GR3SmsytCLhVBgXtW6I",
|
||||
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
|
||||
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
};
|
||||
const UserAgent: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${TGBbs.version}`;
|
||||
|
||||
/**
|
||||
* @description 获取随机数
|
||||
* @since Alpha v0.2.0
|
||||
@@ -42,8 +22,7 @@ function getRandomNumber(min: number, max: number): number {
|
||||
|
||||
/**
|
||||
* @description 获取 ds
|
||||
* @since Beta v0.3.3
|
||||
* @version 2.50.1
|
||||
* @since Beta v0.7.3
|
||||
* @param {string} method 请求方法
|
||||
* @param {string} data 请求数据
|
||||
* @param {SaltKey} saltType salt 类型
|
||||
@@ -51,7 +30,7 @@ function getRandomNumber(min: number, max: number): number {
|
||||
* @returns {string} ds
|
||||
*/
|
||||
function getDS(method: string, data: string, saltType: SaltKey, isSign: boolean): string {
|
||||
const salt = Salt[saltType];
|
||||
const salt = TGBbs.salt[saltType];
|
||||
const time = Math.floor(Date.now() / 1000).toString();
|
||||
let random = getRandomNumber(100000, 200000).toString();
|
||||
if (isSign) random = getRandomString(6);
|
||||
@@ -97,7 +76,7 @@ function transCookie(cookie: Record<string, string>): string {
|
||||
|
||||
/**
|
||||
* @description 获取请求头
|
||||
* @since Beta v0.6.5
|
||||
* @since Beta v0.7.3
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {string} method 请求方法
|
||||
* @param {Record<string, string | number | boolean | Array<string>> | string} data 请求数据
|
||||
@@ -113,7 +92,7 @@ export function getRequestHeader(
|
||||
isSign: boolean = false,
|
||||
): Record<string, string> {
|
||||
return {
|
||||
"user-agent": UserAgent,
|
||||
"user-agent": TGBbs.uap,
|
||||
"x-rpc-app_version": TGBbs.version,
|
||||
"x-rpc-client_type": "5",
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
@@ -147,7 +126,7 @@ export function getDS4JS(
|
||||
body?: Record<string, string | number> | string,
|
||||
query?: Record<string, string | number> | string,
|
||||
): string {
|
||||
const salt = Salt[saltType];
|
||||
const salt = TGBbs.salt[saltType];
|
||||
const time = Math.floor(Date.now() / 1000).toString();
|
||||
let random = getRandomNumber(100000, 200000).toString();
|
||||
let hashStr: string;
|
||||
|
||||
Reference in New Issue
Block a user