diff --git a/src/api/path/system.api.ts b/src/api/path/system.api.ts index 499194c7..1839b109 100644 --- a/src/api/path/system.api.ts +++ b/src/api/path/system.api.ts @@ -12,6 +12,15 @@ export const loginApi = async (data: object) => { } } +// * 新接口 +export const newApi = async (data: object) => { + try { + const resonse = await http(RequestHttpEnum.POST)(`新接口的路劲/xxx/xxx`, data) + } catch (error) { + httpErrorHandle(); + } +} + // * 登出 export const logoutApi = async () => { try { diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 614bfbba..528e60ff 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -129,12 +129,8 @@ export const useSync = () => { // 获取缩略图片 const range = document.querySelector('.go-edit-range') as HTMLElement const ruler = document.getElementById('mb-ruler') - // 去除标尺Dom - if (ruler) ruler.style.display = 'none' // 生成图片 const canvasImage: HTMLCanvasElement = await html2canvas(range) - // 还原标尺 - if (ruler) ruler.style.display = 'block' // 上传预览图 let uploadParams = new FormData() diff --git a/src/views/preview/hooks/useScale.hook.ts b/src/views/preview/hooks/useScale.hook.ts index 0db5e48b..202aaf05 100644 --- a/src/views/preview/hooks/useScale.hook.ts +++ b/src/views/preview/hooks/useScale.hook.ts @@ -4,6 +4,7 @@ import type { ChartEditStorageType } from '../index.d' import { PreviewScaleEnum } from '@/enums/styleEnum' export const useScale = (localStorageInfo: ChartEditStorageType) => { + const entityRef = ref() const previewRef = ref() const width = ref(localStorageInfo.editCanvasConfig.width) diff --git a/src/views/preview/index.d.ts b/src/views/preview/index.d.ts index 612f037f..0dfbe7ca 100644 --- a/src/views/preview/index.d.ts +++ b/src/views/preview/index.d.ts @@ -1,5 +1,6 @@ import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' export interface ChartEditStorageType extends ChartEditStorage { - id: string + id: string, + isRelease?: boolean } \ No newline at end of file diff --git a/src/views/preview/index.vue b/src/views/preview/index.vue index ea057f64..4e6bc664 100644 --- a/src/views/preview/index.vue +++ b/src/views/preview/index.vue @@ -1,100 +1,9 @@ - - diff --git a/src/views/preview/suspenseIndex.vue b/src/views/preview/suspenseIndex.vue new file mode 100644 index 00000000..7036df6e --- /dev/null +++ b/src/views/preview/suspenseIndex.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index 1a97af29..798ed751 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -1,26 +1,40 @@ -import { getSessionStorage } from '@/utils' +import { getSessionStorage, fetchRouteParamsLocation, httpErrorHandle } from '@/utils' +import { ResultEnum } from '@/enums/httpEnum' import { StorageEnum } from '@/enums/storageEnum' import { ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' +import { fetchProjectApi } from '@/api/path' export interface ChartEditStorageType extends ChartEditStorage { id: string } // 根据路由 id 获取存储数据的信息 -export const getSessionStorageInfo = () => { - const urlHash = document.location.hash - const toPathArray = urlHash.split('/') - const id = toPathArray && toPathArray[toPathArray.length - 1] - +export const getSessionStorageInfo = async () => { + const id = fetchRouteParamsLocation() const storageList: ChartEditStorageType[] = getSessionStorage( StorageEnum.GO_CHART_STORAGE_LIST ) - - if(!storageList) return - - for (let i = 0; i < storageList.length; i++) { - if (id.toString() === storageList[i]['id']) { - return storageList[i] + + // 是否本地预览 + if (!storageList) { + // 接口调用 + const res: any = await fetchProjectApi({ projectId: id }) + if (res.code === ResultEnum.SUCCESS) { + const { content, state } = res.data + if (state === -1) { + // 跳转未发布页 + return { isRelease: false } + } + return { ...JSON.parse(content), id } + } else { + httpErrorHandle() + } + } else { + // 本地读取 + for (let i = 0; i < storageList.length; i++) { + if (id.toString() === storageList[i]['id']) { + return storageList[i] + } } } } \ No newline at end of file