mirror of
https://github.com/lyz05/danmaku.git
synced 2026-02-02 17:59:53 +08:00
fix: 支持缓存
This commit is contained in:
10
app.js
10
app.js
@@ -24,12 +24,12 @@ app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false, validate: { trustProxy: false } }));
|
||||
app.use(cookieParser());
|
||||
// 加载静态资源
|
||||
app.use(express.static(path.join(__dirname, "public")));
|
||||
app.use(express.static(path.join(__dirname, "public"), {maxAge: 86400*1000 }));
|
||||
app.use("/assets", [
|
||||
express.static(__dirname + "/node_modules/jquery/dist/"),
|
||||
express.static(__dirname + "/node_modules/bootstrap/dist/"),
|
||||
express.static(__dirname + "/node_modules/axios/dist/"),
|
||||
express.static(__dirname + "/node_modules/leancloud-storage/dist"),
|
||||
express.static(__dirname + "/node_modules/jquery/dist/",{maxAge: 86400*1000}),
|
||||
express.static(__dirname + "/node_modules/bootstrap/dist/",{maxAge: 86400*1000}),
|
||||
express.static(__dirname + "/node_modules/axios/dist/",{maxAge: 86400*1000}),
|
||||
express.static(__dirname + "/node_modules/leancloud-storage/dist",{maxAge: 86400*1000}),
|
||||
]);
|
||||
|
||||
// 加载路由
|
||||
|
||||
@@ -77,8 +77,10 @@ async function resolve(req, res) {
|
||||
//B站视频,直接重定向
|
||||
if (ret.url)
|
||||
res.redirect(ret.url);
|
||||
else
|
||||
else {
|
||||
res.set('Cache-Control', 'public, max-age=86400'); // one year
|
||||
res.render("danmaku-xml", { contents: ret.content });
|
||||
}
|
||||
}
|
||||
|
||||
async function index(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user