bill 2 rokov pred
rodič
commit
73b4ec6f2f

+ 1 - 2
.env

@@ -1,2 +1 @@
-VITE_API_BASE_URL=dev
-VITE_DEV_PORT = 5178
+VITE_DEV_PORT = 5178

+ 2 - 0
.env.development

@@ -0,0 +1,2 @@
+VITE_API_BASE_URL=dev
+VITE_DEV_PORT = 5178

+ 3 - 0
server/index.js

@@ -0,0 +1,3 @@
+import { createServer } from './mock.js'
+
+createServer(8080)

+ 12 - 3
server/mock.ts

@@ -2,19 +2,28 @@ import express from "express";
 import path from "path";
 import bodyParser from 'body-parser'
 import * as fs from "fs";
+import { fileURLToPath } from 'url';
 import fileUpload from 'express-fileupload'
 
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+
 const staticDir = path.resolve(__dirname, "test");
+const publicDir = path.resolve(__dirname, "../dist");
 
-console.log(staticDir);
 let startup = false;
-export async function createServer(port: number) {
+
+
+
+export async function createServer(port) {
   if (startup) {
     return;
   }
 
   const app = express();
   app.use(express.static(staticDir));
+  console.log(publicDir)
+  app.use(express.static(publicDir));
   app.use(bodyParser({ limit: '200mb' }))
   app.use(fileUpload({createParentPath: true}))
   app.listen(port);
@@ -36,7 +45,7 @@ export async function createServer(port: number) {
   })
 
   app.post("/:sceneCode/upload", (req, res) => {
-    const file = (req as any).files.file
+    const file = (req).files.file
     const relUrl = `/attach/upload/${file.name}`
     const absUrl = path.resolve(staticDir, `./${req.params.sceneCode}/${relUrl}`)
     console.log("上传图片完成路径为", relUrl)

+ 5 - 3
src/dbo/main.ts

@@ -2,13 +2,15 @@ import axios from 'axios'
 import {params} from "@/hook";
 
 const instance = axios.create()
-const baseURL =
+
+console.log(import.meta.env)
+export const baseURL =
   import.meta.env.VITE_API_BASE_URL
     ? `/${import.meta.env.VITE_API_BASE_URL}/${params.m}`
-    : "";
+    : `/${params.m}`;
 
 instance.defaults.baseURL = baseURL
 
 export const getStaticFile = (url: string) => baseURL + url
 
-export default instance
+export default instance

+ 1 - 1
src/graphic/CanvasStyle/default.js

@@ -93,7 +93,7 @@ const CurveRoadPoint = {
 const CrossPoint = {
   ...Point,
   strokeStyle: "#3290FF",
-  radius: 8 * coordinate.ratio,
+  radius: 2 * coordinate.ratio,
 };
 
 const Circle = {

+ 10 - 11
src/graphic/Renderer/Draw.js

@@ -282,7 +282,6 @@ export default class Draw {
     if (!isTemp && vector.display && vector.way !== "oneWay") {
       const ctx = this.context;
       const draw = (midDivide) => {
-        console.log(midDivide)
         const startScreen = coordinate.getScreenXY(midDivide.start);
         const endScreen = coordinate.getScreenXY(midDivide.end);
         ctx.beginPath();
@@ -360,13 +359,15 @@ export default class Draw {
         ctx.lineTo(point2.x, point2.y);
         ctx.stroke();
       }
-      this.drawTextByInfo(
-        {
-          x: (edgeVector.start.x + edgeVector.end.x) / 2,
-          y: (edgeVector.start.y + edgeVector.end.y) / 2,
-        },
-        edgeVector.vectorId
-      );
+      if (import.meta.env.DEV) {
+        this.drawTextByInfo(
+          {
+            x: (edgeVector.start.x + edgeVector.end.x) / 2,
+            y: (edgeVector.start.y + edgeVector.end.y) / 2,
+          },
+          edgeVector.vectorId
+        );
+      }
     };
 
     const leftEdge = isTemp
@@ -413,11 +414,9 @@ export default class Draw {
     const extremePoint = coordinate.getScreenXY(vector.extremePoint);
     const ctx = this.context;
     ctx.save();
-    ctx.strokeStyle = "red";
+    help.setVectorStyle(ctx, vector)
     ctx.beginPath();
     ctx.arc(
-      // pt.x,
-      // pt.y,
       extremePoint.x,
       extremePoint.y,
       Style.CrossPoint.radius * coordinate.ratio,

+ 2 - 2
src/store/sync.ts

@@ -10,13 +10,13 @@ import {base64ToBlob, blobToBase64, debounce, getId} from "@/utils";
 import {watch} from "vue";
 import {params} from "@/hook";
 import router, {writeRouteName} from "@/router";
-import {baseURL} from "@/dbo/local";
+import {baseURL} from "@/dbo/main";
 
 const global = window as any;
 
 let count = 0;
 export const api =
-  import.meta.env.DEV && !global.android
+  !global.android
   // true
     ? // const api = import.meta.env.DEV
       {

+ 1 - 0
vite.config.ts

@@ -1,6 +1,7 @@
 import { defineConfig, loadEnv } from "vite";
 import vue from "@vitejs/plugin-vue";
 import path from "path";
+// @ts-ignore
 import { createServer as createMockServer } from "./server/mock";
 
 export default async ({ mode }) => {