Skip to content

Commit 4948d61

Browse files
committed
fix: update comments and clean up unused code across multiple files
1 parent c519b42 commit 4948d61

16 files changed

Lines changed: 28 additions & 117 deletions

File tree

src/access.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// 参考文档 https://umijs.org/docs/max/access
12
export default (initialState: API.UserInfo) => {
2-
// 在这里按照初始化数据定义项目中的权限,统一管理
3-
// 参考文档 https://umijs.org/docs/max/access
3+
// 'dontHaveAccess' 是约定的禁止访问标识符,由后端登录接口返回以拒绝特定用户进入管理后台
44
const canSeeAdmin = !!(initialState && initialState.name !== 'dontHaveAccess');
55
return {
66
canSeeAdmin,

src/app.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// 运行时配置
21
import ErrorBoundary from '@/components/ErrorBoundary';
32
import RightContent from '@/layouts/RightContent';
43
import { appList } from '@/layouts/_defaultProps';
@@ -7,41 +6,36 @@ import 'cesium/Build/Cesium/Widgets/widgets.css';
76
import { getInitialState as libGetInitialState } from './utils/Auth/initalState';
87
import { requestConfig } from './utils/requestConfig';
98

10-
// NOTE: cesium-heatmap 插件需要全局引入 Cesium
11-
// 声明全局 Cesium 类型
9+
// cesium-heatmap 等插件依赖全局 window.Cesium,需在此挂载
10+
// 同时声明类型以避免 TS 报错
1211
declare global {
1312
interface Window {
1413
Cesium: typeof import('cesium');
1514
}
1615
}
1716

1817
import * as Cesium from 'cesium';
19-
// 仅在需要时挂载到 window,避免全局污染;同时统一初始化 Cesium Ion token
18+
// 防止 SSR 或模块重复加载时重复挂载,也避免覆盖已有实例
2019
if (typeof window !== 'undefined' && !window.Cesium) {
2120
window.Cesium = Cesium;
2221
}
22+
// CESIUM_ION_TOKEN 由构建时环境变量注入(见 config/config.ts define 配置)
2323
if (typeof CESIUM_ION_TOKEN !== 'undefined' && CESIUM_ION_TOKEN) {
2424
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
2525
}
2626

27-
// NOTE:全局初始化数据配置,用于 Layout 用户信息和权限初始化
2827
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
2928
export async function getInitialState() {
30-
// return { name: '@umijs/max' };
3129
return await libGetInitialState();
3230
}
3331

34-
// NOTE: Request 运行时配置
3532
export const request: RequestConfig = requestConfig;
3633

37-
// NOTE: Layout 运行时配置
3834
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3935
export const layout: RunTimeLayoutConfig = (initialState) => {
4036
return {
4137
title: 'React Admin',
42-
// logo: '/umi-react-admin/logo.svg',
4338
logo: '/logo.svg',
44-
// 默认布局调整
4539
rightContentRender: () => <RightContent />,
4640
menuHeaderRender: undefined,
4741
appList,
@@ -50,27 +44,17 @@ export const layout: RunTimeLayoutConfig = (initialState) => {
5044
fixSiderbar: true,
5145
fixHeader: true,
5246
childrenRender: (children) => <ErrorBoundary>{children}</ErrorBoundary>,
53-
54-
// 其他属性见:https://procomponents.ant.design/components/layout#prolayout
47+
// 更多 ProLayout 属性见:https://procomponents.ant.design/components/layout#prolayout
5548
};
5649
};
5750

58-
// NOTE: Antd 运行时配置
5951
export const antd: RuntimeAntdConfig = (memo) => {
6052
memo.theme ??= {};
61-
// 1, dark 算法
62-
// 默认算法 theme.defaultAlgorithm
63-
// 暗色算法 theme.darkAlgorithm
64-
// 紧凑算法 theme.compactAlgorithm
65-
66-
// memo.theme.algorithm = theme.darkAlgorithm; // 配置 antd5 的预设 dark 算法
67-
68-
// 2. 组合使用暗色算法与紧凑算法
69-
// algorithm: [theme.darkAlgorithm, theme.compactAlgorithm],
70-
53+
// 如需切换主题算法,取消对应行注释:
54+
// theme.defaultAlgorithm(默认)/ theme.darkAlgorithm(暗色)/ theme.compactAlgorithm(紧凑)
55+
// 也可组合使用:algorithm: [theme.darkAlgorithm, theme.compactAlgorithm]
7156
memo.appConfig = {
7257
message: {
73-
// 配置 message 最大显示数,超过限制时,最早的消息会被自动关闭
7458
maxCount: 3,
7559
},
7660
};

src/components/Designable/index.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useMemo } from 'react';
2-
// import { createRoot } from 'react-dom/client'
31
import { saveSchema } from '@/components/Designable/service';
42
import {
53
ActionsWidget,
@@ -29,6 +27,7 @@ import {
2927
} from '@pind/designable-react';
3028
import { SettingsForm, setNpmCDNRegistry } from '@pind/designable-react-settings-form';
3129
import { Alert } from 'antd';
30+
import { useMemo } from 'react';
3231
setNpmCDNRegistry('//unpkg.com');
3332
const { ErrorBoundary } = Alert;
3433
GlobalRegistry.registerDesignerLocales({
@@ -120,11 +119,3 @@ const Designables = () => {
120119
};
121120

122121
export default Designables;
123-
124-
// const container = document.getElementById('root')
125-
// if (container) {
126-
// const root = createRoot(container)
127-
// root.render(<App />)
128-
// } else {
129-
// console.error('dom root is non-existent')
130-
// }

src/components/Designable/widgets/MarkupSchemaWidget.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @ts-nocheck
2-
// 该文件不做 ESLint 检测
32
/* eslint-disable */
43
import { isEmpty, isPlainObj } from '@formily/shared';
54
import { TreeNode } from '@pind/designable-core';

src/components/Guide/Guide.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ interface Props {
66
name: string;
77
}
88

9-
// 脚手架示例组件
109
const Guide: React.FC<Props> = (props) => {
1110
const { name } = props;
1211
return (

src/layouts/RightContent.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const safeLocalStorage = {
99

1010
const RightContent = () => {
1111
const [messageApi, contextHolder] = message.useMessage();
12-
// NOTE: 多语言
1312
const intl = useIntl();
1413
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1514
const [localeType, setLocaleType] = useState(safeLocalStorage.getItem('umi_locale') || 'zh-CN');
@@ -46,7 +45,6 @@ const RightContent = () => {
4645
return (
4746
<>
4847
{contextHolder}
49-
{/* NOTE: user */}
5048
<Popover
5149
title=""
5250
trigger="hover"
@@ -72,7 +70,6 @@ const RightContent = () => {
7270

7371
<span className="mr-5 border-2 rounded-lg h-7" />
7472

75-
{/* NOTE: 换肤 */}
7673
<Popover
7774
trigger="hover"
7875
placement="bottom"
@@ -96,7 +93,6 @@ const RightContent = () => {
9693
<Button className="flex items-center justify-center" icon={<SkinOutlined />} />
9794
</Popover>
9895

99-
{/* NOTE: 多语言 */}
10096
<Popover
10197
className="mr-5 text-2xl"
10298
trigger="hover"
@@ -121,7 +117,6 @@ const RightContent = () => {
121117
<Button className="flex items-center justify-center" icon={<GlobalOutlined />} />
122118
</Popover>
123119

124-
{/* NOTE: GitHub 链接 */}
125120
<Button
126121
className="mr-6"
127122
icon={<GithubOutlined />}

src/models/global.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// 全局共享数据示例
21
import { DEFAULT_NAME } from '@/constants';
32
import { useState } from 'react';
43

src/pages/Feature/FullCalendar/event-utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EventInput } from '@fullcalendar/core';
22

33
let eventGuid = 0;
4-
let todayStr = new Date().toISOString().replace(/T.*$/, ''); // YYYY-MM-DD of today
4+
let todayStr = new Date().toISOString().replace(/T.*$/, '');
55

66
export function createEventId() {
77
return String(eventGuid++);

src/pages/Feature/FullCalendar/index.tsx

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
/**
2-
* FullCalendar 日历 官网: https://fullcalendar.io/
3-
* dayGridPlugin 月视图
4-
* timeGridPlugin 周视图
5-
* interactionPlugin 交互
6-
* multiMonthPlugin 多月视图
7-
* zhLocale 语言
8-
*/
91
import { ProCard } from '@ant-design/pro-components';
102
import { DateSelectArg, EventApi, EventClickArg, EventContentArg, formatDate } from '@fullcalendar/core';
113
import zhLocale from '@fullcalendar/core/locales/zh-cn';
12-
import dayGridPlugin from '@fullcalendar/daygrid'; // a plugin!
13-
import interactionPlugin from '@fullcalendar/interaction'; // needed for dayClick
4+
import dayGridPlugin from '@fullcalendar/daygrid';
5+
import interactionPlugin from '@fullcalendar/interaction';
146
import multiMonthPlugin from '@fullcalendar/multimonth';
157
import FullCalendar from '@fullcalendar/react';
168
import timeGridPlugin from '@fullcalendar/timegrid';
@@ -59,14 +51,10 @@ export default () => {
5951
return (
6052
<div className="demo-app-sidebar">
6153
<div className="demo-app-sidebar-section">
62-
{/* <h2>Instructions</h2> */}
6354
<h2>说明: </h2>
6455
<ul>
65-
{/* <li>Select dates and you will be prompted to create a new event</li> */}
6656
<li>选择日期,系统将提示您创建一个新事件</li>
67-
{/* <li>Drag, drop, and resize events</li> */}
6857
<li>拖放和调整事件大小</li>
69-
{/* <li>Click an event to delete it</li> */}
7058
<li>单击需要删除的事件</li>
7159
</ul>
7260
</div>
@@ -85,11 +73,11 @@ export default () => {
8573
};
8674

8775
const handleDateSelect = (selectInfo: DateSelectArg) => {
88-
// let title = prompt('Please enter a new title for your event');
8976
let title = prompt('请为您的活动输入一个新标题');
9077
let calendarApi = selectInfo.view.calendar;
9178

92-
calendarApi.unselect(); // clear date selection
79+
// 清除日期选中状态,避免多次触发选中高亮
80+
calendarApi.unselect();
9381

9482
if (title) {
9583
calendarApi.addEvent({
@@ -103,12 +91,7 @@ export default () => {
10391
};
10492

10593
const handleEventClick = (clickInfo: EventClickArg) => {
106-
if (
107-
confirm(
108-
// `Are you sure you want to delete the event '${clickInfo.event.title}'`,
109-
`您确定要删除事件吗 '${clickInfo.event.title}'`,
110-
)
111-
) {
94+
if (confirm(`您确定要删除事件吗 '${clickInfo.event.title}'`)) {
11295
clickInfo.event.remove();
11396
}
11497
};
@@ -124,43 +107,26 @@ export default () => {
124107
<ProCard className="shadow-2xl">
125108
<div className="demo-app">
126109
<FullCalendar
127-
// 语言
128110
locale={zhLocale}
129-
// 插件
130111
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin, multiMonthPlugin]}
131112
headerToolbar={{
132113
left: 'prev,next today',
133114
center: 'title',
134115
right: 'multiMonthYear,dayGridMonth,timeGridWeek,timeGridDay',
135116
}}
136-
// 初始视图
137117
initialView="dayGridMonth"
138118
editable={true}
139119
selectable={true}
140120
selectMirror={true}
141121
dayMaxEvents={true}
142-
// 日期
143-
// weekends={false}
144122
weekends={state.weekendsVisible}
145-
initialEvents={INITIAL_EVENTS} // 或者,使用' events '设置从提要中获取
123+
// 使用静态初始事件;也可改为 events 属性从远程接口拉取
124+
initialEvents={INITIAL_EVENTS}
146125
select={handleDateSelect}
147-
eventContent={renderEventContent} // 自定义渲染功能
126+
eventContent={renderEventContent}
148127
eventClick={handleEventClick}
149-
eventsSet={handleEvents} // 在事件初始化/添加/更改/删除后调用
150-
// 事件
151-
// events={[
152-
// { title: 'event 1', date: '2023-08-15' },
153-
// { title: 'event 2', date: '2019-04-02' },
154-
// ]}
155-
// 点击日期
156-
dateClick={(arg) => {
157-
// alert(arg.dateStr)
158-
}}
159-
/* 你可以在这些触发时更新远程数据库:
160-
eventAdd={function(){}}
161-
eventChange={function(){}}
162-
eventRemove={function(){}}
163-
*/
128+
// 事件初始化/添加/更改/删除后均会触发,用于同步侧边栏事件列表
129+
eventsSet={handleEvents}
164130
/>
165131
<div className="shadow-2xl p-8 m-8">{renderSidebar()}</div>
166132
</div>

src/pages/Feature/Map/Cesium/Cesium.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import * as Cesium from 'cesium';
22

3-
// NOTE: 这里的 CesiumMap 类是对 Cesium.Viewer 的封装,方便使用
43
class CesiumMap {
5-
private viewer: Cesium.Viewer; // Cesium.Viewer 实例
6-
private cesiumContainer: string; // 容器 ID
4+
private viewer: Cesium.Viewer;
5+
private cesiumContainer: string;
76

8-
// 构造函数
97
constructor(cesiumContainer: string) {
108
this.cesiumContainer = cesiumContainer;
119
this.viewer = this.initViewer();
1210
}
1311

14-
// 初始化 Viewer
1512
private initViewer() {
13+
// 每个 Viewer 实例需独立设置 token,确保在 app.tsx 全局初始化之外也能正常鉴权
1614
Cesium.Ion.defaultAccessToken = process.env.CESIUM_ION_TOKEN as string;
1715
return new Cesium.Viewer(this.cesiumContainer, {
1816
animation: false,
@@ -33,12 +31,10 @@ class CesiumMap {
3331
});
3432
}
3533

36-
// 获取 Viewer 实例
3734
public getViewer() {
3835
return this.viewer;
3936
}
4037

41-
// 销毁 Viewer
4238
public destroy() {
4339
this.viewer.destroy();
4440
}

0 commit comments

Comments
 (0)