feat: remove vuex files and change pinia dirname to store

This commit is contained in:
IchliebedichZhu 2024-03-29 18:59:42 +00:00
parent 33eb5555d2
commit 230ef546d2
82 changed files with 113 additions and 1497 deletions

View File

@ -37,8 +37,7 @@
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vue": "3.4.19", "vue": "3.4.19",
"vue-router": "^4.0.0-0", "vue-router": "^4.0.0-0",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0"
"vuex": "^4.0.0-0"
}, },
"devDependencies": { "devDependencies": {
"@types/cropperjs": "^1.3.0", "@types/cropperjs": "^1.3.0",

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2023-11-22 18:11:15 * @LastEditTime: 2023-11-22 18:11:15
*/ */
import { useControlStore, useWidgetStore } from "@/pinia" import { useControlStore, useWidgetStore } from "@/store"
// import store from '@/store' // import store from '@/store'

View File

@ -5,8 +5,8 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn>, Jeremy Yu <https://github.com/JeremyYu-cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>, Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-02 11:50:00 * @LastEditTime: 2024-03-02 11:50:00
*/ */
import { useCanvasStore, usePageStore } from '@/pinia' import { useCanvasStore, usePageStore } from '@/store'
import { TdWidgetData } from '@/pinia/design/widget' import { TdWidgetData } from '@/store/design/widget'
// import store from '@/store' // import store from '@/store'
export default async function setCompData(item: TdWidgetData[] | string) { export default async function setCompData(item: TdWidgetData[] | string) {

View File

@ -7,7 +7,7 @@
*/ */
// import store from '@/store' // import store from '@/store'
import { getImage } from '../getImgDetail' import { getImage } from '../getImgDetail'
import { useCanvasStore, usePageStore } from '@/pinia' import { useCanvasStore, usePageStore } from '@/store'
export type TItem2DataParam = { export type TItem2DataParam = {
id?: string | number id?: string | number

View File

@ -5,7 +5,7 @@
* @LastEditors: ShawnPhang <site: book.palxp.com>, Jeremy Yu <https://github.com/JeremyYu-cn> * @LastEditors: ShawnPhang <site: book.palxp.com>, Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-02 11:50:00 * @LastEditTime: 2024-03-02 11:50:00
*/ */
import { useControlStore } from '@/pinia' import { useControlStore } from '@/store'
// import store from '@/store' // import store from '@/store'
type TAddEventCb = (e: Event) => void type TAddEventCb = (e: Event) => void

View File

@ -26,7 +26,7 @@ import { ref, defineComponent, toRefs, reactive, nextTick } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import 'cropperjs/dist/cropper.css' import 'cropperjs/dist/cropper.css'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import { useControlStore } from '@/pinia' import { useControlStore } from '@/store'
export default defineComponent({ export default defineComponent({
components: { ElDialog }, components: { ElDialog },

View File

@ -26,7 +26,7 @@ import { ref, reactive, nextTick, toRefs } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import 'cropperjs/dist/cropper.css' import 'cropperjs/dist/cropper.css'
import Cropper from 'cropperjs' import Cropper from 'cropperjs'
import { useControlStore } from '@/pinia' import { useControlStore } from '@/store'
type TDoneParams = { type TDoneParams = {
newImg: string, newImg: string,

View File

@ -48,7 +48,7 @@ import uploader from '@/components/common/Uploader/index.vue'
import _dl from '@/common/methods/download' import _dl from '@/common/methods/download'
import ImageExtraction from '../ImageExtraction/index.vue' import ImageExtraction from '../ImageExtraction/index.vue'
import { selectImageFile, uploadCutPhotoToCloud } from './method' import { selectImageFile, uploadCutPhotoToCloud } from './method'
import { useControlStore } from '@/pinia' import { useControlStore } from '@/store'
export type TImageCutoutState = { export type TImageCutoutState = {
show: boolean; show: boolean;

View File

@ -18,7 +18,7 @@ import MoveableHelper from 'moveable-helper'
import useSelecto from './Selecto' import useSelecto from './Selecto'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useCanvasStore, useControlStore, useWidgetStore, useForceStore, useHistoryStore } from '@/pinia' import { useCanvasStore, useControlStore, useWidgetStore, useForceStore, useHistoryStore } from '@/store'
// const store = useStore() // const store = useStore()
const widgetStore = useWidgetStore() const widgetStore = useWidgetStore()

View File

@ -1,7 +1,7 @@
import Selecto from 'selecto' import Selecto from 'selecto'
import Moveable, { getElementInfo } from 'moveable' import Moveable, { getElementInfo } from 'moveable'
// import store from '@/store' // import store from '@/store'
import { useWidgetStore } from '@/pinia' import { useWidgetStore } from '@/store'
export default function(moveable: Moveable) { export default function(moveable: Moveable) {
const widgetStore = useWidgetStore() const widgetStore = useWidgetStore()

View File

@ -36,7 +36,7 @@ import { reactive } from 'vue'
import { ElTabPane, ElTabs, TabPaneName } from 'element-plus' import { ElTabPane, ElTabs, TabPaneName } from 'element-plus'
import api from '@/api' import api from '@/api'
import { TGetImageListResult } from '@/api/material' import { TGetImageListResult } from '@/api/material'
import { useControlStore } from '@/pinia' import { useControlStore } from '@/store'
type TEmits = (event: 'select', data: TGetImageListResult) => void type TEmits = (event: 'select', data: TGetImageListResult) => void

View File

@ -25,7 +25,7 @@ import {
import { getTarget } from '@/common/methods/target' import { getTarget } from '@/common/methods/target'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useControlStore, useWidgetStore } from '@/pinia'; import { useControlStore, useWidgetStore } from '@/store';
// const store = useStore() // const store = useStore()
const menuListData = ref<TMenuItemData>({...menu}) const menuListData = ref<TMenuItemData>({...menu})

View File

@ -15,7 +15,7 @@ import html2canvas from 'html2canvas'
import Qiniu from '@/common/methods/QiNiu' import Qiniu from '@/common/methods/QiNiu'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useCanvasStore, useWidgetStore } from '@/pinia'; import { useCanvasStore, useWidgetStore } from '@/store';
// const store = useStore(); // const store = useStore();
// const { dZoom } = useSetupMapGetters(['dZoom']) // const { dZoom } = useSetupMapGetters(['dZoom'])

View File

@ -84,9 +84,9 @@ import PointImg from '@/utils/plugins/pointImg'
import getComponentsData from '@/common/methods/DesignFeatures/setComponents' import getComponentsData from '@/common/methods/DesignFeatures/setComponents'
import { debounce } from 'throttle-debounce' import { debounce } from 'throttle-debounce'
import { move, moveInit } from '@/mixins/move' import { move, moveInit } from '@/mixins/move'
import { useCanvasStore, useControlStore, useGroupStore, usePageStore, useWidgetStore } from '@/pinia' import { useCanvasStore, useControlStore, useGroupStore, usePageStore, useWidgetStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { TPageState } from '@/pinia/design/page' import { TPageState } from '@/store/design/page'
// //
type TProps = { type TProps = {
pageDesignCanvasId: string pageDesignCanvasId: string

View File

@ -13,7 +13,7 @@
import { watch } from 'vue' import { watch } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import Guides, { GuideOptions } from '@scena/guides' import Guides, { GuideOptions } from '@scena/guides'
import { useCanvasStore } from '@/pinia'; import { useCanvasStore } from '@/store';
type TProps = { type TProps = {
show: boolean show: boolean

View File

@ -27,7 +27,7 @@ import { OtherList, TZoomData, ZoomList } from './data';
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useCanvasStore, useForceStore, usePageStore } from '@/pinia'; import { useCanvasStore, useForceStore, usePageStore } from '@/store';
const route = useRoute() const route = useRoute()
// const store = useStore() // const store = useStore()

View File

@ -39,8 +39,8 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { useWidgetStore } from '@/pinia' import { useWidgetStore } from '@/store'
import { TdWidgetData } from '@/pinia/design/widget' import { TdWidgetData } from '@/store/design/widget'
import { defineComponent, computed, reactive, ref, toRefs } from 'vue' import { defineComponent, computed, reactive, ref, toRefs } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import draggable from 'vuedraggable' import draggable from 'vuedraggable'

View File

@ -25,10 +25,10 @@ import alignIconList, { AlignListData } from '@/assets/data/AlignListData'
import iconItemSelect, { TIconItemSelectData } from '../settings/iconItemSelect.vue' import iconItemSelect, { TIconItemSelectData } from '../settings/iconItemSelect.vue'
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';
import { useControlStore, useGroupStore, useHistoryStore, useWidgetStore } from '@/pinia'; import { useControlStore, useGroupStore, useHistoryStore, useWidgetStore } from '@/store';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { TdWidgetData } from '@/pinia/design/widget'; import { TdWidgetData } from '@/store/design/widget';
import type { TUpdateAlignData } from '@/pinia/design/widget/actions/align' import type { TUpdateAlignData } from '@/store/design/widget/actions/align'
// const store = useStore(); // const store = useStore();
const widgetStore = useWidgetStore() const widgetStore = useWidgetStore()

View File

@ -28,7 +28,7 @@ import api from '@/api'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import { ElImage } from 'element-plus' import { ElImage } from 'element-plus'
import { TGetImageListResult } from '@/api/material'; import { TGetImageListResult } from '@/api/material';
import { usePageStore, useWidgetStore } from '@/pinia'; import { usePageStore, useWidgetStore } from '@/store';
type TCommonPanelData = { type TCommonPanelData = {
color: string color: string

View File

@ -60,7 +60,7 @@ import getComponentsData from '@/common/methods/DesignFeatures/setComponents'
import DragHelper from '@/common/hooks/dragHelper' import DragHelper from '@/common/hooks/dragHelper'
import setItem2Data from '@/common/methods/DesignFeatures/setImage' import setItem2Data from '@/common/methods/DesignFeatures/setImage'
import { TGetCompListResult, TGetTempDetail, TTempDetail } from '@/api/home' import { TGetCompListResult, TGetTempDetail, TTempDetail } from '@/api/home'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
type TState = { type TState = {
loading: boolean loading: boolean

View File

@ -48,7 +48,7 @@ import wSvg from '../../widgets/wSvg/wSvg.vue'
import setImageData from '@/common/methods/DesignFeatures/setImage' import setImageData from '@/common/methods/DesignFeatures/setImage'
import DragHelper from '@/common/hooks/dragHelper' import DragHelper from '@/common/hooks/dragHelper'
import { TGetListData } from '@/api/material' import { TGetListData } from '@/api/material'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
type TProps = { type TProps = {

View File

@ -34,7 +34,7 @@ import api from '@/api'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import setImageData from '@/common/methods/DesignFeatures/setImage' import setImageData from '@/common/methods/DesignFeatures/setImage'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
import { TGetImageListResult } from '@/api/material' import { TGetImageListResult } from '@/api/material'
type TProps = { type TProps = {

View File

@ -32,7 +32,7 @@ import useConfirm from '@/common/methods/confirm'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import imgWaterFall from './components/imgWaterFall.vue' import imgWaterFall from './components/imgWaterFall.vue'
import { IGetTempListData } from '@/api/home' import { IGetTempListData } from '@/api/home'
import {useControlStore, usePageStore, useUserStore, useHistoryStore, useWidgetStore, useForceStore} from '@/pinia' import {useControlStore, usePageStore, useUserStore, useHistoryStore, useWidgetStore, useForceStore} from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
type TState = { type TState = {

View File

@ -29,7 +29,7 @@ import { storeToRefs } from 'pinia';
import { wTextSetting } from '../../widgets/wText/wTextSetting' import { wTextSetting } from '../../widgets/wText/wTextSetting'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia'; import { useControlStore, usePageStore, useWidgetStore } from '@/store';
type TBasicTextData = { type TBasicTextData = {
text: string text: string

View File

@ -33,7 +33,7 @@ import imageCutout from '@/components/business/image-cutout'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { wQrcodeSetting } from '../../widgets/wQrcode/wQrcodeSetting' import { wQrcodeSetting } from '../../widgets/wQrcode/wQrcodeSetting'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
// const store = useStore() // const store = useStore()
const controlStore = useControlStore() const controlStore = useControlStore()

View File

@ -53,7 +53,7 @@ import { TUploadDoneData } from '@/components/common/Uploader/index.vue'
import { IGetTempListData } from '@/api/home' import { IGetTempListData } from '@/api/home'
import eventBus from '@/utils/plugins/eventBus' import eventBus from '@/utils/plugins/eventBus'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
type TProps = { type TProps = {
active?: number active?: number

View File

@ -19,7 +19,7 @@
import {reactive, onMounted, watch } from 'vue' import {reactive, onMounted, watch } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import colorPicker from '@palxp/color-picker' import colorPicker from '@palxp/color-picker'
import { useControlStore } from '@/pinia'; import { useControlStore } from '@/store';
type TProps = { type TProps = {
label?: string label?: string

View File

@ -66,8 +66,8 @@ import _dl from '@/common/methods/download'
import Tabs from '@palxp/color-picker/comps/Tabs.vue' import Tabs from '@palxp/color-picker/comps/Tabs.vue'
import TabPanel from '@palxp/color-picker/comps/TabPanel.vue' import TabPanel from '@palxp/color-picker/comps/TabPanel.vue'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { usePageStore, useWidgetStore } from '@/pinia' import { usePageStore, useWidgetStore } from '@/store'
import { TPageState, } from '@/pinia/design/page' import { TPageState, } from '@/store/design/page'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { proxyToObject } from '@/utils/utils' import { proxyToObject } from '@/utils/utils'
import { Delete as iconDelete, Download as iconDownload } from '@element-plus/icons-vue' import { Delete as iconDelete, Download as iconDownload } from '@element-plus/icons-vue'

View File

@ -28,7 +28,7 @@ const NAME = 'w-group'
import { nextTick, onBeforeUnmount, onMounted, onUpdated, ref } from 'vue' import { nextTick, onBeforeUnmount, onMounted, onUpdated, ref } from 'vue'
// import { useStore } from 'vuex' // import { useStore } from 'vuex'
import { setTransformAttribute } from '@/common/methods/handleTransform' import { setTransformAttribute } from '@/common/methods/handleTransform'
import { useWidgetStore } from '@/pinia'; import { useWidgetStore } from '@/store';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';

View File

@ -44,11 +44,11 @@ import numberSlider from '../../settings/numberSlider.vue'
import layerIconList from '@/assets/data/LayerIconList' import layerIconList from '@/assets/data/LayerIconList'
import alignIconList from '@/assets/data/AlignListData' import alignIconList from '@/assets/data/AlignListData'
import { wGroupSetting } from './groupSetting' import { wGroupSetting } from './groupSetting'
import { useWidgetStore } from '@/pinia' import { useWidgetStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget' import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget'
import { TupdateLayerIndexData } from '@/pinia/design/widget/actions/layer' import { TupdateLayerIndexData } from '@/store/design/widget/actions/layer'
import { TUpdateAlignData } from '@/pinia/design/widget/actions/align' import { TUpdateAlignData } from '@/store/design/widget/actions/align'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
type TState = { type TState = {

View File

@ -42,7 +42,7 @@ import PointImg from '@/utils/plugins/pointImg'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useCanvasStore, useControlStore, useForceStore, useWidgetStore } from '@/pinia' import { useCanvasStore, useControlStore, useForceStore, useWidgetStore } from '@/store'
type TProps = { type TProps = {
params: typeof setting params: typeof setting

View File

@ -89,10 +89,10 @@ import imageCutout from '@/components/business/image-cutout'
import wImageSetting, { TImageSetting } from './wImageSetting' import wImageSetting, { TImageSetting } from './wImageSetting'
import { TGetImageListResult } from '@/api/material' import { TGetImageListResult } from '@/api/material'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useCanvasStore, useControlStore, useForceStore, useWidgetStore } from '@/pinia' import { useCanvasStore, useControlStore, useForceStore, useWidgetStore } from '@/store'
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget' import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget'
import { TupdateLayerIndexData } from '@/pinia/design/widget/actions/layer' import { TupdateLayerIndexData } from '@/store/design/widget/actions/layer'
import { TUpdateAlignData } from '@/pinia/design/widget/actions/align' import { TUpdateAlignData } from '@/store/design/widget/actions/align'
type TState = { type TState = {
picBoxShow: boolean picBoxShow: boolean

View File

@ -41,7 +41,7 @@ import { TWQrcodeSetting } from './wQrcodeSetting';
import { computed, nextTick, onMounted, onUpdated, reactive, ref, watch } from 'vue'; import { computed, nextTick, onMounted, onUpdated, reactive, ref, watch } from 'vue';
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';
import { Options } from 'qr-code-styling'; import { Options } from 'qr-code-styling';
import { useForceStore, useWidgetStore } from '@/pinia'; import { useForceStore, useWidgetStore } from '@/store';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
type TProps = { type TProps = {

View File

@ -74,9 +74,9 @@ import alignIconList from '@/assets/data/AlignListData'
import { wQrcodeSetting, TWQrcodeSetting } from './wQrcodeSetting' import { wQrcodeSetting, TWQrcodeSetting } from './wQrcodeSetting'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useControlStore, useForceStore, useWidgetStore } from '@/pinia' import { useControlStore, useForceStore, useWidgetStore } from '@/store'
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget' import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget'
import { TUpdateAlignData } from '@/pinia/design/widget/actions/align' import { TUpdateAlignData } from '@/store/design/widget/actions/align'
type TState = { type TState = {
activeNames: string[] activeNames: string[]

View File

@ -21,11 +21,11 @@
// svg // svg
// const NAME = 'w-svg' // const NAME = 'w-svg'
// import { mapGetters, mapActions, useStore } from 'vuex' // import { mapGetters, mapActions, useStore } from 'vuex'
import { useCanvasStore, useForceStore, useWidgetStore } from '@/pinia'; import { useCanvasStore, useForceStore, useWidgetStore } from '@/store';
import { TWSvgSetting } from './wSvgSetting' import { TWSvgSetting } from './wSvgSetting'
import { CSSProperties, computed, nextTick, onBeforeMount, onMounted, onUpdated, reactive, ref, watch } from 'vue'; import { CSSProperties, computed, nextTick, onBeforeMount, onMounted, onUpdated, reactive, ref, watch } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget'; import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget';
// import { useSetupMapGetters } from '@/common/hooks/mapGetters'; // import { useSetupMapGetters } from '@/common/hooks/mapGetters';
type TProps = { type TProps = {

View File

@ -47,9 +47,9 @@ import alignIconList from '@/assets/data/AlignListData'
import { TWSvgSetting, wSvgSetting } from './wSvgSetting' import { TWSvgSetting, wSvgSetting } from './wSvgSetting'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useControlStore, useWidgetStore } from '@/pinia' import { useControlStore, useWidgetStore } from '@/store'
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget' import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget'
import { TUpdateAlignData } from '@/pinia/design/widget/actions/align' import { TUpdateAlignData } from '@/store/design/widget/actions/align'
type TState = { type TState = {
activeNames: string[] activeNames: string[]

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2023-10-14 20:29:26 * @LastEditTime: 2023-10-14 20:29:26
*/ */
// import store from '@/store' // import store from '@/store'
import { useWidgetStore } from '@/pinia' import { useWidgetStore } from '@/store'
import { toRaw } from 'vue' import { toRaw } from 'vue'
export default () => { export default () => {
const widgetStore = useWidgetStore() const widgetStore = useWidgetStore()

View File

@ -65,7 +65,7 @@ import { useRoute } from 'vue-router'
import { fontWithDraw } from '@/utils/widgets/loadFontRule' import { fontWithDraw } from '@/utils/widgets/loadFontRule'
import getGradientOrImg from './getGradientOrImg' import getGradientOrImg from './getGradientOrImg'
import { wTextSetting } from './wTextSetting' import { wTextSetting } from './wTextSetting'
import { useForceStore, useHistoryStore, useWidgetStore } from '@/pinia' import { useForceStore, useHistoryStore, useWidgetStore } from '@/store'
export type TwTextParams = { export type TwTextParams = {
rotate?: number rotate?: number

View File

@ -67,9 +67,9 @@ import { useFontStore } from '@/common/methods/fonts'
import usePageFontsFilter from './pageFontsFilter' import usePageFontsFilter from './pageFontsFilter'
import { wTextSetting ,TwTextData } from './wTextSetting'; import { wTextSetting ,TwTextData } from './wTextSetting';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useControlStore, useForceStore, useWidgetStore } from '@/pinia'; import { useControlStore, useForceStore, useWidgetStore } from '@/store';
import { TUpdateWidgetPayload } from '@/pinia/design/widget/actions/widget'; import { TUpdateWidgetPayload } from '@/store/design/widget/actions/widget';
import { TUpdateAlignData } from '@/pinia/design/widget/actions/align'; import { TUpdateAlignData } from '@/store/design/widget/actions/align';
type TState = { type TState = {
activeNames: string[], activeNames: string[],

View File

@ -7,7 +7,7 @@
*/ */
// import store from '@/store' // import store from '@/store'
import handlePaste from './handlePaste' import handlePaste from './handlePaste'
import { useGroupStore, useHistoryStore, useWidgetStore } from '@/pinia' import { useGroupStore, useHistoryStore, useWidgetStore } from '@/store'
export default function dealWithCtrl(e: KeyboardEvent, _this: any) { export default function dealWithCtrl(e: KeyboardEvent, _this: any) {
const groupStore = useGroupStore() const groupStore = useGroupStore()

View File

@ -20,7 +20,7 @@ import { getImage } from '@/common/methods/getImgDetail'
import wImageSetting from '@/components/modules/widgets/wImage/wImageSetting' import wImageSetting from '@/components/modules/widgets/wImage/wImageSetting'
import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting' import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting'
import eventBus from '@/utils/plugins/eventBus' import eventBus from '@/utils/plugins/eventBus'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
// import wText from '@/components/modules/widgets/wText/wText.vue' // import wText from '@/components/modules/widgets/wText/wText.vue'
export default () => { export default () => {

View File

@ -5,8 +5,8 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2023-11-30 10:09:55 * @LastEditTime: 2023-11-30 10:09:55
*/ */
import { useControlStore, useWidgetStore } from '@/pinia' import { useControlStore, useWidgetStore } from '@/store'
import { TdWidgetData } from '@/pinia/design/widget' import { TdWidgetData } from '@/store/design/widget'
// import store from '@/store' // import store from '@/store'
export default function keyCodeOptions(e: any, params: any) { export default function keyCodeOptions(e: any, params: any) {

View File

@ -5,7 +5,7 @@
* @LastEditors: ShawnPhang <site: book.palxp.com> * @LastEditors: ShawnPhang <site: book.palxp.com>
* @LastEditTime: 2023-07-31 09:31:52 * @LastEditTime: 2023-07-31 09:31:52
*/ */
import { useControlStore, useWidgetStore } from '@/pinia' import { useControlStore, useWidgetStore } from '@/store'
// import store from '@/store' // import store from '@/store'
const move = { const move = {

View File

@ -12,7 +12,7 @@
import keyCodeOptions from './methods/keyCodeOptions' import keyCodeOptions from './methods/keyCodeOptions'
import dealWithCtrl from './methods/dealWithCtrl' import dealWithCtrl from './methods/dealWithCtrl'
import { useStore, Store } from 'vuex' import { useStore, Store } from 'vuex'
import { TControlStore } from '@/pinia/design/control' import { TControlStore } from '@/store/design/control'
const ignoreNode = ['INPUT', 'TEXTAREA'] const ignoreNode = ['INPUT', 'TEXTAREA']

View File

@ -1,29 +0,0 @@
/*
* @Author: Jeremy Yu
* @Date: 2024-03-18 21:00:00
* @Description: Store方法export
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-18 21:00:00
*/
import useBaseStore from "./base";
import useUserStore from "./base/user";
import usePageStore from "./design/page"
import useCanvasStore from "./design/canvas"
import useControlStore from './design/control'
import useHistoryStore from './design/history'
import useWidgetStore from './design/widget'
import useGroupStore from './design/group'
import useForceStore from './design/force'
export {
useBaseStore,
useUserStore,
usePageStore,
useCanvasStore,
useControlStore,
useHistoryStore,
useWidgetStore,
useGroupStore,
useForceStore,
}

View File

@ -7,7 +7,7 @@
* @LastEditTime: 2024-03-18 21:00:00 * @LastEditTime: 2024-03-18 21:00:00
*/ */
import { useHistoryStore } from "@/pinia"; import { useHistoryStore } from "@/store";
import { Store, defineStore } from "pinia"; import { Store, defineStore } from "pinia";
type TControlState = { type TControlState = {

View File

@ -8,7 +8,7 @@
import { customAlphabet } from 'nanoid/non-secure' import { customAlphabet } from 'nanoid/non-secure'
import { TGroupStore } from '..' import { TGroupStore } from '..'
import { useHistoryStore, usePageStore, useWidgetStore } from '@/pinia' import { useHistoryStore, usePageStore, useWidgetStore } from '@/store'
import { TdWidgetData } from '../../widget' import { TdWidgetData } from '../../widget'
const nanoid = customAlphabet('1234567890abcdef', 12) const nanoid = customAlphabet('1234567890abcdef', 12)

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-27 21:00:00 * @LastEditTime: 2024-03-27 21:00:00
*/ */
import { useControlStore, usePageStore } from "@/pinia" import { useControlStore, usePageStore } from "@/store"
import { THistoryStore } from ".." import { THistoryStore } from ".."
export default function handleHistory(store: THistoryStore, action: "undo" | "redo") { export default function handleHistory(store: THistoryStore, action: "undo" | "redo") {

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-27 21:00:00 * @LastEditTime: 2024-03-27 21:00:00
*/ */
import { usePageStore, useWidgetStore } from "@/pinia" import { usePageStore, useWidgetStore } from "@/store"
import { THistoryStore } from ".." import { THistoryStore } from ".."
import { proxyToObject } from "@/utils/utils" import { proxyToObject } from "@/utils/utils"

View File

@ -9,7 +9,7 @@
import { Store, defineStore } from "pinia" import { Store, defineStore } from "pinia"
import {pushHistory, pushColorToHistory} from "./actions/pushHistory" import {pushHistory, pushColorToHistory} from "./actions/pushHistory"
import handleHistory from "./actions/handleHistory" import handleHistory from "./actions/handleHistory"
import { usePageStore, useWidgetStore } from "@/pinia" import { usePageStore, useWidgetStore } from "@/store"
export type THistoryParamData = { export type THistoryParamData = {
index: number index: number

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useHistoryStore, usePageStore } from "@/pinia" import { useCanvasStore, useHistoryStore, usePageStore } from "@/store"
import { TWidgetStore, TdWidgetData } from ".." import { TWidgetStore, TdWidgetData } from ".."
type TAlign = 'left' | 'ch' | 'right' | 'top' | 'cv' | 'bottom' type TAlign = 'left' | 'ch' | 'right' | 'top' | 'cv' | 'bottom'

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useHistoryStore } from "@/pinia" import { useCanvasStore, useHistoryStore } from "@/store"
import { TWidgetStore, TdWidgetData } from ".." import { TWidgetStore, TdWidgetData } from ".."
import { customAlphabet } from 'nanoid/non-secure' import { customAlphabet } from 'nanoid/non-secure'
const nanoid = customAlphabet('1234567890abcdef', 12) const nanoid = customAlphabet('1234567890abcdef', 12)

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useHistoryStore } from "@/pinia" import { useCanvasStore, useHistoryStore } from "@/store"
import { TWidgetStore, TdWidgetData } from ".." import { TWidgetStore, TdWidgetData } from ".."
import { customAlphabet } from 'nanoid/non-secure' import { customAlphabet } from 'nanoid/non-secure'
const nanoid = customAlphabet('1234567890abcdef', 12) const nanoid = customAlphabet('1234567890abcdef', 12)

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useControlStore, usePageStore } from "@/pinia" import { useCanvasStore, useControlStore, usePageStore } from "@/store"
import { TWidgetStore } from ".." import { TWidgetStore } from ".."
export type TInidDMovePayload = { export type TInidDMovePayload = {

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useForceStore } from "@/pinia" import { useForceStore } from "@/store"
import { TWidgetStore, TdWidgetData } from ".." import { TWidgetStore, TdWidgetData } from ".."
export type TupdateLayerIndexData = { export type TupdateLayerIndexData = {

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useControlStore, usePageStore } from "@/pinia" import { useCanvasStore, useControlStore, usePageStore } from "@/store"
import { TWidgetStore } from ".." import { TWidgetStore } from ".."
import { updateGroupSize } from "." import { updateGroupSize } from "."

View File

@ -1,4 +1,4 @@
import { useControlStore, useHistoryStore, usePageStore } from "@/pinia" import { useControlStore, useHistoryStore, usePageStore } from "@/store"
import { TWidgetStore } from ".." import { TWidgetStore } from ".."
import { proxyToObject } from "@/utils/utils" import { proxyToObject } from "@/utils/utils"

View File

@ -9,7 +9,7 @@
import { customAlphabet } from 'nanoid/non-secure' import { customAlphabet } from 'nanoid/non-secure'
import { TWidgetStore, TdWidgetData } from '..' import { TWidgetStore, TdWidgetData } from '..'
import { useCanvasStore, useHistoryStore } from '@/pinia' import { useCanvasStore, useHistoryStore } from '@/store'
const nanoid = customAlphabet('1234567890abcdef', 12) const nanoid = customAlphabet('1234567890abcdef', 12)
// TODO: 选择模板 // TODO: 选择模板

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { useCanvasStore, useHistoryStore, usePageStore } from "@/pinia" import { useCanvasStore, useHistoryStore, usePageStore } from "@/store"
import { TWidgetStore, TdWidgetData } from ".." import { TWidgetStore, TdWidgetData } from ".."
import { customAlphabet } from 'nanoid/non-secure' import { customAlphabet } from 'nanoid/non-secure'
const nanoid = customAlphabet('1234567890abcdef', 12) const nanoid = customAlphabet('1234567890abcdef', 12)

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2024-03-28 14:00:00 * @LastEditTime: 2024-03-28 14:00:00
*/ */
import { usePageStore } from "@/pinia" import { usePageStore } from "@/store"
import { TWidgetState, TdWidgetData } from ".." import { TWidgetState, TdWidgetData } from ".."
import { TPageState } from "../../page" import { TPageState } from "../../page"

View File

@ -1,11 +1,29 @@
import { createStore } from 'vuex' /*
* @Author: Jeremy Yu
* @Date: 2024-03-18 21:00:00
* @Description: Store方法export
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-18 21:00:00
*/
// import base from './modules/base' import useBaseStore from "./base";
import design from './modules/design' import useUserStore from "./base/user";
import usePageStore from "./design/page"
import useCanvasStore from "./design/canvas"
import useControlStore from './design/control'
import useHistoryStore from './design/history'
import useWidgetStore from './design/widget'
import useGroupStore from './design/group'
import useForceStore from './design/force'
export default createStore({ export {
// ...base, useBaseStore,
modules: { useUserStore,
design, usePageStore,
}, useCanvasStore,
}) useControlStore,
useHistoryStore,
useWidgetStore,
useGroupStore,
useForceStore,
}

View File

@ -1,20 +0,0 @@
/**
* store.dispatch()
*/
// interface Iprops {
// commit: (a: any, b: any) => void
// state: any
// }
// export default {
// hideLoading(props: Iprops, data: Type.Object) {
// setTimeout(() => {
// props.commit('loading', false)
// }, 600)
// },
// setFonts(store: Iprops, list: Type.Object) {
// store.state.fonts = list
// },
// }

View File

@ -1,46 +0,0 @@
/*
* @Author: ShawnPhang
* @Date: 2021-12-16 16:20:16
* @Description:
* @LastEditors: ShawnPhang <https://m.palxp.cn>, Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-17 15:00:00
*/
// const all = {
// state: {
// loading: null,
// online: true, // 登录状态,
// user: {
// name: localStorage.getItem('username'),
// }, // 储存用户信息
// scroll: true,
// manager: '', // 是否为管理员模式
// tempEditing: false, // 管理员是否正在编辑模板
// fonts: [], // 缓存字体列表
// app: null, // 抠图服务
// },
// getters: {
// online: (state: Type.Object) => {
// return state.online
// },
// user: (state: Type.Object) => {
// return state.user
// },
// manager: (state: Type.Object) => {
// return state.manager
// },
// tempEditing: (state: Type.Object) => {
// return state.tempEditing
// },
// fonts: (state: Type.Object) => {
// return state.fonts
// },
// },
// mutations: {
// ...mutations,
// },
// actions: {
// ...actions,
// },
// }

View File

@ -1,42 +0,0 @@
/*
* @Author: ShawnPhang
* @Date: 2021-12-16 16:20:16
* @Description: store.commit()
* @LastEditors: ShawnPhang <site: book.palxp.com>
* @LastEditTime: 2023-07-13 18:29:13
*/
// import { Toast } from 'vant'
// export default {
// loading(state: Type.Object, data: any) {
// // Toast.clear();
// // let msg = ''
// // if (typeof data === 'string') {
// // msg = data
// // } else {
// // Toast.clear();
// // return false
// // }
// // Toast.loading({
// // duration: 0, // 持续展示 toast
// // loadingType: 'spinner',
// // message: msg
// // });
// },
// changeRoute(state: Type.Object, from: string) {
// state.routeFrom = from
// },
// changeOnline(state: Type.Object, status: string) {
// state.online = status
// },
// changeUser(state: Type.Object, name: string) {
// state.user.name = name
// // state.user = Object.assign({}, state.user)
// state.user = { ...state.user }
// localStorage.setItem('username', name)
// },
// managerEdit(state: Type.Object, status: string) {
// state.tempEditing = status
// },
// }

View File

@ -1,832 +0,0 @@
// import { nextTick } from 'vue'
import { customAlphabet } from 'nanoid/non-secure'
const nanoid = customAlphabet('1234567890abcdef', 12)
// import pushHistory from './methods/pushHistory'
// import handleHistory from './methods/handleHistory'
export default {
/**
*
*
* uuid便
*/
// pushHistory(store: any, msg: string) {
// pushHistory(store, msg)
// },
/**
*
* action为undo表示撤销
* action为redo表示重做
*/
// handleHistory(store: any, action: any) {
// handleHistory(store, action)
// // 激活组件默认为page
// store.state.dActiveElement = store.state.dPage
// },
// updateZoom(store, zoom) {
// store.state.dZoom = zoom
// },
// updateScreen(store, { width, height }) {
// store.state.dScreen.width = width
// store.state.dScreen.height = height
// },
// updateGridSize(store, { width, height }) {
// store.state.gridSize.width = width
// store.state.gridSize.height = height
// },
// updatePageData(store, { key, value, pushHistory }) {
// const page = store.state.dPage
// if (page[key] !== value || pushHistory) {
// page[key] = value
// // 画布修改先不压入历史栈,因为替换模板后会重复压栈
// // store.dispatch('pushHistory', 'updatePageData')
// }
// },
// updateWidgetData(store, { uuid, key, value, pushHistory }: any) {
// const widget = store.state.dWidgets.find((item) => item.uuid === uuid)
// if (widget && (widget[key] !== value || pushHistory)) {
// switch (key) {
// case 'width':
// // const minWidth = widget.record.minWidth
// // const maxWidth = store.state.dPage.width - widget.left
// // value = Math.max(minWidth, Math.min(maxWidth, value))
// break
// case 'height':
// // const minHeight = widget.record.minHeight
// // const maxHeight = store.state.dPage.height - widget.top
// // value = Math.max(minHeight, Math.min(maxHeight, value))
// break
// case 'left':
// case 'top':
// if (widget.isContainer) {
// let dLeft = widget.left - value
// let dTop = widget.top - value
// if (key === 'left') {
// dTop = 0
// }
// if (key === 'top') {
// dLeft = 0
// }
// const len = store.state.dWidgets.length
// for (let i = 0; i < len; ++i) {
// const child = store.state.dWidgets[i]
// if (child.parent === widget.uuid) {
// child.left -= dLeft
// child.top -= dTop
// }
// }
// }
// break
// }
// widget[key] = value
// if (pushHistory) {
// setTimeout(() => {
// pushHistory && store.dispatch('pushHistory', 'updateWidgetData')
// }, 100)
// }
// // store.dispatch('reChangeCanvas')
// }
// },
// updateWidgetMultiple(store, { uuid, data, pushHistory }) {
// for (const item of data) {
// const { key, value } = item
// const widget = store.state.dWidgets.find((item) => item.uuid === uuid)
// if (widget && (widget[key] !== value || pushHistory)) {
// switch (key) {
// case 'left':
// case 'top':
// if (widget.isContainer) {
// let dLeft = widget.left - value
// let dTop = widget.top - value
// if (key === 'left') {
// dTop = 0
// }
// if (key === 'top') {
// dLeft = 0
// }
// const len = store.state.dWidgets.length
// for (let i = 0; i < len; ++i) {
// const child = store.state.dWidgets[i]
// if (child.parent === widget.uuid) {
// child.left -= dLeft
// child.top -= dTop
// }
// }
// }
// break
// }
// widget[key] = value
// }
// }
// setTimeout(() => {
// store.dispatch('pushHistory', 'updateWidgetMultiple')
// }, 100)
// },
// addWidget(store: any, setting: any) {
// setting.uuid = nanoid()
// store.state.dWidgets.push(setting)
// const len = store.state.dWidgets.length
// // store.state.dActiveElement = store.state.dWidgets[len - 1]
// store.dispatch('selectWidget', {
// uuid: store.state.dWidgets[len - 1].uuid,
// })
// store.dispatch('pushHistory', 'addWidget')
// store.dispatch('reChangeCanvas')
// },
// addGroup(store: any, group: Type.Object) {
// let parent: any = null
// group.forEach((item: any) => {
// item.uuid = nanoid() // 重设id
// item.type === 'w-group' && (parent = item) // 找出父组件
// })
// group.forEach((item: any) => {
// !item.isContainer && (item.parent = parent.uuid) // 重设父id
// item.text && (item.text = decodeURIComponent(item.text))
// store.state.dWidgets.push(item)
// })
// // 选中组件
// const len = store.state.dWidgets.length
// store.state.dActiveElement = store.state.dWidgets[len - 1]
// store.dispatch('pushHistory', 'addGroup')
// store.dispatch('reChangeCanvas')
// },
// // TODO: 选择模板
// setTemplate(store: any, allWidgets: any[]) {
// allWidgets.forEach((item: any) => {
// Number(item.uuid) < 0 && (item.uuid = nanoid()) // 重设id
// item.text && (item.text = decodeURIComponent(item.text))
// store.state.dWidgets.push(item)
// })
// store.dispatch('pushHistory', 'setTemplate')
// store.dispatch('reChangeCanvas')
// },
// TODO 删除
// deleteWidget(store: any) {
// const widgets = store.state.dWidgets
// const selectWidgets = store.state.dSelectWidgets
// const activeElement = store.state.dActiveElement
// let count = 0 // 记录容器里的组件数量
// if (selectWidgets.length !== 0) {
// for (let i = 0; i < selectWidgets.length; ++i) {
// const uuid = selectWidgets[i].uuid
// const index = widgets.findIndex((item) => item.uuid === uuid)
// widgets.splice(index, 1)
// try {
// // 清除掉可能存在的选中框
// document.getElementById(uuid).classList.remove('widget-selected')
// } catch (e) {}
// }
// store.state.dSelectWidgets = []
// } else {
// if (activeElement.type === 'page') {
// return
// }
// const uuid = activeElement.uuid
// const index = widgets.findIndex((item) => item.uuid === uuid)
// // 先删除组件
// widgets.splice(index, 1)
// // 如果删除的是容器,须将内部组件一并删除
// if (activeElement.isContainer) {
// for (let i = widgets.length - 1; i >= 0; --i) {
// if (widgets[i].parent === uuid) {
// widgets.splice(i, 1)
// }
// }
// } else if (activeElement.parent !== '-1') {
// for (let i = widgets.length - 1; i >= 0; --i) {
// if (widgets[i].parent === activeElement.parent) {
// count++
// if (count > 1) {
// break
// }
// }
// }
// if (count <= 1) {
// const index = widgets.findIndex((item) => item.uuid === activeElement.parent)
// widgets.splice(index, 1)
// if (count === 1) {
// const widget = widgets.find((item) => item.parent === activeElement.parent)
// widget.parent = '-1'
// }
// count = 0
// }
// }
// }
// if (count === 0) {
// // 重置 activeElement
// store.state.dActiveElement = store.state.dPage
// } else {
// store.state.dActiveElement = widgets.find((item) => item.uuid === activeElement.parent)
// }
// if (store.state.dActiveElement.uuid !== '-1') {
// store.dispatch('updateGroupSize', store.state.dActiveElement.uuid)
// }
// store.dispatch('pushHistory', 'deleteWidget')
// store.dispatch('reChangeCanvas')
// },
// copyWidget(store) {
// const activeElement = JSON.parse(JSON.stringify(store.state.dActiveElement))
// if (activeElement.type === 'page') {
// return
// }
// navigator.clipboard.writeText('') // 清空系统剪贴板内容
// const container = []
// const selectWidgets = store.state.dSelectWidgets
// if (selectWidgets.length === 0) {
// const uuid = activeElement.uuid
// container.push(activeElement)
// if (activeElement.isContainer) {
// const widgets = store.state.dWidgets
// for (let i = 0; i < widgets.length; ++i) {
// if (widgets[i].parent === uuid) {
// container.push(widgets[i])
// }
// }
// }
// } else {
// for (let i = 0; i < selectWidgets.length; ++i) {
// const uuid = selectWidgets[i].uuid
// container.push(selectWidgets[i])
// if (selectWidgets[i].isContainer) {
// const widgets = store.state.dWidgets
// for (let i = 0; i < widgets.length; ++i) {
// if (widgets[i].parent === uuid) {
// container.push(widgets[i])
// }
// }
// }
// }
// }
// store.state.dCopyElement = JSON.parse(JSON.stringify(container))
// },
// pasteWidget(store) {
// const copyElement = JSON.parse(JSON.stringify(store.state.dCopyElement))
// const container = copyElement.find((item) => item.isContainer)
// for (let i = 0; i < copyElement.length; ++i) {
// copyElement[i].uuid = nanoid()
// if (container && copyElement[i].uuid !== container.uuid) {
// copyElement[i].parent = container.uuid
// } else {
// copyElement[i].parent = '-1'
// }
// copyElement[i].top += 30
// copyElement[i].left += 30
// }
// store.state.dWidgets = store.state.dWidgets.concat(copyElement)
// store.state.dActiveElement = copyElement[0]
// store.state.dSelectWidgets = copyElement
// if (container) {
// store.state.dActiveElement = container
// store.state.dSelectWidgets = []
// }
// store.dispatch('pushHistory', 'pasteWidget')
// store.dispatch('copyWidget')
// store.dispatch('reChangeCanvas')
// },
// // TODO: 选中元件与取消选中
// selectWidget(store, { uuid }) {
// const alt = store.state.dAltDown
// const selectWidgets = store.state.dSelectWidgets
// const widget = store.state.dWidgets.find((item) => item.uuid === uuid)
// if (alt) {
// if (uuid !== '-1' && widget.parent === '-1') {
// // && !widget.isContainer
// if (selectWidgets.length === 0) {
// if (store.state.dActiveElement.uuid !== '-1') {
// selectWidgets.push(store.state.dActiveElement)
// }
// }
// const index = selectWidgets.findIndex((item) => {
// return item.uuid === uuid
// })
// // 如果已经存在则取消选择,否则加入选取
// if (index !== -1) {
// selectWidgets.splice(index, 1)
// if (selectWidgets.length === 0) {
// store.state.dActiveElement = store.state.dPage
// }
// } else {
// selectWidgets.push(widget)
// }
// if (selectWidgets.length === 1) {
// store.state.dActiveElement = selectWidgets[0]
// store.state.dSelectWidgets = []
// }
// }
// return
// }
// store.state.dSelectWidgets = []
// if (uuid === '-1') {
// store.state.dActiveElement = store.state.dPage
// const pageHistory = store.state.dPageHistory
// if (pageHistory.length === 0) {
// pageHistory.push(JSON.stringify(store.state.dPage))
// }
// setTimeout(() => {
// store.state.dSelectWidgets = []
// }, 10)
// } else {
// // store.state.dActiveElement = {}
// setTimeout(() => {
// store.state.dActiveElement = widget
// }, 10)
// }
// },
// // 多选元素
// selectWidgetsInOut(store, { uuid }) {
// const selectWidgets = store.state.dSelectWidgets
// const widget = store.state.dWidgets.find((item) => item.uuid === uuid)
// if (widget && uuid !== '-1' && widget.parent === '-1' && !widget.isContainer) {
// if (selectWidgets.length === 0) {
// if (store.state.dActiveElement.uuid !== '-1') {
// selectWidgets.push(store.state.dActiveElement)
// }
// }
// const index = selectWidgets.findIndex((item) => {
// return item.uuid === uuid
// })
// // 如果已经存在则取消选择,否则加入选取
// if (index !== -1) {
// selectWidgets.splice(index, 1)
// if (selectWidgets.length === 0) {
// store.state.dActiveElement = store.state.dPage
// }
// } else {
// selectWidgets.push(widget)
// }
// // if (selectWidgets.length === 1) {
// // store.state.dActiveElement = selectWidgets[0]
// // store.state.dSelectWidgets = []
// // }
// }
// },
// 设置 mousemove 操作的初始值
// initDMove(store, payload) {
// const mouseXY = store.state.dMouseXY
// const widgetXY = store.state.dActiveWidgetXY
// mouseXY.x = payload.startX
// mouseXY.y = payload.startY
// widgetXY.x = payload.originX
// widgetXY.y = payload.originY
// },
// // 组件移动结束
// stopDMove(store) {
// if (store.state.dMoving) {
// store.dispatch('pushHistory', 'stopDMove')
// }
// store.state.dMoving = false
// },
// 移动组件
// dMove(store, payload) {
// const { donotMove } = payload // 由moveable代理移动
// store.state.dMoving = true
// const page = store.state.dPage
// const target = store.state.dActiveElement
// const mouseXY = store.state.dMouseXY
// const widgetXY = store.state.dActiveWidgetXY
// let parent = page
// if (target.parent !== '-1') {
// parent = store.state.dWidgets.find((item) => item.uuid === target.parent)
// }
// const dx = payload.x - mouseXY.x
// const dy = payload.y - mouseXY.y
// let left = widgetXY.x + Math.floor((dx * 100) / store.state.dZoom)
// let top = widgetXY.y + Math.floor((dy * 100) / store.state.dZoom)
// left = Math.max(Math.min(left, page.width - target.record.width), 0)
// top = Math.max(Math.min(top, page.height - target.record.height), 0)
// if (target.isContainer) {
// const dLeft = target.left - left
// const dTop = target.top - top
// const len = store.state.dWidgets.length
// for (let i = 0; i < len; ++i) {
// const widget = store.state.dWidgets[i]
// if (widget.parent === target.uuid) {
// widget.left -= dLeft
// widget.top -= dTop
// }
// }
// }
// if (!donotMove) {
// target.left = left
// target.top = top
// }
// if (parent.uuid !== '-1') {
// store.dispatch('updateGroupSize', parent.uuid)
// }
// store.dispatch('reChangeCanvas')
// },
// // 设置 resize 操作的初始值
// initDResize(store, payload) {
// const mouseXY = store.state.dMouseXY
// const widgetXY = store.state.dActiveWidgetXY
// const resizeWH = store.state.dResizeWH
// mouseXY.x = payload.startX
// mouseXY.y = payload.startY
// widgetXY.x = payload.originX
// widgetXY.y = payload.originY
// resizeWH.width = payload.width
// resizeWH.height = payload.height
// },
// // 更新组件宽高
// dResize(store, { x, y, dirs }) {
// store.state.dResizeing = true
// const page = store.state.dPage
// const target = store.state.dActiveElement
// const mouseXY = store.state.dMouseXY
// const widgetXY = store.state.dActiveWidgetXY
// const resizeWH = store.state.dResizeWH
// let parent = page
// if (target.parent !== '-1') {
// parent = store.state.dWidgets.find((item) => item.uuid === target.parent)
// }
// const dx = x - mouseXY.x
// const dy = y - mouseXY.y
// let left = 0
// let top = 0
// for (let i = 0; i < dirs.length; ++i) {
// const dir = dirs[i]
// switch (dir) {
// case 'top':
// const t = widgetXY.y + Math.floor((dy * 100) / store.state.dZoom)
// top = Math.max(t, 0)
// top = Math.min(widgetXY.y + resizeWH.height - target.record.minHeight, top)
// target.height += target.top - top
// target.height = Math.max(target.height, target.record.minHeight)
// target.top = top
// break
// case 'bottom':
// top = Math.floor((dy * 100) / store.state.dZoom)
// target.height = resizeWH.height + top
// target.height = Math.max(target.height, target.record.minHeight)
// target.height = Math.min(target.height, page.height - target.top)
// break
// case 'left':
// const tLeft = widgetXY.x + Math.floor((dx * 100) / store.state.dZoom)
// left = Math.max(tLeft, 0)
// target.width += target.left - left
// target.width = Math.max(target.width, target.record.minWidth)
// left = Math.min(widgetXY.x + resizeWH.width - target.record.minWidth, left)
// target.left = left
// break
// case 'right':
// left = Math.floor((dx * 100) / store.state.dZoom)
// target.width = resizeWH.width + left
// target.width = Math.max(target.width, target.record.minWidth)
// target.width = Math.min(target.width, page.width - target.left)
// break
// }
// }
// if (parent.uuid !== '-1') {
// store.dispatch('updateGroupSize', parent.uuid)
// }
// store.dispatch('reChangeCanvas')
// },
// // 组件调整结束
// stopDResize(store) {
// if (store.state.dResizeing) {
// store.dispatch('pushHistory', 'stopDResize')
// }
// store.state.dResizeing = false
// },
// // 强制重绘画布
// reChangeCanvas(store) {
// // const tag = store.state.dPage.tag
// // store.state.dPage.tag = tag === 0 ? 0.01 : 0
// },
// pushColorToHistory(store, color) {
// const history = store.state.dColorHistory
// // 如果已经存在就提到前面来,避免重复
// const index = history.indexOf(color)
// if (index !== -1) {
// history.splice(index, 1)
// }
// // 最多保存3种颜色
// if (history.length === 4) {
// history.splice(history.length - 1, 1)
// }
// // 把最新的颜色放在头部
// const head = [color]
// store.state.dColorHistory = head.concat(history)
// },
// updateHoverUuid(store, uuid) {
// store.state.dHoverUuid = uuid
// },
// showRefLine(store, show) {
// store.state.dShowRefLine = show
// },
// updateAlign(store: any, { align, uuid, group }: any) {
// const widgets = store.state.dWidgets
// const target = uuid ? widgets.find((item: any) => item.uuid === uuid) : store.state.dActiveElement
// let parent = group || store.state.dPage
// if (target.parent !== '-1') {
// parent = widgets.find((item: any) => item.uuid === target.parent)
// }
// let left = target.left
// let top = target.top
// let pw = parent.record.width || parent.width
// let ph = parent.record.height || parent.height
// if (parent.uuid === '-1') {
// pw = parent.width
// ph = parent.height
// }
// const targetW = target.width
// const targetH = target.height
// switch (align) {
// case 'left':
// left = parent.left
// break
// case 'ch': // 水平居中
// left = parent.left + pw / 2 - targetW / 2
// break
// case 'right':
// left = parent.left + pw - targetW
// break
// case 'top':
// top = parent.top
// break
// case 'cv': // 垂直居中
// top = parent.top + ph / 2 - targetH / 2
// break
// case 'bottom':
// top = parent.top + ph - targetH
// break
// }
// if (target.left !== left || target.top !== top) {
// if (target.isContainer) {
// const dLeft = target.left - left
// const dTop = target.top - top
// const len = widgets.length
// for (let i = 0; i < len; ++i) {
// const widget = widgets[i]
// if (widget.parent === target.uuid) {
// widget.left -= dLeft
// widget.top -= dTop
// }
// }
// }
// target.left = left
// target.top = top
// store.dispatch('pushHistory', 'updateAlign')
// store.dispatch('reChangeCanvas')
// }
// },
// getWidgetJsonData(store) {
// const page = JSON.parse(JSON.stringify(store.state.dPage))
// const widgets = JSON.parse(JSON.stringify(store.state.dWidgets))
// page.widgets = widgets
// return page
// },
// TODO 组合操作
// updateAltDown(store, value) {
// store.state.dAltDown = value
// console.log('控制组合按键, 成组功能为: realCombined')
// },
// realCombined(store: any) {
// const selectWidgets = store.state.dSelectWidgets
// if (selectWidgets.length > 1) {
// const widgets = store.state.dWidgets
// const group = JSON.parse(store.state.dGroupJson)
// group.uuid = nanoid()
// widgets.push(group)
// let left = Number(store.state.dPage.width)
// let top = Number(store.state.dPage.height)
// let right = 0
// let bottom = 0
// const sortWidgets = [] // 顺序取出元素
// const selectkeys = selectWidgets.map((x: Type.Object) => x.uuid)
// for (const w of widgets) {
// selectkeys.includes(w.uuid) && sortWidgets.push(w)
// }
// for (let i = 0; i < sortWidgets.length; ++i) {
// const uuid = sortWidgets[i].uuid
// const index = widgets.findIndex((item: Type.Object) => item.uuid === uuid)
// const widget = { ...widgets[index] } // clone
// if (widget.isContainer) {
// widgets.splice(index, 1) // 删除旧组合
// for (let i = 0; i < widgets.length; i++) {
// const item = widgets[i]
// item.parent === widget.uuid && (item.parent = group.uuid)
// // if (item.parent === widget.uuid) {
// // item.parent = group.uuid
// // // 重新排列
// // // const index = widgets.findIndex((x) => x.uuid === item.uuid)
// // // widgets.splice(index, 1)
// // // widgets.push(item)
// // }
// }
// } else {
// widget.parent = group.uuid
// // 重新排列
// widgets.splice(index, 1)
// widgets.push(widget)
// }
// // sortWidgets.push({
// // index: index,
// // widget: widget,
// // })
// left = Math.min(left, widget.left)
// top = Math.min(top, widget.top)
// right = Math.max(right, Number(widget.width || widget.record.width) + Number(widget.left))
// bottom = Math.max(bottom, Number(widget.height || widget.record.height) + Number(widget.top))
// }
// // sortWidgets.sort((a, b) => a.index > b.index)
// // for (let i = 0; i < sortWidgets.length; ++i) {
// // const index = widgets.findIndex((item) => item.uuid === sortWidgets[i].widget.uuid)
// // widgets.splice(index, 1)
// // widgets.push(sortWidgets[i].widget)
// // }
// group.left = Number(left)
// group.top = Number(top)
// group.width = Number(right - left)
// group.height = Number(bottom - top)
// store.state.dActiveElement = group
// store.state.dSelectWidgets = []
// store.dispatch('pushHistory', 'realCombined')
// // store.dispatch('reChangeCanvas')
// }
// },
// getCombined(store: any) {
// const selectWidgets = store.state.dSelectWidgets
// return new Promise((resolve) => {
// if (selectWidgets.length > 1) {
// const widgets = store.state.dWidgets
// const group = JSON.parse(store.state.dGroupJson)
// group.uuid = nanoid()
// // widgets.push(group)
// let left = store.state.dPage.width
// let top = store.state.dPage.height
// let right = 0
// let bottom = 0
// const sortWidgets = [] // 顺序取出元素
// const selectkeys = selectWidgets.map((x: Type.Object) => x.uuid)
// for (const w of widgets) {
// selectkeys.includes(w.uuid) && sortWidgets.push(w)
// }
// for (let i = 0; i < sortWidgets.length; ++i) {
// const uuid = sortWidgets[i].uuid
// const index = widgets.findIndex((item: Type.Object) => item.uuid === uuid)
// const widget = { ...widgets[index] } // clone
// left = Math.min(left, widget.left)
// top = Math.min(top, widget.top)
// right = Math.max(right, Number(widget.width) + Number(widget.left))
// bottom = Math.max(bottom, Number(widget.height) + Number(widget.top))
// }
// group.left = left
// group.top = top
// group.width = right - left
// group.height = bottom - top
// resolve(group)
// }
// })
// },
// initGroupJson(store, json) {
// store.state.dGroupJson = json
// },
// updateGroupSize(store, uuid) {
// const widgets = store.state.dWidgets
// const group = widgets.find((item) => item.uuid === uuid)
// let left = store.state.dPage.width
// let top = store.state.dPage.height
// let right = 0
// let bottom = 0
// for (let i = 0; i < widgets.length; ++i) {
// if (widgets[i].parent === group.uuid) {
// left = Math.min(left, widgets[i].left)
// top = Math.min(top, widgets[i].top)
// right = Math.max(right, widgets[i].record.width + widgets[i].left)
// bottom = Math.max(bottom, widgets[i].record.height + widgets[i].top)
// }
// }
// group.width = right - left
// group.height = bottom - top
// group.left = left
// group.top = top
// },
// updateLayerIndex(store, { uuid, value, isGroup }) {
// const widgets = store.state.dWidgets
// const widget = widgets.find((item) => item.uuid === uuid)
// const index = widgets.findIndex((item) => item.uuid === uuid)
// let group = []
// if (isGroup) {
// // 组合组件移动
// group = widgets.filter((item) => item.parent === uuid)
// for (let i = 0; i < group.length; ++i) {
// const pos = widgets.findIndex((item) => item.uuid === group[i].uuid)
// widgets.splice(pos, 1)
// }
// }
// // 单个组件移动,组合的把容器内的组件取出来后也相当于是移动单个组件
// let next = index + value
// let move = false
// const maxLen = widgets.length
// let gCount = 1 // 记录跳过的组合数量
// // 循环找出要目标位置并移动(因为存在组合,所以不能直接移动到下一个位置)
// while (next >= 0 && next < maxLen) {
// const nextWidget = widgets[next]
// if (widget.parent !== '-1') {
// // 如果是在容器里面,比较简单,只要目标组件的父容器一样就移动,不一样说明出了容器了就不移动
// if (nextWidget.parent === widget.parent) {
// widgets.splice(index, 1)
// widgets.splice(next, 0, widget)
// move = true
// }
// break
// // 如果父容器一样并且(目标组件不是容器或者先上移动并且目标组件是容器),则是要移动的位置
// } else if (nextWidget.parent === '-1') {
// if ((gCount === 0 && nextWidget.isContainer) || !nextWidget.isContainer || (value < 0 && nextWidget.isContainer)) {
// if (gCount === 0 && value > 0) {
// next -= value
// }
// widgets.splice(index, 1)
// widgets.splice(next, 0, widget)
// move = true
// break
// } else if (nextWidget.isContainer) {
// gCount = 0
// }
// }
// next += value
// }
// next -= value
// if (!move && next !== index) {
// widgets.splice(index, 1)
// widgets.splice(next, 0, widget)
// }
// // 如果是组合,要把里面的组件添加回去
// if (isGroup) {
// const pos = widgets.findIndex((item) => item.uuid === uuid)
// for (let i = group.length - 1; i >= 0; --i) {
// widgets.splice(pos + 1, 0, group[i])
// }
// }
// },
// // TODO: 取消组合
// ungroup(store, uuid) {
// const widgets = store.state.dWidgets
// const index = widgets.findIndex((item) => item.uuid === uuid)
// widgets.splice(index, 1)
// const len = widgets.length
// for (let i = 0; i < len; ++i) {
// if (widgets[i].parent === uuid) {
// widgets[i].parent = '-1'
// // store.state.dAltDown = true
// // store.dispatch('selectWidgetsInOut', { uuid: widgets[i].uuid })
// store.state.dSelectWidgets.push(widgets[i])
// }
// }
// // store.state.dAltDown = false
// store.commit('updateSelect')
// // store.state.dActiveElement = store.state.dPage
// },
// /**
// * 设置拖拽时在哪个图层
// */
// setDropOver(store: any, uuid: string) {
// store.state.dDropOverUuid = uuid
// },
}

View File

@ -1,191 +0,0 @@
import mutations from './mutations'
import actions from './actions'
const all = {
state: {
// dZoom: 0, // 画布缩放百分比
// dPaddingTop: 0, // 画布垂直居中修正值
// dScreen: {
// width: 0, // 记录编辑界面的宽度
// height: 0, // 记录编辑界面的高度
// },
// gridSize: {
// width: 0, // 网格小格子的宽度
// height: 0, // 网格小格子的高度
// },
// guidelines: {
// // moveable 标尺辅助线
// verticalGuidelines: [],
// horizontalGuidelines: [],
// },
// dActiveWidgetXY: {
// x: 0, // 选中组件的横向初始值
// y: 0, // 选中组件的纵向初始值
// },
// dMouseXY: {
// x: 0, // 鼠标按下时的横坐标
// y: 0, // 鼠标按下时的纵坐标
// },
// dMoving: false, // 是否正在移动组件
// dDraging: false, // 是否正在抓取组件
// dResizeing: false, // 是否正在调整组件宽高
// dShowRefLine: true, // 是否显示参考线
// dResizeWH: {
// // 初始化调整大小时组件的宽高
// width: 0,
// height: 0,
// },
// dActiveElement: {}, // 选中的组件或页面
// dCopyElement: [], // 复制的组件(可能是单个也可能是数组)
// dHoverUuid: '-1', // 鼠标在这个图层上
// dDropOverUuid: '', // 拖动时放在哪个图层上
// dPage: {
// name: '背景页面',
// type: 'page',
// uuid: '-1',
// left: 0,
// top: 0,
// width: 1920, // 画布宽度
// height: 1080, // 画布高度
// backgroundColor: '#ffffff', // 画布背景颜色
// backgroundImage: '', // 画布背景图片
// backgroundTransform: {},
// opacity: 1, // 透明度
// tag: 0, // 强制刷新用
// setting: [
// {
// label: '背景颜色',
// parentKey: 'backgroundColor',
// value: false,
// },
// ],
// record: {},
// },
// dWidgets: [], // 已使用的组件
// dHistory: [], // 记录历史操作保存整个画布的json数据
// dActiveUuidHistory: [], // 记录历史操作对应的激活的组件的uuid
// dPageHistory: [], // 记录历史操作对应的page
// dHistoryParams: {
// index: -1,
// length: 0,
// maxLength: 20,
// },
// dColorHistory: [], // 记录历史选择的颜色
// dAltDown: false, // 记录是否按下alt键 / 或ctrl
// dSelectWidgets: [], // 记录多选的组件
// dGroupJson: {}, // 组合的json数据
// selectItem: { data: null }, // 记录当前选择的元素, data
// activeMouseEvent: null, // 正在活动的鼠标事件
// showMoveable: false, // 全局控制选择框的显示
// showRotatable: true, // 是否显示moveable的旋转按钮
// zoomScreenChange: null, // 画布强制刷新适应度
// updateRect: null, // 强制刷新操作框
// updateSelect: null, // 强制设置选择元素
// dCropUuid: -1, // 正在编辑or裁剪的组件id
// dDragInitData: {}, // 拖拽初始化数据
},
getters: {
// selectItem(state: any) {
// return state.selectItem
// },
// dZoom(state) {
// return state.dZoom
// },
// dPaddingTop(state: any) {
// return state.dPaddingTop
// },
// dScreen(state) {
// return state.dScreen
// },
// gridSize(state) {
// return state.gridSize
// },
// dActiveWidgetXY(state) {
// return state.dActiveWidgetXY
// },
// dMouseXY(state) {
// return state.dMouseXY
// },
// dMoving(state) {
// return state.dMoving
// },
// dDraging(state) {
// return state.dDraging
// },
// dActiveElement(state) {
// return state.dActiveElement
// },
// dPage(state) {
// return state.dPage
// },
// dWidgets(state) {
// return state.dWidgets
// },
// dHistoryParams(state) {
// return state.dHistoryParams
// },
// dColorHistory(state) {
// return state.dColorHistory
// },
// dHoverUuid(state) {
// return state.dHoverUuid
// },
// dResizeing(state) {
// return state.dResizeing
// },
// dShowRefLine(state) {
// return state.dShowRefLine
// },
// dCopyElement(state) {
// return state.dCopyElement
// },
// dAltDown(state) {
// return state.dAltDown
// },
// dSelectWidgets(state) {
// return state.dSelectWidgets
// },
// activeMouseEvent(state: any) {
// return state.activeMouseEvent
// },
// showMoveable(state: any) {
// return state.showMoveable
// },
// showRotatable(state: any) {
// return state.showRotatable
// },
// zoomScreenChange(state: any) {
// return state.zoomScreenChange
// },
// updateRect(state: any) {
// return state.updateRect
// },
// updateSelect(state: any) {
// return state.updateSelect
// },
// dDropOverUuid(state: any) {
// return state.dDropOverUuid
// },
// guidelines(state: any) {
// return state.guidelines
// },
// dCropUuid(state: any) {
// return state.dCropUuid
// },
// dPageHistory(state: any) {
// return state.dPageHistory
// },
// dHistory(state: any) {
// return state.dHistory
// },
// dDragInitData(state: any) {
// return state.dDragInitData
// },
},
mutations: {
...mutations,
},
actions: {
...actions,
},
}
export default all

View File

@ -1,88 +0,0 @@
/*
* @Author: ShawnPhang
* @Date: 2022-03-10 23:05:03
* @Description:
* @LastEditors: ShawnPhang
* @LastEditTime: 2022-03-11 10:13:42
*/
// export default function handleHistory(store: any, action: any) {
// store.commit('setShowMoveable', false) // 清理掉上一次的选择框
// const history = store.state.dHistory
// const pageHistory = store.state.dPageHistory
// const historyParams = store.state.dHistoryParams
// if (action === 'undo') {
// historyParams.index -= 1 // 下标向前移1 撤销
// console.log(historyParams.index)
// if (historyParams.index > -1) {
// store.state.dWidgets = JSON.parse(history[historyParams.index])
// store.state.dPage = JSON.parse(pageHistory[historyParams.index])
// }
// } else if (action === 'redo') {
// historyParams.index += 1 // 下标向后移1 重做
// // 如果下标小于历史记录列表长度,直接取出历史记录
// // if (historyParams.index < historyParams.length) {
// store.state.dWidgets = JSON.parse(history[historyParams.index])
// store.state.dPage = JSON.parse(pageHistory[historyParams.index])
// // } else {
// // // 否则设置下标为列表最后一项
// // historyParams.index = historyParams.length - 1
// // store.state.dWidgets = JSON.parse(history[historyParams.index])
// // store.state.dPage = JSON.parse(pageHistory[historyParams.index + 1])
// // }
// }
// }
// function handleHistory_old(store: any, action: any) {
// store.commit('setShowMoveable', false) // 清理掉上一次的选择框
// const history = store.state.dHistory
// // const uuidHistory = store.state.dActiveUuidHistory
// const pageHistory = store.state.dPageHistory
// const historyParams = store.state.dHistoryParams
// // let uuid = '-1'
// console.log(action, historyParams)
// if (action === 'undo') {
// // 下标向前移1 撤销
// historyParams.index -= 1
// // 如果下表大于等于0直接取出历史记录
// if (historyParams.index >= 0) {
// console.log(1, history)
// console.log(2, pageHistory)
// store.state.dWidgets = JSON.parse(history[historyParams.index])
// store.state.dPage = JSON.parse(pageHistory[historyParams.index + 1])
// // uuid = uuidHistory[historyParams.index]
// } else if (historyParams.length < 10) {
// // 否则如果历史记录长度小于10则设置组件为空
// historyParams.index = -1
// store.state.dWidgets = []
// store.state.dPage = JSON.parse(pageHistory[0])
// } else {
// historyParams.index = -1
// }
// } else if (action === 'redo') {
// // 下标向后移1 重做
// historyParams.index += 1
// // 如果下标小于历史记录列表长度,直接取出历史记录
// if (historyParams.index < historyParams.length) {
// console.log(1, history)
// console.log(2, pageHistory)
// store.state.dWidgets = JSON.parse(history[historyParams.index])
// store.state.dPage = JSON.parse(pageHistory[historyParams.index + 1] || pageHistory[historyParams.index])
// // uuid = uuidHistory[historyParams.index]
// } else {
// // 否则设置下标为列表最后一项
// historyParams.index = historyParams.length - 1
// store.state.dWidgets = JSON.parse(history[historyParams.index])
// store.state.dPage = JSON.parse(pageHistory[historyParams.index + 1])
// // uuid = uuidHistory[historyParams.index]
// }
// }
// // 激活组件默认为page
// // let element = store.state.dPage
// // if (uuid !== '-1') {
// // element = store.state.dWidgets.find((item) => item.uuid === uuid)
// // }
// // store.state.dActiveElement = element
// }

View File

@ -1,73 +0,0 @@
/*
* @Author: ShawnPhang
* @Date: 2022-03-04 19:36:00
* @Description:
* @LastEditors: ShawnPhang
* @LastEditTime: 2022-03-11 10:12:50
*/
// export default function pushHistory(store: any, msg: string) {
// console.log('history压栈', '来源: ' + msg)
// const history = store.state.dHistory
// const pageHistory = store.state.dPageHistory
// const historyParams = store.state.dHistoryParams // index = length - 1
// // 如果有上一次记录,并且与新纪录相同,那么不继续操作
// if (history[history.length - 1] && history[history.length - 1] === JSON.stringify(store.state.dWidgets)) {
// return
// }
// if (historyParams.index < history.length - 1) {
// const index = historyParams.index + 1
// const len = history.length - index
// history.splice(index, len)
// pageHistory.splice(index, len)
// historyParams.length = history.length
// historyParams.index = history.length - 1
// }
// history.push(JSON.stringify(store.state.dWidgets))
// pageHistory.push(JSON.stringify(store.state.dPage))
// historyParams.index = history.length - 1
// historyParams.length = history.length
// }
// function pushHistory_old(store: any) {
// // 历史记录列表
// const history = store.state.dHistory
// // 历史激活组件记录列表
// // const uuidHistory = store.state.dActiveUuidHistory
// // 历史page记录列表
// const pageHistory = store.state.dPageHistory
// // 历史记录列表参数(长度和下标)
// const historyParams = store.state.dHistoryParams
// // 下标不等于-1表示已经存在历史操作记录
// // 下标小于历史列表长度-1则说明不是在末尾添加记录需要先删除掉下标之后的数据否则会出现错乱
// if (historyParams.index < history.length - 1) {
// const index = historyParams.index + 1
// const len = history.length - index
// // 删除下标之后的所有历史记录
// history.splice(index, len)
// // 删除下标之后的所有uuid记录
// // uuidHistory.splice(index, len)
// // 删除下标之后的所有page记录
// pageHistory.splice(index + 1, len - 1)
// historyParams.length = history.length
// }
// // 保存当前操作进历史记录
// if (history[history.length - 1] !== JSON.stringify(store.state.dWidgets)) {
// history.push(JSON.stringify(store.state.dWidgets))
// // uuidHistory.push(store.state.dActiveElement.uuid)
// pageHistory.push(JSON.stringify(store.state.dPage))
// historyParams.index = history.length - 1
// historyParams.length = history.length
// }
// // 历史记录最多n条如果超过则从头部开始删因为每次都是一条一条加的所以只需删一条就行
// if (history.length > 20) {
// history.splice(0, 1)
// // uuidHistory.splice(0, 1)
// pageHistory.splice(0, 1)
// }
// if (pageHistory.length - 1 > history.length) {
// pageHistory.splice(0, 1)
// }
// // historyParams.index = history.length - 1
// // historyParams.length = history.length
// }

View File

@ -1,80 +0,0 @@
/*
* @Author: ShawnPhang
* @Date: 2021-07-14 15:16:43
* @Description:
* @LastEditors: ShawnPhang <site: book.palxp.com>
* @LastEditTime: 2023-07-11 10:22:54
*/
/**
* store.commit()
*/
interface Iprops {
commit: (a: any, b: any) => void
state: {}
}
export default {
// updatePaddingTop(state: Type.Object, num: number) {
// state.dPaddingTop = num
// },
// selectItem(state: Type.Object, { data, type }: any) {
// state.selectItem.data = data
// state.selectItem.type = type
// },
// resize(state: Type.Object, data: Type.Object) {
// const { width, height } = data
// const target = state.dActiveElement
// target.width = width
// target.height = height
// },
// setWidgetStyle(state: Type.Object, { uuid, key, value, pushHistory }: Type.Object) {
// const widget = state.dWidgets.find((item: any) => item.uuid === uuid)
// widget[key] = value
// },
// setMouseEvent(state: Type.Object, e: Event | null) {
// state.activeMouseEvent = e
// },
// setDWidgets(state: Type.Object, e: any) {
// state.dWidgets = e
// },
// setDPage(state: Type.Object, e: any) {
// state.dPage = e
// },
// setShowMoveable(state: Type.Object, show: any) {
// state.showMoveable = show
// // if (!show) {
// // // TODO: 失焦时设置面板也失去关联,但会导致某些失焦状态出错(如裁剪)
// // state.dActiveElement = state.dPage
// // }
// },
// setShowRotatable(state: Type.Object, e: any) {
// state.showRotatable = e
// },
// zoomScreenChange(state: Type.Object, e: any) {
// // 画布尺寸适应度强制刷新
// state.zoomScreenChange = Math.random()
// },
// updateRect(state: Type.Object, e: any) {
// // 强制刷新操作框
// state.updateRect = Math.random()
// },
// updateSelect(state: Type.Object, e: any) {
// // 强制触发元素选择
// state.updateSelect = Math.random()
// },
// updateGuidelines(state: Type.Object, lines: any) {
// // 修改标尺线
// state.guidelines = { ...state.guidelines, ...lines }
// },
// setCropUuid(state: Type.Object, uuid: any) {
// // 设置正在裁剪or编辑的组件
// state.dCropUuid = uuid
// },
// setDraging(state: Type.Object, drag: boolean) {
// state.dDraging = drag
// },
// setDragInitData(state: Type.Object, data: any) {
// state.dDragInitData = data
// },
}

View File

@ -8,7 +8,7 @@
import axios, { AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios' import axios, { AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios'
// import store from '@/store' // import store from '@/store'
import app_config, { LocalStorageKey } from '@/config' import app_config, { LocalStorageKey } from '@/config'
import { useBaseStore, useUserStore } from '@/pinia/index'; import { useBaseStore, useUserStore } from '@/store/index';
axios.defaults.timeout = 30000 axios.defaults.timeout = 30000
axios.defaults.headers.authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTAwMDEsImV4cCI6MTc4ODU3NDc1MDU4NX0.L_t6DFD48Dm6rUPfgIgOWJkz18En1m_-hhMHcpbxliY'; axios.defaults.headers.authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTAwMDEsImV4cCI6MTc4ODU3NDc1MDU4NX0.L_t6DFD48Dm6rUPfgIgOWJkz18En1m_-hhMHcpbxliY';

View File

@ -22,7 +22,7 @@ import zoomControl from '@/components/modules/layout/zoomControl/index.vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { wGroupSetting } from '@/components/modules/widgets/wGroup/groupSetting' import { wGroupSetting } from '@/components/modules/widgets/wGroup/groupSetting'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useGroupStore, usePageStore, useWidgetStore } from '@/pinia' import { useGroupStore, usePageStore, useWidgetStore } from '@/store'
type TState = { type TState = {
style: StyleValue style: StyleValue

View File

@ -72,7 +72,7 @@ import ProgressLoading from '@/components/common/ProgressLoading/index.vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { wGroupSetting } from '@/components/modules/widgets/wGroup/groupSetting' import { wGroupSetting } from '@/components/modules/widgets/wGroup/groupSetting'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useCanvasStore, useControlStore, usePageStore, useHistoryStore, useWidgetStore, useGroupStore } from '@/pinia' import { useCanvasStore, useControlStore, usePageStore, useHistoryStore, useWidgetStore, useGroupStore } from '@/store'
type TState = { type TState = {
style: CSSProperties style: CSSProperties

View File

@ -73,7 +73,7 @@ import ProgressLoading from '@/components/common/ProgressLoading/index.vue'
import { processPSD2Page } from '@/utils/plugins/psd' import { processPSD2Page } from '@/utils/plugins/psd'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting' import { wTextSetting } from '@/components/modules/widgets/wText/wTextSetting'
import { useCanvasStore, useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useCanvasStore, useControlStore, usePageStore, useWidgetStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
type TState = { type TState = {

View File

@ -40,7 +40,7 @@ import _config from '@/config'
import useConfirm from '@/common/methods/confirm' import useConfirm from '@/common/methods/confirm'
// import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue' // import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { useBaseStore, useControlStore, useHistoryStore, usePageStore, useUserStore, useWidgetStore } from '@/pinia/index' import { useBaseStore, useControlStore, useHistoryStore, usePageStore, useUserStore, useWidgetStore } from '@/store/index'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
type TProps = { type TProps = {

View File

@ -22,9 +22,9 @@ import { useFontStore } from '@/common/methods/fonts'
import _config from '@/config' import _config from '@/config'
import github from '@/api/github' import github from '@/api/github'
// import { useSetupMapGetters } from '@/common/hooks/mapGetters' // import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import { useControlStore, usePageStore, useWidgetStore } from '@/pinia' import { useControlStore, usePageStore, useWidgetStore } from '@/store'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { TdWidgetData } from '@/pinia/design/widget' import { TdWidgetData } from '@/store/design/widget'
type TProps = { type TProps = {
modelValue?: string modelValue?: string