Bläddra i källkod

Merge pull request #1412 from visuddhinanda/agile

add convertToPlain
visuddhinanda 2 år sedan
förälder
incheckning
3e07b34654

+ 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 };

+ 1 - 0
dashboard/src/pages/studio/channel/show.tsx

@@ -26,6 +26,7 @@ const Widget = () => {
   useEffect(() => {
     get<IApiResponseChannel>(`/v2/channel/${channelId}`).then((json) => {
       setTitle(json.data.name);
+      document.title = `${json.data.name}`;
     });
   }, [channelId]);
   return (

+ 1 - 0
dashboard/src/pages/studio/course/edit.tsx

@@ -31,6 +31,7 @@ const Widget = () => {
                   courseId={courseId}
                   onTitleChange={(title: string) => {
                     setTitle(title);
+                    document.title = `${title}`;
                   }}
                 />
               ),

+ 1 - 1
dashboard/src/pages/studio/group/edit.tsx

@@ -41,7 +41,7 @@ const Widget = () => {
         request={async () => {
           const res = await get<IGroupResponse>(`/v2/group/${groupId}`);
           setTitle(res.data.name);
-          console.log(res.data);
+          document.title = `${res.data.name}`;
           return {
             id: res.data.uid,
             name: res.data.name,

+ 1 - 0
dashboard/src/pages/studio/group/show.tsx

@@ -17,6 +17,7 @@ const Widget = () => {
   useEffect(() => {
     get<IGroupResponse>(`/v2/group/${groupId}`).then((json) => {
       setTitle(json.data.name);
+      document.title = `${json.data.name}`;
     });
   }, [groupId]);
   return (

+ 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 || "";
+};