mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat:新增吸附修改的全局设置
This commit is contained in:
parent
00f2359b9d
commit
76b22ce05c
5
src/components/SystemSet/index.d.ts
vendored
5
src/components/SystemSet/index.d.ts
vendored
@ -1,8 +1,11 @@
|
|||||||
export type ListType = {
|
export type ListType = {
|
||||||
key: string
|
key: any
|
||||||
type: string
|
type: string
|
||||||
name: string
|
name: string
|
||||||
desc: string
|
desc: string
|
||||||
value: any
|
value: any
|
||||||
|
suffix?: string
|
||||||
|
step?: number
|
||||||
|
min?: number
|
||||||
tip?: string
|
tip?: string
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,17 @@
|
|||||||
@update:value="handleChange($event, item)"
|
@update:value="handleChange($event, item)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="item.type === 'number'">
|
||||||
|
<n-input-number
|
||||||
|
v-model:value="item.value"
|
||||||
|
class="input-num-width"
|
||||||
|
size="small"
|
||||||
|
:step="item.step || null"
|
||||||
|
:suffix="item.suffix || null"
|
||||||
|
:min="item.min || 0"
|
||||||
|
@update:value="handleChange($event, item)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-text class="item-right">{{ item.desc }}</n-text>
|
<n-text class="item-right">{{ item.desc }}</n-text>
|
||||||
@ -58,6 +69,16 @@ defineProps({
|
|||||||
const settingStore = useSettingStore()
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
const list = reactive<ListType[]>([
|
const list = reactive<ListType[]>([
|
||||||
|
{
|
||||||
|
key: SettingStoreEnums.CHART_ALIGN_RANGE,
|
||||||
|
value: settingStore.getChartAlignRange,
|
||||||
|
type: 'number',
|
||||||
|
name: '吸附距离',
|
||||||
|
min: 10,
|
||||||
|
suffix: 'px',
|
||||||
|
step: 2,
|
||||||
|
desc: '移动图表时的吸附距离'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: SettingStoreEnums.ASIDE_ALL_COLLAPSED,
|
key: SettingStoreEnums.ASIDE_ALL_COLLAPSED,
|
||||||
value: settingStore.getAsideAllCollapsed,
|
value: settingStore.getAsideAllCollapsed,
|
||||||
@ -86,18 +107,21 @@ const closeHandle = () => {
|
|||||||
emit('update:modelShow', false)
|
emit('update:modelShow', false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = (e: Event, item: ListType) => {
|
const handleChange = (e: MouseEvent, item: ListType) => {
|
||||||
settingStore.setItem(item.key, item.value)
|
settingStore.setItem(item.key, item.value)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go('system-setting') {
|
@include go("system-setting") {
|
||||||
@extend .go-background-filter;
|
@extend .go-background-filter;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
max-width: 60vw;
|
max-width: 60vw;
|
||||||
.item-left {
|
.item-left {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
.input-num-width {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -8,3 +8,6 @@ export const hidePackageOneCategory = true
|
|||||||
|
|
||||||
// 切换语言是否进行路由刷新
|
// 切换语言是否进行路由刷新
|
||||||
export const changeLangReload = false
|
export const changeLangReload = false
|
||||||
|
|
||||||
|
// 图表拖拽时的吸附距离(px)
|
||||||
|
export const chartAlignRange = '10'
|
@ -39,8 +39,10 @@ export const useChartLayoutStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setItem(key: string, value: boolean): void {
|
setItem<T extends keyof ChartLayoutType, K extends ChartLayoutType[T]>(key: T, value: K): void {
|
||||||
;(this as any)[key] = value
|
this.$patch(state => {
|
||||||
|
state[key]= value
|
||||||
|
});
|
||||||
setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state)
|
setLocalStorage(GO_CHART_LAYOUT_STORE, this.$state)
|
||||||
// 重新计算拖拽区域缩放比例
|
// 重新计算拖拽区域缩放比例
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -2,10 +2,12 @@ export enum SettingStoreEnums {
|
|||||||
HIDE_PACKAGE_ONE_CATEGORY = 'hidePackageOneCategory',
|
HIDE_PACKAGE_ONE_CATEGORY = 'hidePackageOneCategory',
|
||||||
CHANGE_LANG_RELOAD = 'changeLangReload',
|
CHANGE_LANG_RELOAD = 'changeLangReload',
|
||||||
ASIDE_ALL_COLLAPSED = 'asideAllCollapsed',
|
ASIDE_ALL_COLLAPSED = 'asideAllCollapsed',
|
||||||
|
CHART_ALIGN_RANGE = 'chartAlignRange',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingStoreType {
|
export interface SettingStoreType {
|
||||||
[SettingStoreEnums.HIDE_PACKAGE_ONE_CATEGORY]: boolean
|
[SettingStoreEnums.HIDE_PACKAGE_ONE_CATEGORY]: boolean
|
||||||
[SettingStoreEnums.CHANGE_LANG_RELOAD]: boolean
|
[SettingStoreEnums.CHANGE_LANG_RELOAD]: boolean
|
||||||
[SettingStoreEnums.ASIDE_ALL_COLLAPSED]: boolean
|
[SettingStoreEnums.ASIDE_ALL_COLLAPSED]: boolean
|
||||||
|
[SettingStoreEnums.CHART_ALIGN_RANGE]: number
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ import { defineStore } from 'pinia'
|
|||||||
import {
|
import {
|
||||||
hidePackageOneCategory,
|
hidePackageOneCategory,
|
||||||
changeLangReload,
|
changeLangReload,
|
||||||
asideAllCollapsed
|
asideAllCollapsed,
|
||||||
|
chartAlignRange
|
||||||
} from '@/settings/systemSetting'
|
} from '@/settings/systemSetting'
|
||||||
import { asideCollapsedWidth } from '@/settings/designSetting'
|
import { asideCollapsedWidth } from '@/settings/designSetting'
|
||||||
import { SettingStoreType } from './settingStore.d'
|
import { SettingStoreType } from './settingStore.d'
|
||||||
@ -19,7 +20,8 @@ export const useSettingStore = defineStore({
|
|||||||
storageSetting || {
|
storageSetting || {
|
||||||
hidePackageOneCategory,
|
hidePackageOneCategory,
|
||||||
changeLangReload,
|
changeLangReload,
|
||||||
asideAllCollapsed
|
asideAllCollapsed,
|
||||||
|
chartAlignRange
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getHidePackageOneCategory(): boolean {
|
getHidePackageOneCategory(): boolean {
|
||||||
@ -33,11 +35,16 @@ export const useSettingStore = defineStore({
|
|||||||
},
|
},
|
||||||
getAsideCollapsedWidth(): number {
|
getAsideCollapsedWidth(): number {
|
||||||
return this.asideAllCollapsed ? 0 : asideCollapsedWidth
|
return this.asideAllCollapsed ? 0 : asideCollapsedWidth
|
||||||
|
},
|
||||||
|
getChartAlignRange(): number {
|
||||||
|
return this.chartAlignRange
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setItem(key: string, value: boolean): void {
|
setItem<T extends keyof SettingStoreType, K extends SettingStoreType[T]>(key: T, value: K): void {
|
||||||
; (this as any)[key] = value
|
this.$patch(state => {
|
||||||
|
state[key]= value
|
||||||
|
});
|
||||||
setLocalStorage(GO_SYSTEM_SETTING_STORE, this.$state)
|
setLocalStorage(GO_SYSTEM_SETTING_STORE, this.$state)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -18,6 +18,7 @@ import { ref, reactive, computed, watch } from 'vue'
|
|||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import throttle from 'lodash/throttle'
|
import throttle from 'lodash/throttle'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
@ -26,11 +27,10 @@ const designStore = useDesignStore()
|
|||||||
const themeColor = ref(designStore.getAppTheme)
|
const themeColor = ref(designStore.getAppTheme)
|
||||||
|
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
const settingStore = useSettingStore()
|
||||||
|
|
||||||
// 线条集合
|
// * 线条集合
|
||||||
const line = reactive({
|
const line = reactive({
|
||||||
// 吸附距离(px)
|
|
||||||
minDistance: 10,
|
|
||||||
// 行横向row(上中下),列竖线col(左中右)
|
// 行横向row(上中下),列竖线col(左中右)
|
||||||
lineArr: ['rowt', 'rowc', 'rowb', 'coll', 'colc', 'colr'],
|
lineArr: ['rowt', 'rowc', 'rowb', 'coll', 'colc', 'colr'],
|
||||||
// 展示线
|
// 展示线
|
||||||
@ -42,7 +42,7 @@ const line = reactive({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 位置计算
|
// * 位置计算
|
||||||
const useComponentStyle = (attr?: Partial<{ x: number; y: number }>) => {
|
const useComponentStyle = (attr?: Partial<{ x: number; y: number }>) => {
|
||||||
if (!attr) return {}
|
if (!attr) return {}
|
||||||
const componentStyle = {
|
const componentStyle = {
|
||||||
@ -52,26 +52,32 @@ const useComponentStyle = (attr?: Partial<{ x: number; y: number }>) => {
|
|||||||
return componentStyle
|
return componentStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否开始计算
|
// * 吸附距离
|
||||||
|
const minDistance = computed(()=>{
|
||||||
|
return settingStore.getChartAlignRange
|
||||||
|
})
|
||||||
|
|
||||||
|
// * 是否开始计算
|
||||||
const isComputedLine = computed(() => {
|
const isComputedLine = computed(() => {
|
||||||
const isDrag = chartEditStore.getEditCanvas[EditCanvasTypeEnum.IS_DRAG]
|
const isDrag = chartEditStore.getEditCanvas[EditCanvasTypeEnum.IS_DRAG]
|
||||||
return isDrag
|
return isDrag
|
||||||
})
|
})
|
||||||
|
|
||||||
// 吸附判定
|
// * 吸附判定
|
||||||
const isSorption = (selectValue: number, componentValue: number) => {
|
const isSorption = (selectValue: number, componentValue: number) => {
|
||||||
const isSorption = Math.abs(selectValue - componentValue) <= line.minDistance
|
console.log(minDistance.value);
|
||||||
|
const isSorption = Math.abs(selectValue - componentValue) <= minDistance.value
|
||||||
return isSorption
|
return isSorption
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前目标
|
// * 当前目标
|
||||||
const selectId = computed(() => chartEditStore.getTargetChart.selectId)
|
const selectId = computed(() => chartEditStore.getTargetChart.selectId)
|
||||||
const selectTatget = computed(
|
const selectTatget = computed(
|
||||||
() => chartEditStore.getComponentList[chartEditStore.fetchTargetIndex()]
|
() => chartEditStore.getComponentList[chartEditStore.fetchTargetIndex()]
|
||||||
)
|
)
|
||||||
const selectAttr = computed(() => selectTatget.value.attr)
|
const selectAttr = computed(() => selectTatget.value.attr)
|
||||||
|
|
||||||
// 画布坐标
|
// * 画布坐标
|
||||||
const canvasPositionList = computed(() => {
|
const canvasPositionList = computed(() => {
|
||||||
return {
|
return {
|
||||||
id: '0',
|
id: '0',
|
||||||
@ -85,7 +91,7 @@ const canvasPositionList = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 监听鼠标移动
|
// * 监听鼠标移动
|
||||||
watch(
|
watch(
|
||||||
() => chartEditStore.getMousePosition,
|
() => chartEditStore.getMousePosition,
|
||||||
throttle(e => {
|
throttle(e => {
|
||||||
@ -282,7 +288,8 @@ watch(
|
|||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// 取消对齐线
|
|
||||||
|
// * 取消对齐线
|
||||||
watch(
|
watch(
|
||||||
() => isComputedLine.value,
|
() => isComputedLine.value,
|
||||||
(val: boolean) => {
|
(val: boolean) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user