Skip to content

Commit

Permalink
feat: 修改接口定义,同步代码。
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Nov 25, 2024
1 parent 5eb7e0c commit db23308
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 224 deletions.
55 changes: 55 additions & 0 deletions packages/editor/src/api/feedback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import request from '@/utils/request';

/**
* 反馈
*/
export interface FeedbackItem {
id: number;
userId?: number;
title: string;
content: string;
isSolve?: number;
isTop?: number;
like?: number;
userAvatar?: string;
createdAt: string;
nickName: string;
type: number;
images?: string;
issuelUrl?: string;
}

export interface FeedbackCommentItem {
id: number;
userAvatar?: string;
nickName: string;
content: string;
createdAt: string;
feedbackId: number;
isTop?: number;
}
/**
* 反馈接口
*/
export default {
// 发布反馈
createFeedback(params: { title: string; content: string; type: number; images: string }) {
return request.post('/feedback/create', params);
},
// 获取反馈列表
getFeedbackList(params: { pageNum: number; pageSize: number; title: string; type: number }) {
return request.get('/feedback/list', params);
},
getFeedbackDetail(id: number) {
return request.get('/feedback/detail', { id });
},
createFeedbackComment(params: { feedbackId: number; content: string }) {
return request.post('/feedback/createComment', params);
},
getFeedbackComments(feedbackId: number, pageSize: number, pageNum: number) {
return request.get('/feedback/getComments', { feedbackId, pageSize, pageNum });
},
queryFeedbackTotal() {
return request.get('/feedback/queryFeedbackTotal');
},
};
94 changes: 2 additions & 92 deletions packages/editor/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,11 @@
import request from '@/utils/request';
import {
PageParams,
PageReqParams,
CreatePageParams,
PublishPageParams,
PublishListParams,
ProjectListParams,
ProjectCreateParams,
ProjectUpdateParams,
UserListParams,
UserCreateParams,
Menu,
Role,
} from './types';

// 获取页面列表
export const getPageList = (params: PageParams) => {
return request.get('/page/list', params);
};

// 获取页面模板列表
export const getPageTemplateList = (params: Omit<PageParams, 'type'>) => {
return request.get('/page/getPageTemplateList', params);
};
// 获取页面详情
export const getPageDetail = (id: number) => {
return request.get(`/page/detail/${id}`);
};

// 复制页面数据
export const copyPageData = (params: PageReqParams) => {
return request.post('/page/copy', params);
};

// 删除页面数据
export const delPageData = (params: { id: number }) => {
return request.post('/page/delete', params);
};

// 创建页面数据
export const createPageData = (params: CreatePageParams) => {
return request.post('/page/create', params);
};
import { ProjectListParams, ProjectCreateParams, ProjectUpdateParams, UserListParams, UserCreateParams, Menu, Role } from './types';

// 图片上传
export const uploadImg = (params: any) => {
return request.post('/upload/files', params, { showError: false });
};

// 保存页面数据
export const updatePageData = (params: any) => {
return request.post('/page/update', params);
};

// 发布
export const publishPage = (params: PublishPageParams) => {
return request.post('/publish/create', params);
};

// 发布记录
export const publishList = (params: PublishListParams) => {
return request.post('/publish/list', params);
};

// 页面回滚
export const rollbackPage = (params: { pageId: number; env: string; lastPublishId: number }) => {
return request.post('/page/rollback', params);
};

// 获取项目列表
export const getProjectList = (params: ProjectListParams) => {
return request.get('/project/list', params);
Expand Down Expand Up @@ -118,7 +56,7 @@ export const updateMenu = (params: Menu.EditParams) => {
return request.post('/menu/update', params);
};

// 更新菜单
// 复制菜单
export const copyMenu = (params: { id: number }) => {
return request.post('/menu/copy', params);
};
Expand Down Expand Up @@ -172,31 +110,3 @@ export const updateRoleLimits = (params: { id: number; checked: string; halfChec
export const updateRole = (params: { id: number; projectId: string; name: string; remark: string }) => {
return request.post('/role/update', params);
};


// 发布反馈
export const createFeedback = (params: { title: string; content: string, type: number, images: string}) => {
return request.post('/feedback/create', params);
}

// 获取反馈列表
export const getFeedbackList = (params: { pageNum: number; pageSize: number; title: string; type: number }) => {
return request.get('/feedback/list', params);
}

export const getFeedbackDetail = (id: number) => {
return request.get('/feedback/detail', { id });
}

export const createFeedbackComment = (params: { feedbackId: number; content: string }) => {
return request.post('/feedback/createComment', params);
}


export const getFeedbackComments = (feedbackId: number, pageSize: number, pageNum: number) => {
return request.get('/feedback/getComments', { feedbackId, pageSize, pageNum });
}

export const queryFeedbackTotal = () => {
return request.get('/feedback/queryFeedbackTotal');
}
51 changes: 48 additions & 3 deletions packages/editor/src/api/page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
import request from '@/utils/request';
import { PageParams } from './types';
import { PageParams, PageReqParams, CreatePageParams, PublishPageParams, PublishListParams } from './types';
export default {
getCategoryList(params: PageParams) {
return request.get('/page/category', params);
// 获取页面列表
getPageList(params: PageParams) {
return request.get('/page/list', params);
},

// 获取页面模板列表
getPageTemplateList(params: Omit<PageParams, 'type'>) {
return request.get('/page/getPageTemplateList', params);
},
// 获取页面详情
getPageDetail(id: number) {
return request.get(`/page/detail/${id}`);
},

// 复制页面数据
copyPageData(params: PageReqParams) {
return request.post('/page/copy', params);
},

// 删除页面数据
delPageData(params: { id: number }) {
return request.post('/page/delete', params);
},

// 创建页面数据
createPageData(params: CreatePageParams) {
return request.post('/page/create', params);
},

// 保存页面数据
updatePageData(params: any) {
return request.post('/page/update', params);
},

// 发布
publishPage(params: PublishPageParams) {
return request.post('/publish/create', params);
},

// 发布记录
publishList(params: PublishListParams) {
return request.post('/publish/list', params);
},

// 页面回滚
rollbackPage(params: { pageId: number; env: string; lastPublishId: number }) {
return request.post('/page/rollback', params);
},
};
7 changes: 7 additions & 0 deletions packages/editor/src/api/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import request from '@/utils/request';
import { PageParams } from './types';
export default {
getCategoryList(params: PageParams) {
return request.get('/project/category', params);
},
};
1 change: 0 additions & 1 deletion packages/editor/src/api/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import request from '@/utils/request';
import { PageParams } from './types';

export interface IWorkFlow {
id: number;
Expand Down
7 changes: 4 additions & 3 deletions packages/editor/src/components/CreatePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Input, Modal, Form, Select, Space, Flex } from 'antd';
import { useImperativeHandle, useState, MutableRefObject } from 'react';
import { createPageData, updatePageData, getAllProjects } from '@/api';
import { getAllProjects } from '@/api';
import api from '@/api/page';
import { PageItem } from '@/api/pageMember';
import { Project } from '@/api/types';
import { useSearchParams } from 'react-router-dom';
Expand Down Expand Up @@ -58,9 +59,9 @@ const CreatePage = (props: IModalProp) => {
setLoading(true);
try {
if (type === 'create') {
await createPageData(params);
await api.createPageData(params);
} else {
await updatePageData({
await api.updatePageData({
...params,
id: recordId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Button, Space, Tooltip } from 'antd';
import { CheckOutlined, ClockCircleOutlined, LoadingOutlined } from '@ant-design/icons';
import { toBlob } from 'html-to-image';
import { usePageStore } from '@/stores/pageStore';
import { publishPage, uploadImg } from '@/api';
import { uploadImg } from '@/api';
import api from '@/api/page';
import { message } from '@/utils/AntdGlobal';
import styles from './index.module.less';

Expand Down Expand Up @@ -52,7 +53,7 @@ export default function Publish() {
}
try {
const previewImg = await createPreviewImg();
await publishPage({
await api.publishPage({
env,
pageId: pageId,
previewImg,
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/layout/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@ant-design/icons';
import { usePageStore } from '@/stores/pageStore';
import { message } from '@/utils/AntdGlobal';
import { updatePageData } from '@/api';
import api from '@/api/page';
import Publish from './PublishPopover';
import styles from './index.module.less';
import storage from '@/utils/storage';
Expand Down Expand Up @@ -142,7 +142,7 @@ const Header = memo(() => {
prdPublishId: undefined,
});
try {
await updatePageData({
await api.updatePageData({
id: pageId,
name: pageName,
remark: remark,
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/layout/components/Menu/CodingPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Row } from 'antd';
import Editor, { loader } from '@monaco-editor/react';
import { useRef, useEffect, useState } from 'react';
import { updatePageData } from '@/api';
import api from '@/api/page';
import { usePageStore } from '@/stores/pageStore';
import { message } from '@/utils/AntdGlobal';

Expand Down Expand Up @@ -72,7 +72,7 @@ const CodingPanel = () => {
};
setLoading(true);
try {
await updatePageData(params);
await api.updatePageData(params);
setLoading(false);
savePageInfo({
...JSON.parse(params.pageData),
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/layout/components/Menu/Pages/PageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Flex, List, Spin, Tag } from 'antd';
import { PlusOutlined, SyncOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons';
import { useEffect, useRef, useState } from 'react';
import { PageItem } from '@/api/pageMember';
import { getPageList, delPageData } from '@/api';
import api from '@/api/page';
import { useNavigate } from 'react-router-dom';
import { Modal, message } from '@/utils/AntdGlobal';
import { usePageStore } from '@/stores/pageStore';
Expand Down Expand Up @@ -34,7 +34,7 @@ export default () => {
} else {
setLoading(true);
}
const res = await getPageList({
const res = await api.getPageList({
pageNum: current || pageNum,
pageSize,
projectId: 0,
Expand Down Expand Up @@ -65,7 +65,7 @@ export default () => {
okText: '确认',
cancelText: '取消',
onOk: async () => {
await delPageData({
await api.delPageData({
id,
});
message.success('删除成功');
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/pages/admin/menu/CreateMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useImperativeHandle, useRef, useState } from 'react';
import { useParams } from 'react-router-dom';
import { Modal, Form, TreeSelect, Input, Select, InputNumber, Radio, Spin } from 'antd';
import { InfoCircleOutlined } from '@ant-design/icons';
import { message } from '@/utils/AntdGlobal';
import { IAction, IModalProp } from '@/pages/types';
import { Menu } from '@/api/types';
import { getMenuList, addMenu, updateMenu, getPageList } from '@/api';
import { getMenuList, addMenu, updateMenu } from '@/api';
import api from '@/api/page';
import { PageItem } from '@/api/pageMember';
import { arrayToTree } from '@/utils/util';
import CreatePage from '@/components/CreatePage';
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function CreateMenu(props: IModalProp<Menu.EditParams>) {

// 获取用户页面列表
const getMyPageList = async () => {
const res = await getPageList({ pageNum: 1, pageSize: 50, projectId: Number(projectId) });
const res = await api.getPageList({ pageNum: 1, pageSize: 50, projectId: Number(projectId) });
setPageList(res.list);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/pages/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getComponent } from '@/packages/index';
import { IDragTargetItem } from '@/packages/types/index';
import { checkComponentType, createId, getElement } from '@/utils/util';
import storage from '@/utils/storage';
import { getPageDetail } from '@/api';
import api from '@/api/page';
import Toolbar from '@/components/Toolbar/Toolbar';
import { message } from '@/utils/AntdGlobal';
import { usePageStore } from '@/stores/pageStore';
Expand Down Expand Up @@ -72,7 +72,7 @@ const Editor = () => {
if (!id) return;
setLoaded(false);
setCanvasWidth(storage.get('canvasWidth') || 'auto');
getPageDetail(parseInt(id)).then((res) => {
api.getPageDetail(parseInt(id)).then((res) => {
let pageData: any = {};
try {
pageData = JSON.parse(res.pageData || '{}');
Expand Down
Loading

0 comments on commit db23308

Please sign in to comment.