perf: 优化列表默认显示的字段

This commit is contained in:
“huailei000”
2023-02-20 19:23:04 +08:00
committed by huailei
parent 174e7cb0e3
commit 26508ae87b
2 changed files with 14 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ import {
ObjectRelatedFormatter
} from '@/components/TableFormatters'
import i18n from '@/i18n/i18n'
import { newURL } from '@/utils/common'
import { newURL, replaceAllUUID } from '@/utils/common'
import ColumnSettingPopover from './components/ColumnSettingPopover'
export default {
@@ -323,7 +323,8 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
let tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
tableName = replaceAllUUID(tableName)
const configShowColumnsNames = _.get(_tableConfig[tableName], 'showColumns', null)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) {
@@ -371,7 +372,10 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
let tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
// 替换url中的uuid避免同一个类型接口生成多个keylocalStorage中的数据无法共用
tableName = replaceAllUUID(tableName)
_tableConfig[tableName] = {
'showColumns': columns
}

View File

@@ -168,6 +168,13 @@ export function replaceUUID(s, n) {
return s.replace(uuidPattern, n)
}
export function replaceAllUUID(string, replacement = '*') {
if (hasUUID(string)) {
string = string.replace(/[0-9a-zA-Z\-]{36}/g, replacement)
}
return string
}
export function getDaysAgo(days, now) {
if (!now) {
now = new Date()