Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
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
ReactWeb5
CivManage
Commits
b78b8904
Commit
b78b8904
authored
Dec 04, 2020
by
张仲鸣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: app发布页接入更新接口
parent
dfe921b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
19 deletions
+128
-19
VersionPublish.js
src/pages/appConfig/VersionPublish.js
+85
-18
VersionPublish.less
src/pages/appConfig/VersionPublish.less
+40
-1
api.js
src/services/appConfig/api.js
+3
-0
No files found.
src/pages/appConfig/VersionPublish.js
View file @
b78b8904
import
React
,
{
useEffect
,
useState
,
useRef
}
from
'react'
;
import
{
Switch
,
Button
,
Message
,
Spin
,
Modal
}
from
'antd'
;
// import axios from 'axios';
import
BaseForm
from
'@/components/BaseForm/index'
;
import
{
getApkNameAndDate
}
from
'@/services/appConfig/api'
;
import
{
getApkNameAndDate
,
SaveMobileApk
}
from
'@/services/appConfig/api'
;
import
styles
from
'./VersionPublish.less'
;
// const JSON_BASE = `${
// location.origin
// }/cityinterface/rest/services/filedownload.svc/download/BufFile/Mobile/APK/`;
export
default
()
=>
{
const
items
=
[
{
...
...
@@ -41,29 +46,51 @@ export default () => {
],
formType
:
'SINGLE_RADIO'
,
},
{
label
:
'apk上传'
,
dataIndex
:
'file'
,
rules
:
[
{
required
:
true
,
message
:
'请上传对应的apk'
,
},
],
formType
:
'IMGSHOP'
,
},
];
const
formEntity
=
useRef
(
null
);
const
fileEntity
=
useRef
(
null
);
const
[
loading
,
setLoading
]
=
useState
(
true
);
// 显示请求的loading
const
[
showModal
,
setShowModal
]
=
useState
(
false
);
// 显示更新的modal
const
[
fileData
,
setFileData
]
=
useState
({});
// 获取到的包名和更新时间
const
[
file
,
setFile
]
=
useState
({});
// 上传的文件
const
[
fileSuccess
,
setFileSuccess
]
=
useState
(
false
);
// 本地文件是否成功
const
[
progress
,
setProgress
]
=
useState
(
false
);
// 是否正在保存
// const uploadProps = {
// name: 'file',
// action: `${window.location.origin}${PUBLISH_SERVICE}/FileCenter/UploadSingleFile`,
// headers: {
// Authorization: 'Bearer ' + localStorage.getItem('token') || '',
// },
// onChange(info) {
// console.log(info)
// setFile(info.file);
// },
// };
const
submitForm
=
()
=>
{
console
.
log
(
formEntity
);
const
{
validateFields
}
=
formEntity
.
current
;
validateFields
()
.
then
(
values
=>
{
console
.
log
(
values
);
const
{
describe
,
forceUpdate
}
=
values
;
const
formData
=
new
FormData
();
formData
.
set
(
'description'
,
describe
);
formData
.
set
(
'isRefresh'
,
!!
forceUpdate
);
formData
.
set
(
'file'
,
file
);
setProgress
(
true
);
SaveMobileApk
(
formData
).
then
(
res
=>
{
console
.
log
(
res
);
setProgress
(
false
);
if
(
Number
(
res
.
code
)
===
200
)
{
Message
.
success
(
'更新成功'
);
setShowModal
(
false
);
init
();
}
else
{
Message
.
error
(
res
.
msg
);
}
});
})
.
catch
(
res
=>
{
const
{
errorFields
,
values
}
=
res
;
...
...
@@ -75,22 +102,41 @@ export default () => {
formEntity
.
current
=
form
;
};
useEffect
(()
=>
{
const
handleFileChange
=
e
=>
{
console
.
log
(
e
.
target
.
files
);
setFile
(
e
.
target
.
files
[
0
]);
setFileSuccess
(
true
);
};
const
handleUpload
=
()
=>
{
fileEntity
.
current
.
click
();
};
const
init
=
()
=>
{
getApkNameAndDate
({})
.
then
(
res
=>
{
console
.
log
(
res
);
const
message
=
res
.
ResultMessage
||
''
;
const
[
fileName
,
updateTime
]
=
message
.
split
(
','
);
const
[
fileName
=
''
,
updateTime
]
=
message
.
split
(
','
);
setFileData
({
fileName
,
updateTime
,
});
setLoading
(
false
);
// const index = fileName.lastIndexOf('.');
// axios
// .get(`${JSON_BASE}${fileName.slice(0, index)}.json`, {})
// .then(res => {
// console.log(res);
// });
})
.
catch
(
err
=>
{
Message
.
error
(
err
);
setLoading
(
false
);
});
};
useEffect
(()
=>
{
init
();
},
[]);
return
(
...
...
@@ -112,8 +158,8 @@ export default () => {
<
div
className
=
{
styles
.
row
}
>
<
div
className
=
{
styles
.
label
}
>
下载地址:
<
/div
>
<
div
className
=
"value"
>
<
a
href
=
"
https://example.com
"
target
=
"_blank"
>
https
:
//example.com
<
a
href
=
"
/MobileGCK/getApk
"
target
=
"_blank"
>
{
`/MobileGCK/getApk`
}
<
/a
>
<
/div
>
<
/div
>
...
...
@@ -143,6 +189,27 @@ export default () => {
onOk
=
{
submitForm
}
>
<
BaseForm
items
=
{
items
}
getForm
=
{
handleGetForm
}
/
>
<
div
className
=
{
styles
.
row
}
>
<
div
className
=
{
`
${
styles
.
label
}
${
styles
.
required
}
`
}
>
apk
文件:
<
/div
>
<
input
ref
=
{
f
=>
{
fileEntity
.
current
=
f
;
}}
className
=
{
styles
[
'file-item'
]}
type
=
"file"
onChange
=
{
handleFileChange
}
/
>
<
Button
type
=
"primary"
onClick
=
{
handleUpload
}
>
{
fileSuccess
?
'上传成功'
:
'开始上传'
}
<
/Button
>
<
/div
>
{
progress
&&
(
<
div
className
=
{
styles
.
loadingBox
}
>
<
Spin
/>
<
/div
>
)}
<
/Modal
>
)}
<
/div
>
...
...
src/pages/appConfig/VersionPublish.less
View file @
b78b8904
...
...
@@ -19,6 +19,44 @@
}
.label {
width: 100px;
display: flex;
align-items: center;
width: 80px;
flex-shrink: 0;
text-align: right;
color: rgba(0, 0, 0, 0.85);
font-size: 14px;
}
.required {
&::before {
display: inline-block;
margin-right: 4px;
color: #ff4d4f;
font-size: 14px;
font-family: SimSun, sans-serif;
line-height: 1;
content: '*';
}
}
.file-item {
display: none;
}
.ant-form-item:last-child {
margin-bottom: 0;
}
.loadingBox {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
\ No newline at end of file
src/services/appConfig/api.js
View file @
b78b8904
...
...
@@ -107,3 +107,6 @@ export const getApkNameAndDate = params =>
`/Cityinterface/Services/CityServer_MobileBusiness/REST/BaseREST.svc/AppModifyTime`
,
params
,
);
// 上传apk版本信息以及apk包的接口
export
const
SaveMobileApk
=
params
=>
post
(
`/Publish/OMS/FileCenter/SaveMobileApk`
,
params
);
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