fix: 表格自定义缓存修改(1. 初始化读取缓存时,判断缓存里的version和当前version是否一致,不一致则清掉缓存,改用代码里的tableTitle;2. 在保存时,version字段直接用当前version,不用加小版本)

This commit is contained in:
hanyuxia
2024-04-29 17:26:49 +08:00
parent 3f7229098b
commit 859a0ee2cf
4 changed files with 51 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
const BASE_CONFIG = {
baseUrl: 'http://192.168.44.54:8090/',
version: '24.03',
version: '24.04',
apiVersion: 'v1'
}
// 默认时间过滤条件,单位分钟. 0表示请求接口时不传时间参数

View File

@@ -59,7 +59,7 @@
<script>
import indexedDBUtils from '@/indexedDB'
import { storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
import { storageKey, dbTableColumnCustomizeConfigPre,dbTableColumnCustomizeConfig } from '@/utils/constants'
export default {
props: {
customTableTitle: Array, // 自定义的title
@@ -153,7 +153,7 @@ export default {
this.$emit('update', this.custom)
const userId = localStorage.getItem(storageKey.userId)
const tableName = dbTableColumnCustomizeConfigPre + '-' + this.tableId
/*
const defaultConfigInDb = await indexedDBUtils.selectTable(tableName).get({ id: userId })
let fullVersion = ''
if (defaultConfigInDb && defaultConfigInDb.version) {
@@ -167,13 +167,16 @@ export default {
} else {
fullVersion = BASE_CONFIG.version + '.1'
}
*/
let curTableConfig = dbTableColumnCustomizeConfig.find(item => item.tableName === tableName)
if(curTableConfig) {
await indexedDBUtils.selectTable(tableName).put({
id: userId,
version: fullVersion,
version: curTableConfig.version,
config: _.cloneDeep(this.custom)
})
}
}
},
computed: {
// 点击all是否是全部取消选中true为是

View File

@@ -1,5 +1,5 @@
import { tableSort } from '@/utils/tools'
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre,dbTableColumnCustomizeConfig } from '@/utils/constants'
import _ from 'lodash'
import { ref } from 'vue'
import pagination from '@/components/common/Pagination'
@@ -428,9 +428,19 @@ export default {
localStorageTableTitle = await indexedDBUtils.selectTable(tableName).get({ id: userId })
}
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config
? localStorageTableTitle.config
: (this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : [])
let curTableTitles = this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : []
let curTableConfig = dbTableColumnCustomizeConfig.find(item => item.tableName === tableName)
if(localStorageTableTitle && curTableConfig &&
localStorageTableTitle.version !== curTableConfig.version && curTableTitles) {
this.$emit('update', curTableTitles)
await indexedDBUtils.selectTable(tableName).put({
id: userId,
version: curTableConfig.version,
config: _.cloneDeep(curTableTitles)
})
}
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config ? localStorageTableTitle.config : curTableTitles
// this.tools.customTableTitle = this.$refs.dataTable.tableTitle.map((item, index) => { // 修复切换中英文的问题
// if (localStorageTableTitle[index]) {
// item.show = localStorageTableTitle[index].show

View File

@@ -52,6 +52,31 @@ export const storageKey = {
}
export const largeCountryList = ['CN', 'US', 'RU', 'AU', 'CA', 'KZ', 'IN', 'BR']
export const dbTableColumnCustomizeConfig = [
{
version: '24.04.01',
tableName: dbUserTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbRoleTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbOperationLogTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbChartTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbI18nTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbReportTableColumnCustomizeConfig
},{
version: '24.04.01',
tableName: dbGalaxySettingTableColumnCustomizeConfig
}
]
// 统一定义跳转来源
export const fromRoute = {
trafficSummary: 'trafficSummary',