tianyun vor 1 Jahr
Ursprung
Commit
0c2e801a3e
4 geänderte Dateien mit 12 neuen und 12 gelöschten Zeilen
  1. 1 1
      simple-demo/cp_excalidraw_frame.html
  2. 1 1
      simple-demo/edit_online.html
  3. 6 0
      simple-demo/js/util.js
  4. 4 10
      tmp/tmp.js

+ 1 - 1
simple-demo/cp_excalidraw_frame.html

@@ -10,7 +10,7 @@
 <script>
     let str = "{\"type\":\"excalidraw/clipboard\",\"elements\":[{\"type\":\"embeddable\",\"version\":180,\"versionNonce\":1920335448,\"isDeleted\":false,\"id\":\"f9LOsIKv8drPM8aOetFXl\",\"fillStyle\":\"hachure\",\"strokeWidth\":1,\"strokeStyle\":\"solid\",\"roughness\":1,\"opacity\":100,\"angle\":0,\"x\":864.2622041015625,\"y\":232.2603759765625,\"strokeColor\":\"#000000\",\"backgroundColor\":\"transparent\",\"width\":722.40234375,\"height\":318.40625,\"seed\":607107403,\"groupIds\":[],\"frameId\":null,\"roundness\":null,\"boundElements\":[],\"updated\":1704786477631,\"link\":\"https://web.tianyunperfect.cn/simple/edit_online.html?id=667374\",\"locked\":false,\"validated\":true}],\"files\":{}}";
     // 时间戳 秒
-    let timestamp = Date.parse(new Date()) - Date.parse(new Date('2024-01-01 00:00:00'));
+    let timestamp = getTimeStamp();
     str = str.replace(/667374/g, timestamp);
     // 复制到剪切板
     copyUtil.copyText(str);

+ 1 - 1
simple-demo/edit_online.html

@@ -55,7 +55,7 @@
 <script src="//cdn.quilljs.com/1.3.6/quill.js"></script>
 <script>
     // 获取当前时间戳 减去 2024年1月1日的时间戳
-    let timestamp = Date.parse(new Date()) - Date.parse(new Date('2024-01-01 00:00:00'));
+    let timestamp = getTimeStamp();
 
     let id = getQueryString("id");
     // 获取编辑器内容

+ 6 - 0
simple-demo/js/util.js

@@ -443,3 +443,9 @@ function closeWindow() {
 }
 
 
+function getTimeStamp() {
+    const currentTimeStamp = Date.now();
+    const targetTimeStamp = new Date('2024-01-01').getTime();
+    const difference = currentTimeStamp - targetTimeStamp;
+    return difference;
+}

+ 4 - 10
tmp/tmp.js

@@ -1,10 +1,4 @@
-let url = "http://localhost:3000/#room=d20a6268d8970c548f87,5ThfXj5qKTlrs1RdGriNVQ?a=47472717032&version=1";
-const RE_COLLAB_LINK = /^#room=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)/;
-
-
-let hash = new URL(url).hash;
-console.log(RE_COLLAB_LINK.test(hash));
-
-const match = hash.match(RE_COLLAB_LINK);
-console.log(match[1]);
-console.log(match[2].length);
+var currentTimeStamp = Date.now();
+var targetTimeStamp = new Date('2024-01-01').getTime();
+var difference = currentTimeStamp - targetTimeStamp;
+console.log(difference); // 输出时间戳差值