feat: 登录时将下钻table配置改为在indexedDB中缓存
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { dbName, dbGeoDataTableName } from '@/utils/constants'
|
||||
import { dbName, dbGeoDataTableName, dbDrilldownTableConfig } from '@/utils/constants'
|
||||
import Dexie from 'dexie'
|
||||
|
||||
export const db = new Dexie(dbName)
|
||||
db.version(1).stores({
|
||||
[dbGeoDataTableName]: '++name, geo'
|
||||
db.version(2).stores({
|
||||
[dbGeoDataTableName]: '++name, geo',
|
||||
[dbDrilldownTableConfig]: '++id, config'
|
||||
})
|
||||
|
||||
@@ -2,8 +2,9 @@ import { get, post } from '@/utils/http'
|
||||
import router from '@/router'
|
||||
import { sortByOrderNum, getWelcomeMenu } from '@/permission'
|
||||
import { ElMessage } from 'element-plus' // dependent on utc plugin
|
||||
import { storageKey } from '@/utils/constants'
|
||||
import { storageKey, dbDrilldownTableConfig } from '@/utils/constants'
|
||||
import { api } from '@/utils/api'
|
||||
import { db } from '@/indexedDB'
|
||||
|
||||
const user = {
|
||||
state () {
|
||||
@@ -77,9 +78,15 @@ const user = {
|
||||
}
|
||||
}
|
||||
})
|
||||
get(api.config, { ckey: 'drill_down_table_config' }).then(res => {
|
||||
get(api.config, { ckey: 'drill_down_table_config' }).then(async res => {
|
||||
if (res.code === 200 && res.page.list && res.page.list.length > 0) {
|
||||
localStorage.setItem(storageKey.drillDownTableConfig, res.page.list[0].cvalue)
|
||||
await db[dbDrilldownTableConfig].put({
|
||||
id: 'default',
|
||||
config: res.page.list[0].cvalue
|
||||
})
|
||||
// const a = await db[dbDrilldownTableConfig].get({ id: 'default' })
|
||||
// console.info(a)
|
||||
// localStorage.setItem(storageKey.drillDownTableConfig, res.page.list[0].cvalue)
|
||||
}
|
||||
})
|
||||
get(api.config, { ckey: 'link_info' }).then(res => {
|
||||
|
||||
@@ -2,6 +2,7 @@ export const defaultPageSize = 20
|
||||
|
||||
export const dbName = 'cn-db'
|
||||
export const dbGeoDataTableName = 'geodata'
|
||||
export const dbDrilldownTableConfig = 'cn-drilldown-table-config'
|
||||
export const storageKey = {
|
||||
iso36112Capital: 'cn-iso3611-2-capital',
|
||||
iso36112WorldLow: 'cn-iso3611-2-world-low',
|
||||
|
||||
Reference in New Issue
Block a user