Просмотр исходного кода

add console.info("api request"

visuddhinanda 2 лет назад
Родитель
Сommit
d81b9d57ed

+ 7 - 7
dashboard/src/components/discussion/DiscussionAnchor.tsx

@@ -32,14 +32,14 @@ const DiscussionAnchorWidget = ({
 
   useEffect(() => {
     if (typeof topicId === "string") {
-      get<ICommentAnchorResponse>(`/v2/discussion-anchor/${topicId}`).then(
-        (json) => {
-          console.log(json);
-          if (json.ok) {
-            setContent(json.data);
-          }
+      const url = `/v2/discussion-anchor/${topicId}`;
+      console.info("api request", url);
+      get<ICommentAnchorResponse>(url).then((json) => {
+        console.debug("api response", json);
+        if (json.ok) {
+          setContent(json.data);
         }
-      );
+      });
     }
   }, [topicId]);
 

+ 9 - 7
dashboard/src/components/discussion/DiscussionCreate.tsx

@@ -94,11 +94,12 @@ const DiscussionCreateWidget = ({
                     content_type: "markdown",
                     type: topic.type,
                   };
-                  console.log("create topic", topicData);
+                  const url = `/v2/discussion`;
+                  console.log("create topic api request", url, topicData);
                   const newTopic = await post<
                     ICommentRequest,
                     ICommentResponse
-                  >(`/v2/discussion`, topicData);
+                  >(url, topicData);
                   if (newTopic.ok) {
                     setCurrParent(newTopic.data.id);
                     newParent = newTopic.data.id;
@@ -111,9 +112,8 @@ const DiscussionCreateWidget = ({
                   }
                 }
               }
-              console.log("parent", currParent);
-
-              post<ICommentRequest, ICommentResponse>(`/v2/discussion`, {
+              const url = `/v2/discussion`;
+              const data: ICommentRequest = {
                 res_id: resId,
                 res_type: resType,
                 parent: newParent ? newParent : currParent,
@@ -122,9 +122,11 @@ const DiscussionCreateWidget = ({
                 content: values.content,
                 content_type: contentType,
                 type: topic ? topic.type : type,
-              })
+              };
+              console.info("api request", url, data);
+              post<ICommentRequest, ICommentResponse>(url, data)
                 .then((json) => {
-                  console.log("new discussion", json);
+                  console.debug("new discussion api response", json);
                   if (json.ok) {
                     formRef.current?.resetFields();
                     if (typeof onCreated !== "undefined") {

+ 6 - 3
dashboard/src/components/discussion/DiscussionEdit.tsx

@@ -54,12 +54,15 @@ const DiscussionEditWidget = ({
           },
         }}
         onFinish={async (values) => {
-          put<ICommentRequest, ICommentResponse>(`/v2/discussion/${data.id}`, {
+          const url = `/v2/discussion/${data.id}`;
+          const newData: ICommentRequest = {
             title: values.title,
             content: values.content,
-          })
+          };
+          console.info("DiscussionEdit api request", url, newData);
+          put<ICommentRequest, ICommentResponse>(url, newData)
             .then((json) => {
-              console.log(json);
+              console.debug("DiscussionEdit api response", json);
               if (json.ok) {
                 console.log(intl.formatMessage({ id: "flashes.success" }));
                 if (typeof onUpdated !== "undefined") {

+ 3 - 4
dashboard/src/components/discussion/DiscussionListCard.tsx

@@ -110,9 +110,7 @@ const DiscussionListCardWidget = ({
             search: false,
             render(dom, entity, index, action, schema) {
               return (
-                <span key={index}>
-                  {entity.summary ? entity.summary : entity.content}
-                </span>
+                <span key={index}>{entity.summary ?? entity.content}</span>
               );
             },
           },
@@ -147,8 +145,9 @@ const DiscussionListCardWidget = ({
           url += `&limit=${params.pageSize}&offset=${offset}`;
           url += params.keyword ? "&search=" + params.keyword : "";
           url += activeKey ? "&status=" + activeKey : "";
-          console.log("url", url);
+          console.log("DiscussionListCard api request", url);
           const res = await get<ICommentListResponse>(url);
+          console.debug("DiscussionListCard api response", res);
           setCount(res.data.active);
           setCanCreate(res.data.can_create);
           const items: IComment[] = res.data.rows.map((item, id) => {

+ 15 - 7
dashboard/src/components/discussion/DiscussionShow.tsx

@@ -78,9 +78,11 @@ const DiscussionShowWidget = ({
         id: "buttons.no",
       }),
       onOk() {
-        console.log("delete", id);
-        return delete_<IDeleteResponse>(`/v2/discussion/${id}`)
+        const url = `/v2/discussion/${id}`;
+        console.info("Discussion delete api request", url);
+        return delete_<IDeleteResponse>(url)
           .then((json) => {
+            console.debug("api response", json);
             if (json.ok) {
               message.success("删除成功");
               if (typeof onDelete !== "undefined") {
@@ -96,11 +98,14 @@ const DiscussionShowWidget = ({
   };
 
   const close = (value: boolean) => {
-    put<ICommentRequest, ICommentResponse>(`/v2/discussion/${data.id}`, {
+    const url = `/v2/discussion/${data.id}`;
+    const newData: ICommentRequest = {
       title: data.title,
       content: data.content,
       status: value ? "close" : "active",
-    }).then((json) => {
+    };
+    console.info("api request", url, newData);
+    put<ICommentRequest, ICommentResponse>(url, newData).then((json) => {
       console.log(json);
       if (json.ok) {
         setClosed(json.data.status);
@@ -112,13 +117,16 @@ const DiscussionShowWidget = ({
   };
 
   const convert = (newType: TDiscussionType) => {
-    put<ICommentRequest, ICommentResponse>(`/v2/discussion/${data.id}`, {
+    const url = `/v2/discussion/${data.id}`;
+    const newData: ICommentRequest = {
       title: data.title,
       content: data.content,
       status: data.status,
       type: newType,
-    }).then((json) => {
-      console.log(json);
+    };
+    console.debug("api response", url, newData);
+    put<ICommentRequest, ICommentResponse>(url, newData).then((json) => {
+      console.debug("api response", json);
       if (json.ok) {
         notification.info({ message: "转换成功" });
         if (typeof onConvert !== "undefined") {

+ 4 - 1
dashboard/src/components/discussion/DiscussionTopicChildren.tsx

@@ -150,8 +150,11 @@ const DiscussionTopicChildrenWidget = ({
       return;
     }
     setLoading(true);
-    get<ICommentListResponse>(`/v2/discussion?view=answer&id=${topicId}`)
+    const url = `/v2/discussion?view=answer&id=${topicId}`;
+    console.info("api request", url);
+    get<ICommentListResponse>(url)
       .then((json) => {
+        console.debug("api response", json);
         if (json.ok) {
           const discussions: IComment[] = json.data.rows.map((item) => {
             return {

+ 2 - 2
dashboard/src/components/discussion/DiscussionTopicInfo.tsx

@@ -46,11 +46,11 @@ const DiscussionTopicInfoWidget = ({
       return;
     }
     const url = `/v2/discussion/${topicId}`;
-    console.log("discussion url", url);
+    console.info("discussion api request", url);
     get<ICommentResponse>(url)
       .then((json) => {
+        console.debug("api response", json);
         if (json.ok) {
-          console.log("flashes.success");
           const item = json.data;
           const discussion: IComment = {
             id: item.id,

+ 2 - 2
dashboard/src/components/discussion/QaList.tsx

@@ -19,10 +19,10 @@ const QaListWidget = ({ resId, resType, onSelect, onReply }: IWidget) => {
     }
     let url: string = `/v2/discussion?res_type=${resType}&view=res_id&id=${resId}`;
     url += "&dir=asc&type=qa&status=active,close";
-    console.log("url", url);
+    console.info("api request", url);
     get<ICommentListResponse>(url).then((json) => {
       if (json.ok) {
-        console.debug("discussion fetch qa", json);
+        console.debug("discussion api response", json);
         const items: IComment[] = json.data.rows.map((item, id) => {
           return {
             id: item.id,

+ 2 - 0
dashboard/src/pages/library/discussion/list.tsx

@@ -28,7 +28,9 @@ const Widget = () => {
       request={async (params = {}, sorter, filter) => {
         console.log(params, sorter, filter);
         const url = `/v2/discussion?view=all`;
+        console.info("api request", url);
         const json = await get<ICommentListResponse>(url);
+        console.debug("api response", json);
         if (!json.ok) {
           message.error(json.message);
         }