自动释放锁,优化record.getList()

This commit is contained in:
undefined committed 2020-07-27 17:45:32 +08:00
1 parent d3deeaeb96
commit 2bf6adbaa0
12 files changed
+51 -28

No files matched your search

+5 -3
View File
@@ -28,7 +28,7 @@ export function* paginate(page: number, numPages: number) {
let first: number;
let last: number;
if (page > 1) {
yield ['first', 1];
if (page > 2) yield ['first', 1];
yield ['previous', page - 1];
}
if (page <= radius) [first, last] = [1, Math.min(1 + radius * 2, numPages)];
@@ -43,8 +43,10 @@ export function* paginate(page: number, numPages: number) {
else yield ['current', page];
}
if (last < numPages) yield ['ellipsis', 0];
if (page < numPages) yield ['next', page + 1];
yield ['last', numPages];
if (page < numPages) {
yield ['next', page + 1];
if (page < numPages - 1) yield ['last', numPages];
}
}
export function size(s: number, base = 1) {
+1 -1
View File
@@ -18,7 +18,7 @@ class Loader extends nunjucks.Loader {
};
}
let fullpath = null;
const p = path.resolve(argv.template as string, name);
const p = path.resolve(process.cwd(), argv.template as string, name);
if (fs.existsSync(p)) fullpath = p;
if (!fullpath) throw new Error(`Cannot get template ${name}`);
return {