mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
feat: 新增图片和图标
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
<!-- 每一项组件的渲染 -->
|
||||
<div
|
||||
class="item-box"
|
||||
v-for="(item, index) in menuOptions"
|
||||
:key="index"
|
||||
v-for="item in menuOptions"
|
||||
:key="item.title"
|
||||
draggable
|
||||
@dragstart="!item.disabled && dragStartHandle($event, item)"
|
||||
@dragend="!item.disabled && dragendHandle"
|
||||
@@ -55,7 +55,7 @@ import omit from 'lodash/omit'
|
||||
|
||||
const chartEditStore = useChartEditStore()
|
||||
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
menuOptions: {
|
||||
type: Array as PropType<ConfigType[]>,
|
||||
default: () => []
|
||||
@@ -97,7 +97,7 @@ const dblclickHandle = async (item: ConfigType) => {
|
||||
componentInstall(item.conKey, fetchConfigComponent(item))
|
||||
// 创建新图表组件
|
||||
let newComponent: CreateComponentType = await createComponent(item)
|
||||
if (item.virtualComponent) {
|
||||
if (item.redirectComponent) {
|
||||
item.dataset && (newComponent.option.dataset = item.dataset)
|
||||
newComponent.chartConfig.title = item.title
|
||||
}
|
||||
@@ -125,6 +125,10 @@ watch(
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(() => props.menuOptions, (n) => {
|
||||
console.log(n)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -177,7 +181,7 @@ $halfCenterHeight: 50px;
|
||||
overflow: hidden;
|
||||
.list-img {
|
||||
height: 100px;
|
||||
width: 140px;
|
||||
max-width: 140px;
|
||||
border-radius: 6px;
|
||||
@extend .go-transition;
|
||||
}
|
||||
@@ -208,6 +212,9 @@ $halfCenterHeight: 50px;
|
||||
.item-box {
|
||||
width: $halfItemWidth;
|
||||
max-width: $maxItemWidth;
|
||||
.list-img {
|
||||
max-width: 76px;
|
||||
}
|
||||
}
|
||||
.list-center {
|
||||
height: $halfCenterHeight;
|
||||
|
||||
@@ -23,8 +23,11 @@ import { ref, watch, computed, reactive } from 'vue'
|
||||
import { ConfigType } from '@/packages/index.d'
|
||||
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
|
||||
import { loadAsyncComponent } from '@/utils'
|
||||
import { usePackagesStore } from '@/store/modules/packagesStore/packagesStore'
|
||||
import { PackagesCategoryEnum } from '@/packages/index.d'
|
||||
|
||||
const ChartsItemBox = loadAsyncComponent(() => import('../ChartsItemBox/index.vue'))
|
||||
const packagesStore = usePackagesStore()
|
||||
|
||||
const props = defineProps({
|
||||
selectOptions: {
|
||||
@@ -61,7 +64,7 @@ let packages = reactive<{
|
||||
saveSelectOptions: {}
|
||||
})
|
||||
|
||||
const selectValue = ref<string>()
|
||||
const selectValue = ref<string>('all')
|
||||
|
||||
// 设置初始列表
|
||||
const setSelectOptions = (categorys: any) => {
|
||||
@@ -79,7 +82,6 @@ watch(
|
||||
if (!newData) return
|
||||
newData.list.forEach((e: ConfigType) => {
|
||||
const value: ConfigType[] = (packages.categorys as any)[e.category]
|
||||
// @ts-ignore
|
||||
packages.categorys[e.category] = value && value.length ? [...value, e] : [e]
|
||||
packages.categoryNames[e.category] = e.categoryName
|
||||
packages.categorys['all'].push(e)
|
||||
@@ -100,6 +102,16 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => packagesStore.newPhoto,
|
||||
newPhoto => {
|
||||
if (!newPhoto) return
|
||||
const newPhotoCategory = newPhoto.category
|
||||
packages.categorys[newPhotoCategory].splice(1, 0, newPhoto)
|
||||
packages.categorys['all'].splice(1, 0, newPhoto)
|
||||
}
|
||||
)
|
||||
|
||||
// 处理点击事件
|
||||
const clickItemHandle = (key: string) => {
|
||||
packages.selectOptions = packages.categorys[key]
|
||||
|
||||
@@ -71,7 +71,7 @@ import { ref, onUnmounted } from 'vue'
|
||||
import { icon } from '@/plugins'
|
||||
import { createComponent } from '@/packages'
|
||||
import { ConfigType, CreateComponentType } from '@/packages/index.d'
|
||||
import { themeColor, MenuOptionsType } from '../../hooks/useAside.hook'
|
||||
import { themeColor } from '../../hooks/useLayout.hook'
|
||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||
import { ChartModeEnum, ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
|
||||
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
|
||||
@@ -158,7 +158,7 @@ const selectChartHandle = async (item: ConfigType) => {
|
||||
componentInstall(item.conKey, fetchConfigComponent(item))
|
||||
// 创建新图表组件
|
||||
let newComponent: CreateComponentType = await createComponent(item)
|
||||
if (item.virtualComponent) {
|
||||
if (item.redirectComponent) {
|
||||
item.dataset && (newComponent.option.dataset = item.dataset)
|
||||
newComponent.chartConfig.title = item.title
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { shallowReactive, ref } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { icon } from '@/plugins'
|
||||
import { renderLang, renderIcon } from '@/utils'
|
||||
import { themeColor, setItem, getCharts } from './useLayout.hook'
|
||||
import { PackagesCategoryEnum, PackagesCategoryName, PackagesType } from '@/packages/index.d'
|
||||
// 图表
|
||||
import { PackagesCategoryEnum, PackagesCategoryName, ConfigType } from '@/packages/index.d'
|
||||
import { usePackagesStore } from '@/store/modules/packagesStore/packagesStore'
|
||||
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
|
||||
// 图标
|
||||
const { AirPlaneIcon, ImageIcon, BarChartIcon } = icon.ionicons5
|
||||
const { AirPlaneOutlineIcon, ImageIcon, BarChartIcon } = icon.ionicons5
|
||||
const { TableSplitIcon, RoadmapIcon, SpellCheckIcon, GraphicalDataFlowIcon } = icon.carbon
|
||||
|
||||
// 图表
|
||||
@@ -15,12 +14,9 @@ export type MenuOptionsType = {
|
||||
key: string
|
||||
icon: ReturnType<typeof renderIcon>
|
||||
label: ReturnType<typeof renderLang>
|
||||
list: PackagesType
|
||||
list: ConfigType[]
|
||||
}
|
||||
|
||||
const { getPackagesList } = usePackagesStore()
|
||||
const menuOptions: MenuOptionsType[] = []
|
||||
|
||||
const packagesListObj = {
|
||||
[PackagesCategoryEnum.CHARTS]: {
|
||||
icon: renderIcon(RoadmapIcon),
|
||||
@@ -34,53 +30,66 @@ const packagesListObj = {
|
||||
icon: renderIcon(TableSplitIcon),
|
||||
label: PackagesCategoryName.TABLES
|
||||
},
|
||||
[PackagesCategoryEnum.DECORATES]: {
|
||||
icon: renderIcon(GraphicalDataFlowIcon),
|
||||
label: PackagesCategoryName.DECORATES
|
||||
},
|
||||
[PackagesCategoryEnum.PHOTOS]: {
|
||||
icon: renderIcon(ImageIcon),
|
||||
label: PackagesCategoryName.PHOTOS
|
||||
},
|
||||
[PackagesCategoryEnum.ICONS]: {
|
||||
icon: renderIcon(AirPlaneIcon),
|
||||
icon: renderIcon(AirPlaneOutlineIcon),
|
||||
label: PackagesCategoryName.ICONS
|
||||
},
|
||||
[PackagesCategoryEnum.DECORATES]: {
|
||||
icon: renderIcon(GraphicalDataFlowIcon),
|
||||
label: PackagesCategoryName.DECORATES
|
||||
}
|
||||
}
|
||||
|
||||
// 处理列表
|
||||
const handlePackagesList = () => {
|
||||
for (const val in getPackagesList) {
|
||||
menuOptions.push({
|
||||
key: val,
|
||||
// @ts-ignore
|
||||
icon: packagesListObj[val].icon,
|
||||
// @ts-ignore
|
||||
label: packagesListObj[val].label,
|
||||
// @ts-ignore
|
||||
list: getPackagesList[val]
|
||||
})
|
||||
export const useAsideHook = () => {
|
||||
const packagesStore = usePackagesStore()
|
||||
const menuOptions: MenuOptionsType[] = []
|
||||
|
||||
// 处理列表
|
||||
const handlePackagesList = () => {
|
||||
for (const val in packagesStore.getPackagesList) {
|
||||
menuOptions.push({
|
||||
key: val,
|
||||
// @ts-ignore
|
||||
icon: packagesListObj[val].icon,
|
||||
// @ts-ignore
|
||||
label: packagesListObj[val].label,
|
||||
// @ts-ignore
|
||||
list: packagesStore.getPackagesList[val]
|
||||
})
|
||||
}
|
||||
}
|
||||
handlePackagesList()
|
||||
|
||||
// 记录选中值
|
||||
let beforeSelect: string = menuOptions[0]['key']
|
||||
const selectValue = ref<string>(menuOptions[0]['key'])
|
||||
|
||||
// 选中的对象值
|
||||
const selectOptions = ref(menuOptions[0])
|
||||
|
||||
// 点击 item
|
||||
const clickItemHandle = (key: string, item: any) => {
|
||||
selectOptions.value = item
|
||||
// 处理折叠
|
||||
if (beforeSelect === key) {
|
||||
setItem(ChartLayoutStoreEnum.CHARTS, !getCharts.value, false)
|
||||
} else {
|
||||
setItem(ChartLayoutStoreEnum.CHARTS, true, false)
|
||||
}
|
||||
beforeSelect = key
|
||||
}
|
||||
|
||||
return {
|
||||
getCharts,
|
||||
BarChartIcon,
|
||||
themeColor,
|
||||
selectOptions,
|
||||
selectValue,
|
||||
clickItemHandle,
|
||||
menuOptions
|
||||
}
|
||||
}
|
||||
handlePackagesList()
|
||||
|
||||
// 记录选中值
|
||||
let beforeSelect: string = menuOptions[0]['key']
|
||||
const selectValue = ref<string>(menuOptions[0]['key'])
|
||||
|
||||
// 选中的对象值
|
||||
const selectOptions = ref(menuOptions[0])
|
||||
|
||||
// 点击 item
|
||||
const clickItemHandle = (key: string, item: any) => {
|
||||
selectOptions.value = item
|
||||
// 处理折叠
|
||||
if (beforeSelect === key) {
|
||||
setItem(ChartLayoutStoreEnum.CHARTS, !getCharts.value, false)
|
||||
} else {
|
||||
setItem(ChartLayoutStoreEnum.CHARTS, true, false)
|
||||
}
|
||||
beforeSelect = key
|
||||
}
|
||||
|
||||
export { getCharts, BarChartIcon, themeColor, selectOptions, selectValue, clickItemHandle, menuOptions }
|
||||
|
||||
@@ -1,123 +1,105 @@
|
||||
<template>
|
||||
<!-- 左侧所有组件的展示列表 -->
|
||||
<content-box
|
||||
class="go-content-charts"
|
||||
:class="{ scoped: !getCharts }"
|
||||
title="组件"
|
||||
:depth="1"
|
||||
:backIcon="false"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon size="14" :depth="2">
|
||||
<bar-chart-icon></bar-chart-icon>
|
||||
</n-icon>
|
||||
</template>
|
||||
|
||||
<template #top-right>
|
||||
<charts-search v-show="getCharts" :menuOptions="menuOptions"></charts-search>
|
||||
</template>
|
||||
<!-- 图表 -->
|
||||
<aside>
|
||||
<div class="menu-width-box">
|
||||
<n-menu
|
||||
class="menu-width"
|
||||
v-model:value="selectValue"
|
||||
:options="menuOptions"
|
||||
:icon-size="16"
|
||||
:indent="18"
|
||||
@update:value="clickItemHandle"
|
||||
></n-menu>
|
||||
<div class="menu-component-box">
|
||||
<go-skeleton
|
||||
:load="!selectOptions"
|
||||
round
|
||||
text
|
||||
:repeat="2"
|
||||
style="width: 90%"
|
||||
></go-skeleton>
|
||||
<charts-option-content
|
||||
v-if="selectOptions"
|
||||
:selectOptions="selectOptions"
|
||||
:key="selectValue"
|
||||
></charts-option-content>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</content-box>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ContentBox } from '../ContentBox/index'
|
||||
import { ChartsOptionContent } from './components/ChartsOptionContent'
|
||||
import { ChartsSearch } from './components/ChartsSearch'
|
||||
import {
|
||||
getCharts,
|
||||
BarChartIcon,
|
||||
themeColor,
|
||||
selectOptions,
|
||||
selectValue,
|
||||
clickItemHandle,
|
||||
menuOptions,
|
||||
} from './hooks/useAside.hook'
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 整体宽度 */
|
||||
$width: 330px;
|
||||
/* 列表的宽度 */
|
||||
$widthScoped: 65px;
|
||||
/* 此高度与 ContentBox 组件关联 */
|
||||
$topHeight: 40px;
|
||||
|
||||
@include go(content-charts) {
|
||||
width: $width;
|
||||
@extend .go-transition;
|
||||
&.scoped,
|
||||
.menu-width {
|
||||
width: $widthScoped;
|
||||
}
|
||||
.menu-width-box {
|
||||
display: flex;
|
||||
height: calc(100vh - #{$--header-height} - #{$topHeight});
|
||||
.menu-width {
|
||||
flex-shrink: 0;
|
||||
@include fetch-bg-color('background-color2');
|
||||
}
|
||||
.menu-component-box {
|
||||
flex-shrink: 0;
|
||||
width: $width - $widthScoped;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
@include deep() {
|
||||
.menu-width {
|
||||
.n-menu-item {
|
||||
height: auto !important;
|
||||
&.n-menu-item--selected {
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 2px;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
width: 3px;
|
||||
background-color: v-bind('themeColor');
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
}
|
||||
.n-menu-item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 6px 12px !important;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
.n-menu-item-content__icon {
|
||||
font-size: 18px !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<!-- 左侧所有组件的展示列表 -->
|
||||
<content-box class="go-content-charts" :class="{ scoped: !getCharts }" title="组件" :depth="1" :backIcon="false">
|
||||
<template #icon>
|
||||
<n-icon size="14" :depth="2">
|
||||
<bar-chart-icon></bar-chart-icon>
|
||||
</n-icon>
|
||||
</template>
|
||||
|
||||
<template #top-right>
|
||||
<charts-search v-show="getCharts" :menuOptions="menuOptions"></charts-search>
|
||||
</template>
|
||||
<!-- 图表 -->
|
||||
<aside>
|
||||
<div class="menu-width-box">
|
||||
<n-menu
|
||||
class="menu-width"
|
||||
v-model:value="selectValue"
|
||||
:options="menuOptions"
|
||||
:icon-size="16"
|
||||
:indent="18"
|
||||
@update:value="clickItemHandle"
|
||||
></n-menu>
|
||||
<div class="menu-component-box">
|
||||
<go-skeleton :load="!selectOptions" round text :repeat="2" style="width: 90%"></go-skeleton>
|
||||
<charts-option-content
|
||||
v-if="selectOptions"
|
||||
:selectOptions="selectOptions"
|
||||
:key="selectValue"
|
||||
></charts-option-content>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</content-box>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ContentBox } from '../ContentBox/index'
|
||||
import { ChartsOptionContent } from './components/ChartsOptionContent'
|
||||
import { ChartsSearch } from './components/ChartsSearch'
|
||||
import { useAsideHook } from './hooks/useAside.hook'
|
||||
|
||||
const { getCharts, BarChartIcon, themeColor, selectOptions, selectValue, clickItemHandle, menuOptions } = useAsideHook()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 整体宽度 */
|
||||
$width: 330px;
|
||||
/* 列表的宽度 */
|
||||
$widthScoped: 65px;
|
||||
/* 此高度与 ContentBox 组件关联 */
|
||||
$topHeight: 40px;
|
||||
|
||||
@include go(content-charts) {
|
||||
width: $width;
|
||||
@extend .go-transition;
|
||||
&.scoped,
|
||||
.menu-width {
|
||||
width: $widthScoped;
|
||||
}
|
||||
.menu-width-box {
|
||||
display: flex;
|
||||
height: calc(100vh - #{$--header-height} - #{$topHeight});
|
||||
.menu-width {
|
||||
flex-shrink: 0;
|
||||
@include fetch-bg-color('background-color2');
|
||||
}
|
||||
.menu-component-box {
|
||||
flex-shrink: 0;
|
||||
width: $width - $widthScoped;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
@include deep() {
|
||||
.menu-width {
|
||||
.n-menu-item {
|
||||
height: auto !important;
|
||||
&.n-menu-item--selected {
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 2px;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
width: 3px;
|
||||
background-color: v-bind('themeColor');
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
}
|
||||
}
|
||||
.n-menu-item-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 6px 12px !important;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
.n-menu-item-content__icon {
|
||||
font-size: 18px !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user