feat: id改identity
This commit is contained in:
@@ -18,9 +18,9 @@ export const createProjectApi = async (data: object) => {
|
|||||||
try {
|
try {
|
||||||
const res = await http(RequestHttpEnum.POST)<{
|
const res = await http(RequestHttpEnum.POST)<{
|
||||||
/**
|
/**
|
||||||
* 项目id
|
* 项目identity
|
||||||
*/
|
*/
|
||||||
id: number
|
identity: number
|
||||||
}>(`${ModuleTypeEnum.PROJECT}/create`, data)
|
}>(`${ModuleTypeEnum.PROJECT}/create`, data)
|
||||||
return res
|
return res
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
6
src/api/path/project.d.ts
vendored
6
src/api/path/project.d.ts
vendored
@@ -1,8 +1,8 @@
|
|||||||
export type ProjectItem = {
|
export type ProjectItem = {
|
||||||
/**
|
/**
|
||||||
* 项目 id
|
* 项目 identity
|
||||||
*/
|
*/
|
||||||
id: string
|
identity: string
|
||||||
/**
|
/**
|
||||||
* 项目名称
|
* 项目名称
|
||||||
*/
|
*/
|
||||||
@@ -22,7 +22,7 @@ export type ProjectItem = {
|
|||||||
*/
|
*/
|
||||||
indexImage: string
|
indexImage: string
|
||||||
/**
|
/**
|
||||||
* 创建者 id
|
* 创建者 identity
|
||||||
*/
|
*/
|
||||||
createUserId: string
|
createUserId: string
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,19 +2,19 @@ import { ResultEnum } from '@/enums/httpEnum'
|
|||||||
|
|
||||||
export enum ChartEnum {
|
export enum ChartEnum {
|
||||||
// 图表创建
|
// 图表创建
|
||||||
CHART_HOME = '/chart/home/:id(.*)*',
|
CHART_HOME = '/chart/home/:identity(.*)*',
|
||||||
CHART_HOME_NAME = 'ChartHome',
|
CHART_HOME_NAME = 'ChartHome',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum PreviewEnum {
|
export enum PreviewEnum {
|
||||||
// 图表预览
|
// 图表预览
|
||||||
CHART_PREVIEW = '/chart/preview/:id(.*)*',
|
CHART_PREVIEW = '/chart/preview/:identity(.*)*',
|
||||||
CHART_PREVIEW_NAME = 'ChartPreview',
|
CHART_PREVIEW_NAME = 'ChartPreview',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum EditEnum {
|
export enum EditEnum {
|
||||||
// 图表JSON编辑
|
// 图表JSON编辑
|
||||||
CHART_EDIT = '/chart/edit/:id(.*)*',
|
CHART_EDIT = '/chart/edit/:identity(.*)*',
|
||||||
CHART_EDIT_NAME = 'ChartEdit',
|
CHART_EDIT_NAME = 'ChartEdit',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,30 +91,30 @@ const closeHandle = () => {
|
|||||||
const previewHandle = () => {
|
const previewHandle = () => {
|
||||||
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
|
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
|
||||||
if (!path) return
|
if (!path) return
|
||||||
const { id } = routerParamsInfo.params
|
const { identity } = routerParamsInfo.params
|
||||||
// id 标识
|
// identity 标识
|
||||||
const previewId = typeof id === 'string' ? id : id[0]
|
const previewId = typeof identity === 'string' ? identity : identity[0]
|
||||||
const storageInfo = chartEditStore.getStorageInfo()
|
const storageInfo = chartEditStore.getStorageInfo()
|
||||||
const sessionStorageInfo = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
const sessionStorageInfo = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
|
||||||
|
|
||||||
if (sessionStorageInfo?.length) {
|
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) {
|
if (repeateIndex !== -1) {
|
||||||
sessionStorageInfo.splice(repeateIndex, 1, {
|
sessionStorageInfo.splice(repeateIndex, 1, {
|
||||||
id: previewId,
|
identity: previewId,
|
||||||
...storageInfo
|
...storageInfo
|
||||||
})
|
})
|
||||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
||||||
} else {
|
} else {
|
||||||
sessionStorageInfo.push({
|
sessionStorageInfo.push({
|
||||||
id: previewId,
|
identity: previewId,
|
||||||
...storageInfo
|
...storageInfo
|
||||||
})
|
})
|
||||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }])
|
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ identity: previewId, ...storageInfo }])
|
||||||
}
|
}
|
||||||
// 跳转
|
// 跳转
|
||||||
routerTurnByPath(path, [previewId], undefined, true)
|
routerTurnByPath(path, [previewId], undefined, true)
|
||||||
@@ -138,7 +138,7 @@ const copyPreviewPath = (successText?: string, failureText?: string) => {
|
|||||||
// 发布
|
// 发布
|
||||||
const sendHandle = async () => {
|
const sendHandle = async () => {
|
||||||
const res = await changeProjectReleaseApi({
|
const res = await changeProjectReleaseApi({
|
||||||
id: fetchRouteParamsLocation(),
|
identity: fetchRouteParamsLocation(),
|
||||||
// 反过来
|
// 反过来
|
||||||
state: release.value ? -1 : 1
|
state: release.value ? -1 : 1
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const handleBlur = async () => {
|
|||||||
}
|
}
|
||||||
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '')
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '')
|
||||||
const res = (await updateProjectApi({
|
const res = (await updateProjectApi({
|
||||||
id: fetchRouteParamsLocation(),
|
identity: fetchRouteParamsLocation(),
|
||||||
projectName: title.value
|
projectName: title.value
|
||||||
}))
|
}))
|
||||||
if (res && res.code === ResultEnum.SUCCESS) {
|
if (res && res.code === ResultEnum.SUCCESS) {
|
||||||
|
|||||||
@@ -225,15 +225,15 @@ export const useSync = () => {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const updateStoreInfo = (projectData: {
|
const updateStoreInfo = (projectData: {
|
||||||
id: string,
|
identity: string,
|
||||||
projectName: string,
|
projectName: string,
|
||||||
indexImage: string,
|
indexImage: string,
|
||||||
remarks: string,
|
remarks: string,
|
||||||
state: number
|
state: number
|
||||||
}) => {
|
}) => {
|
||||||
const { id, projectName, remarks, indexImage, state } = projectData
|
const { identity, projectName, remarks, indexImage, state } = projectData
|
||||||
// ID
|
// ID
|
||||||
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, id)
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, identity)
|
||||||
// 名称
|
// 名称
|
||||||
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, projectName)
|
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, projectName)
|
||||||
// 描述
|
// 描述
|
||||||
@@ -292,7 +292,7 @@ export const useSync = () => {
|
|||||||
const range = document.querySelector('.go-edit-range') as HTMLElement
|
const range = document.querySelector('.go-edit-range') as HTMLElement
|
||||||
// 生成图片(透明底)
|
// 生成图片(透明底)
|
||||||
const canvasImage: HTMLCanvasElement = await html2canvas(range, {
|
const canvasImage: HTMLCanvasElement = await html2canvas(range, {
|
||||||
backgroundColor: null,
|
backgroundColor: 'transparent',
|
||||||
allowTaint: true,
|
allowTaint: true,
|
||||||
useCORS: true,
|
useCORS: true,
|
||||||
scale: 2,
|
scale: 2,
|
||||||
@@ -311,7 +311,7 @@ export const useSync = () => {
|
|||||||
if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) {
|
if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) {
|
||||||
if (uploadRes.data.result_url) {
|
if (uploadRes.data.result_url) {
|
||||||
await updateProjectApi({
|
await updateProjectApi({
|
||||||
id: fetchRouteParamsLocation(),
|
identity: fetchRouteParamsLocation(),
|
||||||
indexImage: uploadRes.data.result_url,
|
indexImage: uploadRes.data.result_url,
|
||||||
backgroundImage: chartEditStore.getEditCanvasConfig.backgroundImage
|
backgroundImage: chartEditStore.getEditCanvasConfig.backgroundImage
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,25 +8,25 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
|||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
export interface ChartEditStorageType extends ChartEditStorage {
|
export interface ChartEditStorageType extends ChartEditStorage {
|
||||||
id: string
|
identity: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据路由 id 获取存储数据的信息
|
// 根据路由 identity 获取存储数据的信息
|
||||||
export const getSessionStorageInfo = async () => {
|
export const getSessionStorageInfo = async () => {
|
||||||
const id = fetchRouteParamsLocation()
|
const identity = fetchRouteParamsLocation()
|
||||||
const storageList: ChartEditStorageType[] = getSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST)
|
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) {
|
if (res && res.code === ResultEnum.SUCCESS) {
|
||||||
const { content, state } = res.data
|
const { content, state } = res.data
|
||||||
if (state === -1) {
|
if (state === -1) {
|
||||||
// 跳转未发布页
|
// 跳转未发布页
|
||||||
return { isRelease: false }
|
return { isRelease: false }
|
||||||
}
|
}
|
||||||
const parseData = { ...JSONParse(content), id }
|
const parseData = { ...JSONParse(content), identity }
|
||||||
const { editCanvasConfig, requestGlobalConfig, componentList } = parseData
|
const { editCanvasConfig, requestGlobalConfig, componentList } = parseData
|
||||||
chartEditStore.editCanvasConfig = editCanvasConfig
|
chartEditStore.editCanvasConfig = editCanvasConfig
|
||||||
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
||||||
@@ -38,7 +38,7 @@ export const getSessionStorageInfo = async () => {
|
|||||||
} else {
|
} else {
|
||||||
// 本地读取
|
// 本地读取
|
||||||
for (let i = 0; i < storageList.length; i++) {
|
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]
|
const { editCanvasConfig, requestGlobalConfig, componentList } = storageList[i]
|
||||||
chartEditStore.editCanvasConfig = editCanvasConfig
|
chartEditStore.editCanvasConfig = editCanvasConfig
|
||||||
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
chartEditStore.requestGlobalConfig = requestGlobalConfig
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<template #action>
|
<template #action>
|
||||||
<div class="go-flex-items-center list-footer" justify="space-between">
|
<div class="go-flex-items-center list-footer" justify="space-between">
|
||||||
<n-text class="go-ellipsis-1">
|
<n-text class="go-ellipsis-1">
|
||||||
{{ cardData.title || cardData.id || '未命名' }}
|
{{ cardData.title || cardData.identity || '未命名' }}
|
||||||
</n-text>
|
</n-text>
|
||||||
<!-- 工具 -->
|
<!-- 工具 -->
|
||||||
<div class="go-flex-items-center list-footer-ri">
|
<div class="go-flex-items-center list-footer-ri">
|
||||||
|
|||||||
@@ -32,14 +32,14 @@ export const useDataListInit = () => {
|
|||||||
const { count } = res as any // 这里的count与data平级,不在Response结构中
|
const { count } = res as any // 这里的count与data平级,不在Response结构中
|
||||||
paginat.count = count
|
paginat.count = count
|
||||||
list.value = res.data.map(e => {
|
list.value = res.data.map(e => {
|
||||||
const { id, projectName, state, createTime, indexImage, createUserId } = e
|
const { identity, projectName, state, createTime, indexImage, createUserId } = e
|
||||||
return {
|
return {
|
||||||
id: id,
|
identity: identity,
|
||||||
title: projectName,
|
title: projectName,
|
||||||
createId: createUserId,
|
createId: createUserId,
|
||||||
time: createTime,
|
time: createTime,
|
||||||
image: indexImage,
|
image: indexImage,
|
||||||
release: state !== -1
|
release: state === 1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -71,7 +71,7 @@ export const useDataListInit = () => {
|
|||||||
new Promise(res => {
|
new Promise(res => {
|
||||||
res(
|
res(
|
||||||
deleteProjectApi({
|
deleteProjectApi({
|
||||||
ids: cardData.id
|
ids: cardData.identity
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
@@ -88,9 +88,9 @@ export const useDataListInit = () => {
|
|||||||
|
|
||||||
// 发布处理
|
// 发布处理
|
||||||
const releaseHandle = async (cardData: Chartype, index: number) => {
|
const releaseHandle = async (cardData: Chartype, index: number) => {
|
||||||
const { id, release } = cardData
|
const { identity, release } = cardData
|
||||||
const res = await changeProjectReleaseApi({
|
const res = await changeProjectReleaseApi({
|
||||||
id: id,
|
identity: identity,
|
||||||
// [-1未发布, 1发布]
|
// [-1未发布, 1发布]
|
||||||
state: !release ? 1 : -1
|
state: !release ? 1 : -1
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ export const useModalDataInit = () => {
|
|||||||
const editHandle = (cardData: Chartype) => {
|
const editHandle = (cardData: Chartype) => {
|
||||||
if (!cardData) return
|
if (!cardData) return
|
||||||
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||||
routerTurnByPath(path, [cardData.id], undefined, true)
|
routerTurnByPath(path, [cardData.identity], undefined, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 预览处理
|
// 预览处理
|
||||||
const previewHandle = (cardData: Chartype) => {
|
const previewHandle = (cardData: Chartype) => {
|
||||||
openNewWindow(previewPath(cardData.id))
|
openNewWindow(previewPath(cardData.identity))
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
2
src/views/project/items/index.d.ts
vendored
2
src/views/project/items/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
export type Chartype = {
|
export type Chartype = {
|
||||||
id: number | string
|
identity: number | string
|
||||||
title: string // 标题
|
title: string // 标题
|
||||||
label?: string // 标签
|
label?: string // 标签
|
||||||
time: string, // 时间
|
time: string, // 时间
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ const btnHandle = async (key: string) => {
|
|||||||
if(res && res.code === ResultEnum.SUCCESS) {
|
if(res && res.code === ResultEnum.SUCCESS) {
|
||||||
window['$message'].success(window['$t']('project.create_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')
|
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||||
routerTurnByPath(path, [id], undefined, true)
|
routerTurnByPath(path, [identity], undefined, true)
|
||||||
closeHandle()
|
closeHandle()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -55,10 +55,10 @@ const clickHandle = async () => {
|
|||||||
|
|
||||||
if (res && res.code === ResultEnum.SUCCESS) {
|
if (res && res.code === ResultEnum.SUCCESS) {
|
||||||
window['$message'].success(window['$t']('project.create_success'))
|
window['$message'].success(window['$t']('project.create_success'))
|
||||||
const { id } = res.data || {}
|
const { identity } = res.data || {}
|
||||||
console.log('id', id)
|
console.log('identity', identity)
|
||||||
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||||
routerTurnByPath(path, [id], undefined, true)
|
routerTurnByPath(path, [identity], undefined, true)
|
||||||
} else {
|
} else {
|
||||||
window['$message'].error(window['$t']('project.create_failure'))
|
window['$message'].error(window['$t']('project.create_failure'))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user