mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
✏️ 完善类型 #51
This commit is contained in:
18
src/plugins/Mys/types/SctPost.d.ts
vendored
18
src/plugins/Mys/types/SctPost.d.ts
vendored
@@ -21,8 +21,21 @@ declare namespace TGApp.Plugins.Mys.SctPost {
|
||||
* @return Base
|
||||
*/
|
||||
interface Base {
|
||||
insert: any;
|
||||
attributes?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 帖子结构化数据-空类型
|
||||
* @since Beta v0.3.4
|
||||
* @interface Empty
|
||||
* @property {never} insert - 帖子内容
|
||||
* @property {never} attributes - 帖子属性
|
||||
* @return Empty
|
||||
*/
|
||||
interface Empty {
|
||||
insert: never;
|
||||
attributes: never;
|
||||
attributes?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +54,8 @@ declare namespace TGApp.Plugins.Mys.SctPost {
|
||||
| Text
|
||||
| Video
|
||||
| VillaCard
|
||||
| Vod;
|
||||
| Vod
|
||||
| Empty;
|
||||
|
||||
/**
|
||||
* @description 帖子结构化数据-其他类型
|
||||
|
||||
@@ -163,16 +163,16 @@ function transferParser(data: TGApp.Plugins.Mys.SctPost.Common): HTMLDivElement
|
||||
} else if ("villa_card" in data.insert) {
|
||||
return parseVillaCard(<TGApp.Plugins.Mys.SctPost.VillaCard>data);
|
||||
}
|
||||
return parseUnknown(<TGApp.Plugins.Mys.SctPost.Base>data);
|
||||
return parseUnknown(<TGApp.Plugins.Mys.SctPost.Empty>data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 解析未知数据
|
||||
* @since Beta v0.3.4
|
||||
* @param {TGApp.Plugins.Mys.SctPost.Base} data Mys数据
|
||||
* @param {TGApp.Plugins.Mys.SctPost.Empty} data Mys数据
|
||||
* @returns {HTMLDivElement} 解析后的未知数据
|
||||
*/
|
||||
function parseUnknown(data: TGApp.Plugins.Mys.SctPost.Base): HTMLDivElement {
|
||||
function parseUnknown(data: TGApp.Plugins.Mys.SctPost.Empty): HTMLDivElement {
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("mys-post-unknown");
|
||||
const code = document.createElement("code");
|
||||
@@ -251,7 +251,7 @@ function parseDivider(data: TGApp.Plugins.Mys.SctPost.Divider): HTMLDivElement {
|
||||
const dividerList = ["line_1", "line_2", "line_3", "line_4"];
|
||||
if (!dividerList.includes(data.insert.divider)) {
|
||||
console.error("Unknown divider type", data);
|
||||
return parseUnknown(<TGApp.Plugins.Mys.SctPost.Base>data);
|
||||
return parseUnknown(<TGApp.Plugins.Mys.SctPost.Empty>data);
|
||||
}
|
||||
img.src = `/source/post/divider_${data.insert.divider}.webp`;
|
||||
div.appendChild(img);
|
||||
|
||||
Reference in New Issue
Block a user