fix config and gallery
This commit is contained in:
parent
4443e80b6f
commit
3dbcf56546
4
.gitignore
vendored
4
.gitignore
vendored
@ -12,4 +12,6 @@ db.sqlite3
|
||||
build/**
|
||||
app/**
|
||||
settings.json
|
||||
*config.json
|
||||
*config.json
|
||||
|
||||
.pnpm-store/**
|
@ -59,6 +59,7 @@
|
||||
"knex": "^0.95.11",
|
||||
"koa": "^2.13.1",
|
||||
"koa-bodyparser": "^4.3.0",
|
||||
"koa-compose": "^4.1.0",
|
||||
"koa-router": "^10.0.0",
|
||||
"natural-orderby": "^2.0.3",
|
||||
"node-stream-zip": "^1.12.0",
|
||||
@ -74,9 +75,8 @@
|
||||
"@types/tiny-async-pool": "^1.0.0",
|
||||
"electron": "^11.2.0",
|
||||
"electron-builder": "^22.9.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"ts-json-schema-generator": "^0.82.0",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.7.3"
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,10 @@ export interface SettingConfig {
|
||||
* if true, server will bind on '127.0.0.1' rather than '0.0.0.0'
|
||||
*/
|
||||
localmode: boolean,
|
||||
/**
|
||||
* secure only
|
||||
*/
|
||||
secure: boolean,
|
||||
|
||||
/**
|
||||
* guest permission
|
||||
@ -31,8 +35,8 @@ export interface SettingConfig {
|
||||
forbid_remote_admin_login:boolean,
|
||||
}
|
||||
const default_setting:SettingConfig = {
|
||||
|
||||
localmode: true,
|
||||
secure: true,
|
||||
guest:[],
|
||||
jwt_secretkey:"itsRandom",
|
||||
port:8080,
|
||||
|
@ -26,6 +26,7 @@ export const GalleryInfo = (props: GalleryProp) => {
|
||||
const c = await ContentAccessor.findList(props.option);
|
||||
//todo : if c is undefined, retry to fetch 3 times. and show error message.
|
||||
setState({ documents: c });
|
||||
setLoadAll(c.length > 0);
|
||||
})
|
||||
load();
|
||||
}, [props.diff]);
|
||||
@ -59,7 +60,13 @@ export const GalleryInfo = (props: GalleryProp) => {
|
||||
);
|
||||
function loadMore() {
|
||||
let option = {...props.option};
|
||||
option.cursor = state.documents[state.documents.length - 1].id;
|
||||
if(state.documents === undefined || state.documents.length === 0){
|
||||
console.log("loadall");
|
||||
setLoadAll(true);
|
||||
return;
|
||||
}
|
||||
const prev_documents = state.documents;
|
||||
option.cursor = prev_documents[prev_documents.length - 1].id;
|
||||
console.log("load more", option);
|
||||
const load = (async () => {
|
||||
const c = await ContentAccessor.findList(option);
|
||||
@ -67,7 +74,7 @@ export const GalleryInfo = (props: GalleryProp) => {
|
||||
setLoadAll(true);
|
||||
}
|
||||
else{
|
||||
setState({ documents: [...state.documents, ...c] });
|
||||
setState({ documents: [...prev_documents, ...c] });
|
||||
}
|
||||
});
|
||||
load();
|
||||
|
@ -70,19 +70,19 @@ const publishRefreshToken = (
|
||||
);
|
||||
return payload;
|
||||
};
|
||||
const setToken = (
|
||||
function setToken(
|
||||
ctx: Koa.Context,
|
||||
token_name: string,
|
||||
token_payload: string | null,
|
||||
expiredtime: number,
|
||||
) => {
|
||||
) {
|
||||
const setting = get_setting();
|
||||
if (token_payload === null && !!!ctx.cookies.get(token_name)) {
|
||||
return;
|
||||
}
|
||||
ctx.cookies.set(token_name, token_payload, {
|
||||
httpOnly: true,
|
||||
secure: !setting.localmode,
|
||||
secure: setting.secure,
|
||||
sameSite: "strict",
|
||||
expires: new Date(Date.now() + expiredtime * 1000),
|
||||
});
|
||||
|
@ -16,19 +16,18 @@ import Router from "koa-router";
|
||||
let ZipStreamCache: { [path: string]: [ZipAsync, number] } = {};
|
||||
|
||||
async function acquireZip(path: string) {
|
||||
if (ZipStreamCache[path] === undefined) {
|
||||
if (!(path in ZipStreamCache)) {
|
||||
const ret = await readZip(path);
|
||||
if (ZipStreamCache[path] === undefined) {
|
||||
ZipStreamCache[path] = [ret, 1];
|
||||
ZipStreamCache[path] = [ret, 1];
|
||||
//console.log(`acquire ${path} 1`);
|
||||
return ret;
|
||||
}
|
||||
ret.close();
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
const [ret, refCount] = ZipStreamCache[path];
|
||||
ZipStreamCache[path] = [ret, refCount + 1];
|
||||
//console.log(`acquire ${path} ${refCount + 1}`);
|
||||
return ret;
|
||||
}
|
||||
const [ret, refCount] = ZipStreamCache[path];
|
||||
ZipStreamCache[path] = [ret, refCount + 1];
|
||||
//console.log(`acquire ${path} ${refCount + 1}`);
|
||||
return ret;
|
||||
}
|
||||
|
||||
function releaseZip(path: string) {
|
||||
@ -39,9 +38,10 @@ function releaseZip(path: string) {
|
||||
if (refCount === 1) {
|
||||
ref.close();
|
||||
delete ZipStreamCache[path];
|
||||
return;
|
||||
}
|
||||
ZipStreamCache[path] = [ref, refCount - 1];
|
||||
else{
|
||||
ZipStreamCache[path] = [ref, refCount - 1];
|
||||
}
|
||||
}
|
||||
|
||||
async function renderZipImage(ctx: Context, path: string, page: number) {
|
||||
|
Loading…
Reference in New Issue
Block a user