mirror of
https://github.com/Kakune55/ComiPy.git
synced 2025-05-06 18:29:26 +08:00
修复bug 和 添加book详细页
This commit is contained in:
parent
79beba473e
commit
a434e44f7f
10
db/file.py
10
db/file.py
@ -1,4 +1,4 @@
|
|||||||
import shortuuid
|
import shortuuid, time
|
||||||
import db.util as util
|
import db.util as util
|
||||||
|
|
||||||
|
|
||||||
@ -27,18 +27,18 @@ def searchByname(filename: str):
|
|||||||
|
|
||||||
|
|
||||||
# 在数据库中添加一个新的文件记录
|
# 在数据库中添加一个新的文件记录
|
||||||
def new(filename: str):
|
def new(filename: str, pagenumber:int):
|
||||||
suuid = shortuuid.random(8)
|
suuid = shortuuid.random(8)
|
||||||
conn = util.getConn()
|
conn = util.getConn()
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute(
|
c.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO Metadata
|
INSERT INTO Metadata
|
||||||
(id, filename)
|
(id, filename, pagenumber, inputtime)
|
||||||
VALUES
|
VALUES
|
||||||
(?, ?, ?);
|
(?, ?, ?, ?);
|
||||||
""",
|
""",
|
||||||
(suuid, filename),
|
(suuid, filename, pagenumber, int(time.time())),
|
||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
@ -16,7 +16,9 @@ def init():
|
|||||||
CREATE TABLE IF NOT EXISTS Metadata (
|
CREATE TABLE IF NOT EXISTS Metadata (
|
||||||
num INTEGER PRIMARY KEY AUTOINCREMENT,
|
num INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
id TEXT NOT NULL,
|
id TEXT NOT NULL,
|
||||||
filename TEXT NOT NULL
|
filename TEXT NOT NULL,
|
||||||
|
pagenumber INT NOT NULL,
|
||||||
|
inputtime INT NOT NULL
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
2
file.py
2
file.py
@ -24,7 +24,7 @@ def auotLoadFile():
|
|||||||
with zipfile.ZipFile(
|
with zipfile.ZipFile(
|
||||||
config.get("file", "inputdir") + "/" + item, "r"
|
config.get("file", "inputdir") + "/" + item, "r"
|
||||||
) as zip_ref:
|
) as zip_ref:
|
||||||
db.file.new(item) # 添加数据库记录 移动到存储
|
db.file.new(item, len(zip_ref.namelist())) # 添加数据库记录 移动到存储
|
||||||
shutil.move(
|
shutil.move(
|
||||||
config.get("file", "inputdir") + "/" + item,
|
config.get("file", "inputdir") + "/" + item,
|
||||||
config.get("file", "storedir") + "/" + item,
|
config.get("file", "storedir") + "/" + item,
|
||||||
|
82
templates/book.html
Normal file
82
templates/book.html
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<title>详情页面</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 80%;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.movie-poster {
|
||||||
|
flex: 1;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
.movie-details {
|
||||||
|
flex: 2;
|
||||||
|
}
|
||||||
|
.movie-details h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.movie-details p {
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.comments-section {
|
||||||
|
width: 80%;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.comment {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.comment p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<div class="movie-poster">
|
||||||
|
<!-- 封面 -->
|
||||||
|
<img src="/api/img/{{ id }}/1?mini=yes" alt="封面" style="max-width: 100%;">
|
||||||
|
</div>
|
||||||
|
<div class="movie-details">
|
||||||
|
<!-- 详细信息 -->
|
||||||
|
<h1>{{ data[0][2] }}</h1>
|
||||||
|
<h2>时间: {{time}}</h2>
|
||||||
|
<h2>暂无评价</h2>
|
||||||
|
<button onclick="window.location.href='/view/{{ id }}'">在线浏览</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="comments-section">
|
||||||
|
<h2>评论区</h2>
|
||||||
|
<!-- 评论 -->
|
||||||
|
<div class="comment">
|
||||||
|
<p>用户A:Lorem ipsum dolor sit amet consectetur adipisicing elit. Nobis, quam!</p>
|
||||||
|
</div>
|
||||||
|
<div class="comment">
|
||||||
|
<p>用户B:Lorem, ipsum dolor sit amet consectetur adipisicing elit. Aut sunt tempore architecto minus, cum mollitia voluptatibus repellendus aliquid id reprehenderit.</p>
|
||||||
|
</div>
|
||||||
|
<!-- 在此添加更多评论 -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
<div class="alert alert-success mt-3 d-none" id="uploadSuccess" role="alert">
|
<div class="alert alert-success mt-3 d-none" id="uploadSuccess" role="alert">
|
||||||
文件上传成功!
|
文件上传成功!
|
||||||
|
<button onclick="window.location.href='/'">返回首页</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
22
web/page.py
22
web/page.py
@ -1,7 +1,7 @@
|
|||||||
from flask import *
|
from flask import *
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
import configparser
|
import configparser, time
|
||||||
import db.file , file
|
import db.file, file
|
||||||
|
|
||||||
page_bp = Blueprint("page_bp", __name__)
|
page_bp = Blueprint("page_bp", __name__)
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ def overview(page): # 概览
|
|||||||
if request.cookies.get("islogin") is None:
|
if request.cookies.get("islogin") is None:
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20)
|
metaDataList = db.file.getMetadata((page - 1) * 20, page * 20)
|
||||||
|
for item in metaDataList:
|
||||||
|
item[2] = item[2][:-4] #去除文件扩展名
|
||||||
if page <= 3:
|
if page <= 3:
|
||||||
lastPageList = range(1, page)
|
lastPageList = range(1, page)
|
||||||
else:
|
else:
|
||||||
@ -36,14 +38,26 @@ def book(bookid): # 接口
|
|||||||
data = db.file.searchByid(bookid)
|
data = db.file.searchByid(bookid)
|
||||||
if data == "":
|
if data == "":
|
||||||
return abort(404)
|
return abort(404)
|
||||||
return render_template("view.html", id=bookid, index=range(1, data[0][3]))
|
data[0] = list(data[0])
|
||||||
|
data[0][2] = data[0][2][0:-4] # 把文件扩展名去掉
|
||||||
|
local_time = time.localtime(float(data[0][4]))
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"book.html",
|
||||||
|
id=bookid,
|
||||||
|
data=data,
|
||||||
|
time=time.strftime("%Y-%m-%d %H:%M:%S",local_time),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@page_bp.route("/view/<bookid>")
|
@page_bp.route("/view/<bookid>")
|
||||||
def view(bookid): # 接口
|
def view(bookid): # 接口
|
||||||
if request.cookies.get("islogin") is None:
|
if request.cookies.get("islogin") is None:
|
||||||
return abort(403)
|
return abort(403)
|
||||||
return bookid
|
data = db.file.searchByid(bookid)
|
||||||
|
if data == "":
|
||||||
|
return abort(404)
|
||||||
|
return render_template("view.html", id=bookid, index=range(1, data[0][3]))
|
||||||
|
|
||||||
|
|
||||||
@page_bp.route("/upload", methods=["GET", "POST"]) # 文件上传
|
@page_bp.route("/upload", methods=["GET", "POST"]) # 文件上传
|
||||||
|
Loading…
x
Reference in New Issue
Block a user