Skip to content

Commit 0c78e71

Browse files
authored
Merge pull request #77 from guanweiwang/main
添加 允许成员自主注册
2 parents d845f03 + 6acf269 commit 0c78e71

File tree

8 files changed

+60
-15
lines changed

8 files changed

+60
-15
lines changed

ui/src/api/types.ts

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export interface DomainCustomOAuth {
190190
access_token_url?: string;
191191
/** 自定义OAuth授权URL */
192192
authorize_url?: string;
193-
/** 用户信息回包中的头像URL字段名` */
193+
/** 用户信息回包中的头像URL字段名 */
194194
avatar_field?: string;
195195
/** 自定义客户端ID */
196196
client_id?: string;
@@ -202,7 +202,32 @@ export interface DomainCustomOAuth {
202202
enable?: boolean;
203203
/** 用户信息回包中的ID字段名 */
204204
id_field?: string;
205-
/** 用户信息回包中的用户名字段名` */
205+
/** 用户信息回包中的用户名字段名 */
206+
name_field?: string;
207+
/** 自定义OAuth Scope列表 */
208+
scopes?: string[];
209+
/** 自定义OAuth用户信息URL */
210+
userinfo_url?: string;
211+
}
212+
213+
export interface DomainCustomOAuthReq {
214+
/** 自定义OAuth访问令牌URL */
215+
access_token_url?: string;
216+
/** 自定义OAuth授权URL */
217+
authorize_url?: string;
218+
/** 用户信息回包中的头像URL字段名 */
219+
avatar_field?: string;
220+
/** 自定义客户端ID */
221+
client_id?: string;
222+
/** 自定义客户端密钥 */
223+
client_secret?: string;
224+
/** 用户信息回包中的邮箱字段名 */
225+
email_field?: string;
226+
/** 自定义OAuth开关 */
227+
enable?: boolean;
228+
/** 用户信息回包中的ID字段名 */
229+
id_field?: string;
230+
/** 用户信息回包中的用户名字段名 */
206231
name_field?: string;
207232
/** 自定义OAuth Scope列表 */
208233
scopes?: string[];
@@ -219,6 +244,15 @@ export interface DomainDingtalkOAuth {
219244
enable?: boolean;
220245
}
221246

247+
export interface DomainDingtalkOAuthReq {
248+
/** 钉钉客户端ID */
249+
client_id?: string;
250+
/** 钉钉客户端密钥 */
251+
client_secret?: string;
252+
/** 钉钉OAuth开关 */
253+
enable?: boolean;
254+
}
255+
222256
export interface DomainIPInfo {
223257
/** ASN */
224258
asn?: string;
@@ -397,6 +431,8 @@ export interface DomainSetting {
397431
dingtalk_oauth?: DomainDingtalkOAuth;
398432
/** 是否禁用密码登录 */
399433
disable_password_login?: boolean;
434+
/** 是否开启自动登录 */
435+
enable_auto_login?: boolean;
400436
/** 是否开启SSO */
401437
enable_sso?: boolean;
402438
/** 是否强制两步验证 */
@@ -484,11 +520,13 @@ export interface DomainUpdateModelReq {
484520

485521
export interface DomainUpdateSettingReq {
486522
/** 自定义OAuth配置 */
487-
custom_oauth?: DomainCustomOAuth;
523+
custom_oauth?: DomainCustomOAuthReq;
488524
/** 钉钉OAuth配置 */
489-
dingtalk_oauth?: DomainDingtalkOAuth;
525+
dingtalk_oauth?: DomainDingtalkOAuthReq;
490526
/** 是否禁用密码登录 */
491527
disable_password_login?: boolean;
528+
/** 是否开启自动登录 */
529+
enable_auto_login?: boolean;
492530
/** 是否开启SSO */
493531
enable_sso?: boolean;
494532
/** 是否强制两步验证 */

ui/src/components/header/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Button, IconButton, Stack } from '@mui/material';
22
import { Icon, message } from '@c-x/ui';
3-
import { useNavigate } from 'react-router-dom';
3+
import { useNavigate, useLocation } from 'react-router-dom';
44
import LogoutIcon from '@mui/icons-material/Logout';
55
import DownloadIcon from '@mui/icons-material/Download';
66
import { Box } from '@mui/material';
77
import Bread from './Bread';
88

99
const Header = () => {
1010
const navigate = useNavigate();
11-
11+
const { pathname } = useLocation();
1212
return (
1313
<Stack
1414
direction={'row'}
@@ -44,11 +44,10 @@ const Header = () => {
4444
},
4545
}}
4646
onClick={() => {
47-
// 清除本地存储的认证信息
48-
localStorage.removeItem('auth_token');
49-
localStorage.removeItem('user_info');
5047
message.success('退出登录成功');
51-
navigate('/login', { replace: true });
48+
navigate(pathname.startsWith('/user/') ? '/user/login' : '/login', {
49+
replace: true,
50+
});
5251
}}
5352
>
5453
<LogoutIcon sx={{ fontSize: 16 }} />

ui/src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ a {
3636
text-overflow: ellipsis;
3737
white-space: nowrap;
3838
overflow: hidden;
39+
min-width: 0;
3940
}
4041

4142
.multiline-ellipsis {

ui/src/layouts/mainLayout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const MainLayout = () => {
5151
}}
5252
>
5353
<Sidebar />
54-
<Stack gap={2} sx={{ flex: 1, mr: 2, ml: 0 }}>
54+
<Stack gap={2} sx={{ flex: 1, minWidth: 0, mr: 2, ml: 0 }}>
5555
<Header />
5656
<Box
5757
sx={{

ui/src/pages/dashboard/components/memberStatistic.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ const MemberStatistic = ({
124124
container
125125
spacing={2}
126126
sx={{
127-
height: '100%',
128-
overflow: 'auto',
127+
overflowY: 'auto',
129128
borderRadius: '10px',
130129
}}
131130
>

ui/src/pages/user-management/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ const User = () => {
110110
配置
111111
</Button>
112112
</StyledCard>
113+
<StyledCard>
114+
<StyledLabel>允许成员自主注册</StyledLabel>
115+
<Switch
116+
checked={data?.enable_auto_login}
117+
onChange={(e) =>
118+
updateSetting({ enable_auto_login: e.target.checked })
119+
}
120+
/>
121+
</StyledCard>
113122
<LoginHistory />
114123
</Stack>
115124
</Grid>

ui/src/pages/user-management/loginHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const LoginHistory = () => {
6161
},
6262
];
6363
return (
64-
<Card sx={{ flex: 1, height: 'calc(100% - 258px)' }}>
64+
<Card sx={{ flex: 1, height: 'calc(100% - 358px)' }}>
6565
<Stack
6666
direction='row'
6767
justifyContent='space-between'

ui/src/pages/user/dashboard/components/memberStatistic.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ const MemberStatistic = ({
120120
container
121121
spacing={2}
122122
sx={{
123-
height: '100%',
124123
overflow: 'auto',
125124
borderRadius: '10px',
126125
}}

0 commit comments

Comments
 (0)