Skip to content

Commit

Permalink
fix: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
hexqi committed Aug 28, 2024
1 parent 35069dd commit a5602a8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/plugins/materials/src/meta/component/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
<tiny-collapse-item
v-for="(item, index) in state.components"
:key="item.group"
:title="item.label?.zh_CN || item.group"
:title="item.label?.[locale] || item.group"
:name="index"
>
<ul class="component-group" :style="{ gridTemplateColumns }">
<template v-for="child in item.children" :key="child.component">
<canvas-drag-item
v-if="!child.hidden && (child.name?.zh_CN || child.name)"
v-if="!child.hidden && (child.name?.[locale] || child.name)"
:data="generateNode({ component: child.snippetName || child.component })"
@click="componentClick"
>
<li class="component-item">
<div class="component-item-component">
<svg-icon :name="child?.icon?.toLowerCase() || 'row'"></svg-icon>
</div>
<span class="component-item-name" :title="child.name?.zh_CN || child.name">{{
child.name?.zh_CN || child.name
<span class="component-item-name" :title="child.name?.[locale] || child.name">{{
child.name?.[locale] || child.name
}}</span>
</li>
</canvas-drag-item>
Expand All @@ -38,6 +38,7 @@
import { inject, onMounted, reactive, ref } from 'vue'
import { Collapse, CollapseItem, Search } from '@opentiny/vue'
import { SearchEmpty, CanvasDragItem } from '@opentiny/tiny-engine-common'
import i18n from '@opentiny/tiny-engine-common/js/i18n'
import { iconSearch } from '@opentiny/vue-icon'
import { useMaterial, useCanvas } from '@opentiny/tiny-engine-meta-register'
Expand All @@ -57,6 +58,7 @@ export default {
const gridTemplateColumns = ref(COMPONENT_PANEL_COLUMNS)
const panelState = inject('panelState', {})
const { components } = materialState
const { locale } = i18n.global
const fetchComponents = (components, name) => {
if (!name) {
Expand All @@ -68,7 +70,7 @@ export default {
const children = []
component.children.forEach((child) => {
if (child.name?.zh_CN?.toLowerCase().indexOf(name.toLowerCase()) > -1) {
if (child.name?.[locale.value]?.toLowerCase().indexOf(name.toLowerCase()) > -1) {
children.push(child)
}
})
Expand Down Expand Up @@ -113,6 +115,7 @@ export default {
})
return {
locale,
gridTemplateColumns,
state,
change,
Expand Down

0 comments on commit a5602a8

Please sign in to comment.