Browse Source

disable comment cache and pressure for default

dev
xmcp 6 years ago
parent
commit
b2c7238ab0
  1. 7
      src/Config.js
  2. 32
      src/cache.js

7
src/Config.js

@ -12,11 +12,12 @@ const BUILTIN_IMGS={
const DEFAULT_CONFIG={
background_img: 'static/bg/eriri.jpg',
background_color: '#112244',
pressure: true,
pressure: false,
quote: true,
horizontal_scroll: true,
color_picker: true,
easter_egg: true,
comment_cache: false,
};
export function load_config() {
@ -203,6 +204,10 @@ export class ConfigUI extends PureComponent {
description="为不同人的回复分配不同颜色"
/>
<hr />
<ConfigSwitch callback={this.save_changes_bound} id="comment_cache" name="评论缓存"
description="缓存已读树洞的评论(加载更快,但可能有bug)"
/>
<hr />
<ConfigSwitch callback={this.save_changes_bound} id="easter_egg" name="允许彩蛋"
description="在某些情况下显示彩蛋"
/>

32
src/cache.js

@ -6,21 +6,23 @@ class Cache {
constructor() {
this.db=null;
this.added_items_since_maintenance=0;
const open_req=indexedDB.open('hole_cache_db',CACHE_DB_VER);
open_req.onerror=console.error.bind(console);
open_req.onupgradeneeded=(event)=>{
console.log('comment cache db upgrade');
const db=event.target.result;
const store=db.createObjectStore('comment',{
keyPath: 'pid',
});
store.createIndex('last_access','last_access',{unique: false});
};
open_req.onsuccess=(event)=>{
console.log('comment cache db loaded');
this.db=event.target.result;
setTimeout(this.maintenance.bind(this),1);
};
if(window.config.comment_cache) {
const open_req=indexedDB.open('hole_cache_db',CACHE_DB_VER);
open_req.onerror=console.error.bind(console);
open_req.onupgradeneeded=(event)=>{
console.log('comment cache db upgrade');
const db=event.target.result;
const store=db.createObjectStore('comment',{
keyPath: 'pid',
});
store.createIndex('last_access','last_access',{unique: false});
};
open_req.onsuccess=(event)=>{
console.log('comment cache db loaded');
this.db=event.target.result;
setTimeout(this.maintenance.bind(this),1);
};
}
}
get(pid,target_version) {

Loading…
Cancel
Save