diff --git a/src/components/common/PopoverTip.vue b/src/components/common/PopoverTip.vue index e3e2b45..b5d5cb9 100644 --- a/src/components/common/PopoverTip.vue +++ b/src/components/common/PopoverTip.vue @@ -20,7 +20,7 @@ type TProps = { title: string width: number content: string - position: "bottom" | "auto" | "auto-start" | "auto-end" | "top" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" + position?: "bottom" | "auto" | "auto-start" | "auto-end" | "top" | "right" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end" offset?: number } diff --git a/src/components/common/Uploader/index.vue b/src/components/common/Uploader/index.vue index 10db83f..f3461db 100644 --- a/src/components/common/Uploader/index.vue +++ b/src/components/common/Uploader/index.vue @@ -35,9 +35,9 @@ export type TUploadDoneData = { type TQiNiuUploadReturn = { hash: string, key: string } type TProps = { - modelValue: TModelData - options: { bucket: string, prePath: string } - hold: boolean + modelValue?: TModelData + options?: { bucket: string, prePath: string } + hold?: boolean } type TEmits = { diff --git a/src/components/modules/panel/wrap/UserWrap.vue b/src/components/modules/panel/wrap/UserWrap.vue index a2bd8fe..819e917 100644 --- a/src/components/modules/panel/wrap/UserWrap.vue +++ b/src/components/modules/panel/wrap/UserWrap.vue @@ -52,7 +52,7 @@ import { TUploadDoneData } from '@/components/common/Uploader/index.vue' import { IGetTempListData } from '@/api/home' type TProps = { - active: number + active?: number } type TState = { @@ -104,7 +104,6 @@ const load = (init?: boolean) => { } else { state.imgList = state.imgList.concat(list) } - console.log('state.imgList', state.imgList) setTimeout(() => { loading = false if (!imgListRef.value) return @@ -133,11 +132,9 @@ const loadDesign = (init: boolean = false) => { return x }), )) - console.log('state.designList', state.designList) setTimeout(() => { loading = false if (!listRef.value) return - console.log('listRef.value', listRef.value) checkHeight(listRef.value, loadDesign) }, 100) }) diff --git a/src/components/modules/panel/wrap/components/classHeader.vue b/src/components/modules/panel/wrap/components/classHeader.vue index 02a6c3c..769663a 100644 --- a/src/components/modules/panel/wrap/components/classHeader.vue +++ b/src/components/modules/panel/wrap/components/classHeader.vue @@ -30,7 +30,7 @@ export type TClassHeaderTypeData = { type TProps = { types: TClassHeaderTypeData[] - isBack: boolean + isBack?: boolean } type TEmits = { diff --git a/src/components/modules/panel/wrap/components/photoList.vue b/src/components/modules/panel/wrap/components/photoList.vue index 0f9ccf0..1939007 100644 --- a/src/components/modules/panel/wrap/components/photoList.vue +++ b/src/components/modules/panel/wrap/components/photoList.vue @@ -46,9 +46,9 @@ import { IGetTempListData } from '@/api/home'; type TProps = { listData: IGetTempListData[] - edit: Record - isDone: boolean - isShort: boolean + edit?: Record + isDone?: boolean + isShort?: boolean } type TEmits = { @@ -64,7 +64,8 @@ type TState = { } const props = withDefaults(defineProps(), { - isShort: false + isShort: false, + listData: () => ([]) }) const emit = defineEmits() const listRef = ref(null) diff --git a/src/components/modules/panel/wrap/components/searchHeader.vue b/src/components/modules/panel/wrap/components/searchHeader.vue index 88136d1..a25cf80 100644 --- a/src/components/modules/panel/wrap/components/searchHeader.vue +++ b/src/components/modules/panel/wrap/components/searchHeader.vue @@ -37,7 +37,7 @@ import api from '@/api' type TProps = { type?: string - modelValue: string + modelValue?: string } type TEmits = { diff --git a/src/components/modules/settings/colorSelect.vue b/src/components/modules/settings/colorSelect.vue index f626cc8..beb856d 100644 --- a/src/components/modules/settings/colorSelect.vue +++ b/src/components/modules/settings/colorSelect.vue @@ -46,7 +46,7 @@ export default defineComponent({ setup(props, { emit }) { const store = useStore() const state: any = reactive({ - innerColor: '#ffffffff', + innerColor: '', // colorLength: 0, // hasEyeDrop: 'EyeDropper' in window, }) diff --git a/src/mixins/shortcuts.ts b/src/mixins/shortcuts.ts index d064927..5464829 100644 --- a/src/mixins/shortcuts.ts +++ b/src/mixins/shortcuts.ts @@ -14,6 +14,7 @@ _this.dHistoryParams = store.getters.dHistoryParams import keyCodeOptions from './methods/keyCodeOptions' import dealWithCtrl from './methods/dealWithCtrl' +import { useStore, Store } from 'vuex' const ignoreNode = ['INPUT', 'TEXTAREA'] @@ -36,94 +37,98 @@ let hadDown = false const shortcuts = { methods: { - handleKeydowm(e: any) { - const nodeName = e.target.nodeName - if (ignoreNode.indexOf(nodeName) !== -1 || (nodeName === 'DIV' && e.target.contentEditable === 'true')) { - return - } - // if (hadDown || this.showMenuBg) { - // e.stopPropagation() - // e.preventDefault() - // return - // } - // hadDown = true - const ctrl = e.key === 'Control' || e.key === 'Meta' - const alt = e.key === 'Alt' - const shift = e.key === 'Shift' - // const dir = e.keyCode === 37 || e.keyCode === 38 || e.keyCode === 39 || e.keyCode === 40 - // const specialKey = ctrl || alt || shift || dir - // if (specialKey || e.metaKey) { - // hadDown = false - // } - if (shift || ctrl) { - this.$store.dispatch('updateAltDown', true) - clearInterval(this.checkCtrl) - this.checkCtrl = setInterval(() => { - // TODO: 防止组合键导致页面失焦无法操作 - if (!document.hasFocus()) { - clearInterval(this.checkCtrl) - hadDown = false - this.$store.dispatch('updateAltDown', false) - } - }, 500) - } - // const systemKey = systemKeyCode.find((item) => { - // let f = false - // let f2 = false - // for (let i = 0; i < item.key.length; ++i) { - // f = e[item.key[i]] - // if (f) { - // break - // } - // } - // if (item.key2) { - // for (let i = 0; i < item.key2.length; ++i) { - // f2 = e[item.key2[i]] - // if (f2) { - // break - // } - // } - // } - // return f && f2 && e.keyCode === item.code - // }) - // if (systemKey) { - // return - // } - const withCtrl = e.ctrlKey || e.metaKey - if (withCtrl && !(ctrl || alt || shift)) { - this.dealCtrl(e) - return - } - // const withAlt = e.altKey - // if (withAlt && !specialKey) { - // return - // } - const withShift = e.shiftKey - // if (withShift && !specialKey) { - // return - // } - // // TODO - // if (!this.dActiveElement) { - // return - // } - // if (this.dActiveElement.uuid === '-1') { - // return - // } - // e.stopPropagation() - // e.preventDefault() - const f = withShift ? 10 : 1 - keyCodeOptions(e, { f }) - }, - handleKeyup(e) { - console.log(e) - clearInterval(this.checkCtrl) - hadDown = false - if (e.key === 'Alt' || e.key === 'Shift' || e.key === 'Control' || e.key === 'Meta') { - this.$store.dispatch('updateAltDown', false) + handleKeydowm(store: Store, checkCtrl: number | undefined, instance: any, dealCtrl: (e: any, instance: any) => void) { + return (e: any) => { + const nodeName = e.target.nodeName + if (ignoreNode.indexOf(nodeName) !== -1 || (nodeName === 'DIV' && e.target.contentEditable === 'true')) { + return + } + // if (hadDown || this.showMenuBg) { + // e.stopPropagation() + // e.preventDefault() + // return + // } + // hadDown = true + const ctrl = e.key === 'Control' || e.key === 'Meta' + const alt = e.key === 'Alt' + const shift = e.key === 'Shift' + // const dir = e.keyCode === 37 || e.keyCode === 38 || e.keyCode === 39 || e.keyCode === 40 + // const specialKey = ctrl || alt || shift || dir + // if (specialKey || e.metaKey) { + // hadDown = false + // } + if (shift || ctrl) { + store.dispatch('updateAltDown', true) + clearInterval(checkCtrl) + checkCtrl = setInterval(() => { + // TODO: 防止组合键导致页面失焦无法操作 + if (!document.hasFocus()) { + clearInterval(checkCtrl) + hadDown = false + store.dispatch('updateAltDown', false) + } + }, 500) + } + // const systemKey = systemKeyCode.find((item) => { + // let f = false + // let f2 = false + // for (let i = 0; i < item.key.length; ++i) { + // f = e[item.key[i]] + // if (f) { + // break + // } + // } + // if (item.key2) { + // for (let i = 0; i < item.key2.length; ++i) { + // f2 = e[item.key2[i]] + // if (f2) { + // break + // } + // } + // } + // return f && f2 && e.keyCode === item.code + // }) + // if (systemKey) { + // return + // } + const withCtrl = e.ctrlKey || e.metaKey + if (withCtrl && !(ctrl || alt || shift)) { + dealCtrl(e, instance) + return + } + // const withAlt = e.altKey + // if (withAlt && !specialKey) { + // return + // } + const withShift = e.shiftKey + // if (withShift && !specialKey) { + // return + // } + // // TODO + // if (!this.dActiveElement) { + // return + // } + // if (this.dActiveElement.uuid === '-1') { + // return + // } + // e.stopPropagation() + // e.preventDefault() + const f = withShift ? 10 : 1 + keyCodeOptions(e, { f }) } }, - dealCtrl(e: any) { - dealWithCtrl(e, this) + handleKeyup(store: Store, checkCtrl: number | undefined) { + return (e: any) => { + console.log(e) + clearInterval(checkCtrl) + hadDown = false + if (e.key === 'Alt' || e.key === 'Shift' || e.key === 'Control' || e.key === 'Meta') { + store.dispatch('updateAltDown', false) + } + } + }, + dealCtrl(e: any, instance: any) { + dealWithCtrl(e, instance) console.log(e.key, e.keyCode) }, }, diff --git a/src/views/Index.vue b/src/views/Index.vue index 16eb594..50b5088 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -8,10 +8,10 @@ --> -