帖子话题内容解析跳转

This commit is contained in:
目棃
2024-12-05 13:42:03 +08:00
parent 5357df3743
commit dbed43bf7e
5 changed files with 39 additions and 20 deletions

View File

@@ -104,21 +104,13 @@ interface TwoSelectCEmits {
const props = defineProps<TwoSelectCProps>();
const emits = defineEmits<TwoSelectCEmits>();
const visible = computed({
get() {
return props.modelValue;
},
set(value) {
emits("update:modelValue", value);
},
const visible = computed<boolean>({
get: () => props.modelValue,
set: (v: boolean) => emits("update:modelValue", v),
});
const reset = computed({
get() {
return props.reset;
},
set(value) {
emits("update:reset", value);
},
const reset = computed<boolean>({
get: () => props.reset,
set: (v: boolean) => emits("update:reset", v),
});
watch(

View File

@@ -80,6 +80,7 @@
</template>
<v-list-item-title @click="confirmUpdateDevice()">刷新设备信息</v-list-item-title>
<v-list-item-subtitle>
<!-- @ts-expect-error-next-line Deprecated symbol used -->
{{ appStore.deviceInfo.device_name }}({{ appStore.deviceInfo.product }}) -
{{ appStore.deviceInfo.device_fp }}
</v-list-item-subtitle>

View File

@@ -1,13 +1,14 @@
/**
* @file src/utils/linkParser.ts
* @description 处理链接
* @since Beta v0.6.3
* @since Beta v0.6.5
*/
import { emit } from "@tauri-apps/api/event";
import showDialog from "../components/func/dialog.js";
import showSnackbar from "../components/func/snackbar.js";
import { getGameId } from "../web/utils/tools.js";
import TGClient from "./TGClient.js";
import { createPost } from "./TGWindow.js";
@@ -56,7 +57,7 @@ export async function parsePost(link: string): Promise<false | string> {
/**
* @function parseLink
* @since Beta v0.6.3
* @since Beta v0.6.5
* @description 处理链接
* @param {string} link - 链接
* @param {boolean} useInner - 是否采用内置 JSBridge 打开
@@ -118,6 +119,14 @@ export async function parseLink(
}
await createPost(postId);
return true;
} else 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 = getGameId(game);
await emit("active_deep_link", `router?path=/posts/topic/${id}/${topicId}`);
return true;
}
}
if (url.hostname === "webstatic.mihoyo.com") {

View File

@@ -24,24 +24,24 @@ export const BBS_SALT = {
/**
* @description 频道列表
* @version 2.72.2
* @since Beta v0.5.1
* @since Beta v0.6.5
* @interface ToChannelItem
* @property {string} title - 频道名称
* @property {string} icon - 频道图标
* @property {string} gid - 频道 gid
* @property {string} mini - 频道简称
* @return ToChannelItem
*/
export interface ToChannelItem {
title: string;
icon: string;
gid: string;
mini: string;
}
/**
* @description 渠道列表
* @version 2.72.2
* @since Beta v0.5.1
* @since Beta v0.6.5
* @type {Array<ToChannelItem>}
*/
export const CHANNEL_LIST: ToChannelItem[] = [
@@ -49,35 +49,42 @@ export const CHANNEL_LIST: ToChannelItem[] = [
title: "原神",
icon: "/platforms/mhy/ys.webp",
gid: "2",
mini: "ys",
},
{
title: "崩坏:星穹铁道",
icon: "/platforms/mhy/sr.webp",
gid: "6",
mini: "sr",
},
{
title: "绝区零",
icon: "/platforms/mhy/zzz.webp",
gid: "8",
mini: "zzz",
},
{
title: "崩坏3",
icon: "/platforms/mhy/bh3.webp",
gid: "1",
mini: "bh3",
},
{
title: "崩坏2",
icon: "/platforms/mhy/bh2.webp",
gid: "3",
mini: "bh2",
},
{
title: "未定事件簿",
icon: "/platforms/mhy/wd.webp",
gid: "4",
mini: "wd",
},
{
title: "大别野",
icon: "/platforms/mhy/dby.webp",
gid: "5",
mini: "dby",
},
];

View File

@@ -64,3 +64,13 @@ export function getGameName(gid: number): string {
const game = TGConstant.BBS.CHANNELS.find((item) => item.gid === gid.toString());
return game ? game.title : "未知游戏";
}
/**
* @description 获取游戏id
* @param {string} mini
* @returns {string}
*/
export function getGameId(mini: string): string {
const game = TGConstant.BBS.CHANNELS.find((item) => item.mini === mini);
return game ? game.gid : "0";
}