Commit 2a199671 authored by 彭俊龙's avatar 彭俊龙

新增APP上传功能以及下载模板页

parent 34427c53
Pipeline #93497 passed with stages
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>APK下载</title>
<style>
body {
font-family: "Roboto", sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
color: #333;
}
.container {
max-width: 600px;
margin: auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
.header {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
.app-icon {
width: 40px; /* 图标大小 */
border: 2px solid #007bff;
border-radius: 10px;
padding: 5px;
background-color: white;
margin-right: 20px; /* 图标和标题之间的间距 */
}
h1 {
color: #007bff;
font-size: 2em;
margin: 0;
}
.download, .version-info, .history {
margin-bottom: 20px;
padding: 15px;
border-radius: 8px;
background-color: #e9ecef;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.download a {
display: block;
padding: 15px;
background: #007bff;
color: white;
text-align: center;
border-radius: 5px;
text-decoration: none;
transition: background 0.3s;
}
.download a:hover {
background: #0056b3;
}
.history {
max-height: 200px; /* 设置最大高度 */
overflow-y: auto; /* 启用垂直滚动条 */
}
.history-item {
margin: 10px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
position: relative;
}
.toggle-button {
margin-left: 10px;
color: #007bff;
cursor: pointer;
font-size: 14px;
text-decoration: underline;
}
.history-details {
display: none;
margin-top: 10px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
background: #f9f9f9;
}
.history-button {
display: inline-block;
padding: 10px 15px;
background: #007bff;
color: white;
border-radius: 5px;
text-decoration: none;
transition: background 0.3s;
margin-top: 10px;
}
.history-button:hover {
background: #0056b3;
}
.empty-message {
color: #888;
text-align: center;
font-size: 1.2em;
}
ul {
list-style: none; /* 去掉项目符号 */
padding: 0; /* 去掉内边距 */
margin: 0; /* 去掉外边距 */
}
</style>
<script>
function toggleDetails(version) {
const details = document.getElementById("details-" + version);
details.style.display = details.style.display === "block" ? "none" : "block";
}
function generateHistory(versions) {
const historyContainer = document.getElementById("historyList");
const currentVerContainer = document.getElementById("currentVerList");
const bodyContent = document.getElementById("content");
if (versions.length === 0) {
bodyContent.style.display = "none";
const emptyMessage = document.createElement("div");
emptyMessage.className = "empty-message";
emptyMessage.textContent = "没有APP上传数据";
const content = document.getElementById("empty");
content.appendChild(emptyMessage);
return;
}
versions.forEach((v, i) => {
if (i > 0) {
// 历史版本
const item = document.createElement("li");
item.className = "history-item";
const downloadButton = document.createElement("a");
downloadButton.className = "history-button";
downloadButton.href = v.downloadLink;
downloadButton.download = true;
downloadButton.textContent = `点击下载 ${v.version}`;
const toggleButton = document.createElement("span");
toggleButton.className = "toggle-button";
toggleButton.onclick = () => toggleDetails(i);
toggleButton.textContent = "查看说明";
const detailsDiv = document.createElement("div");
detailsDiv.className = "history-details";
detailsDiv.id = "details-" + i;
detailsDiv.innerHTML = `<p>版本: ${v.version}</p>
<p>更新内容: </p><ul>${v.details.map(item => `<li>${item}</li>`).join("")}</ul><p>发版时间: ${v.date} </p>`;
item.appendChild(downloadButton);
item.appendChild(toggleButton);
item.appendChild(detailsDiv);
historyContainer.appendChild(item);
} else {
// 最新版本
document.getElementById("downNewApp").setAttribute("href", v.downloadLink);
const h2 = document.querySelector(".version-info h2");
h2.innerHTML += " " + v.version;
document.getElementById("verTime").innerHTML = `发版时间:${v.date}`;
const detailsDiv = document.createElement("ul");
detailsDiv.innerHTML = `${v.details.filter(x => x).map(item => `<li>${item}</li>`).join("")}`;
currentVerContainer.appendChild(detailsDiv);
}
});
}
window.onload = async () => {
let versions = [];
try {
const response = await fetch(`${window.origin}/PandaOMS/OMS/Mobile/GetAppUploadRecords`);
const resJson = await response.json();
if (resJson.code === 0) {
const records = resJson.data || [];
if (records.length > 0) {
records.forEach(v => {
versions.push({
version: v.Ver,
date: v.UploadTime,
downloadLink: `${window.origin}${v.DownUrl}`,
details: v.UploadLog.split("\n"),
});
});
}
}
} catch (e) {
console.log(e, "请求失败");
}
generateHistory(versions);
};
</script>
</head>
<body>
<div class="container">
<div class="header">
<img src="panda_logo.png" alt="App Icon" class="app-icon" />
<h1>APK下载页</h1>
</div>
<div id="content">
<div class="download">
<h2>最新版本</h2>
<a id="downNewApp">点击下载最新版本</a>
</div>
<div class="version-info">
<h2>版本说明</h2>
<p>本次版本更新了以下内容:</p>
<div id="currentVerList"></div>
<p id="verTime"></p>
</div>
<div class="history">
<h2>历史版本</h2>
<ul id="historyList"></ul>
</div>
</div>
<div id="empty"></div>
</div>
</body>
</html>
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="JSON" path="*.json" verb="GET,POST" modules="IsapiModule" scriptProcessor="C:\Windows\System32\inetsrv\asp.dll" resourceType="File" preCondition="bitness64" />
</handlers>
</system.webServer>
</configuration>
This diff was suppressed by a .gitattributes entry.
......@@ -4,6 +4,7 @@ import ProCard from '@ant-design/pro-card';
import PageContainer from '@/components/BasePageContainer';
import SevenParams from './menuconfig/SevenParams';
import VersionPublish from './menuconfig/VersionPublish';
import ApkUpload from './menuconfig/ApkUpload';
import WorkDesign from './menuconfig/WorkDesign';
import { getMiniAppModuleTree, deleteWebsite, deleteMiniMenu } from '@/services/mobileConfig/api';
import { ExclamationCircleOutlined } from '@ant-design/icons';
......@@ -200,6 +201,11 @@ const MobileConfigPage = props => {
{activeKey === tabArr[4].key && tabArr[4].component}
</TabPane>
)}
{showConfig && subType !== 'add' && (
<TabPane tab={tabArr[5].title} key={tabArr[5].key}>
{activeKey === tabArr[5].key && tabArr[5].component}
</TabPane>
)}
</Tabs>
{/* </Spin> */}
</Card>
......@@ -245,6 +251,11 @@ const MobileConfigPage = props => {
key: '4',
component: <WorkDesign />,
},
{
title: 'APP发版',
key: '5',
component: <ApkUpload />,
},
];
return (
<PageContainer>
......
import React, { useEffect, useMemo, useState } from 'react';
import styles from './index.less';
import { Form, Modal, Input, message, Button, Upload, Select } from 'antd';
import { getAppUploadRecords, postAppVersionInfo } from '@/services/mobileConfig/api';
import { UploadOutlined } from '@ant-design/icons';
import { request } from '@wisdom-utils/utils/es';
const ApkUpload = props => {
const [loadding, setLoadding] = useState(false);
const { TextArea } = Input;
const tailLayout = {
wrapperCol: { offset: 6, span: 8 },
};
const layout = {
labelCol: {
span: 6,
},
wrapperCol: {
span: 8,
},
};
const [form] = Form.useForm();
useEffect(()=>{
//getAppUploadRecords().then(x=> console.log(x, '上传记录'))
}, [])
const normFile = e => {
if (Array.isArray(e)) {
return e;
}
return e?.fileList;
};
const postAPPUploadInfo = async () => {
await form.validateFields();
const formData = form.getFieldsValue();
if (!formData.DownUrl) {
message.error('请上传app');
return;
}
setLoadding(true);
postAppVersionInfo(formData).then(res=> {
if(res.code === 0){
message.success('新版本提交成功!');
form.resetFields()
}else{
message.error(res.msg)
}
}).catch(err=>{
console.log(err, '提交失败')
});
setLoadding(false);
};
return (
<Form
{...layout}
initialValues={{
DownUrl: '',
ApkName: '水务掌天下'
}}
form={form}
name="control-hooks"
onFinish={valus => console.log(valus, '表单完成信息')}
>
<Form.Item name="ApkName" label="应用名称" rules={[{ required: true }]}>
<Input placeholder="请输入应用名称" />
</Form.Item>
<Form.Item name="Ver" label="发布版本号" rules={[{ required: true }]}>
<Input placeholder="请输入发布版本号" />
</Form.Item>
<Form.Item name="UploadLog" label="发版说明" rules={[{ required: true }]}>
<TextArea rows={6} placeholder="请输入发版说明" />
</Form.Item>
<Form.Item name="DownUrl" style={{ display: 'none' }} />
<Form.Item
name="UploadFile"
label="上传APK"
rules={[{ required: true }]}
valuePropName="fileList"
getValueFromEvent={normFile}
>
<Upload
maxCount={1}
onChange={baseFile => {
const file = baseFile.file;
let sourcePath = '';
if (file.status === 'done' && file.response.code === 0) {
sourcePath = `/PandaOMS/OMS/FileCenter/DownLoadFiles?filepath=${file.response.data}`;
message.success('上传成功!');
} else if (file.status === 'done' && file.response.code !== 0) {
message.error('上传失败:' + file.response.msg);
}
form.setFieldsValue({
DownUrl: sourcePath,
});
console.log(file, '上传图片');
}}
name="file"
a
action={`${window.origin}/PandaOMS/OMS/FileCenter/UploadApk`}
accept=".apk"
>
<Button icon={<UploadOutlined />}>上传APK</Button>
</Upload>
</Form.Item>
<Form.Item {...tailLayout}>
<Button
loading={loadding}
type="primary"
onClick={() => {
console.log(form.getFieldsValue(), '表单完成信息');
postAPPUploadInfo();
}}
>
提交
</Button>
</Form.Item>
</Form>
);
};
export default ApkUpload;
......@@ -120,3 +120,7 @@ export const getCardVersion = parmas => get(`${PUBLISH_SERVICE}/WebSite/AppWorkS
//更新版本
export const upgradeCardVersion = parmas => post(`${PUBLISH_SERVICE}/WebSite/AppWorkSpace_UpgradeCardVersion`, parmas);
export const postAppVersionInfo = parmas => post(`${PUBLISH_SERVICE}/Mobile/PostAppVersionInfo`, parmas);
export const getAppUploadRecords = parmas => get(`${PUBLISH_SERVICE}/Mobile/GetAppUploadRecords`, parmas);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment