Quellcode durchsuchen

fix: 添加需求

bill vor 2 Jahren
Ursprung
Commit
c6e54f9a49

+ 49 - 3
src/components/base/components/icon/iconfont/demo_index.html

@@ -55,6 +55,18 @@
           <ul class="icon_lists dib-box">
           
             <li class="dib">
+              <span class="icon iconfont">&#xe7aa;</span>
+                <div class="name">share</div>
+                <div class="code-name">&amp;#xe7aa;</div>
+              </li>
+          
+            <li class="dib">
+              <span class="icon iconfont">&#xe7a9;</span>
+                <div class="name">impower</div>
+                <div class="code-name">&amp;#xe7a9;</div>
+              </li>
+          
+            <li class="dib">
               <span class="icon iconfont">&#xe7a8;</span>
                 <div class="name">tabulation</div>
                 <div class="code-name">&amp;#xe7a8;</div>
@@ -954,9 +966,9 @@
 <pre><code class="language-css"
 >@font-face {
   font-family: 'iconfont';
-  src: url('iconfont.woff2?t=1689556787062') format('woff2'),
-       url('iconfont.woff?t=1689556787062') format('woff'),
-       url('iconfont.ttf?t=1689556787062') format('truetype');
+  src: url('iconfont.woff2?t=1691631024836') format('woff2'),
+       url('iconfont.woff?t=1691631024836') format('woff'),
+       url('iconfont.ttf?t=1691631024836') format('truetype');
 }
 </code></pre>
           <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@@ -983,6 +995,24 @@
         <ul class="icon_lists dib-box">
           
           <li class="dib">
+            <span class="icon iconfont icon-share"></span>
+            <div class="name">
+              share
+            </div>
+            <div class="code-name">.icon-share
+            </div>
+          </li>
+          
+          <li class="dib">
+            <span class="icon iconfont icon-impower"></span>
+            <div class="name">
+              impower
+            </div>
+            <div class="code-name">.icon-impower
+            </div>
+          </li>
+          
+          <li class="dib">
             <span class="icon iconfont icon-tabulation"></span>
             <div class="name">
               tabulation
@@ -2334,6 +2364,22 @@
           
             <li class="dib">
                 <svg class="icon svg-icon" aria-hidden="true">
+                  <use xlink:href="#icon-share"></use>
+                </svg>
+                <div class="name">share</div>
+                <div class="code-name">#icon-share</div>
+            </li>
+          
+            <li class="dib">
+                <svg class="icon svg-icon" aria-hidden="true">
+                  <use xlink:href="#icon-impower"></use>
+                </svg>
+                <div class="name">impower</div>
+                <div class="code-name">#icon-impower</div>
+            </li>
+          
+            <li class="dib">
+                <svg class="icon svg-icon" aria-hidden="true">
                   <use xlink:href="#icon-tabulation"></use>
                 </svg>
                 <div class="name">tabulation</div>

+ 11 - 3
src/components/base/components/icon/iconfont/iconfont.css

@@ -1,8 +1,8 @@
 @font-face {
   font-family: "iconfont"; /* Project id 4084834 */
-  src: url('iconfont.woff2?t=1689556787062') format('woff2'),
-       url('iconfont.woff?t=1689556787062') format('woff'),
-       url('iconfont.ttf?t=1689556787062') format('truetype');
+  src: url('iconfont.woff2?t=1691631024836') format('woff2'),
+       url('iconfont.woff?t=1691631024836') format('woff'),
+       url('iconfont.ttf?t=1691631024836') format('truetype');
 }
 
 .iconfont {
@@ -13,6 +13,14 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.icon-share:before {
+  content: "\e7aa";
+}
+
+.icon-impower:before {
+  content: "\e7a9";
+}
+
 .icon-tabulation:before {
   content: "\e7a8";
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
src/components/base/components/icon/iconfont/iconfont.js


+ 14 - 0
src/components/base/components/icon/iconfont/iconfont.json

@@ -6,6 +6,20 @@
   "description": "交通事故现场勘验系统",
   "glyphs": [
     {
+      "icon_id": "36848606",
+      "name": "share",
+      "font_class": "share",
+      "unicode": "e7aa",
+      "unicode_decimal": 59306
+    },
+    {
+      "icon_id": "36634890",
+      "name": "impower",
+      "font_class": "impower",
+      "unicode": "e7a9",
+      "unicode_decimal": 59305
+    },
+    {
       "icon_id": "36453663",
       "name": "tabulation",
       "font_class": "tabulation",

BIN
src/components/base/components/icon/iconfont/iconfont.ttf


BIN
src/components/base/components/icon/iconfont/iconfont.woff


BIN
src/components/base/components/icon/iconfont/iconfont.woff2


+ 0 - 1
src/main.ts

@@ -14,7 +14,6 @@ import { setupI18n } from "@/lang";
 import { router, setupRouter } from "@/router";
 import appConfig from "./appConfig";
 import { currentApp, setCurrentApp } from "@/store/app";
-import { os } from "@/utils";
 import App from "./main.vue";
 
 const app = createApp(App);

+ 20 - 45
src/store/sync.ts

@@ -51,6 +51,9 @@ export const api = !global.android
         window.open(URL.createObjectURL(file));
         return true;
       },
+      async shareImage(filename: string) {
+        await window.open(await api.getFile(filename));
+      },
       async getFile(url) {
         if (url.includes(baseURL)) {
           url = url.substring(baseURL.length);
@@ -91,6 +94,17 @@ export const api = !global.android
       },
     }
   : {
+      shareImage(filename: string) {
+        return new Promise((resolve) => {
+          console.log("shareImage", filename);
+          global.shareImageCallback = (data) => {
+            console.log("shareImage返回", data);
+            delete global.shareImageCallback;
+            resolve(data);
+          };
+          global.android.shareImage(filename, "shareImageCallback");
+        });
+      },
       setStore(data) {
         return new Promise((resolve) => {
           console.log("调用setSceneStore参数", JSON.stringify(data));
@@ -112,19 +126,14 @@ export const api = !global.android
             console.log("getSceneStoreCallback返回", data);
             resolve(data);
           };
-          global.android.getSceneStore(
-            params.m + "/store.json",
-            "getSceneStoreCallback"
-          );
+          global.android.getSceneStore(params.m + "/store.json", "getSceneStoreCallback");
         });
       },
       // genUseLoading()
       async getFile(fileUrl: string) {
         fileUrl = fileUrl.trim();
         if (fileUrl.includes(params.m)) {
-          fileUrl = fileUrl.substring(
-            fileUrl.indexOf(params.m) + params.m.length
-          );
+          fileUrl = fileUrl.substring(fileUrl.indexOf(params.m) + params.m.length);
         }
         fileUrl = new URL(fileUrl, "http://www.a.com").pathname;
         fileUrl = (params.realPath || params.m) + fileUrl;
@@ -142,10 +151,7 @@ export const api = !global.android
           return await new Promise<string>((resolve) => {
             const apiName = `getImageCallback${count++}`;
             global[apiName] = (base64) => {
-              console.error(
-                "请求url:" + fileUrl,
-                "返回:" + base64.substring(0, 60)
-              );
+              console.error("请求url:" + fileUrl, "返回:" + base64.substring(0, 60));
               resolve(URL.createObjectURL(base64ToBlob(base64)));
               delete global[apiName];
             };
@@ -245,15 +251,12 @@ const loadStore = async () => {
 };
 
 export const updateSceneStore = debounce(api.setStore, 300);
-export const uploadImage = (blob: Blob) => {
-  const file = new File([blob], `${getId()}.jpg`);
+export const uploadImage = (blob: Blob, name = `${getId()}.jpg`) => {
+  const file = new File([blob], name);
   return api.uploadImage(file);
 };
 
-export const downloadImage = async (
-  data: Blob | string,
-  name: string = getId()
-) => {
+export const downloadImage = async (data: Blob | string, name: string = getId()) => {
   const blob: Blob =
     typeof data === "string"
       ? (await axios.get(data, { responseType: "blob" })).data
@@ -282,34 +285,6 @@ const syncSceneStore = () => {
     { deep: true }
   );
 };
-//
-// // if (global.android) {
-//   const isEditInput = (dom: HTMLElement) => {
-//     const tagName = dom.tagName.toUpperCase();
-//     const isInput = tagName === "INPUT"
-//     const isTextarea = tagName === "TEXTAREA"
-//     console.log(isInput && dom.getAttribute("type") === "text")
-//     if (!(isInput && dom.getAttribute("type") === "text") && !isTextarea) {
-//       return false;
-//     }
-//     console.log("???")
-//     return !dom.hasAttribute("readonly")
-//   }
-//   document.documentElement.addEventListener('focusin', ev => {
-//     console.log("获得焦点")
-//     console.log(ev.target)
-//     if (isEditInput(ev.target as HTMLElement)) {
-//       global.android.inputMethodManager(true);
-//     }
-//   })
-//   document.documentElement.addEventListener('focusout', ev => {
-//     console.log("失去焦点")
-//     console.log(ev.target)
-//     if (isEditInput(ev.target as HTMLElement)) {
-//       global.android.inputMethodManager(false);
-//     }
-//   })
-// // }
 
 loadStore().catch((e) => {
   console.error(e);

+ 8 - 0
src/views/photos/index.vue

@@ -100,6 +100,14 @@ const menus = [
     text: "删除",
     onClick: () => delPhoto(),
   },
+  {
+    key: "share",
+    icon: "share",
+    text: "分享",
+    onClick: () => {
+      api.shareImage(active.value.url);
+    },
+  },
 ];
 
 const selectMenus = [

+ 11 - 4
src/views/scene/photo.vue

@@ -27,7 +27,7 @@ import { photos } from "@/store/photos";
 import { useSDK } from "@/hook/useLaser";
 import { genUseLoading } from "@/hook";
 import { disabledMap } from "@/hook/custom";
-import { base64ToBlob, getId } from "@/utils";
+import { base64ToBlob, formatDate, getId } from "@/utils";
 import { computed, nextTick, ref } from "vue";
 import { api, downloadImage, uploadImage } from "@/store/sync";
 import { router, writeRouteName } from "@/router";
@@ -55,10 +55,17 @@ const screenshot = async (sdk: LaserSDK) => {
   const dom = sdk.scene.el;
   dom.style.pointerEvents = "none";
 
-  const getScreenshot = async () => {
+  const getScreenshot = async (down = false) => {
     const data = sdk.scene.screenshot(dom.offsetWidth, dom.offsetHeight);
     const { dataUrl: base64 } = await data.finishPromise;
-    const url = await uploadImage(base64ToBlob(base64));
+    const blob = base64ToBlob(base64);
+    const filename = `img_${formatDate(new Date(), "yyyyMMddhhmmss")}_${
+      data.meterPerPixel || 1
+    }.jpg`;
+    const url = await uploadImage(blob, filename);
+    if (down) {
+      await downloadImage(blob, filename);
+    }
     return {
       url,
       meterPerPixel: data.meterPerPixel,
@@ -68,7 +75,7 @@ const screenshot = async (sdk: LaserSDK) => {
 
   baseLines.value.concat(list.value).forEach((item) => (item.show = false));
   await nextTick();
-  const screenshot = await getScreenshot();
+  const screenshot = await getScreenshot(true);
   baseLines.value.concat(list.value).forEach((item) => (item.show = true));
   await nextTick();