mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-02 23:23:28 +08:00
上传文件页面添加关联文件下拉框;小调整
This commit is contained in:
@@ -135,7 +135,7 @@ router.get('/dashboard/:group/:page/:subpage?', function (req, res) {
|
||||
pageTemplate: "Account",
|
||||
},
|
||||
"debug": {
|
||||
title: "调试",
|
||||
title: "系统配置",
|
||||
baseTemplate: "blank",
|
||||
pageTemplate: "Debug",
|
||||
}
|
||||
|
@@ -1,3 +1,9 @@
|
||||
<p>
|
||||
查看后端项目配置是否配置正确
|
||||
</p>
|
||||
<p>
|
||||
请按 F12 查看详情
|
||||
</p>
|
||||
<script>
|
||||
postRequest('/debug/status', { token: localStorageUtils.getToken() })
|
||||
.then(function (response) {
|
||||
@@ -7,7 +13,6 @@
|
||||
|
||||
if (status === "success") {
|
||||
console.log(data);
|
||||
$(".main").html("请在 F12 查看");
|
||||
} else {
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
|
@@ -67,13 +67,6 @@
|
||||
})
|
||||
});
|
||||
if (renderData.length == 0) {
|
||||
function htmlEncode(str) {
|
||||
// refer: https://stackoverflow.com/questions/4183801/escape-html-chracters
|
||||
var div = document.createElement('div');
|
||||
var txt = document.createTextNode(str);
|
||||
div.appendChild(txt);
|
||||
return div.innerHTML;
|
||||
}
|
||||
renderTable({ data: `暂无文件`, tableId: tableElementId, renderTableHead: true });
|
||||
} else {
|
||||
renderTable({ data: renderData, tableId: tableElementId, renderTableHead: true });
|
||||
|
@@ -0,0 +1,5 @@
|
||||
<p>
|
||||
<h3>文件详情</h3>
|
||||
<hr>
|
||||
<h3>关联文件对象</h3>
|
||||
</p>
|
@@ -53,6 +53,35 @@
|
||||
border-radius: 4px;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
/* 上传按钮样式 */
|
||||
#beginUpload {
|
||||
margin-top: 30px;
|
||||
padding: 5px 12px;
|
||||
transition: all 0.25s;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#beginUpload:hover {
|
||||
transform: scale(1.1);
|
||||
background-color: #39a705;
|
||||
color: #caf6b6;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#beginUpload[disabled]:hover {
|
||||
transform: initial;
|
||||
background-color: initial;
|
||||
color: initial;
|
||||
border-radius: initial;
|
||||
cursor: initial;
|
||||
}
|
||||
|
||||
#fileAssociator {
|
||||
padding: 3px 12px;
|
||||
min-width: 200px;
|
||||
}
|
||||
</style>
|
||||
<p>
|
||||
<a href="<%= pageUrl %>../">返回文件管理</a>
|
||||
@@ -86,8 +115,19 @@
|
||||
<div id="processBar2Inner" class="process-bar-inner"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>关联文件</p>
|
||||
<select id="fileAssociator">
|
||||
<option value="0">新建文件</option>
|
||||
</select>
|
||||
</div>
|
||||
<button id="beginUpload" disabled="true">开始上传</button>
|
||||
|
||||
<p>
|
||||
<input type="checkbox" id="checkbox-auto-upload" checked="true">
|
||||
<label for="checkbox-auto-upload">连续上传(上传完成后留在本页)</label>
|
||||
</p>
|
||||
|
||||
<script src="/assets/lib/crypto-js/sha1.js"></script>
|
||||
<script>
|
||||
var file = null;
|
||||
@@ -350,7 +390,7 @@
|
||||
xhr.onload = function (e) {
|
||||
console.log('上传成功', xhr.status, xhr.statusText);
|
||||
// 等待进度条走到 100% 否则小文件进度条还没有走完就提示上传完成会让人感觉有点奇怪
|
||||
setTimeout(function(){
|
||||
setTimeout(function () {
|
||||
alert("上传成功!");
|
||||
window.location.reload();
|
||||
}, 300);
|
||||
@@ -360,4 +400,30 @@
|
||||
};
|
||||
xhr.send(file); // file 是要上传的文件对象
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var fileAssociator = document.getElementById("fileAssociator");
|
||||
// 下拉框列表
|
||||
getRequest("/file/list", { token: localStorageUtils.getToken() })
|
||||
.then(function (responseData) {
|
||||
var axiosData = responseData.data;
|
||||
var status = axiosData.status;
|
||||
var data = axiosData.data;
|
||||
if (status === "success") {
|
||||
// console.log(data);
|
||||
// 数据进行转换
|
||||
var optionHTML = "";
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
const element = data[i];
|
||||
optionHTML += `<option value="${element.id}">[${element.id}] ${element.fileDisplayName}.${element.fileFormat}</option>`;
|
||||
}
|
||||
// 渲染到下拉框内
|
||||
fileAssociator.innerHTML += optionHTML;
|
||||
} else {
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
alert("无法连接到服务器,请检查网络连接!");
|
||||
});
|
||||
</script>
|
@@ -20,6 +20,7 @@ __域名__ : localhost:8090
|
||||
|
||||
* 书籍信息 : Book Controller
|
||||
* 书籍分类信息 : Category Controller
|
||||
* 文件管理 : File Controller
|
||||
* 用户操作 : User Controller
|
||||
* 第三方登录 : Third Party Controller
|
||||
* 系统调试接口 : Debug Controller
|
||||
@@ -258,7 +259,78 @@ __必填__|id|integer (int32)
|
||||
----
|
||||
|
||||
|
||||
[[_addfavoritesusingpost_1]]
|
||||
[[_getfavoriteslistusingpost]]
|
||||
==== 【用户】用户收藏书籍列表
|
||||
....
|
||||
POST /api/book/getFavoritesList
|
||||
....
|
||||
|
||||
|
||||
===== 说明
|
||||
获取用户的收藏书籍列表
|
||||
|
||||
|
||||
===== 参数
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^4a"]
|
||||
|===
|
||||
|类型|名称|类型
|
||||
|**FormData**|**token** +
|
||||
__可选__|string
|
||||
|===
|
||||
|
||||
|
||||
===== 响应
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP代码|说明|类型
|
||||
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|
||||
|**201**|Created|无内容
|
||||
|**401**|Unauthorized|无内容
|
||||
|**403**|Forbidden|无内容
|
||||
|**404**|Not Found|无内容
|
||||
|===
|
||||
|
||||
|
||||
===== 消耗
|
||||
|
||||
* `application/x-www-form-urlencoded`
|
||||
|
||||
|
||||
===== 生成
|
||||
|
||||
* `\*/*`
|
||||
|
||||
|
||||
===== HTTP请求示例
|
||||
|
||||
====== 请求 path
|
||||
----
|
||||
/api/book/getFavoritesList
|
||||
----
|
||||
|
||||
|
||||
====== 请求 formData
|
||||
[source,json]
|
||||
----
|
||||
"string"
|
||||
----
|
||||
|
||||
|
||||
===== HTTP响应示例
|
||||
|
||||
====== 响应 200
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"data" : "object",
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[_getfavoritesstatususingpost]]
|
||||
==== 【用户】收藏/取消收藏书籍
|
||||
....
|
||||
POST /api/book/getFavoritesStatus
|
||||
@@ -399,7 +471,7 @@ __可选__|publishingHouse|string
|
||||
----
|
||||
|
||||
|
||||
[[_addfavoritesusingpost]]
|
||||
[[_togglefavoritesusingpost]]
|
||||
==== 【用户】收藏/取消收藏书籍
|
||||
....
|
||||
POST /api/book/toggleFavorites
|
||||
@@ -585,6 +657,200 @@ GET /api/category/list
|
||||
----
|
||||
|
||||
|
||||
[[_5505c91c7c23d55a117904f2a3fe6081]]
|
||||
=== 文件管理
|
||||
File Controller
|
||||
|
||||
|
||||
[[_cosusingpost]]
|
||||
==== 创建腾讯云 COS 预授权 URL
|
||||
....
|
||||
POST /api/file/cos/{httpMethod}
|
||||
....
|
||||
|
||||
|
||||
===== 参数
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|类型|名称|说明|类型
|
||||
|**Path**|**httpMethod** +
|
||||
__必填__|httpMethod|string
|
||||
|**FormData**|**expireMinute** +
|
||||
__可选__||integer (int32)
|
||||
|**FormData**|**fileName** +
|
||||
__可选__||string
|
||||
|**FormData**|**token** +
|
||||
__可选__||string
|
||||
|===
|
||||
|
||||
|
||||
===== 响应
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP代码|说明|类型
|
||||
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|
||||
|**201**|Created|无内容
|
||||
|**401**|Unauthorized|无内容
|
||||
|**403**|Forbidden|无内容
|
||||
|**404**|Not Found|无内容
|
||||
|===
|
||||
|
||||
|
||||
===== 消耗
|
||||
|
||||
* `application/x-www-form-urlencoded`
|
||||
|
||||
|
||||
===== 生成
|
||||
|
||||
* `\*/*`
|
||||
|
||||
|
||||
===== HTTP请求示例
|
||||
|
||||
====== 请求 path
|
||||
----
|
||||
/api/file/cos/string
|
||||
----
|
||||
|
||||
|
||||
====== 请求 formData
|
||||
[source,json]
|
||||
----
|
||||
"string"
|
||||
----
|
||||
|
||||
|
||||
===== HTTP响应示例
|
||||
|
||||
====== 响应 200
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"data" : "object",
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[_listusingget]]
|
||||
==== 查询文件列表
|
||||
....
|
||||
GET /api/file/list
|
||||
....
|
||||
|
||||
|
||||
===== 说明
|
||||
查询文件列表
|
||||
|
||||
|
||||
===== 参数
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|类型|名称|说明|类型
|
||||
|**Query**|**token** +
|
||||
__可选__|token|string
|
||||
|===
|
||||
|
||||
|
||||
===== 响应
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP代码|说明|类型
|
||||
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|
||||
|**401**|Unauthorized|无内容
|
||||
|**403**|Forbidden|无内容
|
||||
|**404**|Not Found|无内容
|
||||
|===
|
||||
|
||||
|
||||
===== 生成
|
||||
|
||||
* `\*/*`
|
||||
|
||||
|
||||
===== HTTP请求示例
|
||||
|
||||
====== 请求 path
|
||||
----
|
||||
/api/file/list
|
||||
----
|
||||
|
||||
|
||||
===== HTTP响应示例
|
||||
|
||||
====== 响应 200
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"data" : "object",
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[_objectlistusingget]]
|
||||
==== 查询文件对象列表
|
||||
....
|
||||
GET /api/file/object/list
|
||||
....
|
||||
|
||||
|
||||
===== 说明
|
||||
查询文件列表
|
||||
|
||||
|
||||
===== 参数
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|类型|名称|说明|类型
|
||||
|**Query**|**token** +
|
||||
__可选__|token|string
|
||||
|===
|
||||
|
||||
|
||||
===== 响应
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP代码|说明|类型
|
||||
|**200**|OK|<<_commonreturntype,CommonReturnType>>
|
||||
|**401**|Unauthorized|无内容
|
||||
|**403**|Forbidden|无内容
|
||||
|**404**|Not Found|无内容
|
||||
|===
|
||||
|
||||
|
||||
===== 生成
|
||||
|
||||
* `\*/*`
|
||||
|
||||
|
||||
===== HTTP请求示例
|
||||
|
||||
====== 请求 path
|
||||
----
|
||||
/api/file/object/list
|
||||
----
|
||||
|
||||
|
||||
===== HTTP响应示例
|
||||
|
||||
====== 响应 200
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"data" : "object",
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[_9083a36b9e1b060bcb75ff62bb4bda37]]
|
||||
=== 用户操作
|
||||
User Controller
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user