feat: id改identity

This commit is contained in:
ygx
2025-12-27 14:10:16 +08:00
parent 7a5fa1f4ea
commit 53cccfaa59
13 changed files with 44 additions and 44 deletions

View File

@@ -18,9 +18,9 @@ export const createProjectApi = async (data: object) => {
try {
const res = await http(RequestHttpEnum.POST)<{
/**
* 项目id
* 项目identity
*/
id: number
identity: number
}>(`${ModuleTypeEnum.PROJECT}/create`, data)
return res
} catch {

View File

@@ -1,8 +1,8 @@
export type ProjectItem = {
/**
* 项目 id
* 项目 identity
*/
id: string
identity: string
/**
* 项目名称
*/
@@ -22,7 +22,7 @@ export type ProjectItem = {
*/
indexImage: string
/**
* 创建者 id
* 创建者 identity
*/
createUserId: string
/**

View File

@@ -2,19 +2,19 @@ import { ResultEnum } from '@/enums/httpEnum'
export enum ChartEnum {
// 图表创建
CHART_HOME = '/chart/home/:id(.*)*',
CHART_HOME = '/chart/home/:identity(.*)*',
CHART_HOME_NAME = 'ChartHome',
}
export enum PreviewEnum {
// 图表预览
CHART_PREVIEW = '/chart/preview/:id(.*)*',
CHART_PREVIEW = '/chart/preview/:identity(.*)*',
CHART_PREVIEW_NAME = 'ChartPreview',
}
export enum EditEnum {
// 图表JSON编辑
CHART_EDIT = '/chart/edit/:id(.*)*',
CHART_EDIT = '/chart/edit/:identity(.*)*',
CHART_EDIT_NAME = 'ChartEdit',
}

View File

@@ -91,30 +91,30 @@ const closeHandle = () => {
const previewHandle = () => {
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
if (!path) return
const { id } = routerParamsInfo.params
// id 标识
const previewId = typeof id === 'string' ? id : id[0]
const { identity } = routerParamsInfo.params
// identity 标识
const previewId = typeof identity === 'string' ? identity : identity[0]
const storageInfo = chartEditStore.getStorageInfo()
const sessionStorageInfo = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
if (sessionStorageInfo?.length) {
const repeateIndex = sessionStorageInfo.findIndex((e: { id: string }) => e.id === previewId)
const repeateIndex = sessionStorageInfo.findIndex((e: { identity: string }) => e.identity === previewId)
// 重复替换
if (repeateIndex !== -1) {
sessionStorageInfo.splice(repeateIndex, 1, {
id: previewId,
identity: previewId,
...storageInfo
})
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
} else {
sessionStorageInfo.push({
id: previewId,
identity: previewId,
...storageInfo
})
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
}
} else {
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }])
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ identity: previewId, ...storageInfo }])
}
// 跳转
routerTurnByPath(path, [previewId], undefined, true)
@@ -138,7 +138,7 @@ const copyPreviewPath = (successText?: string, failureText?: string) => {
// 发布
const sendHandle = async () => {
const res = await changeProjectReleaseApi({
id: fetchRouteParamsLocation(),
identity: fetchRouteParamsLocation(),
// 反过来
state: release.value ? -1 : 1
})

View File

@@ -75,7 +75,7 @@ const handleBlur = async () => {
}
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '')
const res = (await updateProjectApi({
id: fetchRouteParamsLocation(),
identity: fetchRouteParamsLocation(),
projectName: title.value
}))
if (res && res.code === ResultEnum.SUCCESS) {

View File

@@ -225,15 +225,15 @@ export const useSync = () => {
* @returns
*/
const updateStoreInfo = (projectData: {
id: string,
identity: string,
projectName: string,
indexImage: string,
remarks: string,
state: number
}) => {
const { id, projectName, remarks, indexImage, state } = projectData
const { identity, projectName, remarks, indexImage, state } = projectData
// ID
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, id)
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, identity)
// 名称
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, projectName)
// 描述
@@ -292,7 +292,7 @@ export const useSync = () => {
const range = document.querySelector('.go-edit-range') as HTMLElement
// 生成图片(透明底)
const canvasImage: HTMLCanvasElement = await html2canvas(range, {
backgroundColor: null,
backgroundColor: 'transparent',
allowTaint: true,
useCORS: true,
scale: 2,
@@ -311,7 +311,7 @@ export const useSync = () => {
if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) {
if (uploadRes.data.result_url) {
await updateProjectApi({
id: fetchRouteParamsLocation(),
identity: fetchRouteParamsLocation(),
indexImage: uploadRes.data.result_url,
backgroundImage: chartEditStore.getEditCanvasConfig.backgroundImage
})

View File

@@ -8,25 +8,25 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
const chartEditStore = useChartEditStore()
export interface ChartEditStorageType extends ChartEditStorage {
id: string
identity: string
}
// 根据路由 id 获取存储数据的信息
// 根据路由 identity 获取存储数据的信息
export const getSessionStorageInfo = async () => {
const id = fetchRouteParamsLocation()
const identity = fetchRouteParamsLocation()
const storageList: ChartEditStorageType[] = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST)
// 是否本地预览
if (!storageList || storageList.findIndex(e => e.id === id.toString()) === -1) {
if (!storageList || storageList.findIndex(e => e.identity === identity.toString()) === -1) {
// 接口调用
const res = await fetchProjectApi({ projectId: id })
const res = await fetchProjectApi({ projectId: identity })
if (res && res.code === ResultEnum.SUCCESS) {
const { content, state } = res.data
if (state === -1) {
// 跳转未发布页
return { isRelease: false }
}
const parseData = { ...JSONParse(content), id }
const parseData = { ...JSONParse(content), identity }
const { editCanvasConfig, requestGlobalConfig, componentList } = parseData
chartEditStore.editCanvasConfig = editCanvasConfig
chartEditStore.requestGlobalConfig = requestGlobalConfig
@@ -38,7 +38,7 @@ export const getSessionStorageInfo = async () => {
} else {
// 本地读取
for (let i = 0; i < storageList.length; i++) {
if (id.toString() === storageList[i]['id']) {
if (identity.toString() === storageList[i]['identity']) {
const { editCanvasConfig, requestGlobalConfig, componentList } = storageList[i]
chartEditStore.editCanvasConfig = editCanvasConfig
chartEditStore.requestGlobalConfig = requestGlobalConfig

View File

@@ -32,7 +32,7 @@
<template #action>
<div class="go-flex-items-center list-footer" justify="space-between">
<n-text class="go-ellipsis-1">
{{ cardData.title || cardData.id || '未命名' }}
{{ cardData.title || cardData.identity || '未命名' }}
</n-text>
<!-- 工具 -->
<div class="go-flex-items-center list-footer-ri">

View File

@@ -32,14 +32,14 @@ export const useDataListInit = () => {
const { count } = res as any // 这里的count与data平级不在Response结构中
paginat.count = count
list.value = res.data.map(e => {
const { id, projectName, state, createTime, indexImage, createUserId } = e
const { identity, projectName, state, createTime, indexImage, createUserId } = e
return {
id: id,
identity: identity,
title: projectName,
createId: createUserId,
time: createTime,
image: indexImage,
release: state !== -1
release: state === 1
}
})
setTimeout(() => {
@@ -71,7 +71,7 @@ export const useDataListInit = () => {
new Promise(res => {
res(
deleteProjectApi({
ids: cardData.id
ids: cardData.identity
})
)
}),
@@ -88,9 +88,9 @@ export const useDataListInit = () => {
// 发布处理
const releaseHandle = async (cardData: Chartype, index: number) => {
const { id, release } = cardData
const { identity, release } = cardData
const res = await changeProjectReleaseApi({
id: id,
identity: identity,
// [-1未发布, 1发布]
state: !release ? 1 : -1
})

View File

@@ -23,12 +23,12 @@ export const useModalDataInit = () => {
const editHandle = (cardData: Chartype) => {
if (!cardData) return
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
routerTurnByPath(path, [cardData.id], undefined, true)
routerTurnByPath(path, [cardData.identity], undefined, true)
}
// 预览处理
const previewHandle = (cardData: Chartype) => {
openNewWindow(previewPath(cardData.id))
openNewWindow(previewPath(cardData.identity))
}
return {

View File

@@ -1,5 +1,5 @@
export type Chartype = {
id: number | string
identity: number | string
title: string // 标题
label?: string // 标签
time: string, // 时间

View File

@@ -99,9 +99,9 @@ const btnHandle = async (key: string) => {
if(res && res.code === ResultEnum.SUCCESS) {
window['$message'].success(window['$t']('project.create_success'))
const { id } = res.data
const { identity } = res.data
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
routerTurnByPath(path, [id], undefined, true)
routerTurnByPath(path, [identity], undefined, true)
closeHandle()
}
} catch (error) {

View File

@@ -55,10 +55,10 @@ const clickHandle = async () => {
if (res && res.code === ResultEnum.SUCCESS) {
window['$message'].success(window['$t']('project.create_success'))
const { id } = res.data || {}
console.log('id', id)
const { identity } = res.data || {}
console.log('identity', identity)
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
routerTurnByPath(path, [id], undefined, true)
routerTurnByPath(path, [identity], undefined, true)
} else {
window['$message'].error(window['$t']('project.create_failure'))
}