Skip to content

Commit 0cb33da

Browse files
committed
feat: ui add system settings
1 parent 40df595 commit 0cb33da

File tree

37 files changed

+3318
-144
lines changed

37 files changed

+3318
-144
lines changed

apps/users/views/login.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
from users.api.login import LoginAPI, CaptchaAPI
1818
from users.serializers.login import LoginSerializer, CaptchaSerializer
1919

20+
2021
def _get_details(request):
2122
path = request.path
2223
body = request.data
2324
query = request.query_params
2425
return {
25-
'path':path,
26-
'body':{**body, 'password': encryption(body.get('password',''))},
26+
'path': path,
27+
'body': {**body, 'password': encryption(body.get('password', ''))},
2728
'query': query
2829
}
2930

31+
3032
class LoginView(APIView):
3133
@extend_schema(methods=['POST'],
3234
description=_("Log in"),
@@ -37,7 +39,7 @@ class LoginView(APIView):
3739
responses=LoginAPI.get_response())
3840
@log(menu='User management', operate='Log in', get_user=lambda r: {'username': r.data.get('username', None)},
3941
get_details=_get_details,
40-
get_operation_object=lambda r,k: {'name': r.data.get('username')})
42+
get_operation_object=lambda r, k: {'name': r.data.get('username')})
4143
def post(self, request: Request):
4244
return result.success(LoginSerializer().login(request.data))
4345

apps/users/views/user.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ def get_user_operation_object(user_id):
3232
user_model = QuerySet(model=User).filter(id=user_id).first()
3333
if user_model is not None:
3434
return {
35-
"name":user_model.name
35+
"name": user_model.name
3636
}
3737
return {}
3838

39+
3940
def get_re_password_details(request):
4041
path = request.path
4142
body = request.data
4243
query = request.query_params
4344
return {
4445
"path": path,
4546
"body": {**body, 'password': encryption(body.get('password', '')),
46-
're_password': encryption(body.get('re_password',''))},
47+
're_password': encryption(body.get('re_password', ''))},
4748
"query": query
4849
}
4950

5051

51-
5252
class UserProfileView(APIView):
5353
authentication_classes = [TokenAuth]
5454

@@ -145,7 +145,7 @@ class Operate(APIView):
145145
responses=DefaultModelResponse.get_response())
146146
@has_permissions(PermissionConstants.USER_DELETE)
147147
@log(menu='User management', operate='Delete user',
148-
get_operation_object= lambda r,k: get_user_operation_object(k.get('user_id')))
148+
get_operation_object=lambda r, k: get_user_operation_object(k.get('user_id')))
149149
def delete(self, request: Request, user_id):
150150
return result.success(UserManageSerializer.Operate(data={'id': user_id}).delete(with_valid=True))
151151

@@ -185,7 +185,7 @@ class BatchDelete(APIView):
185185
responses=DefaultModelResponse.get_response())
186186
@has_permissions(PermissionConstants.USER_DELETE)
187187
@log(menu='User management', operate='Batch delete user',
188-
get_operation_object= lambda r,k: get_user_operation_object(k.get('user_id')))
188+
get_operation_object=lambda r, k: get_user_operation_object(k.get('user_id')))
189189
def post(self, request: Request):
190190
return result.success(UserManageSerializer.BatchDelete(data=request.data).batch_delete(with_valid=True))
191191

@@ -201,7 +201,7 @@ class RePassword(APIView):
201201
request=ChangeUserPasswordApi.get_request(),
202202
responses=DefaultModelResponse.get_response())
203203
@log(menu='User management', operate='Change password',
204-
get_operation_object= lambda r,k: get_user_operation_object(k.get('user_id')),
204+
get_operation_object=lambda r, k: get_user_operation_object(k.get('user_id')),
205205
get_details=get_re_password_details)
206206
def put(self, request: Request, user_id):
207207
return result.success(

ui/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
"@codemirror/lang-json": "^6.0.1",
1717
"@codemirror/lang-python": "^6.2.1",
1818
"@codemirror/theme-one-dark": "^6.1.2",
19+
"@wecom/jssdk": "^2.3.1",
1920
"axios": "^1.8.4",
21+
"dingtalk-jsapi": "^3.1.0",
2022
"element-plus": "^2.9.10",
2123
"nprogress": "^0.2.0",
2224
"pinia": "^3.0.1",
2325
"use-element-plus-theme": "^0.0.5",
2426
"vue": "^3.5.13",
27+
"vue-clipboard3": "^2.0.0",
2528
"vue-codemirror": "^6.1.1",
2629
"vue-i18n": "^11.1.3",
2730
"vue-router": "^4.5.0"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {Result} from '@/request/Result'
2+
import {get, post, put} from '@/request/index'
3+
import {type Ref} from 'vue'
4+
5+
const prefix = '/auth'
6+
/**
7+
* 获取认证设置
8+
*/
9+
const getAuthSetting: (auth_type: string, loading?: Ref<boolean>) => Promise<Result<any>> = (auth_type, loading) => {
10+
return get(`${prefix}/${auth_type}/detail`, undefined, loading)
11+
}
12+
13+
/**
14+
* ldap连接测试
15+
*/
16+
const postAuthSetting: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
17+
data,
18+
loading
19+
) => {
20+
return post(`${prefix}/connection`, data, undefined, loading)
21+
}
22+
23+
/**
24+
* 修改邮箱设置
25+
*/
26+
const putAuthSetting: (auth_type: string, data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
27+
auth_type,
28+
data,
29+
loading
30+
) => {
31+
return put(`${prefix}/${auth_type}/info`, data, undefined, loading)
32+
}
33+
34+
export default {
35+
getAuthSetting,
36+
postAuthSetting,
37+
putAuthSetting
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Result } from '@/request/Result'
2+
import { get, post, del, put } from '@/request/index'
3+
import type { pageRequest } from '@/api/type/common'
4+
import { type Ref } from 'vue'
5+
6+
const prefix = '/email_setting'
7+
/**
8+
* 获取邮箱设置
9+
*/
10+
const getEmailSetting: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
11+
return get(`${prefix}`, undefined, loading)
12+
}
13+
14+
/**
15+
* 邮箱测试
16+
*/
17+
const postTestEmail: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
18+
data,
19+
loading
20+
) => {
21+
return post(`${prefix}`, data, undefined, loading)
22+
}
23+
24+
/**
25+
* 修改邮箱设置
26+
*/
27+
const putEmailSetting: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
28+
data,
29+
loading
30+
) => {
31+
return put(`${prefix}`, data, undefined, loading)
32+
}
33+
34+
export default {
35+
getEmailSetting,
36+
postTestEmail,
37+
putEmailSetting
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Result } from '@/request/Result'
2+
import { get, post, del, put } from '@/request/index'
3+
import { type Ref } from 'vue'
4+
5+
const prefix = '/platform'
6+
const getPlatformInfo: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
7+
return get(`${prefix}/source`, undefined, loading)
8+
}
9+
10+
const updateConfig: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
11+
data,
12+
loading
13+
) => {
14+
return post(`${prefix}/source`, data, undefined, loading)
15+
}
16+
17+
const validateConnection: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
18+
data,
19+
loading
20+
) => {
21+
return put(`${prefix}/source`, data, undefined, loading)
22+
}
23+
export default {
24+
getPlatformInfo,
25+
updateConfig,
26+
validateConnection
27+
}

ui/src/api/systemSettings/theme.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {Result} from '@/request/Result'
2+
import {get, post, del, put} from '@/request/index'
3+
import type {Ref} from 'vue'
4+
5+
const prefix = '/display'
6+
7+
/**
8+
* 查看外观设置
9+
*/
10+
const getThemeInfo: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
11+
return get(`${prefix}/info`, undefined, loading)
12+
}
13+
14+
/**
15+
* 更新外观设置
16+
* @param 参数
17+
* * formData {
18+
* theme
19+
* icon
20+
* loginLogo
21+
* loginImage
22+
* title
23+
* slogan
24+
* }
25+
*/
26+
const postThemeInfo: (data: any, loading?: Ref<boolean>) => Promise<Result<boolean>> = (
27+
data,
28+
loading
29+
) => {
30+
return put(`${prefix}/update`, data, undefined, loading)
31+
}
32+
33+
export default {
34+
getThemeInfo,
35+
postThemeInfo
36+
}

ui/src/api/user/login.ts

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { Result } from '@/request/Result'
2-
import { get, post } from '@/request/index'
3-
import type { LoginRequest } from '@/api/type/login'
4-
import type { Ref } from 'vue'
1+
import {Result} from '@/request/Result'
2+
import {get, post} from '@/request/index'
3+
import type {LoginRequest} from '@/api/type/login'
4+
import type {Ref} from 'vue'
5+
import type {User} from "@/api/type/user.ts";
6+
57
/**
68
* 登录
79
* @param request 登录接口请求表单
@@ -15,6 +17,23 @@ const login: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<a
1517
return post('/user/login', request, undefined, loading)
1618
}
1719

20+
const ldapLogin: (request: LoginRequest, loading?: Ref<boolean>) => Promise<Result<any>> = (
21+
request,
22+
loading,
23+
) => {
24+
return post('/ldap/login', request, undefined, loading)
25+
}
26+
27+
28+
/**
29+
* 登出
30+
* @param loading 接口加载器
31+
* @returns
32+
*/
33+
const logout: (loading?: Ref<boolean>) => Promise<Result<boolean>> = (loading) => {
34+
return post('/user/logout', undefined, undefined, loading)
35+
}
36+
1837
/**
1938
* 获取验证码
2039
* @param loading 接口加载器
@@ -23,7 +42,75 @@ const getCaptcha: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) =
2342
return get('/user/captcha', undefined, loading)
2443
}
2544

45+
/**
46+
* 获取登录方式
47+
*/
48+
const getAuthType: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
49+
return get('auth/types', undefined, loading)
50+
}
51+
52+
/**
53+
* 获取二维码类型
54+
*/
55+
const getQrType: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
56+
return get('qr_type', undefined, loading)
57+
}
58+
59+
const getQrSource: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
60+
return get('qr_type/source', undefined, loading)
61+
}
62+
63+
const getDingCallback: (code: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
64+
code,
65+
loading
66+
) => {
67+
return get('dingtalk', {code}, loading)
68+
}
69+
70+
const getDingOauth2Callback: (code: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
71+
code,
72+
loading
73+
) => {
74+
return get('dingtalk/oauth2', {code}, loading)
75+
}
76+
77+
const getWecomCallback: (code: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
78+
code,
79+
loading
80+
) => {
81+
return get('wecom', {code}, loading)
82+
}
83+
const getLarkCallback: (code: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
84+
code,
85+
loading
86+
) => {
87+
return get('lark/oauth2', {code}, loading)
88+
}
89+
90+
/**
91+
* 设置语言
92+
* data: {
93+
* "language": "string"
94+
* }
95+
*/
96+
const postLanguage: (data: any, loading?: Ref<boolean>) => Promise<Result<User>> = (
97+
data,
98+
loading
99+
) => {
100+
return post('/user/language', data, undefined, loading)
101+
}
102+
26103
export default {
27104
login,
105+
logout,
28106
getCaptcha,
107+
getAuthType,
108+
getDingCallback,
109+
getQrType,
110+
getWecomCallback,
111+
postLanguage,
112+
getDingOauth2Callback,
113+
getLarkCallback,
114+
getQrSource,
115+
ldapLogin
29116
}

ui/src/api/user/user.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ const getUserProfile: (loading?: Ref<boolean>) => Promise<Result<User>> = (loadi
1212
return get('/user/profile', undefined, loading)
1313
}
1414

15+
/**
16+
* 获取profile
17+
*/
18+
const getProfile: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
19+
return get('/profile', undefined, loading)
20+
}
21+
1522
/**
1623
* 获取版本profile
1724
*/
@@ -21,4 +28,5 @@ const getUserProfile: (loading?: Ref<boolean>) => Promise<Result<User>> = (loadi
2128

2229
export default {
2330
getUserProfile,
31+
getProfile
2432
}
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)