Skip to content

Commit

Permalink
feat: 替换变量为驼峰
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft authored and jianbing.chen committed Dec 18, 2024
1 parent 8c4dd8b commit 2d5285a
Show file tree
Hide file tree
Showing 53 changed files with 461 additions and 486 deletions.
2 changes: 1 addition & 1 deletion packages/admin/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const getProjectMenu = (projectId: string | number) => {

// 获取项目配置
export const getProjectDetail = (projectId: string | number) => {
return request.get('/admin/getProjectConfig?project_id=' + projectId);
return request.get('/admin/getProjectConfig?projectId=' + projectId);
};
2 changes: 1 addition & 1 deletion packages/admin/src/components/BreadList/BreadList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function BreadList() {
breadList.unshift({
title: cur.name,
});
cur = menuMap[cur.parent_id];
cur = menuMap[cur.parentId];
}
setMenuPath(breadList);
}, [pathname, menuMap]);
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const Header = memo(() => {
updateCollapsed();
};

const isLight = projectInfo.menu_theme_color === 'light' || projectInfo.layout === 1;
const isLight = projectInfo.menuThemeColor === 'light' || projectInfo.layout === 1;
const style: React.CSSProperties = {
backgroundColor: isLight ? '#fff' : '#001529',
color: projectInfo.menu_theme_color === 'light' ? '#000' : '#fff',
color: projectInfo.menuThemeColor === 'light' ? '#000' : '#fff',
};
return (
<div className={styles.header} style={style}>
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/components/Logo/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Logo() {
const [nameStyle, setNameStyle] = useState({});
useEffect(() => {
// 左右布局模式下,Logo背景需要跟着主题色变化
if (projectInfo.menu_theme_color === 'dark') {
if (projectInfo.menuThemeColor === 'dark') {
setStyle({ backgroundColor: '#001529', color: '#fff', height: 64, padding: '10px 20px' });
} else {
setStyle({ backgroundColor: '#fff', color: '#000', height: 64, padding: '10px 20px' });
Expand All @@ -25,7 +25,7 @@ function Logo() {
fontSize: projectInfo.name.length > 9 ? 14 : 16,
});
}
}, [projectInfo.layout, projectInfo.menu_theme_color]);
}, [projectInfo.layout, projectInfo.menuThemeColor]);
return (
<div
className={styles.logo}
Expand Down
16 changes: 8 additions & 8 deletions packages/admin/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const MenuComponent: React.FC = () => {
if (item.type === 1 && item.status === 1) {
const iconsList: { [key: string]: any } = Icons;
if (item.buttons?.length || !item.children) {
const path = `/project/${projectId}/${item.path.startsWith('/') ? item.path.slice(1) : item.path || item.page_id || -item.id}`;
const path = `/project/${projectId}/${item.path.startsWith('/') ? item.path.slice(1) : item.path || item.pageId || -item.id}`;
return treeList.push(getMenuItem(item.name, path, iconsList[item.icon] && React.createElement(iconsList[item.icon])));
}
const path = `${projectId}-${item.id}`;
Expand Down Expand Up @@ -69,11 +69,11 @@ const MenuComponent: React.FC = () => {
return (
<div
style={
projectInfo.menu_mode === 'horizontal'
projectInfo.menuMode === 'horizontal'
? { width: 'calc(100vw - 458px)' }
: {
width: collapsed ? 79 : 255,
background: projectInfo.menu_theme_color === 'light' ? '#fff' : '#001529',
background: projectInfo.menuThemeColor === 'light' ? '#fff' : '#001529',
borderRight: projectInfo.layout === 2 ? '1px solid #e8e9eb' : 'none',
overflowX: 'hidden',
}
Expand All @@ -84,19 +84,19 @@ const MenuComponent: React.FC = () => {
components: {
Menu: {
darkItemColor: '#fff',
darkItemHoverColor: projectInfo.system_theme_color,
darkItemHoverColor: projectInfo.systemThemeColor,
iconSize: 16,
},
},
}}
>
<Menu
onClick={onClick}
theme={projectInfo.menu_theme_color as MenuTheme}
theme={projectInfo.menuThemeColor as MenuTheme}
selectedKeys={selectedKeys}
style={projectInfo.menu_mode === 'horizontal' ? {} : { height: 'calc(100vh - 64px)', border: 'none', overflowY: 'auto' }}
mode={projectInfo.menu_mode}
inlineCollapsed={projectInfo.menu_mode === 'horizontal' ? undefined : collapsed}
style={projectInfo.menuMode === 'horizontal' ? {} : { height: 'calc(100vh - 64px)', border: 'none', overflowY: 'auto' }}
mode={projectInfo.menuMode}
inlineCollapsed={projectInfo.menuMode === 'horizontal' ? undefined : collapsed}
items={menuList}
/>
</ConfigProvider>
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/components/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function Tab() {
setActiveKey('welcome');
return;
}
const page_id = getPageId(pageId, pageMap);
const menuItem = pageMap[Number(page_id)];
const id = getPageId(pageId, pageMap);
const menuItem = pageMap[Number(id)];
if (!menuItem) return;
if (!tabsList.find((item) => item.key == pathname)) {
tabsList.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const AdminLayout = () => {
locale={locale}
theme={{
token: {
colorPrimary: projectInfo.system_theme_color || '#1677ff',
colorPrimary: projectInfo.systemThemeColor || '#1677ff',
},
hashed: false,
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/pages/console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function Console() {
<p style={{ color: 'rgba(0, 0, 0, 0.88)' }}>{item.remark}</p>
<p style={{ marginTop: 10 }}>
<UserOutlined style={{ fontSize: 14, marginRight: 5 }} />
{item.updated_at}
{item.updatedAt}
</p>
</>
}
Expand Down
12 changes: 6 additions & 6 deletions packages/admin/src/pages/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ export default function () {
}
let pageData: any = {};
try {
pageData = JSON.parse(res.page_data || '{}');
pageData = JSON.parse(res.pageData || '{}');
} catch (error) {
console.error(error);
console.info('【json数据】', res.page_data);
console.info('【json数据】', res.pageData);
message.error('页面数据格式错误,请检查');
}
clearPageInfo();
savePageInfo({
pageId: res.id,
pageName: res.name,
remark: res.remark,
is_public: res.is_public,
stg_publish_id: res.stg_publish_id,
pre_publish_id: res.pre_publish_id,
prd_publish_id: res.prd_publish_id,
isPublic: res.isPublic,
stgPublishId: res.stgPublishId,
prePublishId: res.prePublishId,
prdPublishId: res.prdPublishId,
...pageData,
});
setPageData(pageData);
Expand Down
10 changes: 5 additions & 5 deletions packages/admin/src/pages/project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ export default function () {
useEffect(() => {
let env = storage.get(`${projectId}-env`) || 'prd';
// 获取页面ID
const page_id = getPageId(pageId, pageMap);
if (!page_id) {
const id = getPageId(pageId, pageMap);
if (!id) {
setNotFound(true);
return;
}
if (!isEnv(env)) {
env = 'prd';
}
getPageDetail(env as string, Number(page_id))
getPageDetail(env as string, Number(id))
.then((res: any) => {
let pageData: any = {};
try {
pageData = JSON.parse(res.page_data || '{}');
pageData = JSON.parse(res.pageData || '{}');
} catch (error) {
console.error(error);
console.info('【json数据】', res.page_data);
console.info('【json数据】', res.pageData);
message.error('页面数据格式错误,请检查');
}
clearPageInfo();
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/src/stores/projectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export interface ProjectInfo {
footer?: number;
layout?: number;
logo?: string;
menu_mode: 'inline' | 'horizontal' | 'vertical';
menu_theme_color?: string;
menuMode: 'inline' | 'horizontal' | 'vertical';
menuThemeColor?: string;
name: string;
system_theme_color?: string;
systemThemeColor?: string;
breadcrumb?: number;
tag?: number;
}
Expand All @@ -32,7 +32,7 @@ export interface ProjectAction {
export const useProjectStore = create<PageState & ProjectAction>((set, get) => ({
projectInfo: {
name: '',
menu_mode: 'inline',
menuMode: 'inline',
},
collapsed: false,
menuTree: [],
Expand Down
24 changes: 9 additions & 15 deletions packages/admin/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

export interface IMenuItem {
id: number;
project_id: number;
projectId: number;
name: string;
parent_id: number;
parentId: number;
type: number;
icon: string;
path: string;
page_id: number;
sort_num: number;
pageId: number;
sortNum: number;
status: number;
created_at: string;
createdAt: string;
buttons?: IMenuItem[];
children?: IMenuItem[];
}
Expand All @@ -23,14 +23,8 @@ export interface ProjectItem {
name: string;
remark: string;
logo: string;
user_name: string;
user_id: string;
updated_at: string;
created_at: string;
members: Array<{
id: number;
role: 1 | 2;
user_id: string;
user_name: string;
}>;
userName: string;
userId: string;
updatedAt: string;
createdAt: string;
}
24 changes: 12 additions & 12 deletions packages/admin/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export function isEnv(env?: string) {
*/
export function getPageId(pageId: string | number | undefined, pageMap: Record<number, any>): number {
if (!pageId || !pageMap) return 0;
const page_id = isNaN(Number(pageId))
? Object.values(pageMap).filter((item) => (item.path.startsWith('/') ? item.path.slice(1) === pageId : item.path === pageId))?.[0]?.page_id
const id = isNaN(Number(pageId))
? Object.values(pageMap).filter((item) => (item.path.startsWith('/') ? item.path.slice(1) === pageId : item.path === pageId))?.[0]?.pageId
: pageId;
return page_id;
return id;
}
/**
* 菜单数据转换
Expand All @@ -29,16 +29,16 @@ export function getPageId(pageId: string | number | undefined, pageMap: Record<n
*/
export function arrayToTree(array: IMenuItem[] = []) {
const buttons: IMenuItem[] = [];
const pageMap: { [key: number]: Pick<IMenuItem, 'id' | 'page_id' | 'parent_id' | 'name' | 'path'> } = {};
const pageMap: { [key: number]: Pick<IMenuItem, 'id' | 'pageId' | 'parentId' | 'name' | 'path'> } = {};
const menuMap: { [key: number]: IMenuItem } = {};
// 创建一个映射,将id映射到节点对象
const map: { [key: number]: IMenuItem & { children?: IMenuItem[] } } = {};
array.forEach((item) => {
map[item.id] = { ...item };
if (item.type === 2) buttons.push(item);
if (item.type === 1 || item.type === 3) {
if (item.page_id) {
pageMap[item.page_id] = { id: item.id, page_id: item.page_id, parent_id: item.parent_id, name: item.name, path: item.path };
if (item.pageId) {
pageMap[item.pageId] = { id: item.id, pageId: item.pageId, parentId: item.parentId, name: item.name, path: item.path };
} else {
menuMap[item.id] = { ...item };
}
Expand All @@ -47,22 +47,22 @@ export function arrayToTree(array: IMenuItem[] = []) {

// 找到每个节点的父节点
array.forEach((item) => {
if (item.parent_id && map[item.parent_id]) {
const parentItem = map[item.parent_id];
if (item.parentId && map[item.parentId]) {
const parentItem = map[item.parentId];
if (item.type === 1 || item.type === 3) {
if (!parentItem.children) parentItem.children = [];
parentItem.children?.push(map[item.id]);
// 按照sort_num进行降序排序
parentItem.children = parentItem.children.sort((a, b) => a.sort_num - b.sort_num);
// 按照sortNum进行降序排序
parentItem.children = parentItem.children.sort((a, b) => a.sortNum - b.sortNum);
} else {
if (!parentItem.buttons) parentItem.buttons = [];
parentItem.buttons?.push(map[item.id]);
}
}
});
const menuTree = Object.values(map)
.filter((item) => !item.parent_id)
.sort((a, b) => a.sort_num - b.sort_num);
.filter((item) => !item.parentId)
.sort((a, b) => a.sortNum - b.sortNum);
return {
menuTree,
buttons,
Expand Down
14 changes: 7 additions & 7 deletions packages/editor/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const publishList = (params: PublishListParams) => {
};

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

Expand Down Expand Up @@ -134,7 +134,7 @@ export const delUser = (params: { id: number }) => {
};

// 更新项目用户
export const updateUser = (params: { id: number; system_role: number; role_id: number }) => {
export const updateUser = (params: { id: number; systemRole: number; roleId: number }) => {
return request.post('/project/user/update', params);
};

Expand All @@ -144,8 +144,8 @@ export const getRoleList = (params: Role.Params) => {
};

// 获取所有角色
export const getRoleListAll = (project_id: number) => {
return request.get('/role/listAll', { project_id });
export const getRoleListAll = (projectId: number) => {
return request.get('/role/listAll', { projectId });
};

// 新增角色
Expand All @@ -154,16 +154,16 @@ export const createRole = (params: Role.CreateParams) => {
};

// 删除角色
export const delRoleById = (params: { id: number; project_id: number }) => {
export const delRoleById = (params: { id: number; projectId: number }) => {
return request.post('/role/delete', params);
};

// 更新角色
export const updateRoleLimits = (params: { id: number; checked: string; half_checked: string }) => {
export const updateRoleLimits = (params: { id: number; checked: string; halfChecked: string }) => {
return request.post('/role/updateLimits', params);
};

// 更新角色权限
export const updateRole = (params: { id: number; project_id: string; name: string; remark: string }) => {
export const updateRole = (params: { id: number; projectId: string; name: string; remark: string }) => {
return request.post('/role/update', params);
};
Loading

0 comments on commit 2d5285a

Please sign in to comment.