Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs_vsofpm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wuhao
cs_vsofpm
Commits
6b170a4e
Commit
6b170a4e
authored
May 11, 2023
by
wuhao
🎯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asder
parent
10337167
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
697 additions
and
12 deletions
+697
-12
routes.ts
config/routes.ts
+5
-0
sxcard.jsx
src/components/ProductCard/sxcard.jsx
+1
-1
config.jsx
src/layouts/dashboard/nav/config.jsx
+1
-1
index.jsx
src/pages/bustrain/index.jsx
+114
-3
index.jsx
src/pages/lessons/index.jsx
+13
-7
index.jsx
src/pages/mybustrain/index.jsx
+433
-0
index.less
src/pages/mybustrain/index.less
+8
-0
pickColor.js
src/utils/pickColor.js
+122
-0
No files found.
config/routes.ts
View file @
6b170a4e
...
...
@@ -109,6 +109,11 @@ export default [
path
:
"/work/dobustrain/:id"
,
component
:
"./dobustrain"
,
},
{
name
:
"我的实训"
,
path
:
"/work/mybustrain"
,
component
:
"./mybustrain"
,
},
],
},
{
...
...
src/components/ProductCard/sxcard.jsx
View file @
6b170a4e
...
...
@@ -70,7 +70,7 @@ export default function ShopProductCard({
<
Label
variant=
"filled"
color=
{
(
type
===
1
&&
"warning"
)
||
(
type
===
3
&&
"default"
)
||
"info
"
(
type
===
1
&&
"warning"
)
||
(
type
===
2
&&
"info"
)
||
(
type
===
3
&&
"default"
)
||
(
type
===
4
&&
"error"
)
||
"danger
"
}
sx=
{
{
zIndex
:
9
,
...
...
src/layouts/dashboard/nav/config.jsx
View file @
6b170a4e
...
...
@@ -41,7 +41,7 @@ const navConfig = [
children
:[
{
title
:
"我的实训"
,
path
:
"/work/
usera
"
,
path
:
"/work/
mybustrain
"
,
icon
:
icon
(
"ic_training"
),
},
{
...
...
src/pages/bustrain/index.jsx
View file @
6b170a4e
...
...
@@ -7,11 +7,15 @@ import ShopProductCard from "@/components/ProductCard/sxcard";
import
{
doFetch
}
from
"@/utils/doFetch"
;
import
PRODUCTS
from
"@/_mock/products"
;
import
{
Box
,
Container
,
Grid
,
Stack
,
Typography
}
from
"@mui/material"
;
import
Checkbox
from
"@mui/material/Checkbox"
;
import
FormControlLabel
from
"@mui/material/FormControlLabel"
;
import
FormGroup
from
"@mui/material/FormGroup"
;
import
{
useRequest
}
from
"ahooks"
;
import
{
Empty
,
message
}
from
"antd"
;
import
{
Empty
,
Input
,
message
}
from
"antd"
;
import
{
useMemo
,
useState
}
from
"react"
;
import
"./index.less"
;
function
Lessons
()
{
const
[
dialogprops
,
setdialogprops
]
=
useState
({
open
:
false
,
...
...
@@ -19,7 +23,7 @@ function Lessons() {
const
[
params
,
setparams
]
=
useState
({
trainName
:
""
,
status
:
null
,
type
:
null
,
type
List
:
[
"1"
,
"2"
,
"3"
,
"4"
,
"5"
]
,
});
const
handleClose
=
()
=>
{
...
...
@@ -42,16 +46,18 @@ function Lessons() {
const
datalist
=
useRequest
(
async
()
=>
{
let
res
=
await
doFetch
({
url
:
"/busTrain/list"
,
params
});
return
res
?.
data
?.
dataList
;
},
{
debounceWait
:
400
,
refreshDeps
:
[
params
],
}
);
const
edit
=
(
row
)
=>
{
console
.
log
(
row
);
setdialogprops
({
open
:
true
,
defaultFormValue
:
{
...
row
},
...
...
@@ -258,6 +264,111 @@ function Lessons() {
>
<
Typography
variant=
"h5"
>
实训管理
</
Typography
>
<
Stack
spacing=
{
2
}
direction=
"row"
>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
length
===
5
}
indeterminate=
{
params
?.
typeList
?.
length
>
0
&&
params
?.
typeList
?.
length
<
5
}
/>
}
label=
"全部"
onChange=
{
(
e
)
=>
{
setparams
((
s
)
=>
{
let
news
=
[];
if
(
e
.
target
.
checked
)
{
news
=
[
"1"
,
"2"
,
"3"
,
"4"
,
"5"
];
}
return
{
...
s
,
typeList
:
news
,
};
});
}
}
/>
<
FormGroup
row
value=
{
params
?.
typeList
??
[]
}
onChange=
{
(
e
)
=>
{
let
val
=
e
.
target
.
value
;
setparams
((
s
)
=>
{
let
news
=
[...
s
?.
typeList
];
if
(
news
.
includes
(
val
))
{
news
=
news
.
filter
((
it
)
=>
it
!==
val
);
}
else
{
news
=
[...
news
,
val
];
}
console
.
log
(
news
);
return
{
...
s
,
typeList
:
news
,
};
});
}
}
>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"1"
)
}
color=
{
"warning"
}
/>
}
label=
"待发布"
value=
{
1
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"2"
)
}
color=
{
"info"
}
/>
}
label=
"已发布"
value=
{
2
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"3"
)
}
color=
{
"default"
}
/>
}
label=
"已发布(暂停)"
value=
{
3
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"4"
)
}
color=
{
"default"
}
/>
}
label=
"已结束"
value=
{
4
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"5"
)
}
color=
{
"default"
}
/>
}
label=
"已关闭"
value=
{
5
}
/>
</
FormGroup
>
<
Input
placeholder=
"请输入课程名称"
style=
{
{
width
:
200
}
}
value=
{
params
?.
trainName
}
onChange=
{
(
e
)
=>
{
setparams
((
s
)
=>
({
...
s
,
trainName
:
e
.
target
.
value
,
}));
}
}
></
Input
>
<
ImportExcel
></
ImportExcel
>
<
PremButton
btn=
{
{
...
...
src/pages/lessons/index.jsx
View file @
6b170a4e
...
...
@@ -5,6 +5,7 @@ import PremButton from "@/components/PremButton";
import
ShopProductCard
from
"@/components/ProductCard"
;
import
ShopProductLoadingCard
from
"@/components/ProductCard/loading"
;
import
{
doFetch
}
from
"@/utils/doFetch"
;
import
generateColor
from
"@/utils/pickColor"
;
import
PRODUCTS
from
"@/_mock/products"
;
import
{
Box
,
Container
,
Grid
,
Stack
,
Typography
}
from
"@mui/material"
;
import
Checkbox
from
"@mui/material/Checkbox"
;
...
...
@@ -50,7 +51,7 @@ function Lessons() {
},
{
debounceWait
:
400
,
refreshDeps
:
[
params
]
refreshDeps
:
[
params
],
}
);
...
...
@@ -312,12 +313,17 @@ function Lessons() {
/>
</
FormGroup
>
<
Input
placeholder=
"请输入课程名称"
style=
{
{
width
:
200
}
}
value=
{
params
?.
courseName
}
onChange=
{
(
e
)
=>
{
setparams
(
s
=>
({
...
s
,
courseName
:
e
.
target
.
value
}))
}
}
></
Input
>
<
Input
placeholder=
"请输入课程名称"
style=
{
{
width
:
200
}
}
value=
{
params
?.
courseName
}
onChange=
{
(
e
)
=>
{
setparams
((
s
)
=>
({
...
s
,
courseName
:
e
.
target
.
value
,
}));
}
}
></
Input
>
<
ImportExcel
></
ImportExcel
>
...
...
src/pages/mybustrain/index.jsx
0 → 100644
View file @
6b170a4e
import
DraggableDialog
from
"@/components/DraggableDialog"
;
import
ImportExcel
from
"@/components/ImportExcel"
;
import
InitForm
from
"@/components/InitForm"
;
import
PremButton
from
"@/components/PremButton"
;
import
ShopProductLoadingCard
from
"@/components/ProductCard/loading"
;
import
ShopProductCard
from
"@/components/ProductCard/sxcard"
;
import
{
doFetch
}
from
"@/utils/doFetch"
;
import
PRODUCTS
from
"@/_mock/products"
;
import
{
Box
,
Container
,
Grid
,
Stack
,
Typography
}
from
"@mui/material"
;
import
Checkbox
from
"@mui/material/Checkbox"
;
import
FormControlLabel
from
"@mui/material/FormControlLabel"
;
import
FormGroup
from
"@mui/material/FormGroup"
;
import
{
useRequest
}
from
"ahooks"
;
import
{
Empty
,
Input
,
message
}
from
"antd"
;
import
{
useMemo
,
useState
}
from
"react"
;
import
"./index.less"
;
function
Lessons
()
{
const
[
dialogprops
,
setdialogprops
]
=
useState
({
open
:
false
,
});
const
[
params
,
setparams
]
=
useState
({
trainName
:
""
,
status
:
null
,
typeList
:
[
"1"
,
"2"
,
"3"
,
"4"
,
"5"
],
});
const
handleClose
=
()
=>
{
setdialogprops
((
s
)
=>
({
...
s
,
open
:
false
,
}));
};
const
{
runAsync
,
loading
}
=
useRequest
(
doFetch
,
{
manual
:
true
,
onSuccess
:
(
res
,
parames
)
=>
{
if
(
res
?.
code
==
"0000"
)
{
handleClose
();
message
.
success
(
"操作成功"
);
datalist
?.
refresh
();
}
},
});
const
datalist
=
useRequest
(
async
()
=>
{
let
res
=
await
doFetch
({
url
:
"/busTrain/list"
,
params
});
return
res
?.
data
?.
dataList
;
},
{
debounceWait
:
400
,
refreshDeps
:
[
params
],
}
);
const
edit
=
(
row
)
=>
{
setdialogprops
({
open
:
true
,
defaultFormValue
:
{
...
row
},
title
:
"编辑"
,
});
};
const
authorized
=
(
row
)
=>
{
doFetch
({
url
:
"/trainStudent/queryRelationStudent"
,
params
:
{
trainId
:
row
?.
id
},
}).
then
((
res
)
=>
{
if
(
res
.
code
===
"0000"
)
{
setdialogprops
({
open
:
true
,
maxWidth
:
"xl"
,
defaultFormValue
:
{
...
row
},
studentIdList
:
res
?.
data
?.
dataList
,
title
:
"授权"
,
});
}
});
};
const
remove
=
(
row
)
=>
{
runAsync
({
url
:
"/busTrain/delete"
,
params
:
{
id
:
row
.
id
},
});
};
const
publish
=
(
row
,
params
)
=>
{
const
type
=
row
?.
type
===
1
?
2
:
row
?.
type
===
2
?
1
:
null
;
const
extra
=
params
??
{
type
};
runAsync
({
url
:
"/busTrain/pubOrNotPub"
,
params
:
{
id
:
row
.
id
,
...
extra
},
});
};
const
columns
=
useMemo
(
()
=>
[
{
title
:
"课程"
,
dataIndex
:
"courseId"
,
key
:
"courseId"
,
valueType
:
"select"
,
options
:
{
path
:
"/sysCourse/getLoginTeacherCourseSection"
,
params
:
{},
},
colProps
:
{
span
:
24
,
},
},
{
title
:
"实训名称"
,
dataIndex
:
"trainName"
,
key
:
"trainName"
},
{
title
:
"截止日期"
,
dataIndex
:
"deadline"
,
key
:
"deadline"
,
valueType
:
"date"
,
},
{
title
:
"实训封面"
,
dataIndex
:
"pic"
,
key
:
"pic"
,
valueType
:
"uploadImage"
,
fieldProps
:
{
limit
:
1
,
},
colProps
:
{
span
:
24
,
},
},
],
[]
);
return
(
<
Container
maxWidth=
{
false
}
>
<
DraggableDialog
handleClose=
{
handleClose
}
loading=
{
loading
}
dialogprops=
{
dialogprops
}
maxWidth=
{
dialogprops
?.
maxWidth
??
"xs"
}
>
{
dialogprops
?.
title
===
"编辑"
||
dialogprops
?.
title
===
"新增实训"
?
(
<
InitForm
fields=
{
columns
}
defaultFormValue=
{
dialogprops
?.
defaultFormValue
}
onValuesChange=
{
async
(
changedValues
,
allValues
,
formRef
)
=>
{
console
.
log
(
changedValues
);
if
(
Object
.
keys
(
changedValues
)[
0
]
===
"courseId"
)
{
let
id
=
Object
.
values
(
changedValues
)?.[
0
]
??
null
;
let
res
=
await
doFetch
({
url
:
"/sysCourse/detail"
,
params
:
{
id
},
});
let
pic
=
res
?.
data
?.
data
?.
pic
??
[];
console
.
log
(
pic
);
formRef
?.
current
?.
setFieldsValue
({
pic
:
[
{
uid
:
"1655501390426017792"
,
url
:
"https://ng-website.oss-cn-hangzhou.aliyuncs.com/2023/05/08/1655501389482299392Bl6w2X.jpg"
,
name
:
"a1.jpg"
,
},
],
});
}
}
}
onFinish=
{
(
val
,
extra
)
=>
{
let
postdata
=
{
...
val
},
url
=
"/busTrain/saveOrUpdate"
;
switch
(
dialogprops
?.
title
)
{
case
"编辑"
:
postdata
=
{
...
val
,
id
:
dialogprops
?.
defaultFormValue
?.
id
,
};
break
;
default
:
break
;
}
runAsync
({
url
,
params
:
postdata
,
});
}
}
></
InitForm
>
)
:
(
<
InitForm
defaultFormValue=
{
{
studentIdList
:
dialogprops
?.
studentIdList
,
}
}
fields=
{
[
{
rowKey
:
"id"
,
rowName
:
"id"
,
valueType
:
"FormSelectList"
,
dataIndex
:
"studentIdList"
,
colProps
:
{
span
:
24
,
},
columns
:
[
{
title
:
"账号"
,
key
:
"userAccount"
,
dataIndex
:
"userAccount"
,
editable
:
false
,
},
{
title
:
"学生姓名"
,
key
:
"name"
,
dataIndex
:
"name"
,
editable
:
false
,
},
{
title
:
"学校名称"
,
key
:
"schoolId"
,
dataIndex
:
"schoolName"
,
valueType
:
"select"
,
search
:
false
,
editable
:
false
,
},
{
title
:
"院系名称"
,
key
:
"departmentName"
,
dataIndex
:
"departmentName"
,
editable
:
false
,
},
{
title
:
"班级名称"
,
key
:
"className"
,
dataIndex
:
"className"
,
editable
:
false
,
},
],
path
:
"/user/getAllStudentByCurrentTeacherSchool"
,
params
:
{
type
:
"3"
,
},
},
]
}
onFinish=
{
(
val
)
=>
{
const
studentIdList
=
val
?.
studentIdList
?.
map
((
it
)
=>
it
?.
id
);
runAsync
({
url
:
"/trainStudent/relationTrainStudent"
,
params
:
{
studentIdList
,
trainId
:
dialogprops
?.
defaultFormValue
?.
id
,
},
});
}
}
/>
)
}
</
DraggableDialog
>
<
Box
display=
{
"flex"
}
justifyContent=
{
"space-between"
}
alignItems=
{
"center"
}
sx=
{
{
mb
:
2.5
}
}
mt=
{
0
}
>
<
Typography
variant=
"h5"
>
实训管理
</
Typography
>
<
Stack
spacing=
{
2
}
direction=
"row"
>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
length
===
5
}
indeterminate=
{
params
?.
typeList
?.
length
>
0
&&
params
?.
typeList
?.
length
<
5
}
/>
}
label=
"全部"
onChange=
{
(
e
)
=>
{
setparams
((
s
)
=>
{
let
news
=
[];
if
(
e
.
target
.
checked
)
{
news
=
[
"1"
,
"2"
,
"3"
,
"4"
,
"5"
];
}
return
{
...
s
,
typeList
:
news
,
};
});
}
}
/>
<
FormGroup
row
value=
{
params
?.
typeList
??
[]
}
onChange=
{
(
e
)
=>
{
let
val
=
e
.
target
.
value
;
setparams
((
s
)
=>
{
let
news
=
[...
s
?.
typeList
];
if
(
news
.
includes
(
val
))
{
news
=
news
.
filter
((
it
)
=>
it
!==
val
);
}
else
{
news
=
[...
news
,
val
];
}
console
.
log
(
news
);
return
{
...
s
,
typeList
:
news
,
};
});
}
}
>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"1"
)
}
color=
{
"warning"
}
/>
}
label=
"待发布"
value=
{
1
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"2"
)
}
color=
{
"info"
}
/>
}
label=
"已发布"
value=
{
2
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"3"
)
}
color=
{
"default"
}
/>
}
label=
"已发布(暂停)"
value=
{
3
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"4"
)
}
color=
{
"default"
}
/>
}
label=
"已结束"
value=
{
4
}
/>
<
FormControlLabel
control=
{
<
Checkbox
checked=
{
params
?.
typeList
?.
includes
(
"5"
)
}
color=
{
"default"
}
/>
}
label=
"已关闭"
value=
{
5
}
/>
</
FormGroup
>
<
Input
placeholder=
"请输入课程名称"
style=
{
{
width
:
200
}
}
value=
{
params
?.
trainName
}
onChange=
{
(
e
)
=>
{
setparams
((
s
)
=>
({
...
s
,
trainName
:
e
.
target
.
value
,
}));
}
}
></
Input
>
<
ImportExcel
></
ImportExcel
>
<
PremButton
btn=
{
{
variant
:
"contained"
,
onClick
:
(
e
)
=>
{
e
.
stopPropagation
();
setdialogprops
({
open
:
true
,
defaultFormValue
:
{},
title
:
"新增实训"
,
});
},
}
}
>
新增实训
</
PremButton
>
</
Stack
>
</
Box
>
<
Box
mt=
{
2.5
}
>
<
Grid
container
spacing=
{
3
}
>
{
datalist
?.
loading
&&
!
datalist
?.
data
?
(
PRODUCTS
?.
map
((
product
,
i
)
=>
{
return
(
<
Grid
key=
{
product
.
id
}
item
xs=
{
12
}
sm=
{
6
}
md=
{
4
}
lg=
{
3
}
xl=
{
2.4
}
>
<
ShopProductLoadingCard
product=
{
product
}
/>
</
Grid
>
);
})
)
:
datalist
?.
data
?.
length
===
0
?
(
<
Grid
xs=
{
12
}
mt=
{
12
}
>
<
Empty
></
Empty
>
</
Grid
>
)
:
(
datalist
?.
data
?.
map
?.((
product
)
=>
(
<
Grid
key=
{
product
.
id
}
item
xs=
{
12
}
sm=
{
6
}
md=
{
4
}
lg=
{
3
}
xl=
{
2.4
}
>
<
ShopProductCard
product=
{
product
}
loading=
{
datalist
?.
loading
}
edit=
{
edit
}
remove=
{
remove
}
publish=
{
publish
}
authorized=
{
authorized
}
/>
</
Grid
>
))
)
}
</
Grid
>
</
Box
>
</
Container
>
);
}
export
default
Lessons
;
src/pages/mybustrain/index.less
0 → 100644
View file @
6b170a4e
.white {
.ant-pro-card {
background-color: #f6f6f6 !important;
}
.ant-table-tbody,td {
background-color: #f9f9f9 !important;
}
}
src/utils/pickColor.js
0 → 100644
View file @
6b170a4e
export
default
function
generateColor
(
baseColor
)
{
// 生成背景色
const
backgroundColor
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
// 计算附加色 1
const
color1
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
color1
.
r
-=
Math
.
round
((
color1
.
r
-
baseColor
.
r
)
*
0.25
);
color1
.
g
-=
Math
.
round
((
color1
.
g
-
baseColor
.
g
)
*
0.25
);
color1
.
b
-=
Math
.
round
((
color1
.
b
-
baseColor
.
b
)
*
0.25
);
// 计算附加色 2
const
color2
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
color2
.
r
-=
Math
.
round
((
color2
.
r
-
baseColor
.
r
)
*
0.5
);
color2
.
g
-=
Math
.
round
((
color2
.
g
-
baseColor
.
g
)
*
0.5
);
color2
.
b
-=
Math
.
round
((
color2
.
b
-
baseColor
.
b
)
*
0.5
);
// 计算警告色
const
warningColor
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
warningColor
.
r
-=
Math
.
round
((
warningColor
.
r
-
baseColor
.
r
)
*
0.3
);
warningColor
.
g
-=
Math
.
round
((
warningColor
.
g
-
baseColor
.
g
)
*
0.3
);
warningColor
.
b
-=
Math
.
round
((
warningColor
.
b
-
baseColor
.
b
)
*
0.3
);
// 计算成功色
const
successColor
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
successColor
.
r
-=
Math
.
round
((
successColor
.
r
-
baseColor
.
r
)
*
0.2
);
successColor
.
g
-=
Math
.
round
((
successColor
.
g
-
baseColor
.
g
)
*
0.2
);
successColor
.
b
-=
Math
.
round
((
successColor
.
b
-
baseColor
.
b
)
*
0.2
);
// 计算失败色
const
failureColor
=
{
r
:
255
,
g
:
255
,
b
:
255
,
};
failureColor
.
r
-=
Math
.
round
((
failureColor
.
r
-
baseColor
.
r
)
*
0.2
);
failureColor
.
g
-=
Math
.
round
((
failureColor
.
g
-
baseColor
.
g
)
*
0.2
);
failureColor
.
b
-=
Math
.
round
((
failureColor
.
b
-
baseColor
.
b
)
*
0.2
);
// 转换为十六进制颜色值
function
rgbToHex
(
rgbColor
)
{
const
{
r
,
g
,
b
}
=
rgbColor
;
const
red
=
Math
.
round
(
r
);
const
green
=
Math
.
round
(
g
);
const
blue
=
Math
.
round
(
b
);
const
hexRed
=
red
.
toString
(
16
).
padStart
(
2
,
"0"
);
const
hexGreen
=
green
.
toString
(
16
).
padStart
(
2
,
"0"
);
const
hexBlue
=
blue
.
toString
(
16
).
padStart
(
2
,
"0"
);
return
`#
${
hexRed
}${
hexGreen
}${
hexBlue
}
`
;
}
const
hexBaseColor
=
baseColor
;
const
hexBackgroundColor
=
rgbToHex
(
backgroundColor
);
const
hexColor1
=
rgbToHex
(
color1
);
const
hexColor2
=
rgbToHex
(
color2
);
const
hexWarningColor
=
rgbToHex
(
warningColor
);
const
hexSuccessColor
=
rgbToHex
(
successColor
);
const
hexFailureColor
=
rgbToHex
(
failureColor
);
return
{
baseColor
:
hexBaseColor
,
backgroundColor
:
hexBackgroundColor
,
color1
:
hexColor1
,
color2
:
hexColor2
,
warningColor
:
hexWarningColor
,
successColor
:
hexSuccessColor
,
failureColor
:
hexFailureColor
,
};
}
function
generateColorScheme
(
baseColor
)
{
// 将基础色转换为 RGB 格式
const
rgbBaseColor
=
hexToRGB
(
baseColor
);
// 生成配色方案
const
colorScheme
=
{
baseColor
:
baseColor
,
backgroundColor
:
rgbBaseColor
,
color1
:
""
,
color2
:
""
,
warningColor
:
""
,
successColor
:
""
,
failureColor
:
""
,
};
// 生成其他颜色
const
colors
=
[
{
name
:
"color1"
,
offset
:
0.25
},
{
name
:
"color2"
,
offset
:
0.5
},
{
name
:
"warningColor"
,
offset
:
0.3
},
{
name
:
"successColor"
,
offset
:
0.2
},
{
name
:
"failureColor"
,
offset
:
0.2
},
];
for
(
const
color
of
colors
)
{
const
newColor
=
generateOffsetColor
(
rgbBaseColor
,
color
.
offset
);
colorScheme
[
color
.
name
]
=
rgbToHex
(
newColor
);
}
return
colorScheme
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment