diff --git a/public/index.html b/public/index.html index 8dcf3f8..4f368fc 100644 --- a/public/index.html +++ b/public/index.html @@ -26,6 +26,6 @@ 新T树洞 -
开启javascript,或刷新重试
+
请开启javascript,或稍等片刻
diff --git a/public/static/favicon/180.png b/public/static/favicon/180.png index b08e109..cd70386 100644 Binary files a/public/static/favicon/180.png and b/public/static/favicon/180.png differ diff --git a/public/static/favicon/192.png b/public/static/favicon/192.png index ed4f0c8..f15b6f8 100644 Binary files a/public/static/favicon/192.png and b/public/static/favicon/192.png differ diff --git a/public/static/favicon/512.png b/public/static/favicon/512.png index 0ac9fec..9730e22 100644 Binary files a/public/static/favicon/512.png and b/public/static/favicon/512.png differ diff --git a/src/Common.js b/src/Common.js index d0735df..cf2f9cb 100644 --- a/src/Common.js +++ b/src/Common.js @@ -16,7 +16,7 @@ import renderMd from './Markdown'; export { format_time, Time, TitleLine }; -export const API_BASE = '/_api/v1/'; +export const API_BASE = '/_api/v1'; // https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex function escape_regex(string) { @@ -164,6 +164,7 @@ export class HighlightedMarkdown extends Component { ['url', URL_RE], ['pid', PID_RE], ['nickname', NICKNAME_RE], + //TODO: tag ]); return ( @@ -217,30 +218,15 @@ export class HighlightedMarkdown extends Component { }, ]; const parser = new HtmlToReact.Parser(); - if (props.author && props.text.match(/^(?:#+ |>|```|\t|\s*-|\s*\d+\.)/)) { - const renderedMarkdown = renderMd(props.text); - return ( - <> - {props.author} - {parser.parseWithInstructions( - renderedMarkdown, - (node) => node.type !== 'script', - processInstructions, - ) || ''} - - ); - } else { - let rawMd = props.text; - if (props.author) rawMd = props.author + ' ' + rawMd; - const renderedMarkdown = renderMd(rawMd); - return ( - parser.parseWithInstructions( - renderedMarkdown, - (node) => node.type !== 'script', - processInstructions, - ) || null - ); - } + let rawMd = props.text; + const renderedMarkdown = renderMd(rawMd); + return ( + parser.parseWithInstructions( + renderedMarkdown, + (node) => node.type !== 'script', + processInstructions, + ) || null + ); } } @@ -314,6 +300,7 @@ export class SafeTextarea extends Component { onChange={this.on_change_bound} value={this.state.text} onKeyDown={this.on_keydown_bound} + maxLength="4096" /> ); } diff --git a/src/Flows.css b/src/Flows.css index b2d794d..0e1bcf2 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -254,7 +254,7 @@ color: white; } -.box-header-tag { +.box-header-cw { color: white; background-color: #00c; font-weight: bold; @@ -263,7 +263,16 @@ padding: 0 .25em; } -.root-dark-mode .box-header-tag { +.box-header-name { + color: white; + background-color: #3338; + font-weight: bold; + border-radius: 5px; + margin-right: .5em; + padding: .1em .5em; +} + +.root-dark-mode .box-header-cw { background-color: #00a; } @@ -282,4 +291,4 @@ float: right; padding: 0 .5em; opacity: .4; -} \ No newline at end of file +} diff --git a/src/Flows.js b/src/Flows.js index 4aa89d2..e4cfa3c 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -30,19 +30,6 @@ const CLICKABLE_TAGS = { a: true, audio: true }; const PREVIEW_REPLY_COUNT = 10; // const QUOTE_BLACKLIST=['23333','233333','66666','666666','10086','10000','100000','99999','999999','55555','555555']; const QUOTE_BLACKLIST = []; -const FOLD_TAGS = [ - '性相关', - '政治相关', - '性话题', - '政治话题', - '折叠', - 'NSFW', - '刷屏', - '真实性可疑', - '用户举报较多', - '举报较多', - '重复内容', -]; window.LATEST_POST_ID = parseInt(localStorage['_LATEST_POST_ID'], 10) || 0; @@ -104,11 +91,8 @@ class Reply extends PureComponent { } render() { - const replyContent = this.props.info.text; - const splitIdx = replyContent.indexOf(']'); - - const author = replyContent.substr(0, splitIdx + 1), - replyText = replyContent.substr(splitIdx + 2); + const author = this.props.info.name, + replyText = this.props.info.text; return (
- #{this.props.info.cid} {!!this.props.do_filter_name && ( )}   - {this.props.info.tag !== null && ( - {this.props.info.tag} + {( + {this.props.info.name} )}
(r.tag ? '【' + r.tag + '】' : '') + r.text) + .map((r) => (r.cw ? '【' + r.cw + '】' : '') + r.text) .join('\n'), ); } @@ -237,8 +222,8 @@ class FlowItem extends PureComponent {   - {props.info.tag !== null && props.info.tag !== '折叠' && ( - {props.info.tag} + {props.info.cw !== null && ( + {props.info.cw} )}
@@ -634,8 +619,7 @@ class FlowSidebar extends PureComponent { class FlowItemRow extends PureComponent { constructor(props) { super(props); - this.needFold = - FOLD_TAGS.indexOf(props.info.tag) > -1 && + this.needFold = props.info.cw && (props.search_param === '热榜' || !props.search_param) && window.config.fold && props.mode !== 'attention' && props.mode !== 'attention_finished'; @@ -861,8 +845,8 @@ class FlowItemRow extends PureComponent { )} #{this.props.info.pid}   - {this.props.info.tag !== null && this.props.info.tag !== '折叠' && ( - {this.props.info.tag} + {this.props.info.cw !== null && ( + {this.props.info.cw} )}
) : ( - + <> + + + )}

diff --git a/src/flows_api.js b/src/flows_api.js index 9010902..4f70ac5 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -1,9 +1,9 @@ -import { get_json, API_VERSION_PARAM } from './infrastructure/functions'; +import { get_json} from './infrastructure/functions'; import { API_BASE } from './Common'; import { cache } from './cache'; export function token_param(token) { - return API_VERSION_PARAM() + (token ? '&user_token=' + token : ''); + return token ? '?user_token=' + token : '?notoken'; } export { get_json }; @@ -34,7 +34,7 @@ export const API = { load_replies: async (pid, token, color_picker, cache_version) => { pid = parseInt(pid); let response = await fetch( - API_BASE + '/api.php?action=getcomment&pid=' + pid + token_param(token), + API_BASE + '/getcomment' + token_param(token) + '&pid=' + pid , ); let json = await handle_response(response); // Why delete then put ?? @@ -61,7 +61,7 @@ export const API = { data.append('pid', pid); data.append('switch', attention ? '1' : '0'); let response = await fetch( - API_BASE + '/api.php?action=attention' + token_param(token), + API_BASE + '/attention' + token_param(token), { method: 'POST', headers: { @@ -81,7 +81,7 @@ export const API = { data.append('pid', pid); data.append('reason', reason); let response = await fetch( - API_BASE + '/api.php?action=report' + token_param(token), + API_BASE + '/report' + token_param(token), { method: 'POST', headers: { @@ -95,7 +95,7 @@ export const API = { get_list: async (page, token) => { let response = await fetch( - API_BASE + '/api.php?action=getlist' + '&p=' + page + token_param(token), + API_BASE + '/getlist' + token_param(token) + '&p=' + page, ); return handle_response(response); }, @@ -103,28 +103,28 @@ export const API = { get_search: async (page, keyword, token) => { let response = await fetch( API_BASE + - '/api.php?action=search' + + '/search' + + token_param(token) + '&pagesize=' + SEARCH_PAGESIZE + '&page=' + page + '&keywords=' + - encodeURIComponent(keyword) + - token_param(token), + encodeURIComponent(keyword) ); return handle_response(response); }, get_single: async (pid, token) => { let response = await fetch( - API_BASE + '/api.php?action=getone' + '&pid=' + pid + token_param(token), + API_BASE + '/getone' + token_param(token) + '&pid=' + pid, ); return handle_response(response); }, get_attention: async (token) => { let response = await fetch( - API_BASE + '/api.php?action=getattention' + token_param(token), + API_BASE + '/getattention' + token_param(token), ); return handle_response(response); }, diff --git a/src/infrastructure/functions.js b/src/infrastructure/functions.js index 842ddaa..89c4c94 100644 --- a/src/infrastructure/functions.js +++ b/src/infrastructure/functions.js @@ -1,5 +1,5 @@ export function get_json(res) { - if(!res.ok) throw Error(`网络错误 ${res.status} ${res.statusText}`); + if(!res.ok) throw Error(`错误 ${res.status} ${res.statusText}`); return ( res .text() @@ -30,6 +30,3 @@ export function listen_darkmode(override) { // override: true/false/undefined }); } -export function API_VERSION_PARAM() { - return '&PKUHelperAPI=3.0&jsapiver='+encodeURIComponent((process.env.REACT_APP_BUILD_INFO||'null')+'-'+(Math.floor(+new Date()/7200000)*2)); -} \ No newline at end of file