|
@@ -132,10 +132,34 @@
|
|
|
|
|
|
<div class="flex-grow"></div>
|
|
|
<t-tooltip content="预览" placement="bottom">
|
|
|
- <a><t-icon name="browse" /></a>
|
|
|
+ <a @click="preview"><t-icon name="browse" /></a>
|
|
|
</t-tooltip>
|
|
|
- <t-tooltip content="运行" placement="bottom">
|
|
|
- <a><t-icon name="caret-right" /></a>
|
|
|
+ <t-tooltip
|
|
|
+ :content="isLock === 2 ? '锁定' : isLock === 1 ? '预览' : '编辑'"
|
|
|
+ placement="bottom"
|
|
|
+ >
|
|
|
+ <a>
|
|
|
+ <!-- <t-icon name="caret-right" /> -->
|
|
|
+ <svg
|
|
|
+ v-if="isLock === 1"
|
|
|
+ class="l-icon"
|
|
|
+ aria-hidden="true"
|
|
|
+ @click="onLock"
|
|
|
+ >
|
|
|
+ <use xlink:href="#l-lock"></use>
|
|
|
+ </svg>
|
|
|
+ <svg
|
|
|
+ v-else-if="isLock === 2"
|
|
|
+ class="l-icon"
|
|
|
+ aria-hidden="true"
|
|
|
+ @click="onLock"
|
|
|
+ >
|
|
|
+ <use xlink:href="#l-wufayidong"></use>
|
|
|
+ </svg>
|
|
|
+ <svg v-else class="l-icon" aria-hidden="true" @click="onLock">
|
|
|
+ <use xlink:href="#l-unlock"></use>
|
|
|
+ </svg>
|
|
|
+ </a>
|
|
|
</t-tooltip>
|
|
|
<t-tooltip content="手机查看" placement="bottom">
|
|
|
<a><t-icon name="qrcode" /></a>
|
|
@@ -156,7 +180,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { Meta2d, Options, Pen, deepClone } from "@meta2d/core";
|
|
|
+import { Meta2d, Options, Pen, deepClone, LockState } from "@meta2d/core";
|
|
|
import { onMounted, onUnmounted, watch, ref, reactive } from "vue";
|
|
|
import { registerBasicDiagram } from "@/services/register";
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
@@ -173,7 +197,9 @@ import {
|
|
|
import { useSelection, SelectionMode } from "@/services/selections";
|
|
|
import { defaultFormat } from "@/services/defaults";
|
|
|
import { MessagePlugin } from "tdesign-vue-next";
|
|
|
-
|
|
|
+import { localMeta2dDataName } from "@/services/utils";
|
|
|
+import localforage from "localforage";
|
|
|
+import { checkData } from "@/services/utils";
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
const { user, message, getUser, getMessage, signout } = useUser();
|
|
@@ -401,6 +427,38 @@ const onAddShape = (event: DragEvent, name: string) => {
|
|
|
}
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
+
|
|
|
+const isLock = ref(0);
|
|
|
+function onLock() {
|
|
|
+ !isLock.value && (isLock.value = 0);
|
|
|
+ if (isLock.value === LockState.DisableMove) {
|
|
|
+ isLock.value = LockState.None;
|
|
|
+ } else {
|
|
|
+ isLock.value++;
|
|
|
+ }
|
|
|
+ meta2d.lock(isLock.value);
|
|
|
+ meta2d.hideInput();
|
|
|
+}
|
|
|
+
|
|
|
+const preview = async () => {
|
|
|
+ meta2d.stopAnimate();
|
|
|
+ const data: Meta2dBackData = meta2d.data();
|
|
|
+ checkData(data);
|
|
|
+ if (dot && user && data._id) {
|
|
|
+ // 有 id ,是修改后保存
|
|
|
+ await save(SaveType.Save);
|
|
|
+ }
|
|
|
+ if (!data._id) {
|
|
|
+ await localforage.setItem(localMeta2dDataName, JSON.stringify(data));
|
|
|
+ }
|
|
|
+ router.push({
|
|
|
+ path: "/preview",
|
|
|
+ query: {
|
|
|
+ r: Date.now() + "",
|
|
|
+ id: data._id,
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="postcss" scoped>
|
|
|
.meta2d {
|