mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-25 00:33:00 +08:00
fix: 优化颜色列表卡顿问题
This commit is contained in:
parent
987f4f73a2
commit
67dc58e08e
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="content-left">
|
||||||
<div
|
<div
|
||||||
class="content-left-item go-transition-quick go-mb-0"
|
class="content-left-item go-transition-quick go-mb-0"
|
||||||
span="12 1000:6 1400:4 1800:4 2200:2"
|
span="12 1000:6 1400:4 1800:4 2200:2"
|
||||||
@ -48,21 +49,31 @@
|
|||||||
</n-space>
|
</n-space>
|
||||||
</n-space>
|
</n-space>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { PropType } from 'vue'
|
||||||
import { AppThemeColorType } from '@/store/modules/designStore/designStore.d'
|
import { AppThemeColorType } from '@/store/modules/designStore/designStore.d'
|
||||||
import designColor from '@/settings/designColor.json'
|
|
||||||
import designColorRecommend from '@/settings/designColorRecommend.json'
|
import designColorRecommend from '@/settings/designColorRecommend.json'
|
||||||
|
|
||||||
const emits = defineEmits(['colorSelectHandle'])
|
const emits = defineEmits(['colorSelectHandle'])
|
||||||
|
defineProps({
|
||||||
|
designColor: {
|
||||||
|
type: Object as PropType<AppThemeColorType[]>,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
const colorSelectHandle = (color: AppThemeColorType) => {
|
const colorSelectHandle = (color: AppThemeColorType) => {
|
||||||
emits('colorSelectHandle', color)
|
emits('colorSelectHandle', color)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.content-left {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-right: 200px;
|
||||||
.content-left-item {
|
.content-left-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -98,4 +109,5 @@ const colorSelectHandle = (color: AppThemeColorType) => {
|
|||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -13,12 +13,10 @@
|
|||||||
</n-icon>
|
</n-icon>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-divider />
|
<n-divider />
|
||||||
<div class="model-content">
|
<div class="model-content" ref="contentLeftRef">
|
||||||
<n-scrollbar>
|
<div class="content-left" v-if="modelShow">
|
||||||
<div class="content-left">
|
<ColorList :designColor="designColorSplit" @colorSelectHandle="colorSelectHandle" />
|
||||||
<ColorList @colorSelectHandle="colorSelectHandle" />
|
|
||||||
</div>
|
</div>
|
||||||
</n-scrollbar>
|
|
||||||
<div class="content-right">
|
<div class="content-right">
|
||||||
<div class="color-name-detail">
|
<div class="color-name-detail">
|
||||||
<n-text v-if="appThemeDetail" class="color-name">{{ appThemeDetail.name }}</n-text>
|
<n-text v-if="appThemeDetail" class="color-name">{{ appThemeDetail.name }}</n-text>
|
||||||
@ -45,20 +43,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, watch, toRefs } from 'vue'
|
||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
import { AppThemeColorType } from '@/store/modules/designStore/designStore.d'
|
import { AppThemeColorType } from '@/store/modules/designStore/designStore.d'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import themeColorLogo from '@/assets/images/exception/theme-color.png'
|
import themeColorLogo from '@/assets/images/exception/theme-color.png'
|
||||||
import { loadAsyncComponent } from '@/utils'
|
import { loadAsyncComponent } from '@/utils'
|
||||||
|
import { useScroll } from '@vueuse/core'
|
||||||
|
import designColor from '@/settings/designColor.json'
|
||||||
|
|
||||||
const ColorList = loadAsyncComponent(() =>
|
const ColorList = loadAsyncComponent(() =>
|
||||||
import('./components/ColorList.vue')
|
import('./components/ColorList.vue')
|
||||||
)
|
)
|
||||||
const { ColorWandIcon, CloseIcon } = icon.ionicons5
|
const { ColorWandIcon, CloseIcon } = icon.ionicons5
|
||||||
|
|
||||||
|
let splitNumber = 50
|
||||||
|
|
||||||
const designStore = useDesignStore()
|
const designStore = useDesignStore()
|
||||||
const modelShow = ref(false)
|
const modelShow = ref(false)
|
||||||
|
const contentLeftRef = ref<HTMLElement | null>(null)
|
||||||
|
const designColorSplit = ref(designColor.slice(0, splitNumber))
|
||||||
|
|
||||||
|
const { arrivedState } = useScroll(contentLeftRef, {
|
||||||
|
offset: { bottom: 200 },
|
||||||
|
})
|
||||||
|
const { bottom } = toRefs(arrivedState)
|
||||||
|
|
||||||
const appThemeDetail = computed(() => {
|
const appThemeDetail = computed(() => {
|
||||||
return designStore.getAppThemeDetail
|
return designStore.getAppThemeDetail
|
||||||
@ -67,6 +76,19 @@ const appThemeDetail = computed(() => {
|
|||||||
const colorSelectHandle = (color: AppThemeColorType) => {
|
const colorSelectHandle = (color: AppThemeColorType) => {
|
||||||
designStore.setAppColor(color)
|
designStore.setAppColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(() => bottom.value, (newData: boolean) => {
|
||||||
|
if (newData) {
|
||||||
|
splitNumber = splitNumber + 50
|
||||||
|
designColorSplit.value = designColor.slice(0, splitNumber)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => modelShow.value, (modelShow: boolean) => {
|
||||||
|
if (!modelShow) {
|
||||||
|
splitNumber = 50
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -89,12 +111,7 @@ $height: 85vh;
|
|||||||
.model-content {
|
.model-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: calc(#{$height} - 40px - 48px - 36px);
|
height: calc(#{$height} - 40px - 48px - 36px);
|
||||||
/* 左侧 */
|
overflow: auto;
|
||||||
.content-left {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-right: 200px;
|
|
||||||
}
|
|
||||||
/* 右侧 */
|
/* 右侧 */
|
||||||
.content-right {
|
.content-right {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
body {
|
body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 设置滚动条的样式 */
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
/* 滚动槽 */
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
/* 滚动条滑块 */
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #a3a3a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user