Forráskód Böngészése

feat: 配置生产环境

banxia 1 hónapja
szülő
commit
c479e7b501

+ 3 - 0
.env.production

@@ -3,3 +3,6 @@ NODE_ENV = "production"
 
 # 线上环境接口地址
 VITE_API_URL = "https://mock.mengxuegu.com/mock/62abda3212c1416424630a45"
+
+VITE_NOTIFICATION_URL = "http://114.215.252.134:8989"
+VITE_USER_LOGIN_URL = "http://182.44.10.206:8000"

+ 5 - 1
src/components/MessageModal/MessageModal.tsx

@@ -137,7 +137,11 @@ const MessageModal: React.FC<MessageModalProps> = ({
           <div
             className="cursor-pointer hover:bg-gray-100 rounded-md px-2 py-1 ml-2 text-xs flex justify-center items-center gap-1"
             onClick={async () => {
-              const res = await axios.post(`/notification/bazb/clearMsg`);
+              const baseUrl =
+                import.meta.env.MODE === "development"
+                  ? "/notification"
+                  : import.meta.env.VITE_NOTIFICATION_URL;
+              const res = await axios.post(`${baseUrl}/bazb/clearMsg`);
               if (res.data.code === 200) {
                 changeNotification({ type: "clear" });
               }

+ 6 - 2
src/layouts/Header/index.tsx

@@ -31,9 +31,13 @@ const LayoutHeader = (props) => {
   };
 
   const fetchNoticeList = async (id?: number, isRead?: number) => {
+    const baseUrl = import.meta.env.MODE === 'development' 
+      ? '/notification' 
+      : import.meta.env.VITE_NOTIFICATION_URL;
+    
     const res = await axios.get(
-      `/notification/bazb/getMsgList${id ? `?msgId=${id}` : ""}${
-        isRead !== undefined ? `${id ? "&" : "?"}isRead=${isRead}` : ""
+      `${baseUrl}/bazb/getMsgList${id ? `?msgId=${id}` : ""}${
+        isRead !== undefined ? `${id ? '&' : '?'}isRead=${isRead}` : ""
       }`
     );
     if (res?.data?.data?.list?.data) {

+ 5 - 1
src/pages/login/login.tsx

@@ -67,7 +67,11 @@ export default function LoginPage() {
     setLoading(true);
 
     try {
-      const response = await axios.post("/userLogin/api/login", {
+      const baseUrl =
+        import.meta.env.MODE === "development"
+          ? "/userLogin"
+          : import.meta.env.VITE_USER_LOGIN_URL;
+      const response = await axios.post(`${baseUrl}/api/login`, {
         name: account,
         password: password,
       });