diff --git a/src/App.vue b/src/App.vue index 2c7a76e..6feeac0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,17 @@ diff --git a/src/components/editor/blocks/font/index.ts b/src/components/editor/blocks/font/index.ts new file mode 100644 index 0000000..02bb70f --- /dev/null +++ b/src/components/editor/blocks/font/index.ts @@ -0,0 +1,19 @@ +import Option from "./option.vue"; +import Render from "./render.vue"; +import { Font } from "./interface"; +export * from "./interface"; + +export const FontRender = Render; + +export const FontOption = Option; + +export const font: Font = { + content: "请输入文字", + family: "microsoft yahei", + size: 14, + color: "#000000", + bold: false, + italic: false, + underline: false, + align: 3, +}; diff --git a/src/components/editor/blocks/font/interface.ts b/src/components/editor/blocks/font/interface.ts new file mode 100644 index 0000000..805ae12 --- /dev/null +++ b/src/components/editor/blocks/font/interface.ts @@ -0,0 +1,124 @@ +import { CSSProperties, StyleValue } from "vue"; + +export interface Font { + /** + * 文字内容 + */ + content: string; + /** + * 字体 + */ + family: string; + /** + * 字号(px) + */ + size: number; + /** + * 颜色(16进制) + */ + color: string; + /** + * 是否加粗 + */ + bold: boolean; + /** + * 是否斜体 + */ + italic: boolean; + /** + * 是否下划线 + */ + underline: boolean; + /** + * 对齐方式 + */ + align: number; +} + +export const AlignOptions = [ + { + label: "居上", + value: 1, + }, + { + label: "居下", + value: 2, + }, + { + label: "居中", + value: 3, + }, + { + label: "居左", + value: 4, + }, + { + label: "居右", + value: 5, + }, +]; + +export const FontFamilyOptions = [ + { + label: "微软雅黑", + value: "microsoft yahei", + }, + { + label: "黑体", + value: "gothic", + }, + { + label: "宋体", + value: "simsun", + }, + { + label: "Arial", + value: "arial", + }, +]; + +export const getFontStyle = (font: Font) => { + const { size, family: fontFamily, color, bold, italic, underline, align } = font; + const fontSize = `${size}px`; + const fontWeight = bold ? "bold" : "normal"; + const fontStyle = italic ? "italic" : "normal"; + const textDecoration = underline ? "underline" : "none"; + let textAlign = "left"; + let verticalAlign = "middle"; + + switch (align) { + case 1: + textAlign = "center"; + verticalAlign = "top"; + break; + case 2: + textAlign = "center"; + verticalAlign = "bottom"; + break; + case 3: + textAlign = "center"; + verticalAlign = "middle"; + break; + case 4: + textAlign = "left"; + verticalAlign = "middle"; + break; + case 5: + textAlign = "right"; + verticalAlign = "middle"; + break; + default: + break; + } + + return { + fontFamily, + fontSize, + fontWeight, + fontStyle, + textDecoration, + color, + textAlign, + verticalAlign, + } as CSSProperties; +}; diff --git a/src/components/editor/blocks/font/option.vue b/src/components/editor/blocks/font/option.vue new file mode 100644 index 0000000..ff70001 --- /dev/null +++ b/src/components/editor/blocks/font/option.vue @@ -0,0 +1,70 @@ + + + + + +./types \ No newline at end of file diff --git a/src/components/editor/blocks/font/render.vue b/src/components/editor/blocks/font/render.vue new file mode 100644 index 0000000..f07af59 --- /dev/null +++ b/src/components/editor/blocks/font/render.vue @@ -0,0 +1,28 @@ + + + + + +./types diff --git a/src/components/editor/blocks/index.ts b/src/components/editor/blocks/index.ts index 6ee82cd..96140f6 100644 --- a/src/components/editor/blocks/index.ts +++ b/src/components/editor/blocks/index.ts @@ -1,11 +1,11 @@ import Text from "./text"; export const BlockerMap = { - [Text.initial.type]: Text, + [Text.type]: Text, }; export const getBlockerRender = (type: string) => { return BlockerMap[type].render; -} +}; -export default BlockerMap; \ No newline at end of file +export default BlockerMap; diff --git a/src/components/editor/blocks/text/index.ts b/src/components/editor/blocks/text/index.ts index 64dd377..8c63e60 100644 --- a/src/components/editor/blocks/text/index.ts +++ b/src/components/editor/blocks/text/index.ts @@ -1,27 +1,44 @@ -import { defineBlocker } from '../../config' -import Option from './option.vue' -import Render from './render.vue' -export * from './interface' +import { defineBlocker } from "../../config"; +import Render from "./render.vue"; +import Option from "./option.vue"; +import { TextData } from "./interface"; -export default defineBlocker({ +export default defineBlocker({ + type: "text", + icon: "icon-park-outline-text", + title: "文本组件", + description: "文字", + render: Render, + option: Option, initial: { id: "", type: "text", x: 0, y: 0, - w: 50, - h: 50, + w: 300, + h: 100, xFixed: false, yFixed: false, bgImage: "", bgColor: "", - data: {}, meta: {}, actived: false, resizable: true, draggable: true, + data: { + marquee: false, + marqueeSpeed: 1, + marqueeDirection: "left", + fontCh: { + content: "请输入文字", + family: "微软雅黑", + size: 14, + color: "#000000", + bold: false, + italic: false, + underline: false, + align: 3, + }, + }, }, - render: Render, - option: Option, -}) - +}); diff --git a/src/components/editor/blocks/text/interface.ts b/src/components/editor/blocks/text/interface.ts index 80de743..999180c 100644 --- a/src/components/editor/blocks/text/interface.ts +++ b/src/components/editor/blocks/text/interface.ts @@ -1,87 +1,43 @@ -export interface Text { +import { Font } from "../font"; + +export interface TextData { /** - * 文字内容 + * 是否滚动 */ - text: string; + marquee?: boolean; /** - * 字体 + * 滚动速度 */ - family: string; + marqueeSpeed?: number; /** - * 字号(px) + * 滚动方向 */ - size: number; + marqueeDirection?: "left" | "right" | "up" | "down"; /** - * 颜色(16进制) + * 内容(中文) */ - color: string; - /** - * 是否加粗 - */ - bold: boolean; - /** - * 是否斜体 - */ - italic: boolean; - /** - * 是否下划线 - */ - underline: boolean; - /** - * 对齐方式 - */ - align: number; + fontCh: Font; } -export const DefaultText: Text = { - text: "双击编辑文字", - family: "microsoft yahei", - size: 14, - color: "#000000", - bold: false, - italic: false, - underline: false, - align: 3, -} - -export const TextAlignOptions = [ +export const DirectionOptions = [ { - label: "居上", - value: 1, + icon: "icon-park-outline-arrow-left", + tip: "向左滚动", + value: "left", }, { - label: "居下", - value: 2, + icon: "icon-park-outline-arrow-up", + tip: "向上滚动", + value: "up", }, { - label: "居中", - value: 3, + icon: "icon-park-outline-arrow-down", + tip: "向下滚动", + value: "down", }, { - label: "居左", - value: 4, - }, - { - label: "居右", - value: 5, - }, -]; - -export const TextFamilyOptions = [ - { - label: "微软雅黑111111111", - value: "microsoft yahei", - }, - { - label: "黑体", - value: "gothic", - }, - { - label: "宋体", - value: "simsun", - }, - { - label: "Arial", - value: "arial", + icon: "icon-park-outline-arrow-right", + tip: "向右滚动", + value: "right", }, ]; diff --git a/src/components/editor/blocks/text/marquee.vue b/src/components/editor/blocks/text/marquee.vue new file mode 100644 index 0000000..a1e2030 --- /dev/null +++ b/src/components/editor/blocks/text/marquee.vue @@ -0,0 +1,224 @@ + + + + + diff --git a/src/components/editor/blocks/text/option.vue b/src/components/editor/blocks/text/option.vue index ef4205b..15be301 100644 --- a/src/components/editor/blocks/text/option.vue +++ b/src/components/editor/blocks/text/option.vue @@ -1,65 +1,57 @@ + + diff --git a/src/components/editor/blocks/text/render.vue b/src/components/editor/blocks/text/render.vue index cbcf4e5..d62c9f3 100644 --- a/src/components/editor/blocks/text/render.vue +++ b/src/components/editor/blocks/text/render.vue @@ -1,64 +1,31 @@ diff --git a/src/components/editor/components/BaseOption.vue b/src/components/editor/components/BaseOption.vue new file mode 100644 index 0000000..69af507 --- /dev/null +++ b/src/components/editor/components/BaseOption.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/editor/components/ImagePicker.vue b/src/components/editor/components/ImagePicker.vue index 185bdcc..7197083 100644 --- a/src/components/editor/components/ImagePicker.vue +++ b/src/components/editor/components/ImagePicker.vue @@ -1,11 +1,12 @@ @@ -93,6 +92,13 @@ const props = defineProps({ }, }); +const emit = defineEmits(["update:modelValue", "update:visible"]); + +const innerVisible = computed({ + get: () => props.visible, + set: (value) => emit("update:visible", value), +}); + const loadData = async () => { const { page, size } = pagination.value; const params = { ...search.value, page, size }; @@ -141,19 +147,12 @@ const onSelectedImage = (image: any) => { watch( () => props.visible, - async (value) => { - if (!value) return; - - loadData(); + (value) => { + if (value) { + loadData(); + } } ); - -const emit = defineEmits(["update:modelValue", "update:visible"]); - -const innerVisible = computed({ - get: () => props.visible, - set: (value) => emit("update:visible", value), -}); diff --git a/src/components/editor/panel-left/index.vue b/src/components/editor/panel-left/index.vue index 9192dc2..52b379f 100644 --- a/src/components/editor/panel-left/index.vue +++ b/src/components/editor/panel-left/index.vue @@ -15,7 +15,7 @@ 当前组件 -
+
diff --git a/src/components/editor/panel-main/components/block.vue b/src/components/editor/panel-main/components/block.vue index 0ff5917..66a554c 100644 --- a/src/components/editor/panel-main/components/block.vue +++ b/src/components/editor/panel-main/components/block.vue @@ -17,7 +17,7 @@ @resizing="onItemDragOrResize" @activated="setCurrentBlock(data)" > - + diff --git a/src/components/editor/panel-main/components/header.vue b/src/components/editor/panel-main/components/header.vue index c1537ac..f35aee4 100644 --- a/src/components/editor/panel-main/components/header.vue +++ b/src/components/editor/panel-main/components/header.vue @@ -12,7 +12,7 @@ {{ Math.floor(container.x) }} , {{ Math.floor(container.y) }} - 尺寸: + 画布: {{ container.width }} * {{ container.height }} diff --git a/src/components/editor/panel-main/components/texter.vue b/src/components/editor/panel-main/components/texter.vue index f310257..ec9458a 100644 --- a/src/components/editor/panel-main/components/texter.vue +++ b/src/components/editor/panel-main/components/texter.vue @@ -7,7 +7,7 @@ > - + - - diff --git a/src/components/editor/panel-right/index.vue b/src/components/editor/panel-right/index.vue index 5c3dbf4..0dafeb9 100644 --- a/src/components/editor/panel-right/index.vue +++ b/src/components/editor/panel-right/index.vue @@ -2,16 +2,13 @@
基本 - 字体 + 文本
-
- 中文设置 - -
+
diff --git a/src/components/editor/panel-right/text-attr.vue b/src/components/editor/panel-right/text-attr.vue deleted file mode 100644 index 94b5ad0..0000000 --- a/src/components/editor/panel-right/text-attr.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - - - diff --git a/src/types/auto-component.d.ts b/src/types/auto-component.d.ts index 0b9225d..0bb0cab 100644 --- a/src/types/auto-component.d.ts +++ b/src/types/auto-component.d.ts @@ -7,43 +7,34 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { - AAvatar: typeof import('@arco-design/web-vue')['Avatar'] - ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'] - ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'] AButton: typeof import('@arco-design/web-vue')['Button'] ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'] - ACheckboxGroup: typeof import('@arco-design/web-vue')['CheckboxGroup'] - AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider'] ADivider: typeof import('@arco-design/web-vue')['Divider'] ADoption: typeof import('@arco-design/web-vue')['Doption'] - ADrawer: typeof import('@arco-design/web-vue')['Drawer'] - ADropdown: typeof import('@arco-design/web-vue')['Dropdown'] ADropdownButton: typeof import('@arco-design/web-vue')['DropdownButton'] + AEmpty: typeof import('@arco-design/web-vue')['Empty'] AForm: typeof import('@arco-design/web-vue')['Form'] AFormItem: typeof import('@arco-design/web-vue')['FormItem'] AInput: typeof import('@arco-design/web-vue')['Input'] AInputNumber: typeof import('@arco-design/web-vue')['InputNumber'] + AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'] AInputSearch: typeof import('@arco-design/web-vue')['InputSearch'] - ALayout: typeof import('@arco-design/web-vue')['Layout'] - ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent'] - ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader'] - ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider'] ALink: typeof import('@arco-design/web-vue')['Link'] AMenu: typeof import('@arco-design/web-vue')['Menu'] AMenuItem: typeof import('@arco-design/web-vue')['MenuItem'] - AMenuItemGroup: typeof import('@arco-design/web-vue')['MenuItemGroup'] AModal: typeof import('@arco-design/web-vue')['Modal'] APagination: typeof import('@arco-design/web-vue')['Pagination'] APopover: typeof import('@arco-design/web-vue')['Popover'] ARadio: typeof import('@arco-design/web-vue')['Radio'] + ARadioButton: typeof import('@arco-design/web-vue')['RadioButton'] ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup'] - AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar'] ASelect: typeof import('@arco-design/web-vue')['Select'] + ASpace: typeof import('@arco-design/web-vue')['Space'] ASpin: typeof import('@arco-design/web-vue')['Spin'] ATag: typeof import('@arco-design/web-vue')['Tag'] ATextarea: typeof import('@arco-design/web-vue')['Textarea'] ATooltip: typeof import('@arco-design/web-vue')['Tooltip'] - AUpload: typeof import('@arco-design/web-vue')['Upload'] + BaseOption: typeof import('./../components/editor/components/BaseOption.vue')['default'] Block: typeof import('./../components/editor/panel-main/components/block.vue')['default'] BlockAttr: typeof import('./../components/editor/panel-right/block-attr.vue')['default'] BreadCrumb: typeof import('./../components/breadcrumb/bread-crumb.vue')['default'] @@ -55,14 +46,15 @@ declare module '@vue/runtime-core' { ImagePicker: typeof import('./../components/editor/components/ImagePicker.vue')['default'] InputColor: typeof import('./../components/editor/components/InputColor.vue')['default'] InputImage: typeof import('./../components/editor/components/InputImage.vue')['default'] - Option: typeof import('./../components/editor/blocks/text/option.vue')['default'] + Marquee: typeof import('./../components/editor/blocks/text/marquee.vue')['default'] + Option: typeof import('./../components/editor/blocks/font/option.vue')['default'] Page403: typeof import('./../components/error/page-403.vue')['default'] PanelHeader: typeof import('./../components/editor/panel-header/index.vue')['default'] PanelLeft: typeof import('./../components/editor/panel-left/index.vue')['default'] PanelMain: typeof import('./../components/editor/panel-main/index.vue')['default'] PanelRight: typeof import('./../components/editor/panel-right/index.vue')['default'] Preview: typeof import('./../components/editor/preview/index.vue')['default'] - Render: typeof import('./../components/editor/blocks/text/render.vue')['default'] + Render: typeof import('./../components/editor/blocks/font/render.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] TextAttr: typeof import('./../components/editor/panel-right/text-attr.vue')['default']