mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
fix: 优化颜色列表卡顿问题
This commit is contained in:
parent
987f4f73a2
commit
67dc58e08e
@ -1,101 +1,113 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div class="content-left">
|
||||||
class="content-left-item go-transition-quick go-mb-0"
|
<div
|
||||||
span="12 1000:6 1400:4 1800:4 2200:2"
|
class="content-left-item go-transition-quick go-mb-0"
|
||||||
v-for="(item, index) in designColorRecommend"
|
span="12 1000:6 1400:4 1800:4 2200:2"
|
||||||
:key="index"
|
v-for="(item, index) in designColorRecommend"
|
||||||
@click="colorSelectHandle(item)"
|
:key="index"
|
||||||
>
|
@click="colorSelectHandle(item)"
|
||||||
<n-space>
|
>
|
||||||
<div class="content-left-item-color" :style="{ backgroundColor: item.hex }" />
|
<n-space>
|
||||||
<n-space vertical>
|
<div class="content-left-item-color" :style="{ backgroundColor: item.hex }" />
|
||||||
<n-space>
|
<n-space vertical>
|
||||||
<span :style="{ color: item.hex }">{{ item.name }}</span>
|
<n-space>
|
||||||
<span class="Pinyin-upper">{{ item.pinyin.toUpperCase() }}</span>
|
<span :style="{ color: item.hex }">{{ item.name }}</span>
|
||||||
|
<span class="Pinyin-upper">{{ item.pinyin.toUpperCase() }}</span>
|
||||||
|
</n-space>
|
||||||
|
<n-text>
|
||||||
|
{{ item.hex }}
|
||||||
|
<n-divider vertical />
|
||||||
|
{{
|
||||||
|
`rgb(${item.RGB[0]}, ${item.RGB[1]}, ${item.RGB[2]})`
|
||||||
|
}}
|
||||||
|
</n-text>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-text>
|
|
||||||
{{ item.hex }}
|
|
||||||
<n-divider vertical />
|
|
||||||
{{
|
|
||||||
`rgb(${item.RGB[0]}, ${item.RGB[1]}, ${item.RGB[2]})`
|
|
||||||
}}
|
|
||||||
</n-text>
|
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-space>
|
</div>
|
||||||
</div>
|
<n-divider />
|
||||||
<n-divider/>
|
<div
|
||||||
<div
|
class="content-left-item go-transition-quick"
|
||||||
class="content-left-item go-transition-quick"
|
span="12 1000:6 1400:4 1800:4 2200:2"
|
||||||
span="12 1000:6 1400:4 1800:4 2200:2"
|
v-for="(item, index) in designColor"
|
||||||
v-for="(item, index) in designColor"
|
:key="index"
|
||||||
:key="index"
|
@click="colorSelectHandle(item)"
|
||||||
@click="colorSelectHandle(item)"
|
>
|
||||||
>
|
<n-space>
|
||||||
<n-space>
|
<div class="content-left-item-color" :style="{ backgroundColor: item.hex }" />
|
||||||
<div class="content-left-item-color" :style="{ backgroundColor: item.hex }" />
|
<n-space vertical>
|
||||||
<n-space vertical>
|
<n-space>
|
||||||
<n-space>
|
<span :style="{ color: item.hex }">{{ item.name }}</span>
|
||||||
<span :style="{ color: item.hex }">{{ item.name }}</span>
|
<span class="Pinyin-upper">{{ item.pinyin.toUpperCase() }}</span>
|
||||||
<span class="Pinyin-upper">{{ item.pinyin.toUpperCase() }}</span>
|
</n-space>
|
||||||
|
<n-text>
|
||||||
|
{{ item.hex }}
|
||||||
|
<n-divider vertical />
|
||||||
|
{{
|
||||||
|
`rgb(${item.RGB[0]}, ${item.RGB[1]}, ${item.RGB[2]})`
|
||||||
|
}}
|
||||||
|
</n-text>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-text>
|
|
||||||
{{ item.hex }}
|
|
||||||
<n-divider vertical />
|
|
||||||
{{
|
|
||||||
`rgb(${item.RGB[0]}, ${item.RGB[1]}, ${item.RGB[2]})`
|
|
||||||
}}
|
|
||||||
</n-text>
|
|
||||||
</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-item {
|
.content-left {
|
||||||
position: relative;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 10px;
|
flex-wrap: wrap;
|
||||||
margin-right: 10px;
|
margin-right: 200px;
|
||||||
padding: 10px 20px;
|
.content-left-item {
|
||||||
min-width: 300px;
|
position: relative;
|
||||||
border-radius: 5px;
|
display: flex;
|
||||||
cursor: pointer;
|
margin-bottom: 10px;
|
||||||
border: 1px solid rgba(0, 0, 0, 0);
|
margin-right: 10px;
|
||||||
&:hover {
|
padding: 10px 20px;
|
||||||
@include hover-border-color("background-color5");
|
min-width: 300px;
|
||||||
}
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
z-index: -1;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
opacity: 0.7;
|
|
||||||
overflow: hidden;
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@extend .go-background-filter-shallow;
|
cursor: pointer;
|
||||||
}
|
border: 1px solid rgba(0, 0, 0, 0);
|
||||||
&-color {
|
&:hover {
|
||||||
width: 8px;
|
@include hover-border-color("background-color5");
|
||||||
height: 40px;
|
}
|
||||||
border-radius: 2px;
|
&::after {
|
||||||
}
|
content: "";
|
||||||
.Pinyin-upper {
|
z-index: -1;
|
||||||
font-size: 8px;
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
opacity: 0.7;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 5px;
|
||||||
|
@extend .go-background-filter-shallow;
|
||||||
|
}
|
||||||
|
&-color {
|
||||||
|
width: 8px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
.Pinyin-upper {
|
||||||
|
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