visuddhinanda 2 лет назад
Родитель
Сommit
6a5b6475ec
2 измененных файлов с 14 добавлено и 2 удалено
  1. 3 2
      dashboard/src/pages/library/article/show.tsx
  2. 11 0
      dashboard/src/utils.ts

+ 3 - 2
dashboard/src/pages/library/article/show.tsx

@@ -36,7 +36,7 @@ import { paraParam } from "../../../reducers/para-change";
 import { get } from "../../../request";
 import store from "../../../store";
 import { IRecent } from "../../../components/recent/RecentList";
-import { fullUrl } from "../../../utils";
+import { convertToPlain, fullUrl } from "../../../utils";
 import ThemeSelect from "../../../components/general/ThemeSelect";
 
 /**
@@ -296,7 +296,8 @@ const Widget = () => {
               }}
               onLoad={(article: IArticleDataResponse) => {
                 setLoadedArticleData(article);
-                document.title = article.title.slice(0, 128);
+
+                document.title = convertToPlain(article.title).slice(0, 128);
               }}
               onAnthologySelect={(id: string) => {
                 let output: any = { anthology: id };

+ 11 - 0
dashboard/src/utils.ts

@@ -51,3 +51,14 @@ export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
   }
   return url;
 };
+
+export const convertToPlain = (html: string): string => {
+  // Create a new div element
+  var tempDivElement = document.createElement("div");
+
+  // Set the HTML content with the given value
+  tempDivElement.innerHTML = html;
+
+  // Retrieve the text property of the element
+  return tempDivElement.textContent || tempDivElement.innerText || "";
+};