mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
fix(parser):完善 linkCard 解析
This commit is contained in:
@@ -51,13 +51,13 @@
|
||||
}
|
||||
|
||||
.mys-post-link-card-cover {
|
||||
width: 180px;
|
||||
width: auto;
|
||||
height: 180px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.mys-post-link-card-cover img {
|
||||
width: 180px;
|
||||
width: auto;
|
||||
height: 180px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ export interface PostStructuredContentVod {
|
||||
* @description 帖子结构化内容-链接卡片
|
||||
* @since Alpha v0.1.1
|
||||
* @interface PostStructuredContentLinkCard
|
||||
* @property {number} link_type 链接类型 // TODO: 未知
|
||||
* @property {number} link_type 链接类型 // 1: 帖子,2:商品 TODO: 未知
|
||||
* @property {string} origin_url 原始链接
|
||||
* @property {string} landing_url 落地页链接
|
||||
* @property {string} cover 封面图 URL
|
||||
|
||||
@@ -310,18 +310,24 @@ function LinkCardParser(data: PostStructuredContent): HTMLDivElement {
|
||||
title.innerHTML = data.insert.link_card.title;
|
||||
// 插入 title
|
||||
content.appendChild(title);
|
||||
// 创建价格
|
||||
const price = document.createElement("div");
|
||||
price.classList.add("mys-post-link-card-price");
|
||||
price.innerHTML = data.insert.link_card.price;
|
||||
// 插入 price
|
||||
content.appendChild(price);
|
||||
if (data.insert.link_card.price) {
|
||||
const price = document.createElement("div");
|
||||
price.classList.add("mys-post-link-card-price");
|
||||
price.innerHTML = data.insert.link_card.price;
|
||||
content.appendChild(price);
|
||||
}
|
||||
// 创建 button
|
||||
const button = document.createElement("a");
|
||||
button.classList.add("mys-post-link-card-btn");
|
||||
button.innerHTML = data.insert.link_card.button_text + " >";
|
||||
button.href = data.insert.link_card.origin_url;
|
||||
button.target = "view_window";
|
||||
button.innerHTML = data.insert.link_card.button_text || "详情" + " >";
|
||||
const link_url = data.insert.link_card.origin_url;
|
||||
if (link_url.startsWith("https://www.miyoushe.com/ys/article/")) {
|
||||
button.href = "/post_detail/" + link_url.split("/").pop();
|
||||
button.target = "_self";
|
||||
} else {
|
||||
button.href = link_url;
|
||||
button.target = "view_window";
|
||||
}
|
||||
// 插入 button
|
||||
content.appendChild(button);
|
||||
// 插入 content
|
||||
|
||||
Reference in New Issue
Block a user