code refactor

This commit is contained in:
MaysWind
2023-08-13 15:03:31 +08:00
parent f6a2246aab
commit 66f0b38008
6 changed files with 50 additions and 76 deletions
+2 -24
View File
@@ -38,6 +38,7 @@
<script>
import { arrayContainsFieldvalue } from '@/lib/common.js';
import { getIconsInRows } from '@/lib/icon.js';
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
import {
@@ -69,30 +70,7 @@ export default {
},
computed: {
allIconRows() {
const ret = [];
let rowCount = 0;
for (let iconInfoId in this.allIconInfos) {
if (!Object.prototype.hasOwnProperty.call(this.allIconInfos, iconInfoId)) {
continue;
}
const iconInfo = this.allIconInfos[iconInfoId];
if (!ret[rowCount]) {
ret[rowCount] = [];
} else if (ret[rowCount] && ret[rowCount].length >= this.itemPerRow) {
rowCount++;
ret[rowCount] = [];
}
ret[rowCount].push({
id: iconInfoId,
icon: iconInfo.icon
});
}
return ret;
return getIconsInRows(this.allIconInfos, this.itemPerRow);
},
icon: {
get: function () {