This commit is contained in:
2026-02-16 16:16:42 +08:00
parent 43c81289ab
commit e24c839c05
3 changed files with 13 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ export default function Notification(message: string, type: 'success' | 'error'
const colors = {
success: { bg: '#4caf50', icon: '✓' },
error: { bg: '#f44336', icon: '✕' },
info: { bg: '#2196f3', icon: '' }
info: { bg: '#2196f3', icon: 'i' }
};
const color = colors[type];

View File

@@ -91,15 +91,16 @@ export class PocketBaseDb implements Db {
}
}
async createCollection(name: string, fields: Record<string, unknown>[], indexes: string[]) {
const nindexes = indexes.map(i => i.replaceAll('{name}', `${this.cfg.prefix}${name}`));
await this.client.collections.create({
name: `${this.cfg.prefix}${name}`,
type: 'base',
fields: fields,
indexes: indexes,
indexes: nindexes,
});
}
async updateCollection(name: string, fields: Record<string, unknown>[], indexes: string[]) {
const nidexes = indexes.map(i => i.replace('{name}', `${this.cfg.prefix}${name}`));
const nidexes = indexes.map(i => i.replaceAll('{name}', `${this.cfg.prefix}${name}`));
await this.client.collections.update(`${this.cfg.prefix}${name}`, {
fields: fields,
indexes: nidexes,
@@ -119,7 +120,7 @@ export class PocketBaseDb implements Db {
}
}
for (const index of indexes) {
const tindex = index.replace('{name}', col.name);
const tindex = index.replaceAll('{name}', col.name);
if (!col.indexes.includes(tindex)) {
return false;
}

View File

@@ -29,8 +29,14 @@ async function load() {
const bookInfo = pageData.pageContext.pageProps.pageData.bookInfo;
let contents: string[] | undefined = undefined;
if (chapterInfo.vipStatus !== 0) {
if (!chapterInfo.isBuy) return;
if (chapterInfo.cES !== 0) return;
if (!chapterInfo.isBuy) {
Notification(`章节《${chapterInfo.chapterName}》未购买,跳过保存`, 'info');
return;
}
if (chapterInfo.cES !== 0) {
Notification(`章节《${chapterInfo.chapterName}》有特殊加密,无法保存`, 'info');
return;
}
contents = getContents();
} else {
contents = get_chapter_content(chapterInfo.content);