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