Browse Source

修改设置(折叠豁免、忽略所有折叠洞)

pull/6/head
hole-thu 5 years ago
parent
commit
b539919550
  1. 29
      src/Config.js
  2. 18
      src/Flows.js
  3. 24
      src/UserAction.js
  4. 5
      src/flows_api.js
  5. 16
      src/infrastructure/widgets.css
  6. 15
      src/infrastructure/widgets.js

29
src/Config.js

@ -3,8 +3,10 @@ import React, { PureComponent } from 'react';
import './Config.css';
const BUILTIN_IMGS = {
'https://www.tsinghua.edu.cn/images/footer.jpg':
'清华紫(默认)',
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg':
'寻觅繁星(默认)',
'寻觅繁星',
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/eriri.jpg':
'平成著名画师',
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/yurucamp.jpg':
@ -21,13 +23,14 @@ const BUILTIN_IMGS = {
const DEFAULT_CONFIG = {
background_img:
'https://cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg',
'https://www.tsinghua.edu.cn/images/footer.jpg',
background_color: '#113366',
pressure: false,
easter_egg: true,
color_scheme: 'default',
fold: true,
no_c_post: false,
block_words: [],
whitelist_cw: []
};
export function load_config() {
@ -370,7 +373,7 @@ export class ConfigUI extends PureComponent {
</p>
<p>
<b>
修改设置后{' '}
部分设置修改后需要{' '}
<a
onClick={() => {
window.location.reload();
@ -407,6 +410,16 @@ export class ConfigUI extends PureComponent {
parse={(string) => string.split('\n')}
/>
<hr />
<ConfigTextArea
id="whitelist_cw"
callback={this.save_changes_bound}
name="展开指定的折叠警告"
description={'完全匹配的树洞不会被折叠,每行一个豁免词,也可使用一个星号("*")表示豁免所有'}
display={(array) => array.join('\n')}
sift={(array) => array.filter((v) => v)}
parse={(string) => string.split('\n')}
/>
<hr />
<ConfigSwitch
callback={this.save_changes_bound}
id="pressure"
@ -423,15 +436,15 @@ export class ConfigUI extends PureComponent {
<hr />
<ConfigSwitch
callback={this.save_changes_bound}
id="fold"
name="折叠树洞"
description="在时间线中折叠可能引起不适的树洞"
id="no_c_post"
name="忽略折叠树洞"
description="不获取所有带折叠警告的树洞,折叠警告豁免将不起作用"
/>
<hr />
<p>
新功能建议或问题反馈请在&nbsp;
<a
href="https://github.com/thuhole/thuhole-go-backend/issues"
href="https://github.com/newthuhole/hole-backend/issues"
target="_blank"
>
GitHub <span className="icon icon-github" />

18
src/Flows.js

@ -666,7 +666,7 @@ class FlowItemRow extends PureComponent {
super(props);
this.needFold = props.info.cw &&
(props.search_param === '热榜' || !props.search_param) &&
window.config.fold &&
(window.config.whitelist_cw.indexOf('*')==-1 && window.config.whitelist_cw.indexOf(props.info.cw)==-1) &&
props.mode !== 'attention' && props.mode !== 'attention_finished';
this.state = {
replies: [],
@ -674,8 +674,8 @@ class FlowItemRow extends PureComponent {
reply_error: null,
info: Object.assign({}, props.info, { variant: {} }),
hidden: window.config.block_words.some((word) =>
props.info.text.includes(word),
) || this.needFold,
props.info.text.includes(word),
) || this.needFold,
attention:
props.attention_override === null ? false : props.attention_override,
cached: true, // default no display anything
@ -897,7 +897,7 @@ class FlowItemRow extends PureComponent {
)}
<Time stamp={this.props.info.timestamp} short={true} />
<span className="box-header-badge">
{this.needFold ? '已隐藏' : '已屏蔽'}
{this.needFold ? '已折叠' : '已屏蔽'}
</span>
<div style={{ clear: 'both' }} />
</div>
@ -1073,7 +1073,7 @@ export class Flow extends PureComponent {
this.setState((prev, props) => ({
loaded_pages: prev.loaded_pages - 1,
loading_status: 'failed',
error_msg: prev.loaded_pages>1 ? '找不到更多了' : '' + err,
error_msg: prev.loaded_pages > 1 ? '找不到更多了' : '' + err,
}));
};
@ -1095,10 +1095,10 @@ export class Flow extends PureComponent {
json.data.forEach((x) => {
if (x.comments) {
let comment_json = {
'code': 0,
'attention': x.attention,
'data': x.comments
}
code: 0,
attention: x.attention,
data: x.comments,
};
//console.log('My cache', comment_json, x.pid, x.reply)
cache().put(x.pid, parseInt(x.reply, 10), comment_json);
}

24
src/UserAction.js

@ -25,8 +25,8 @@ const MAX_IMG_DIAM = 8000;
const MAX_IMG_PX = 5000000;
const MAX_IMG_FILESIZE = 450000 * BASE64_RATE;
const REPOSITORY = 'https://a.com/b';
const EMAIL = '[email protected]';
const REPOSITORY = 'https://github.com/newthuhole';
const EMAIL = '[email protected]';
export const TokenCtx = React.createContext({
value: null,
@ -39,6 +39,11 @@ export function InfoSidebar(props) {
<PromotionBar />
<LoginForm show_sidebar={props.show_sidebar} />
<div className="box list-menu">
<a href="/about.html" target="_blank">
<span className="icon icon-textfile" />
<label>关于</label>
</a>
&nbsp;&nbsp;
<a
onClick={() => {
props.show_sidebar('设置', <ConfigUI />);
@ -52,14 +57,6 @@ export function InfoSidebar(props) {
<span className="icon icon-textfile" />
<label>树洞规范试行</label>
</a>
&nbsp;&nbsp;
<a
href={REPOSITORY+"/issues"}
target="_blank"
>
<span className="icon icon-github" />
<label>意见反馈</label>
</a>
</div>
<div className="box help-desc-box">
<p>
@ -88,7 +85,8 @@ export function InfoSidebar(props) {
</p>
</div>
<div className="box help-desc-box">
<p>联系我们<a href={"mailto:"+EMAIL}>{EMAIL}</a></p>
<p>意见反馈请加tag #意见反馈 或到github后端的issus区</p>
<p>联系我们<a href={"mailto:"+EMAIL}>{EMAIL}</a> </p>
</div>
<div className="box help-desc-box">
<p>
@ -102,7 +100,7 @@ export function InfoSidebar(props) {
<a href={REPOSITORY} target="_blank">
GitHub
</a>{' '}
开源
开源
</p>
<p>
新T树洞 网页版基于
@ -121,7 +119,7 @@ export function InfoSidebar(props) {
<a href="https://icomoon.io/#icons" target="_blank" rel="noopener">
IcoMoon
</a>
等开源项目
等开源项目
</p>
</div>
</div>

5
src/flows_api.js

@ -118,7 +118,10 @@ export const API = {
get_list: async (page, token) => {
let response = await fetch(
API_BASE + '/getlist' + token_param(token) + '&p=' + page,
API_BASE + '/getlist'
+ token_param(token)
+ '&p=' + page
+ (window.config.no_c_post ? '&no_cw' : '')
);
return handle_response(response);
},

16
src/infrastructure/widgets.css

@ -301,13 +301,15 @@ a.app-switcher-item, .app-switcher-item a {
}
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
color: initial;
text-decoration: none;
color: initial;
min-width: 6em;
font-size: 0.85em;
min-width: 6em;
font-size: 0.85em;
padding: 5px;
}

15
src/infrastructure/widgets.js

@ -76,27 +76,30 @@ class LoginPopupSelf extends Component {
<b>通过第三方验证登陆T大树洞</b>
</p>
<p>
<a className="button" href="/_login?p=cs" target="_blank"
>
闭社
<a href="/_login?p=cs" target="_blank">
<span className="icon icon-login" />
&nbsp;闭社
</a>
</p>
<p>
<button type="button" disabled
>
T大树洞
<span className="icon icon-login" />
&nbsp;T大树洞
</button>
</p>
<p>
<button type="button" disabled
>
未名bbs
<span className="icon icon-login" />
&nbsp;未名bbs
</button>
</p>
<p>
<button type="button" disabled
>
清华统一身份认证
<span className="icon icon-login" />
&nbsp;清华统一身份认证
</button>
</p>
<hr />

Loading…
Cancel
Save