Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xxx_phase2_web
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
夏敏伟
xxx_phase2_web
Commits
d301e904
Commit
d301e904
authored
Dec 20, 2023
by
以墨为白
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sse支持
parent
93b74234
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
17 deletions
+92
-17
src/util/http_util.js
src/util/http_util.js
+59
-5
src/view/home.vue
src/view/home.vue
+26
-12
webpack.config.js
webpack.config.js
+7
-0
No files found.
src/util/http_util.js
View file @
d301e904
...
@@ -708,7 +708,7 @@ let post_machineWriting = (url, data, headers = {}) => {
...
@@ -708,7 +708,7 @@ let post_machineWriting = (url, data, headers = {}) => {
body
:
typeof
data
==
"
object
"
?
JSON
.
stringify
(
data
)
:
data
,
body
:
typeof
data
==
"
object
"
?
JSON
.
stringify
(
data
)
:
data
,
headers
:
headers
:
{
{
'
apiKey
'
:
'
7838fab88cde479d84d710d3d2453276
'
,
'
apiKey
'
:
'
7838fab88cde479d84d710d3d2453276
'
,
'
Content-Type
'
:
'
application/json
'
'
Content-Type
'
:
'
application/json
'
}
}
...
@@ -731,6 +731,58 @@ let post_machineWriting = (url, data, headers = {}) => {
...
@@ -731,6 +731,58 @@ let post_machineWriting = (url, data, headers = {}) => {
.
catch
(
err
=>
reject
(
err
));
.
catch
(
err
=>
reject
(
err
));
})
})
}
}
let
httpSSERequest
=
(
url
,
success
,
error
)
=>
{
if
(
typeof
(
EventSource
)
!==
"
undefined
"
)
{
var
eventSource
=
new
EventSource
(
url
);
eventSource
.
onmessage
=
function
(
event
)
{
success
(
event
.
data
);
}
eventSource
.
addEventListener
(
'
error
'
,
function
(
event
)
{
error
(
"
错误:
"
+
event
);
});
eventSource
.
addEventListener
(
'
open
'
,
function
(
event
)
{
error
(
"
建立连接:
"
+
event
);
});
}
else
{
error
(
"
抱歉,您的浏览器不支持 server-sent 事件 ...
"
);
}
}
/**
* oss文件上传
* @param {*} url
* @param {*} file
*/
let
uploadOSS
=
(
url
,
file
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
fetch
(
url
).
then
(
res
=>
{
if
(
res
.
status
==
200
)
{
return
res
.
json
();
}
else
{
console
.
log
(
res
.
statusText
);
reject
(
HTTP_STATUS
);
}
}).
then
(
res
=>
{
if
(
res
.
code
==
9000
)
{
return
fetch
(
res
.
data
,
{
method
:
"
put
"
,
body
:
file
});
}
else
{
return
Promise
.
reject
({
err
:
res
.
message
});
}
}).
then
(
res
=>
{
if
(
res
.
status
==
200
)
{
resolve
();
}
else
{
console
.
log
(
res
.
statusText
);
reject
(
HTTP_STATUS
);
}
}).
catch
(
err
=>
{
reject
({
err
:
err
});
})
})
}
export
{
export
{
...
@@ -771,5 +823,7 @@ export {
...
@@ -771,5 +823,7 @@ export {
addParamNew
,
addParamNew
,
arr_img_format
,
arr_img_format
,
fileUploadProgress
,
fileUploadProgress
,
post_machineWriting
post_machineWriting
,
httpSSERequest
,
uploadOSS
}
}
\ No newline at end of file
src/view/home.vue
View file @
d301e904
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
</div>
</div>
<div
class=
"button-list-right"
>
<div
class=
"button-list-right"
>
<div
v-for=
"(item, index) in modules.rightModule"
<div
v-for=
"(item, index) in modules.rightModule"
:class=
"['module-info', isSelected - 3 == index ? 'selectedModule' : '']"
@
click=
"choiceModule(index + 3)"
:class=
"['module-info', isSelected - 3 == index ? 'selectedModule' : '']"
v-text=
"item.name"
>
@
click=
"choiceModule(index + 3)"
v-text=
"item.name"
>
</div>
</div>
</div>
</div>
<h1><span
v-text=
"system_name"
></span></h1>
<h1><span
v-text=
"system_name"
></span></h1>
...
@@ -77,7 +77,7 @@
...
@@ -77,7 +77,7 @@
import
"
../assets/css/home.css
"
;
import
"
../assets/css/home.css
"
;
// import jh_bg from "../assets/img/main/logo-bg.png";
// import jh_bg from "../assets/img/main/logo-bg.png";
// import jh from "/static/img/main/logo.png";
// import jh from "/static/img/main/logo.png";
import
{
endLoading
,
get
,
post
}
from
"
../util/http_util
"
;
import
{
endLoading
,
get
,
post
,
httpSSERequest
}
from
"
../util/http_util
"
;
import
{
queryDictItem
}
from
'
../api/dictitem
'
;
import
{
queryDictItem
}
from
'
../api/dictitem
'
;
import
Push
from
'
push.js
'
import
Push
from
'
push.js
'
import
dayjs
from
'
dayjs
'
;
import
dayjs
from
'
dayjs
'
;
...
@@ -118,9 +118,9 @@ export default {
...
@@ -118,9 +118,9 @@ export default {
],
],
},
},
isSelected
:
0
,
isSelected
:
0
,
myDate
:{
myDate
:
{
day
:
null
,
day
:
null
,
week
:
null
week
:
null
},
},
system_name
:
SYSTEM_NAME
system_name
:
SYSTEM_NAME
};
};
...
@@ -269,8 +269,20 @@ export default {
...
@@ -269,8 +269,20 @@ export default {
//获取时间
//获取时间
this
.
myDate
.
day
=
dayjs
().
format
(
'
YYYY年MM月DD日
'
);
this
.
myDate
.
day
=
dayjs
().
format
(
'
YYYY年MM月DD日
'
);
const
weekList
=
[
'
星期日
'
,
'
星期一
'
,
'
星期二
'
,
'
星期三
'
,
'
星期四
'
,
'
星期五
'
,
'
星期六
'
];
const
weekList
=
[
'
星期日
'
,
'
星期一
'
,
'
星期二
'
,
'
星期三
'
,
'
星期四
'
,
'
星期五
'
,
'
星期六
'
];
this
.
myDate
.
week
=
weekList
[
dayjs
().
get
(
'
day
'
)]
this
.
myDate
.
week
=
weekList
[
dayjs
().
get
(
'
day
'
)]
// httpSSERequest("http://localhost:8081/api_ws/stream-sse", (data) => {
// console.log(data)
// }, (err) => {
// console.log(err)
// });
httpSSERequest
(
"
api_ws/stream-sse
"
,
(
data
)
=>
{
console
.
log
(
data
)
},
(
err
)
=>
{
console
.
log
(
err
)
});
},
},
computed
:
{
computed
:
{
userInfo
()
{
userInfo
()
{
...
@@ -577,7 +589,8 @@ export default {
...
@@ -577,7 +589,8 @@ export default {
.el-dropdown-link
{
.el-dropdown-link
{
cursor
:
pointer
;
cursor
:
pointer
;
color
:
white
;
color
:
white
;
.el-icon-more.setting_button
{
.el-icon-more.setting_button
{
font-size
:
25px
;
font-size
:
25px
;
}
}
}
}
...
@@ -864,4 +877,5 @@ export default {
...
@@ -864,4 +877,5 @@ export default {
transition
:
all
0
.4s
ease
;
transition
:
all
0
.4s
ease
;
cursor
:
pointer
;
cursor
:
pointer
;
}
}
}
</
style
>
}
\ No newline at end of file
</
style
>
\ No newline at end of file
webpack.config.js
View file @
d301e904
...
@@ -106,6 +106,7 @@ module.exports = {
...
@@ -106,6 +106,7 @@ module.exports = {
]
]
},
},
devServer
:
{
devServer
:
{
compress
:
false
,
//SSE 依赖的是换行符。gzip 会破坏这种依赖。因此需要在webpack-dev-server 配置里把 gzip 关掉devserver{compress:false}
port
:
8088
,
port
:
8088
,
hot
:
true
,
hot
:
true
,
static
:
'
./
'
,
static
:
'
./
'
,
...
@@ -120,6 +121,12 @@ module.exports = {
...
@@ -120,6 +121,12 @@ module.exports = {
'
^/api/
'
:
'
/
'
'
^/api/
'
:
'
/
'
}
}
},
},
'
/api_ws/**
'
:
{
target
:
'
http://localhost:8081
'
,
ws
:
true
,
secure
:
false
,
changeOrigin
:
true
,
},
'
/websocket/**
'
:
{
'
/websocket/**
'
:
{
target
:
'
ws://192.168.168.213:8081
'
,
target
:
'
ws://192.168.168.213:8081
'
,
ws
:
true
,
ws
:
true
,
...
...
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