mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-29 21:28:52 +00:00
perf: 优化列表默认显示的字段
This commit is contained in:
@@ -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,避免同一个类型接口生成多个key,localStorage中的数据无法共用
|
||||
tableName = replaceAllUUID(tableName)
|
||||
|
||||
_tableConfig[tableName] = {
|
||||
'showColumns': columns
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user