From b86eddcc2eb72c68e41ff33a259939e7e9f6db24 Mon Sep 17 00:00:00 2001 From: "yuekin.wang" Date: Wed, 20 Dec 2023 09:39:21 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=AF=BC?= =?UTF-8?q?=E5=85=A5json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Editor/layouts/header/headerBar.vue | 30 +- .../Editor/layouts/header/left/fileOper.vue | 410 +++++++++--------- .../Editor/layouts/header/right/saveOper.vue | 6 - 3 files changed, 229 insertions(+), 217 deletions(-) diff --git a/src/views/Editor/layouts/header/headerBar.vue b/src/views/Editor/layouts/header/headerBar.vue index 6f23728..a9ee485 100644 --- a/src/views/Editor/layouts/header/headerBar.vue +++ b/src/views/Editor/layouts/header/headerBar.vue @@ -5,6 +5,11 @@

不做简历

+
+ + + + +
@@ -47,31 +51,27 @@ import { Platform, Group, Text, Line, Rect, Image } from "leafer-ui"; import { getDefaultName } from "@/views/Editor/utils/utils"; import Zoom from "./left/zoom.vue"; import SaveOper from "./right/saveOper.vue"; +import { selectFiles } from "@/utils/designUtil"; Platform.image.suffix = ""; -const { keybinding, editor } = useEditor(); - +const { canvas, keybinding, editor } = useEditor(); const changeLineGuides = () => { keybinding.trigger("shift+r"); } -const dragStart = (e: Element, item: any) => {} - const iconList = ref([ { name: "icon-24gl-pointer", content: "选择", type: "point" }, - // { name: 'icon-bianji', content: '铅笔', type: 'pencil' }, { name: "icon-editor-text", content: "文字", type: "text" }, { name: "icon-fengexian", content: "线", type: "line" }, { name: "icon-kuang", content: "框", type: "box" }, { name: "icon-tupian", content: "图片", type: "img" }, ]); - const nowSelectOp = ref({ name: "icon-24gl-pointer", content: "选择", type: "point", }) -function selectOp(item: any) { +const selectOp = (item: any) => { if (item === -1) { changeLineGuides() } else { @@ -80,10 +80,21 @@ function selectOp(item: any) { } } -function gotoGithub() { +const gotoGithub = () => { window.open("https://github.com/shuangxunian/no-resume", "_blank"); } +const importJsonFile = () => { + selectFiles({ accept: ".json" }).then((files: any) => { + const [file] = files + const reader = new FileReader() + reader.readAsText(file, "UTF-8") + reader.onload = () => { + canvas.importJsonToCurrentPage(JSON.parse(reader.result), true) + } + }) +} + const addText = (item: any) => { let text; if (editor.objectIsTypes(item.json, "Text")) { @@ -215,6 +226,7 @@ const iconClick = (item: any) => { border-radius: 8px; line-height: 32px; text-align: center; + cursor: pointer; } .select-icon-box { background-color: #e9e7ef; diff --git a/src/views/Editor/layouts/header/left/fileOper.vue b/src/views/Editor/layouts/header/left/fileOper.vue index 670d8c6..cb44ee7 100644 --- a/src/views/Editor/layouts/header/left/fileOper.vue +++ b/src/views/Editor/layouts/header/left/fileOper.vue @@ -1,227 +1,233 @@ - + diff --git a/src/views/Editor/layouts/header/right/saveOper.vue b/src/views/Editor/layouts/header/right/saveOper.vue index 32b35dc..0806b7b 100644 --- a/src/views/Editor/layouts/header/right/saveOper.vue +++ b/src/views/Editor/layouts/header/right/saveOper.vue @@ -6,12 +6,6 @@ 预览 - - - 保存 - 下载作品