From 9bbebd9f11b58f105e2e4f2497938f110deecf18 Mon Sep 17 00:00:00 2001 From: xmcp Date: Thu, 23 Aug 2018 11:40:43 +0800 Subject: [PATCH] add new post detection --- src/Common.js | 6 +++--- src/Flows.css | 12 ++++++++++++ src/Flows.js | 7 +++++++ src/Title.js | 5 +++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Common.js b/src/Common.js index e3ad0d5..53c8c48 100644 --- a/src/Common.js +++ b/src/Common.js @@ -1,7 +1,7 @@ import React, {Component} from 'react'; import TimeAgo from 'react-timeago'; -import Linkify, {linkify} from 'react-linkify'; +import Linkify from 'react-linkify'; import chineseStrings from 'react-timeago/lib/language-strings/zh-CN'; import buildFormatter from 'react-timeago/lib/formatters/buildFormatter'; @@ -9,8 +9,8 @@ import './Common.css'; const chinese_format=buildFormatter(chineseStrings); -const PID_RE=/(^|[^\d])([1-9]\d{4,5})(?!\d)/g; -const NICKNAME_RE=/((?:(?:Angry|Baby|Crazy|Diligent|Excited|Fat|Greedy|Hungry|Interesting|Japanese|Kind|Little|Magic|Naïve|Old|Powerful|Quiet|Rich|Superman|THU|Undefined|Valuable|Wifeless|Xiangbuchulai|Young|Zombie)\s)?(?:Alice|Bob|Carol|Dave|Eve|Francis|Grace|Hans|Isabella|Jason|Kate|Louis|Margaret|Nathan|Olivia|Paul|Queen|Richard|Susan|Thomas|Uma|Vivian|Winnie|Xander|Yasmine|Zach)|You Win|洞主)/gi; +const PID_RE=/(^|\D)([1-9]\d{4,5})(?=\D)/g; +const NICKNAME_RE=/(^|\W)((?:(?:Angry|Baby|Crazy|Diligent|Excited|Fat|Greedy|Hungry|Interesting|Japanese|Kind|Little|Magic|Naïve|Old|Powerful|Quiet|Rich|Superman|THU|Undefined|Valuable|Wifeless|Xiangbuchulai|Young|Zombie)\s)?(?:Alice|Bob|Carol|Dave|Eve|Francis|Grace|Hans|Isabella|Jason|Kate|Louis|Margaret|Nathan|Olivia|Paul|Queen|Richard|Susan|Thomas|Uma|Vivian|Winnie|Xander|Yasmine|Zach)|You Win|洞主)(?=\W)/gi; function pad2(x) { return x<10 ? '0'+x : ''+x; diff --git a/src/Flows.css b/src/Flows.css index 1bc4d9a..0dbdf4e 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -109,4 +109,16 @@ .box-id { font-family: Consolas, Courier, monospace; opacity: .6; +} + +.flow-item-dot { + position: relative; + top: calc(-.5em - 5px); + left: calc(-.5em - 5px); + width: 10px; + height: 10px; + margin-bottom: -10px; + border-radius: 50%; + background-color: orange; + box-shadow: 0 0 5px rgba(0,0,0,.4); } \ No newline at end of file diff --git a/src/Flows.js b/src/Flows.js index dfd1714..8f3d281 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -13,6 +13,8 @@ const SEARCH_PAGESIZE=50; const CLICKABLE_TAGS={a: true, audio: true}; const PREVIEW_REPLY_COUNT=10; +const LATEST_POST_ID=parseInt(localStorage['_LATEST_POST_ID'],10)||0; + function Reply(props) { return (
+ {parseInt(props.info.pid,10)>LATEST_POST_ID &&
}
{!!parseInt(props.info.likenum,10) && {props.info.likenum}★} {!!parseInt(props.info.reply,10) && {props.info.reply}回复} @@ -179,6 +182,10 @@ export class Flow extends Component { .then((json)=>{ if(json.code!==0) throw new Error(json.code); + json.data.forEach((x)=>{ + if(parseInt(x.pid,10)>(parseInt(localStorage['_LATEST_POST_ID'],10)||0)) + localStorage['_LATEST_POST_ID']=x.pid; + }); this.setState((prev,props)=>({ chunks: prev.chunks.concat([{ title: 'Page '+page, diff --git a/src/Title.js b/src/Title.js index 7d678f6..741b657 100644 --- a/src/Title.js +++ b/src/Title.js @@ -5,9 +5,10 @@ const HELP_TEXT=(

使用提示:

    -
  • 为保证使用体验,请使用 Chrome 浏览器 stable 分支最新版
  • -
  • 在列表中点击帖子可以显示全部回复
  • +
  • 为保证使用体验,请使用 Chrome 或 Mobile Safari 浏览器最新版
  • +
  • 在列表中点击帖子可以展开全部回复
  • 在搜索框输入 #472865 等可以查看指定 ID 的树洞
  • +
  • 新的帖子会在左上角显示一个圆点
  • 请注意:使用 HTTPS 访问本站可能会大幅减慢加载速度
  • 自定义背景图片请修改 localStorage['REPLACE_ERIRI_WITH_URL']