update
- add cr_version_test - remove track config - remove comment_cache and horizontal_scroll config
This commit is contained in:
@@ -33,6 +33,10 @@
|
|||||||
_czc.push(["_setCustomVar","has_token",localStorage['TOKEN']?'yes':'no',1]);
|
_czc.push(["_setCustomVar","has_token",localStorage['TOKEN']?'yes':'no',1]);
|
||||||
_czc.push(["_setCustomVar","standalone",((window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone))?'yes':'no',1]);
|
_czc.push(["_setCustomVar","standalone",((window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone))?'yes':'no',1]);
|
||||||
_czc.push(["_setCustomVar","build_info","%REACT_APP_BUILD_INFO%"||'---']);
|
_czc.push(["_setCustomVar","build_info","%REACT_APP_BUILD_INFO%"||'---']);
|
||||||
|
var cr_version=/Chrome\/(\d+)/.exec(navigator.userAgent);
|
||||||
|
_czc.push(["_setCustomVar","cr_version_test",cr_version?cr_version[1]:'[null]',2]);
|
||||||
|
/*
|
||||||
|
// track config
|
||||||
try {
|
try {
|
||||||
var config=JSON.parse(localStorage['hole_config']||'{}');
|
var config=JSON.parse(localStorage['hole_config']||'{}');
|
||||||
for(var key in config)
|
for(var key in config)
|
||||||
@@ -42,6 +46,7 @@
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.trace(e);
|
console.trace(e);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
var cnzz_s_tag = document.createElement('script');
|
var cnzz_s_tag = document.createElement('script');
|
||||||
cnzz_s_tag.type = 'text/javascript';
|
cnzz_s_tag.type = 'text/javascript';
|
||||||
cnzz_s_tag.async = true;
|
cnzz_s_tag.async = true;
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ const DEFAULT_CONFIG={
|
|||||||
background_img: 'static/bg/gbp.jpg',
|
background_img: 'static/bg/gbp.jpg',
|
||||||
background_color: '#113366',
|
background_color: '#113366',
|
||||||
pressure: false,
|
pressure: false,
|
||||||
horizontal_scroll: true,
|
|
||||||
easter_egg: true,
|
easter_egg: true,
|
||||||
comment_cache: false,
|
|
||||||
color_scheme: 'default',
|
color_scheme: 'default',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -223,7 +221,6 @@ export class ConfigUI extends PureComponent {
|
|||||||
<div>
|
<div>
|
||||||
<div className="box config-ui-header">
|
<div className="box config-ui-header">
|
||||||
<p>这些功能仍在测试,可能不稳定(<a onClick={this.reset_settings.bind(this)}>全部重置</a>)</p>
|
<p>这些功能仍在测试,可能不稳定(<a onClick={this.reset_settings.bind(this)}>全部重置</a>)</p>
|
||||||
<p>我们会收集你的设置,以用于改进产品</p>
|
|
||||||
<p><b>修改设置后 <a onClick={()=>{window.location.reload()}}>刷新页面</a> 方可生效</b></p>
|
<p><b>修改设置后 <a onClick={()=>{window.location.reload()}}>刷新页面</a> 方可生效</b></p>
|
||||||
</div>
|
</div>
|
||||||
<div className="box">
|
<div className="box">
|
||||||
@@ -235,14 +232,6 @@ export class ConfigUI extends PureComponent {
|
|||||||
description="短暂按住 Esc 键或重压屏幕(3D Touch)可以快速返回或者刷新树洞"
|
description="短暂按住 Esc 键或重压屏幕(3D Touch)可以快速返回或者刷新树洞"
|
||||||
/>
|
/>
|
||||||
<hr />
|
<hr />
|
||||||
<ConfigSwitch callback={this.save_changes_bound} id="horizontal_scroll" name="横向滚动"
|
|
||||||
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="允许彩蛋"
|
<ConfigSwitch callback={this.save_changes_bound} id="easter_egg" name="允许彩蛋"
|
||||||
description="在某些情况下显示彩蛋"
|
description="在某些情况下显示彩蛋"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -53,9 +53,6 @@
|
|||||||
padding-left: 18px;
|
padding-left: 18px;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
.flow-reply-row.config-no-scroll {
|
|
||||||
overflow-x: hidden !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flow-reply-row::-webkit-scrollbar {
|
.flow-reply-row::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ class FlowItemRow extends PureComponent {
|
|||||||
}}>
|
}}>
|
||||||
<FlowItem parts={parts} info={this.state.info} attention={this.state.attention} img_clickable={false} is_quote={this.props.is_quote}
|
<FlowItem parts={parts} info={this.state.info} attention={this.state.attention} img_clickable={false} is_quote={this.props.is_quote}
|
||||||
color_picker={this.color_picker} show_pid={show_pid} replies={this.state.replies} />
|
color_picker={this.color_picker} show_pid={show_pid} replies={this.state.replies} />
|
||||||
<div className={'flow-reply-row'+(window.config.horizontal_scroll ? '' : ' config-no-scroll')}>
|
<div className="flow-reply-row">
|
||||||
{this.state.reply_status==='loading' && <div className="box box-tip">加载中</div>}
|
{this.state.reply_status==='loading' && <div className="box box-tip">加载中</div>}
|
||||||
{this.state.reply_status==='failed' &&
|
{this.state.reply_status==='failed' &&
|
||||||
<div className="box box-tip"><a onClick={()=>{this.load_replies()}}>重新加载</a></div>
|
<div className="box box-tip"><a onClick={()=>{this.load_replies()}}>重新加载</a></div>
|
||||||
|
|||||||
38
src/cache.js
38
src/cache.js
@@ -6,23 +6,21 @@ class Cache {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.db=null;
|
this.db=null;
|
||||||
this.added_items_since_maintenance=0;
|
this.added_items_since_maintenance=0;
|
||||||
if(window.config.comment_cache) {
|
const open_req=indexedDB.open('hole_cache_db',CACHE_DB_VER);
|
||||||
const open_req=indexedDB.open('hole_cache_db',CACHE_DB_VER);
|
open_req.onerror=console.error.bind(console);
|
||||||
open_req.onerror=console.error.bind(console);
|
open_req.onupgradeneeded=(event)=>{
|
||||||
open_req.onupgradeneeded=(event)=>{
|
console.log('comment cache db upgrade');
|
||||||
console.log('comment cache db upgrade');
|
const db=event.target.result;
|
||||||
const db=event.target.result;
|
const store=db.createObjectStore('comment',{
|
||||||
const store=db.createObjectStore('comment',{
|
keyPath: 'pid',
|
||||||
keyPath: 'pid',
|
});
|
||||||
});
|
store.createIndex('last_access','last_access',{unique: false});
|
||||||
store.createIndex('last_access','last_access',{unique: false});
|
};
|
||||||
};
|
open_req.onsuccess=(event)=>{
|
||||||
open_req.onsuccess=(event)=>{
|
console.log('comment cache db loaded');
|
||||||
console.log('comment cache db loaded');
|
this.db=event.target.result;
|
||||||
this.db=event.target.result;
|
setTimeout(this.maintenance.bind(this),1);
|
||||||
setTimeout(this.maintenance.bind(this),1);
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get(pid,target_version) {
|
get(pid,target_version) {
|
||||||
@@ -35,15 +33,15 @@ class Cache {
|
|||||||
get_req.onsuccess=()=>{
|
get_req.onsuccess=()=>{
|
||||||
let res=get_req.result;
|
let res=get_req.result;
|
||||||
if(!res) {
|
if(!res) {
|
||||||
console.log('cache miss');
|
//console.log('comment cache miss '+pid);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
} else if(target_version===res.version) { // hit
|
} else if(target_version===res.version) { // hit
|
||||||
console.log('cache hit');
|
console.log('comment cache hit '+pid);
|
||||||
res.last_access=(+new Date());
|
res.last_access=(+new Date());
|
||||||
store.put(res);
|
store.put(res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
} else { // expired
|
} else { // expired
|
||||||
console.log('cache expired: ver',res.version,'target',target_version);
|
console.log('comment cache expired '+pid+': ver',res.version,'target',target_version);
|
||||||
store.delete(pid);
|
store.delete(pid);
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user