mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🐛 修复部分链接点击异常
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<template #title>近期活动</template>
|
||||
<template #default>
|
||||
<div class="position-grid">
|
||||
<v-card v-for="card in positionCards" :key="card.postId" rounded class="position-card">
|
||||
<v-card v-for="(card, index) in positionCards" :key="index" rounded class="position-card">
|
||||
<v-list class="position-list">
|
||||
<v-list-item :title="card.title" :subtitle="card.abstract">
|
||||
<template #prepend>
|
||||
@@ -12,9 +12,7 @@
|
||||
</v-avatar>
|
||||
</template>
|
||||
<template #append>
|
||||
<v-btn class="position-card-btn" @click="createPost(card.postId, card.title)">
|
||||
查看
|
||||
</v-btn>
|
||||
<v-btn class="position-card-btn" @click="openPosition(card)"> 查看</v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
@@ -41,8 +39,10 @@
|
||||
import { ref, onMounted, onUnmounted } from "vue";
|
||||
|
||||
import Mys from "../../plugins/Mys/index.js";
|
||||
import { parseLink } from "../../utils/linkParser.js";
|
||||
import { createPost } from "../../utils/TGWindow.js";
|
||||
import { stamp2LastTime } from "../../utils/toolFunc.js";
|
||||
import showSnackbar from "../func/snackbar.js";
|
||||
|
||||
import THomeCard from "./t-homecard.vue";
|
||||
|
||||
@@ -94,6 +94,19 @@ onMounted(async () => {
|
||||
emits("success");
|
||||
});
|
||||
|
||||
async function openPosition(card: TGApp.Plugins.Mys.Position.RenderCard): Promise<void> {
|
||||
const res = await parseLink(card.link);
|
||||
if (res === "post") await createPost(card.postId, card.title);
|
||||
if (res === false) {
|
||||
showSnackbar({
|
||||
text: `未知链接:${card.link}`,
|
||||
color: "error",
|
||||
timeout: 3000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
Object.keys(positionTimer.value).forEach((key) => {
|
||||
clearInterval(positionTimer.value[Number(key)]);
|
||||
|
||||
6
src/plugins/Mys/types/Position.d.ts
vendored
6
src/plugins/Mys/types/Position.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Position.d.ts
|
||||
* @description Mys 插件热点追踪接口
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.5.3
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -74,10 +74,11 @@ declare namespace TGApp.Plugins.Mys.Position {
|
||||
|
||||
/**
|
||||
* @description 渲染用的热点追踪信息
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.5.3
|
||||
* @interface RenderCard
|
||||
* @property {string} title 标题
|
||||
* @property {number} postId 帖子ID
|
||||
* @property {string} link 链接
|
||||
* @property {string} icon 图标
|
||||
* @property {string} abstract 摘要
|
||||
* @property time 时间
|
||||
@@ -90,6 +91,7 @@ declare namespace TGApp.Plugins.Mys.Position {
|
||||
interface RenderCard {
|
||||
title: string;
|
||||
postId: number;
|
||||
link: string;
|
||||
icon: string;
|
||||
abstract: string;
|
||||
time: {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file plugins/Mys/utils/getPositionCard.ts
|
||||
* @description Mys 插件热点追踪工具
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.3
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 根据热点追踪信息转为渲染用的数据
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.3
|
||||
* @param {TGApp.Plugins.Mys.Position.Data[]} positionData 列表
|
||||
* @returns {TGApp.Plugins.Mys.Position.RenderCard[]} 返回列表
|
||||
*/
|
||||
@@ -24,6 +24,7 @@ function getPositionCard(
|
||||
const card: TGApp.Plugins.Mys.Position.RenderCard = {
|
||||
title: position.title,
|
||||
postId: Number(position.url.split("/").pop()),
|
||||
link: position.url,
|
||||
icon: position.icon,
|
||||
abstract: position.abstract,
|
||||
time: {
|
||||
|
||||
Reference in New Issue
Block a user