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
7e294f1b
Commit
7e294f1b
authored
May 26, 2023
by
wuhao
🎯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
usdar
parent
2f4c0ca3
Pipeline
#3482
passed with stages
in 4 minutes and 12 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
173 additions
and
30 deletions
+173
-30
app.jsx
src/app.jsx
+1
-0
index.jsx
src/components/OnlineChat/index.jsx
+136
-0
index.less
src/components/OnlineChat/index.less
+0
-0
DashboardLayout.jsx
src/layouts/dashboard/DashboardLayout.jsx
+19
-1
index.jsx
src/layouts/dashboard/header/index.jsx
+1
-1
index.jsx
src/layouts/index.jsx
+1
-25
index.jsx
src/pages/dobustrain/index.jsx
+8
-1
index.jsx
src/pages/domybustrain/index.jsx
+6
-0
index.jsx
src/pages/user/login/index.jsx
+0
-1
head.jsx
src/pages/usercenter/head.jsx
+1
-1
No files found.
src/app.jsx
View file @
7e294f1b
...
@@ -13,6 +13,7 @@ export async function getInitialState() {
...
@@ -13,6 +13,7 @@ export async function getInitialState() {
const
msg
=
await
doFetch
({
const
msg
=
await
doFetch
({
url
:
"/system/me"
,
url
:
"/system/me"
,
});
});
localStorage
.
setItem
(
"ID"
,
msg
?.
data
?.
data
?.
id
)
return
msg
.
data
.
data
;
return
msg
.
data
.
data
;
}
catch
(
error
)
{
}
catch
(
error
)
{
history
.
push
(
loginPath
);
history
.
push
(
loginPath
);
...
...
src/components/OnlineChat/index.jsx
0 → 100644
View file @
7e294f1b
import
difftime
from
"@/utils/difftime"
;
import
{
doFetch
}
from
"@/utils/doFetch"
;
import
{
Avatar
,
Box
,
Stack
}
from
"@mui/material"
;
import
{
useRequest
}
from
"ahooks"
;
import
{
Input
}
from
"antd"
;
import
dayjs
from
"dayjs"
;
import
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
Scrollbars
}
from
"react-custom-scrollbars"
;
import
"./index.less"
;
function
OnlineChat
({
trainId
})
{
const
currentUserId
=
localStorage
.
getItem
(
"ID"
);
const
[
value
,
setvalue
]
=
useState
();
const
scrollRef
=
useRef
();
useEffect
(()
=>
{},
[]);
const
handleKeyDown
=
(
e
)
=>
{
if
(
e
.
key
===
"Enter"
)
{
if
(
e
.
ctrlKey
)
{
e
.
target
.
value
+=
"
\n
"
;
}
else
{
e
.
preventDefault
();
doFetch
({
url
:
"/trainMessage/sendMessage"
,
params
:
{
trainId
,
messageContent
:
value
},
}).
then
((
res
)
=>
{
if
(
res
?.
code
===
"0000"
)
{
refresh
();
setvalue
(
null
);
}
});
}
}
};
const
{
data
,
loading
,
refresh
}
=
useRequest
(
async
()
=>
{
let
res
=
await
doFetch
({
url
:
"/trainMessage/list"
,
params
:
{
trainId
},
});
return
res
?.
data
?.
dataList
;
},
{
onSuccess
:
(
res
,
params
)
=>
{
setTimeout
(()
=>
{
scrollRef
?.
current
?.
scrollToBottom
();
},
10
);
},
}
);
return
(
<
Box
display=
{
"flex"
}
flexDirection=
{
"column"
}
boxShadow=
{
"0 0 18px #f0f0f0"
}
borderRadius=
{
2
}
padding=
{
2
}
bgcolor=
{
"white"
}
height=
{
"calc(100vh - 240px)"
}
>
<
Box
flex=
{
1
}
>
<
Scrollbars
thumbMinSize=
{
10
}
autoHide
style=
{
{
width
:
"100%"
,
height
:
"100%"
,
}
}
hideTracksWhenNotNeeded
ref=
{
scrollRef
}
>
{
data
?.
map
?.((
it
,
i
)
=>
{
if
(
it
?.
sendUserId
==
currentUserId
)
{
return
(
<
Stack
direction=
{
"row"
}
mb=
{
2
}
justifyContent=
{
"flex-end"
}
>
<
Stack
direction=
{
"column"
}
mr=
{
1
}
pt=
{
0.4
}
>
<
Box
textAlign=
{
"right"
}
>
<
span
style=
{
{
fontSize
:
12
}
}
>
{
" "
}
{
difftime
(
dayjs
(),
dayjs
(
it
?.
createTime
))
}
</
span
>
</
Box
>
<
Box
mt=
{
0.8
}
p=
{
2
}
bgcolor=
{
"#c8facd"
}
borderRadius=
{
2
}
>
{
it
?.
messageContent
}
</
Box
>
</
Stack
>
<
Avatar
src=
{
it
?.
pic
?.[
0
]?.
url
}
sx=
{
{
border
:
"2px solid rgba(0,0,0,0.2)"
}
}
></
Avatar
>
</
Stack
>
);
}
return
(
<
Stack
direction=
{
"row"
}
mb=
{
2
}
>
<
Avatar
src=
{
it
?.
pic
?.[
0
]?.
url
}
sx=
{
{
border
:
"2px solid rgba(0,0,0,0.2)"
}
}
></
Avatar
>
<
Stack
direction=
{
"column"
}
ml=
{
1
}
pt=
{
0.4
}
>
<
Box
textAlign=
{
"left"
}
>
<
b
>
{
it
?.
sendUserName
}
</
b
>
<
span
style=
{
{
fontSize
:
12
}
}
>
{
" "
}
{
difftime
(
dayjs
(),
dayjs
(
it
?.
createTime
))
}
</
span
>
</
Box
>
<
Box
mt=
{
0.8
}
p=
{
2
}
bgcolor=
{
"#f4f6f7"
}
borderRadius=
{
2
}
>
{
it
?.
messageContent
}
</
Box
>
</
Stack
>
</
Stack
>
);
})
}
</
Scrollbars
>
</
Box
>
<
Box
height=
{
68
}
bgcolor=
{
"#e0e0e0"
}
padding=
{
1
}
borderRadius=
{
2
}
>
<
Input
.
TextArea
placeholder=
"请输入"
bordered=
{
false
}
style=
{
{
height
:
"100%"
,
resize
:
"none"
,
margin
:
"0 -8px"
}
}
onKeyDown=
{
handleKeyDown
}
value=
{
value
}
onChange=
{
(
e
)
=>
{
setvalue
(
e
.
target
.
value
);
}
}
></
Input
.
TextArea
>
</
Box
>
</
Box
>
);
}
export
default
OnlineChat
;
src/components/OnlineChat/index.less
0 → 100644
View file @
7e294f1b
src/layouts/dashboard/DashboardLayout.jsx
View file @
7e294f1b
import
{
useState
}
from
"react"
;
import
{
Outlet
}
from
"@umijs/max"
;
import
{
Outlet
}
from
"@umijs/max"
;
import
{
useEffect
,
useState
}
from
"react"
;
// @mui
// @mui
import
{
styled
}
from
"@mui/material/styles"
;
import
{
styled
}
from
"@mui/material/styles"
;
import
{
Scrollbars
}
from
"react-custom-scrollbars"
;
import
{
Scrollbars
}
from
"react-custom-scrollbars"
;
import
io
from
"socket.io-client"
;
import
Header
from
"./header"
;
import
Header
from
"./header"
;
import
Nav
from
"./nav"
;
import
Nav
from
"./nav"
;
const
socket
=
io
(
SOCKET_IO_URL
,
{
query
:
{
id
:
localStorage
.
getItem
(
"ID"
)
}
});
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
const
APP_BAR_MOBILE
=
64
;
const
APP_BAR_MOBILE
=
64
;
...
@@ -35,6 +38,21 @@ const Main = styled("div")(({ theme }) => ({
...
@@ -35,6 +38,21 @@ const Main = styled("div")(({ theme }) => ({
export
default
function
DashboardLayout
()
{
export
default
function
DashboardLayout
()
{
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
useEffect
(()
=>
{
socket
.
connect
();
socket
.
on
(
"message"
,
(
data
)
=>
{
console
.
log
(
"===================================="
);
console
.
log
(
data
);
console
.
log
(
"===================================="
);
if
(
data
?.
wsMsgModel
===
""
)
{
}
});
return
()
=>
{
// 关闭 WebSocket 连接
socket
.
disconnect
();
};
},
[]);
return
(
return
(
<
StyledRoot
>
<
StyledRoot
>
<
Header
onOpenNav=
{
()
=>
setOpen
(
true
)
}
/>
<
Header
onOpenNav=
{
()
=>
setOpen
(
true
)
}
/>
...
...
src/layouts/dashboard/header/index.jsx
View file @
7e294f1b
...
@@ -18,7 +18,7 @@ import { useModel } from "@umijs/max";
...
@@ -18,7 +18,7 @@ import { useModel } from "@umijs/max";
import
AccountPopover
from
"./AccountPopover"
;
import
AccountPopover
from
"./AccountPopover"
;
import
Searchbar
from
"./Searchbar"
;
import
Searchbar
from
"./Searchbar"
;
//
----------------------------------------------------------------------
//
----------------------------------------------------------------------//
const
HEADER_MOBILE
=
64
;
const
HEADER_MOBILE
=
64
;
...
...
src/layouts/index.jsx
View file @
7e294f1b
...
@@ -5,10 +5,8 @@ import Slide from "@mui/material/Slide";
...
@@ -5,10 +5,8 @@ import Slide from "@mui/material/Slide";
import
Snackbar
from
"@mui/material/Snackbar"
;
import
Snackbar
from
"@mui/material/Snackbar"
;
import
*
as
Sentry
from
"@sentry/react"
;
import
*
as
Sentry
from
"@sentry/react"
;
import
{
Outlet
,
useModel
}
from
"@umijs/max"
;
import
{
Outlet
,
useModel
}
from
"@umijs/max"
;
import
io
from
"socket.io-clien
t"
;
import
React
from
"reac
t"
;
import
ThemeProvider
from
"./theme"
;
import
ThemeProvider
from
"./theme"
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
const
socket
=
io
(
SOCKET_IO_URL
,
{
query
:
{
id
:
localStorage
.
getItem
(
"ID"
)
}
});
// 自定义主题
// 自定义主题
// const { palette } = useTheme();
// const { palette } = useTheme();
...
@@ -74,28 +72,6 @@ function App() {
...
@@ -74,28 +72,6 @@ function App() {
setInitialState
,
setInitialState
,
}
=
useModel
(
"@@initialState"
);
}
=
useModel
(
"@@initialState"
);
useEffect
(()
=>
{
socket
.
connect
();
socket
.
on
(
'message'
,
(
data
)
=>
{
console
.
log
(
'===================================='
);
console
.
log
(
data
);
console
.
log
(
'===================================='
);
if
(
data
?.
wsMsgModel
===
""
){
}
})
return
()
=>
{
// 关闭 WebSocket 连接
socket
.
disconnect
();
};
},
[]);
return
(
return
(
<
ThemeProvider
>
<
ThemeProvider
>
<
CssBaseline
/>
<
CssBaseline
/>
...
...
src/pages/dobustrain/index.jsx
View file @
7e294f1b
import
AutoTable
from
"@/components/AutoTable"
;
import
AutoTable
from
"@/components/AutoTable"
;
import
DraggableDialog
from
"@/components/DraggableDialog"
;
import
DraggableDialog
from
"@/components/DraggableDialog"
;
import
InitForm
from
"@/components/InitForm"
;
import
InitForm
from
"@/components/InitForm"
;
import
OnlineChat
from
"@/components/OnlineChat"
;
import
PremButton
from
"@/components/PremButton"
;
import
PremButton
from
"@/components/PremButton"
;
import
TreeRender
from
"@/components/TreeRender/sxtree"
;
import
TreeRender
from
"@/components/TreeRender/sxtree"
;
import
{
doFetch
}
from
"@/utils/doFetch"
;
import
{
doFetch
}
from
"@/utils/doFetch"
;
...
@@ -11,6 +12,7 @@ import { useRequest } from "ahooks";
...
@@ -11,6 +12,7 @@ import { useRequest } from "ahooks";
import
{
Badge
,
message
,
Tabs
}
from
"antd"
;
import
{
Badge
,
message
,
Tabs
}
from
"antd"
;
import
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
{
history
}
from
"umi"
;
import
{
history
}
from
"umi"
;
import
"./index.less"
;
import
"./index.less"
;
function
Dolessons
()
{
function
Dolessons
()
{
...
@@ -348,6 +350,11 @@ function Dolessons() {
...
@@ -348,6 +350,11 @@ function Dolessons() {
</
Box
>
</
Box
>
),
),
},
},
{
key
:
"4"
,
label
:
"在线沟通"
,
children
:
<
OnlineChat
trainId=
{
params
?.
id
}
></
OnlineChat
>,
},
];
];
const
addHandel
=
(
val
)
=>
{
const
addHandel
=
(
val
)
=>
{
...
@@ -546,7 +553,7 @@ function Dolessons() {
...
@@ -546,7 +553,7 @@ function Dolessons() {
</
PremButton
>
</
PremButton
>
<
PremButton
<
PremButton
btn=
{
{
btn=
{
{
disabled
:
ifs
,
disabled
:
ifs
,
variant
:
"contained"
,
variant
:
"contained"
,
onClick
:
addHandel
,
onClick
:
addHandel
,
}
}
}
}
...
...
src/pages/domybustrain/index.jsx
View file @
7e294f1b
...
@@ -11,6 +11,7 @@ import { useRequest } from "ahooks";
...
@@ -11,6 +11,7 @@ import { useRequest } from "ahooks";
import
{
Badge
,
message
,
Tabs
}
from
"antd"
;
import
{
Badge
,
message
,
Tabs
}
from
"antd"
;
import
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
{
useEffect
,
useMemo
,
useRef
,
useState
}
from
"react"
;
import
{
history
}
from
"umi"
;
import
{
history
}
from
"umi"
;
import
OnlineChat
from
"@/components/OnlineChat"
;
import
"./index.less"
;
import
"./index.less"
;
function
Dolessons
()
{
function
Dolessons
()
{
...
@@ -303,6 +304,11 @@ function Dolessons() {
...
@@ -303,6 +304,11 @@ function Dolessons() {
</
Box
>
</
Box
>
),
),
},
},
{
key
:
"4"
,
label
:
"在线沟通"
,
children
:
<
OnlineChat
trainId=
{
params
?.
id
}
></
OnlineChat
>,
},
];
];
const
addHandel
=
(
val
)
=>
{
const
addHandel
=
(
val
)
=>
{
...
...
src/pages/user/login/index.jsx
View file @
7e294f1b
...
@@ -18,7 +18,6 @@ function Login() {
...
@@ -18,7 +18,6 @@ function Login() {
const
fetchUserInfo
=
async
()
=>
{
const
fetchUserInfo
=
async
()
=>
{
const
userInfo
=
await
initialState
?.
fetchUserInfo
();
const
userInfo
=
await
initialState
?.
fetchUserInfo
();
if
(
userInfo
)
{
if
(
userInfo
)
{
localStorage
.
setItem
(
"ID"
,
userInfo
?.
id
);
await
setInitialState
((
s
)
=>
{
await
setInitialState
((
s
)
=>
{
return
{
...
s
,
currentUser
:
userInfo
};
return
{
...
s
,
currentUser
:
userInfo
};
});
});
...
...
src/pages/usercenter/head.jsx
View file @
7e294f1b
...
@@ -123,7 +123,7 @@ const Head = ({ defaultImg, dofetchUserInfo }) => {
...
@@ -123,7 +123,7 @@ const Head = ({ defaultImg, dofetchUserInfo }) => {
backgroundColor
:
"rgba(0,0,0,0.6)"
,
backgroundColor
:
"rgba(0,0,0,0.6)"
,
}
}
}
}
>
>
<
img
src=
{
src
}
alt=
""
style=
{
{
borderRadius
:
112
}
}
/>
<
img
src=
{
src
}
alt=
""
style=
{
{
borderRadius
:
112
,
width
:
"100%"
,
height
:
"100%"
}
}
/>
</
div
>
</
div
>
)
}
)
}
<
div
<
div
...
...
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