storage.ts
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { getSessionStorage, fetchRouteParamsLocation, JSONParse } from '@/utils'
import { StorageEnum } from '@/enums/storageEnum'
import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d'
import { getDataView } from '@/api/external/contentSave/content'
export interface ChartEditStorageType extends ChartEditStorage {
id: string
}
// THINGS_KIT
// 根据路由 id 获取存储数据的信息
export const getSessionStorageInfo = async () => {
const id = fetchRouteParamsLocation()
const storageList: ChartEditStorageType[] = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST)
console.log(id)
console.log(storageList)
// 是否本地预览
// if (!storageList || storageList.findIndex(e => e.id === id.toString()) === -1) {
// 接口调用
const res = await getDataView(id)
if (res) {
const { dataViewContent, state, dataViewName, dataViewId } = res
// if (state === 1) {
// // 跳转未发布页
// return { isRelease: false }
// }
return { ...JSONParse(dataViewContent?.content), id: dataViewId, projectName: dataViewName }
// } else {
// console.log('本地读取')
// // 本地读取
// for (let i = 0; i < storageList.length; i++) {
// if (id.toString() === storageList[i]['id']) {
// return storageList[i]
// }
// }
// }
}
}