Commit af1c801c905e9f57ec38656fe61bb110725fc726

Authored by fengtao
1 parent 15ec8d5e

perf(src/packages/components): 优化多实时属性修改一下显示顺序,现在是从右往左,改为从左往右,更符合大众

@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <!-- <n-input type="textarea" @input="handleTestInput($event, option)" size="small" placeholder="请输入"></n-input> 11 <!-- <n-input type="textarea" @input="handleTestInput($event, option)" size="small" placeholder="请输入"></n-input>
12 <n-code word-wrap :code="toString(testInputValue)" language="json"></n-code> --> 12 <n-code word-wrap :code="toString(testInputValue)" language="json"></n-code> -->
13 <n-divider /> 13 <n-divider />
14 - <div v-for="(item, index) in groupList" :key="item.key + index"> 14 + <div v-for="(item, index) in cacheGroupList" :key="item.key + index">
15 <n-space justify="space-between"> 15 <n-space justify="space-between">
16 <n-ellipsis> 组件id </n-ellipsis> 16 <n-ellipsis> 组件id </n-ellipsis>
17 <n-input size="small" v-model:value="item.id" :disabled="true"></n-input> 17 <n-input size="small" v-model:value="item.id" :disabled="true"></n-input>
@@ -52,12 +52,16 @@ import { SelectOption } from 'naive-ui' @@ -52,12 +52,16 @@ import { SelectOption } from 'naive-ui'
52 52
53 const { targetData } = useTargetData() 53 const { targetData } = useTargetData()
54 54
55 -const { groupList, option } = toRefs(targetData.value) 55 +const { groupList, option } = toRefs(targetData.value as unknown as Recordable)
  56 +
  57 +const cacheGroupList = computed(()=>{
  58 + return (groupList.value as unknown as CreateComponentType[]).reverse()
  59 +})
56 60
57 const saveHistoryInputValueList = ref<saveHistoryInputValueListType>([]) 61 const saveHistoryInputValueList = ref<saveHistoryInputValueListType>([])
58 62
59 const handleSelectDataKey = (key:string, options:SelectOption[], currentComponentId:string, groupList:CreateComponentType[]) => { 63 const handleSelectDataKey = (key:string, options:SelectOption[], currentComponentId:string, groupList:CreateComponentType[]) => {
60 - saveHistoryInputValueList.value.unshift({ 64 + saveHistoryInputValueList.value.push({
61 id:currentComponentId, 65 id:currentComponentId,
62 inputValue:key 66 inputValue:key
63 }) 67 })
@@ -115,6 +119,10 @@ const dataCacheKeys = computed(()=>{ @@ -115,6 +119,10 @@ const dataCacheKeys = computed(()=>{
115 return [] 119 return []
116 }) 120 })
117 121
  122 +const cacheTargetDataGroupList = computed(()=>{
  123 + return (targetData.value?.groupList as unknown as CreateComponentType[]).reverse()
  124 +})
  125 +
118 watch( 126 watch(
119 () => targetData.value, 127 () => targetData.value,
120 (newValue: CreateComponentType | CreateComponentGroupType) => { 128 (newValue: CreateComponentType | CreateComponentGroupType) => {
@@ -124,7 +132,7 @@ watch( @@ -124,7 +132,7 @@ watch(
124 newValue.saveHistoryInput = JSON.stringify(uniqHistoryInputValueList) 132 newValue.saveHistoryInput = JSON.stringify(uniqHistoryInputValueList)
125 window.localStorage.setItem('CACHE_HISTORY_INPUT_VALUE', JSON.stringify(uniqHistoryInputValueList)) 133 window.localStorage.setItem('CACHE_HISTORY_INPUT_VALUE', JSON.stringify(uniqHistoryInputValueList))
126 } 134 }
127 - newValue?.groupList?.forEach((item: CreateComponentType) => { 135 + cacheTargetDataGroupList.value?.forEach((item: CreateComponentType) => {
128 uniqHistoryInputValueList.forEach((uniqueItem: historyInputValue) => { 136 uniqHistoryInputValueList.forEach((uniqueItem: historyInputValue) => {
129 if (uniqueItem.id === item.id) { 137 if (uniqueItem.id === item.id) {
130 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 138 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion