Ver Fonte

:bug: fix api base env

China Kassapa há 2 meses atrás
pai
commit
db8cd1d5ef

+ 0 - 2
dashboard-v4/dashboard/src/api/index.ts

@@ -1,2 +0,0 @@
-export const api_url = (path: string) =>
-  `${process.env.REACT_APP_API_BASE}${path}`;

+ 4 - 4
dashboard-v4/dashboard/src/components/notification/NotificationIcon.tsx

@@ -26,7 +26,7 @@ const NotificationIconWidget = () => {
     }
     }
     const now = new Date();
     const now = new Date();
     const notificationUpdatedAt = localStorage.getItem(
     const notificationUpdatedAt = localStorage.getItem(
-      "notification/updatedAt"
+      "notification/updatedAt",
     );
     );
     if (notificationUpdatedAt) {
     if (notificationUpdatedAt) {
       if (now.getTime() - parseInt(notificationUpdatedAt) < 59000) {
       if (now.getTime() - parseInt(notificationUpdatedAt) < 59000) {
@@ -46,7 +46,7 @@ const NotificationIconWidget = () => {
         console.debug("notification fetch ok ", json.data.unread);
         console.debug("notification fetch ok ", json.data.unread);
         localStorage.setItem(
         localStorage.setItem(
           "notification/updatedAt",
           "notification/updatedAt",
-          now.getTime().toString()
+          now.getTime().toString(),
         );
         );
         localStorage.setItem("notification/count", json.data.unread.toString());
         localStorage.setItem("notification/count", json.data.unread.toString());
         setCount(json.data.unread);
         setCount(json.data.unread);
@@ -60,7 +60,7 @@ const NotificationIconWidget = () => {
             const content = json.data.rows[0].content;
             const content = json.data.rows[0].content;
             localStorage.setItem(
             localStorage.setItem(
               "notification/message",
               "notification/message",
-              JSON.stringify({ title: title, content: content })
+              JSON.stringify({ title: title, content: content }),
             );
             );
             //发送通知
             //发送通知
             console.debug("notification isMute", isMute, mute);
             console.debug("notification isMute", isMute, mute);
@@ -70,7 +70,7 @@ const NotificationIconWidget = () => {
                   const notification = new Notification(title, {
                   const notification = new Notification(title, {
                     body: content,
                     body: content,
                     icon:
                     icon:
-                      process.env.REACT_APP_API_HOST +
+                      process.env.REACT_APP_API_BASE +
                       "/assets/images/wikipali_logo.png",
                       "/assets/images/wikipali_logo.png",
                     tag: json.data.rows[0].id,
                     tag: json.data.rows[0].id,
                   });
                   });

+ 4 - 8
dashboard-v4/dashboard/src/request.ts

@@ -17,16 +17,12 @@ export interface I500Response {
   message: string;
   message: string;
 }
 }
 
 
-export const backend = (u: string) => `${API_HOST}/api${u}`;
+export const backend = (p: string) =>
+  `${process.env.REACT_APP_API_BASE}/api${p}`;
 
 
 export const GRPC_HOST: string =
 export const GRPC_HOST: string =
   process.env.REACT_APP_GRPC_HOST || "http://127.0.0.1:9999";
   process.env.REACT_APP_GRPC_HOST || "http://127.0.0.1:9999";
 
 
-export const API_HOST: string =
-  process.env.NODE_ENV === "development" && process.env.REACT_APP_API_HOST
-    ? process.env.REACT_APP_API_HOST
-    : "";
-
 export const grpc_metadata = (): Metadata => {
 export const grpc_metadata = (): Metadata => {
   return {
   return {
     authorization: `Bearer ${getToken()}`,
     authorization: `Bearer ${getToken()}`,
@@ -84,7 +80,7 @@ export const post = async <Q, R>(path: string, body: Q): Promise<R> => {
 
 
 export const patch = <Request, Response>(
 export const patch = <Request, Response>(
   path: string,
   path: string,
-  body: Request
+  body: Request,
 ): Promise<Response> => {
 ): Promise<Response> => {
   const data = options("PATCH");
   const data = options("PATCH");
   data.body = JSON.stringify(body);
   data.body = JSON.stringify(body);
@@ -98,7 +94,7 @@ export const patch = <Request, Response>(
 
 
 export const put = async <Request, Response>(
 export const put = async <Request, Response>(
   path: string,
   path: string,
-  body: Request
+  body: Request,
 ): Promise<Response> => {
 ): Promise<Response> => {
   const data = options("PUT");
   const data = options("PUT");
   data.body = JSON.stringify(body);
   data.body = JSON.stringify(body);