gemercheung 1 éve
szülő
commit
b560fa7c2b

+ 53 - 24
src/app/mirror/App.vue

@@ -91,7 +91,7 @@
               :class="{
                 activefileList: row.fileList && row.fileList.length == 1,
               }"
-            :before-upload="beforeUpload"
+              :before-upload="beforeUpload"
               list-type="picture-card"
               :action="uploadFileUrl"
               :on-success="handleUploadSuccess"
@@ -149,7 +149,7 @@
             <div class="marksDiv">
               <el-input
                 class="gray"
-                  maxlength="1000"
+                maxlength="1000"
                 type="textarea"
                 :autosize="{ minRows: 3 }"
                 v-model="row.marks"
@@ -202,9 +202,18 @@ link.setAttribute("href", linkIco);
 
 const caseId = ref(null);
 const project = reactive({
-  title: '我的脚本',
+  title: "我的脚本",
 });
-const DrawFormats = [".jpg", ".jpeg", ".png",".mp4",".m4v",".mp3",".aac", ".wav"]
+const DrawFormats = [
+  ".jpg",
+  ".jpeg",
+  ".png",
+  ".mp4",
+  ".m4v",
+  ".mp3",
+  ".aac",
+  ".wav",
+];
 const isNotFound = ref(false);
 
 const dialogImageUrl = ref("");
@@ -261,16 +270,16 @@ const columns = ref([
   { prop: "marks", label: "备注" },
 ]);
 const beforeUpload = async (file: File) => {
-    const fileType = file.name
-      .substring(file.name.lastIndexOf("."))
-      .toUpperCase();
-    if (!DrawFormats.some((type) => type.toUpperCase() === fileType)) {
-      ElMessage.error(`请上传${DrawFormats}格式的文件`);
-      return false;
-    } else {
-      return true;
-    }
-  };
+  const fileType = file.name
+    .substring(file.name.lastIndexOf("."))
+    .toUpperCase();
+  if (!DrawFormats.some((type) => type.toUpperCase() === fileType)) {
+    ElMessage.error(`请上传${DrawFormats}格式的文件`);
+    return false;
+  } else {
+    return true;
+  }
+};
 const checkSourceIsVideo = computed(() => (url: string) => {
   return url.includes(".mp4") || url.includes(".m4v");
 });
@@ -278,7 +287,12 @@ const checkSourceIsAudio = computed(() => (url: string) => {
   return url.includes(".mp3") || url.includes(".aac") || url.includes(".wav");
 });
 const checkSourceIsImage = computed(() => (url: string) => {
-  return url.includes(".jpg") || url.includes(".png") || url.includes(".jpeg") || url.includes(".gif");
+  return (
+    url.includes(".jpg") ||
+    url.includes(".png") ||
+    url.includes(".jpeg") ||
+    url.includes(".gif")
+  );
 });
 
 const getCoverUrl = computed(() => (url: string) => {
@@ -287,7 +301,10 @@ const getCoverUrl = computed(() => (url: string) => {
     //   return (
     //     url + "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"
     //   );
-    case url.includes(".mp3") ||  url.includes(".aac") || url.includes(".wmv") || url.includes(".wav"):
+    case url.includes(".mp3") ||
+      url.includes(".aac") ||
+      url.includes(".wmv") ||
+      url.includes(".wav"):
       return musicHeadphones;
     default:
       return url;
@@ -310,19 +327,32 @@ onMounted(async () => {
       isNotFound.value = true;
     }
   } catch (error) {
-    isNotFound.value = true;
+    //TODO hack 由于没hook
+    if (error === "用户未登录") {
+      location.href = getRootLoginURl();
+    } else {
+      isNotFound.value = true;
+    }
   }
 
   getCaseScriptList();
   console.log("caseId", caseId); //query传参
 });
 
+function getRootLoginURl() {
+  const currentPath = location.pathname.replace("/mirror.html", "");
+  const loginUrl =
+    location.protocol + "//" + location.host + currentPath + "/#/login";
+  console.log("loginUrl", loginUrl);
+  return loginUrl;
+}
+
 function getCaseScriptList() {
   getCaseScriptInfo(caseId.value)
     .then((res) => {
-      project.title = res && res.name || '我的脚本';
-      data.list = res && res.content || [];
-      data.newSortList = res && res.content || [];
+      project.title = (res && res.name) || "我的脚本";
+      data.list = (res && res.content) || [];
+      data.newSortList = (res && res.content) || [];
       const idList = data.list.map((ele) => ele.id);
       active.value = idList.length == 0 ? 0 : Math.max.apply(null, idList) || 1;
       sortList.value = data.list.map((_, index) => index);
@@ -348,8 +378,7 @@ function handleAdd() {
   // data.list.length = 0;
   // Object.assign(data.list, content);
   console.log("add", data.list, data.newSortList);
-  if(data.newSortList.length == 0){
-
+  if (data.newSortList.length == 0) {
   }
   for (var i = 1; i <= addLine.value; i++) {
     console.log(i);
@@ -389,11 +418,11 @@ const handlePictureCardPreview = (file: UploadFile) => {
 const saveProject = () => {
   // let content = sortList.value.map((index) => data.list[index]);
   let apiDataList = data.newSortList.map((item) => {
-    let asData = data.list.find(ele => ele.id === item.id) || {};
+    let asData = data.list.find((ele) => ele.id === item.id) || {};
     return {
       ...item,
       ...asData,
-    }
+    };
   });
   console.log("saveProject", data.list, data.newSortList);
   CaseScriptSaveOrUpdate({

+ 4 - 1
src/app/mirror/store/script.ts

@@ -66,7 +66,10 @@ export const getCaseScriptInfo = async (caseId) => {
     return res.data;
   } else {
     // window.location.href = '/'
-    throw "用户未登录";
+    throw {
+      code: 4008,
+      msg: "用户未登录"
+    };
   }
 };
 

+ 35 - 7
src/core/Scene.js

@@ -269,6 +269,7 @@ export default class Scene extends Mitt {
     let slides = Math.floor(total / 3);
 
     console.log("slides", slides);
+
     if (slides >= 1) {
       for (var i = 0; i <= slides; i++) {
         (function (index, that) {
@@ -296,13 +297,40 @@ export default class Scene extends Mitt {
   }
   test() {
     const object = this.boxManager.model;
-    const box = new THREE.Box3().setFromObject(object);
-    let size = new THREE.Vector3();
-    box.getSize(size);
-    const distance = this.orthCamera.position.distanceTo(object.position);
-    console.log("size", size);
-    console.log("distance", distance);
-    new screenshotObject(object, this.orthCamera, this.renderer);
+    const boundingBox = new THREE.Box3().setFromObject(object);
+    this.lockView(true);
+    // let size = new THREE.Vector3();
+    // boundingBox.getSize(size);
+    const width = boundingBox.max.x - boundingBox.min.x;
+    const height = boundingBox.max.y - boundingBox.min.y;
+    const z = boundingBox.max.z - boundingBox.min.z;
+    const radio = width / height;
+    // const dynamicWidth = this.height * radio;
+
+    // (this.orthCamera.left = -dynamicWidth / 2),
+    //   (this.orthCamera.right = dynamicWidth / 2),
+    //   (this.orthCamera.bottom = -this.height / 2),
+    //   (this.orthCamera.top = this.height / 2),
+    //   this.orthCamera.updateProjectionMatrix();
+
+    // this.renderer.setSize(dynamicWidth, this.height);
+    // this.renderRes = window.devicePixelRatio;
+    // this.defaultUseZoom = this.defaultZoom / this.renderRes;
+    // this.renderer.setPixelRatio(this.renderRes);
+
+    // console.log("dynamicWidth", dynamicWidth);
+
+    // console.log("height", height);
+  }
+
+  center() {
+    const center = new THREE.Vector3();
+    // const object = new THREE.Mesh(
+    //   this.boxManager.model,
+    //   new THREE.MeshBasicMaterial(0xff0000)
+    // );
+    // const box = new THREE.BoxHelper(object, 0xffff00);
+    // this.scene.add(box);
   }
 
   onBindEvent = () => {

+ 2 - 1
src/core/utils/cap.js

@@ -11,6 +11,7 @@ export function screenshotObject(obj, camera, renderer) {
   var distance = this.distance();
   this.size = this.getSizeInPixel(distance);
   this.pos = this.getPositionInPixel();
+  debugger;
   this.getImage(this.size.w, this.size.h, this.pos.x, this.pos.y);
 }
 
@@ -28,7 +29,7 @@ screenshotObject.prototype.getSizeInPixel = function (distance) {
   self.box.getSize(size);
 
   // Calc visible height and width
-  var vFOV = THREE.Math.degToRad(self.camera.fov); // convert vertical fov to radians
+  var vFOV = THREE.MathUtils.degToRad(self.camera.far); // convert vertical fov to radians
   var height = 2 * Math.tan(vFOV / 2) * Math.abs(distance); // visible height
   var width =
     height * (self.renderer.domElement.width / self.renderer.domElement.height); // visible width

+ 8 - 2
src/view/case/caseFile.vue

@@ -198,11 +198,17 @@ onMounted(async () => {
     } else {
       console.error("该案件不存在!");
       throw "该案件不存在!";
-      // router.replace({ name: RouteName.noCase });
     }
   } catch (error) {
     console.error("该案件不存在!");
-    router.replace({ name: RouteName.noCase });
+    // debugger;
+    //TODO 由于没有登录状态可以判断或hook插入,只能延时进入no-case router当前的router
+    setTimeout(() => {
+      console.log("current-router", router.currentRoute.value.name);
+      if (router.currentRoute.value.name !== "login") {
+        router.replace({ name: RouteName.noCase });
+      }
+    }, 1000);
   }
 });