diff --git a/.env b/.env index f0819725..060d351c 100644 --- a/.env +++ b/.env @@ -3,8 +3,9 @@ VITE_DEV_PORT = '8080' # development path # VITE_DEV_PATH = 'https://demo.mtruning.club' -VITE_DEV_PATH = 'http://192.168.0.120:3001' +VITE_DEV_PATH = 'http://192.168.0.34:8024' +# VITE_DEV_PATH = 'http://192.168.0.120:3001' # production path # VITE_PRO_PATH = 'https://demo.mtruning.club' -VITE_PRO_PATH = 'http://192.168.0.120:3001' +VITE_PRO_PATH = 'http://192.168.0.34:8024' diff --git a/index.html b/index.html index 49904d92..234c9351 100644 --- a/index.html +++ b/index.html @@ -4,15 +4,10 @@ - - - - - GoView diff --git a/src/App.vue b/src/App.vue index 7f6fedb9..f0a3bbca 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,6 +18,9 @@ import { NConfigProvider } from 'naive-ui' import { GoAppProvider } from '@/components/GoAppProvider' import { I18n } from '@/components/I18n' import { useSystemInit, useDarkThemeHook, useThemeOverridesHook, useCode, useLang } from '@/hooks' +import { getToken } from '@/api/path' + +getToken() // 暗黑主题 const darkTheme = useDarkThemeHook() diff --git a/src/api/axios.ts b/src/api/axios.ts index e04743f3..ac51a2a2 100644 --- a/src/api/axios.ts +++ b/src/api/axios.ts @@ -13,7 +13,7 @@ export interface MyResponseType { data: T message: string // 兼顾主系统 - errcode: any + errcode: string } export interface MyRequestInstance extends Axios { diff --git a/src/api/path/business.api.ts b/src/api/path/business.api.ts index 76aed621..d706a8c9 100644 --- a/src/api/path/business.api.ts +++ b/src/api/path/business.api.ts @@ -3,32 +3,23 @@ import { http } from "@/api/http"; import { RequestHttpEnum } from "@/enums/httpEnum"; import { httpErrorHandle } from '@/utils' -const allCookies = document.cookie; -function getCookie(name: string) { - const cookies = document.cookie.split(';'); - for (const cookie of cookies) { - const [cookieName, cookieValue] = cookie.trim().split('='); - if (cookieName === name) { - return decodeURIComponent(cookieValue); - } - } - return null; -} -console.log(allCookies, getCookie('access_token')); - export function getToken() { - const TokenKey = 'access_token' - if (getCookie(TokenKey)) { - return getCookie(TokenKey) - } else { - return sessionStorage.getItem(TokenKey) - } + let queryStr = window.location.href + queryStr = queryStr.split('?')[1] + if(queryStr.indexOf('#') > -1) queryStr = queryStr.split('#')[0] + console.log(queryStr) + let query:{[key:string]: string} = {} + queryStr.split('&').forEach((item:string) => { + query[item.split('=')[0]] = item.split('=')[1] + }) + return query.access_token } -export const publicInterface = async (paramType:string, interfaceType:string, paramData:unknown) =>{ +export const publicInterface = async (paramType:string, interfaceType:string, paramData?:unknown) =>{ try { const access_token = getToken() - const res = await http(RequestHttpEnum.POST)(paramType, { + console.log(access_token, window) + const res = await http(RequestHttpEnum.POST)(paramType, { access_token, type: interfaceType, data: paramData diff --git a/src/api/path/project.api.ts b/src/api/path/project.api.ts index ee0001ba..d8604abd 100644 --- a/src/api/path/project.api.ts +++ b/src/api/path/project.api.ts @@ -1,99 +1,50 @@ -import { http } from '@/api/http' -import { httpErrorHandle } from '@/utils' -import { ContentTypeEnum, RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' -import { ProjectItem, ProjectDetail } from './project' +import {publicInterface} from './business.api' +import {http} from "@/api/http"; +import {ContentTypeEnum, RequestHttpEnum} from "@/enums/httpEnum"; +import {httpErrorHandle} from "@/utils"; // * 项目列表 export const projectListApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/list`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'get', data) } // * 新增项目 export const createProjectApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.POST)<{ - /** - * 项目id - */ - id: number - }>(`${ModuleTypeEnum.PROJECT}/create`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'add', data) } // * 获取项目 export const fetchProjectApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/getData`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'get_one', data) } // * 保存项目 export const saveProjectApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.POST)( - `${ModuleTypeEnum.PROJECT}/save/data`, - data, - ContentTypeEnum.FORM_URLENCODED - ) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'mod', data) } // * 修改项目基础信息 export const updateProjectApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/edit`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'mod', data) } // * 删除项目 export const deleteProjectApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.DELETE)(`${ModuleTypeEnum.PROJECT}/delete`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'del', data) } // * 修改发布状态 [-1未发布,1发布] export const changeProjectReleaseApi = async (data: object) => { - try { - const res = await http(RequestHttpEnum.PUT)(`${ModuleTypeEnum.PROJECT}/publish`, data) - return res - } catch { - httpErrorHandle() - } + return publicInterface('/dcim/system/custom_large_screen', 'mod', data) } // * 上传文件 export const uploadFile = async (data: object) => { - try { - const res = await http(RequestHttpEnum.POST)<{ - /** - * 文件地址 - */ - fileName: string, - fileurl: string, - }>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA) - return res - } catch { - httpErrorHandle() - } + try { + const res = await http(RequestHttpEnum.POST)('/dcim/system/custom_large_screen/upload_file', data, ContentTypeEnum.FORM_DATA) + return res + } catch { + httpErrorHandle() + } + // return publicInterface('/dcim/system/custom_large_screen/upload_file', 'get', data) } diff --git a/src/api/path/projectV3.api.ts b/src/api/path/projectV3.api.ts new file mode 100644 index 00000000..ee0001ba --- /dev/null +++ b/src/api/path/projectV3.api.ts @@ -0,0 +1,99 @@ +import { http } from '@/api/http' +import { httpErrorHandle } from '@/utils' +import { ContentTypeEnum, RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum' +import { ProjectItem, ProjectDetail } from './project' + +// * 项目列表 +export const projectListApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/list`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 新增项目 +export const createProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)<{ + /** + * 项目id + */ + id: number + }>(`${ModuleTypeEnum.PROJECT}/create`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 获取项目 +export const fetchProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.PROJECT}/getData`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 保存项目 +export const saveProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)( + `${ModuleTypeEnum.PROJECT}/save/data`, + data, + ContentTypeEnum.FORM_URLENCODED + ) + return res + } catch { + httpErrorHandle() + } +} + +// * 修改项目基础信息 +export const updateProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.PROJECT}/edit`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 删除项目 +export const deleteProjectApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.DELETE)(`${ModuleTypeEnum.PROJECT}/delete`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 修改发布状态 [-1未发布,1发布] +export const changeProjectReleaseApi = async (data: object) => { + try { + const res = await http(RequestHttpEnum.PUT)(`${ModuleTypeEnum.PROJECT}/publish`, data) + return res + } catch { + httpErrorHandle() + } +} + +// * 上传文件 +export const uploadFile = async (data: object) => { + try { + const res = await http(RequestHttpEnum.POST)<{ + /** + * 文件地址 + */ + fileName: string, + fileurl: string, + }>(`${ModuleTypeEnum.PROJECT}/upload`, data, ContentTypeEnum.FORM_DATA) + return res + } catch { + httpErrorHandle() + } +} diff --git a/src/hooks/useSystemInit.hook.ts b/src/hooks/useSystemInit.hook.ts index ee7dc7e1..551c7d77 100644 --- a/src/hooks/useSystemInit.hook.ts +++ b/src/hooks/useSystemInit.hook.ts @@ -10,14 +10,18 @@ export const useSystemInit = async () => { // 获取 OSS 信息的 url 地址,用来拼接展示图片的地址 const getOssUrl = async () => { - const res = await ossUrlApi({}) - if (res && res.code === ResultEnum.SUCCESS) { - systemStore.setItem(SystemStoreEnum.FETCH_INFO, { - OSSUrl: res.data?.bucketURL - }) - } + // const res = await ossUrlApi({}) + // if (res && res.code === ResultEnum.SUCCESS) { + // systemStore.setItem(SystemStoreEnum.FETCH_INFO, { + // OSSUrl: res.data?.bucketURL + // }) + // } + const url = window.location.origin + systemStore.setItem(SystemStoreEnum.FETCH_INFO, { + OSSUrl: url + }) } // 执行 getOssUrl() -} \ No newline at end of file +} diff --git a/src/packages/components/CustomComponents/CustomComponents/ComprehensivePUE/VCircle.vue b/src/packages/components/CustomComponents/CustomComponents/ComprehensivePUE/VCircle.vue index cacaf740..8d7e828a 100644 --- a/src/packages/components/CustomComponents/CustomComponents/ComprehensivePUE/VCircle.vue +++ b/src/packages/components/CustomComponents/CustomComponents/ComprehensivePUE/VCircle.vue @@ -267,9 +267,9 @@ type ValueType = ItemType[] const { value } = defineProps(['value']) as { value: ValueType } const color = ref('#4dca59') -const getRotate = (horizontal, data) => { +const getRotate = (horizontal:string, data:number) => { // 传入指针水平位置,计算指针角度,水平位置即为指针角度为0时,两端点的纵坐标 - const pue = parseFloat(data) // 当前指针值 + const pue = parseFloat(data.toString()) // 当前指针值 if (pue >= 0 && pue < 1.7) { color.value = '#4dca59' } else if (pue >= 1.7 && pue < 2.2) { diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue index f79be187..13fd1f4a 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/index.vue @@ -277,10 +277,10 @@ const customRequest = (options: UploadCustomRequestOptions) => { type: file.file.type }) let uploadParams = new FormData() - uploadParams.append('object', newNameFile) + uploadParams.append('files', newNameFile) const uploadRes = await uploadFile(uploadParams) - if (uploadRes && uploadRes.code === ResultEnum.SUCCESS) { + if (uploadRes && uploadRes.errcode === '00000') { if (uploadRes.data.fileurl) { chartEditStore.setEditCanvasConfig( EditCanvasConfigEnum.BACKGROUND_IMAGE, diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 0542274f..f40e2c3c 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -251,11 +251,20 @@ export const useSync = () => { chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.START) try { const res = await fetchProjectApi({ projectId: fetchRouteParamsLocation() }) - if (res && res.code === ResultEnum.SUCCESS) { + console.log(res) + if (res) { + // type dataType = { + // id: string + // projectName: string, + // indexImage: string, + // remarks: string, + // state: number, + // content: string, + // } if (res.data) { - updateStoreInfo(res.data) + updateStoreInfo(res.data as any) // 更新全局数据 - await updateComponent(JSONParse(res.data.content)) + await updateComponent(JSONParse((res.data as any).content)) return }else { chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_ID, fetchRouteParamsLocation()) @@ -267,6 +276,7 @@ export const useSync = () => { } chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.FAILURE) } catch (error) { + console.log(error) chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.FAILURE) httpErrorHandle() } @@ -298,19 +308,19 @@ export const useSync = () => { // 上传预览图 let uploadParams = new FormData() - uploadParams.append('object', base64toFile(canvasImage.toDataURL(), `${fetchRouteParamsLocation()}_index_preview.png`)) + uploadParams.append('files', base64toFile(canvasImage.toDataURL(), `${fetchRouteParamsLocation()}_index_preview.png`)) const uploadRes = await uploadFile(uploadParams) // 保存预览图 - if(uploadRes && uploadRes.code === ResultEnum.SUCCESS) { - if (uploadRes.data.fileurl) { + if(uploadRes && uploadRes.data) { + if (uploadRes.data.length) { await updateProjectApi({ - id: fetchRouteParamsLocation(), - indexImage: `${uploadRes.data.fileurl}` + id: Number(fetchRouteParamsLocation()), + indexImage: `${uploadRes.data[0]}` }) } else { await updateProjectApi({ - id: fetchRouteParamsLocation(), - indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data.fileName}` + id: Number(fetchRouteParamsLocation()), + indexImage: `${systemStore.getFetchInfo.OSSUrl}${uploadRes.data[0]}` }) } } @@ -320,12 +330,16 @@ export const useSync = () => { } // 保存数据 - let params = new FormData() - params.append('projectId', projectId) - params.append('content', JSONStringify(chartEditStore.getStorageInfo() || {})) + // let params = new FormData() + // params.append('projectId', projectId) + // params.append('content', JSONStringify(chartEditStore.getStorageInfo() || {})) + const params = { + id: projectId, + content: JSONStringify(chartEditStore.getStorageInfo() || {}) + } const res= await saveProjectApi(params) - if (res && res.code === ResultEnum.SUCCESS) { + if (res && res.data) { // 成功状态 setTimeout(() => { chartEditStore.setEditCanvas(EditCanvasTypeEnum.SAVE_STATUS, SyncEnum.SUCCESS) diff --git a/src/views/preview/utils/storage.ts b/src/views/preview/utils/storage.ts index 15b5d5b6..4008d438 100644 --- a/src/views/preview/utils/storage.ts +++ b/src/views/preview/utils/storage.ts @@ -20,14 +20,14 @@ export const getSessionStorageInfo = async () => { if (!storageList || storageList.findIndex(e => e.id === id.toString()) === -1) { // 接口调用 const res = await fetchProjectApi({ projectId: id }) - if (res && res.code === ResultEnum.SUCCESS) { + if (res) { const { content, state } = res.data - if (state === -1) { - // 跳转未发布页 - return { isRelease: false } - } + // if (state === -1) { + // // 跳转未发布页 + // return { isRelease: false } + // } console.log(content) - const parseData = { ...JSONParse(content), id } + const parseData = { ...JSONParse(content ? content : '{}'), id } const { editCanvasConfig, requestGlobalConfig, componentList } = parseData chartEditStore.editCanvasConfig = editCanvasConfig chartEditStore.requestGlobalConfig = requestGlobalConfig diff --git a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts index d54d1290..936d99a1 100644 --- a/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts +++ b/src/views/project/items/components/ProjectItemsList/hooks/useData.hook.ts @@ -30,7 +30,7 @@ export const useDataListInit = () => { if (res && res.data) { const { count } = res as any // 这里的count与data平级,不在Response结构中 paginat.count = count - list.value = res.data.map(e => { + list.value = res.data.map((e:any) => { const { id, projectName, state, createTime, indexImage, createUserId } = e return { id: id, @@ -69,13 +69,11 @@ export const useDataListInit = () => { onPositiveCallback: () => new Promise(res => { res( - deleteProjectApi({ - ids: cardData.id - }) + deleteProjectApi([cardData.id]) ) }), promiseResCallback: (res: any) => { - if (res.code === ResultEnum.SUCCESS) { + if (res.errcode === '00000') { window['$message'].success(window['$t']('global.r_delete_success')) fetchList() return diff --git a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue index 10ae9871..1339e498 100644 --- a/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue +++ b/src/views/project/layout/components/ProjectLayoutCreate/components/CreateModal/index.vue @@ -95,7 +95,7 @@ const btnHandle = async (key: string) => { // 图片地址 indexImage: null, }) - if(res && res.code === ResultEnum.SUCCESS) { + if(res && res.data) { window['$message'].success(window['$t']('project.create_success')) const { id } = res.data diff --git a/vite.config.ts b/vite.config.ts index 182a3d6e..25d4deeb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -47,6 +47,14 @@ export default ({ mode }) => defineConfig({ port: 3000, proxy: { [axiosPre]: { + // @ts-ignore + target: loadEnv(mode, process.cwd()).VITE_DEV_PATH, + changeOrigin: true, + rewrite: (path) => path.replace(new RegExp(`^${axiosPre}`), ''), + ws: true, + secure: true, + }, + '/data/file': { // @ts-ignore target: loadEnv(mode, process.cwd()).VITE_DEV_PATH, changeOrigin: true,