Browse Source

代理配置

zhangjie 1 year ago
parent
commit
628ac61118
3 changed files with 40 additions and 12 deletions
  1. 26 0
      README.md
  2. 12 11
      src/main.ts
  3. 2 1
      vite.config.ts

+ 26 - 0
README.md

@@ -54,3 +54,29 @@ src/features/student/studentInspect/MarkBody.vue 整卷渲染的组件,凡是
 ### 版本信息
 ### 版本信息
 
 
 1.基于云阅卷 1.3.13 开发
 1.基于云阅卷 1.3.13 开发
+
+### 开发模式 本地 Nginx 配置
+
+```bash
+server {
+  listen       8051;
+  server_name  localhost;
+
+  # 知学知考
+  location / {
+    proxy_pass  http://localhost:8056;
+  }
+
+  # 阅卷端
+  location /mark/ {
+    proxy_pass  http://localhost:8059;
+
+  }
+
+  location /api/ {
+    # api代理地址
+    proxy_pass  http://192.168.11.167:7001;
+  }
+
+}
+```

+ 12 - 11
src/main.ts

@@ -38,14 +38,15 @@ app.component("QmDialog", QmDialog);
  */
  */
 initMarkStore();
 initMarkStore();
 
 
-if (import.meta.env.DEV) {
-  await import("./devLogin")
-    .then((m) => {
-      return m.initLogin();
-    })
-    .then(() => {
-      app.mount("#app");
-    });
-} else {
-  app.mount("#app");
-}
+// if (import.meta.env.DEV) {
+//   await import("./devLogin")
+//     .then((m) => {
+//       return m.initLogin();
+//     })
+//     .then(() => {
+//       app.mount("#app");
+//     });
+// } else {
+//   app.mount("#app");
+// }
+app.mount("#app");

+ 2 - 1
vite.config.ts

@@ -6,6 +6,7 @@ import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
 const viteEnv = loadEnv("development", process.cwd());
 const viteEnv = loadEnv("development", process.cwd());
 const SERVER_URL = viteEnv.VITE_APP_PROXY_URL;
 const SERVER_URL = viteEnv.VITE_APP_PROXY_URL;
 console.log("SERVER_URL:", SERVER_URL);
 console.log("SERVER_URL:", SERVER_URL);
+const isDev = viteEnv.VITE_ENV_TYPE === "development";
 
 
 const path = require("path");
 const path = require("path");
 
 
@@ -23,7 +24,7 @@ function mockDevLogin(): Plugin {
 
 
 // https://vitejs.dev/config/
 // https://vitejs.dev/config/
 export default defineConfig({
 export default defineConfig({
-  base: "./",
+  base: isDev ? "/mark" : "./",
   plugins: [
   plugins: [
     vue({
     vue({
       reactivityTransform: true,
       reactivityTransform: true,