可选允许搜索
This commit is contained in:
@@ -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://www.tsinghua.edu.cn/image/nav-bg.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':
|
||||
@@ -23,7 +25,7 @@ const BUILTIN_IMGS = {
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
background_img:
|
||||
'https://www.tsinghua.edu.cn/images/footer.jpg',
|
||||
'//cdn.jsdelivr.net/gh/thuhole/webhole@gh-pages/static/bg/gbp.jpg',
|
||||
background_color: '#113366',
|
||||
pressure: false,
|
||||
easter_egg: true,
|
||||
@@ -452,10 +454,10 @@ export class ConfigUI extends PureComponent {
|
||||
<p>
|
||||
新功能建议或问题反馈请在
|
||||
<a
|
||||
href="https://github.com/newthuhole/hole-backend/issues"
|
||||
href="https://git.thu.monster/newthuhole/hole_thu_backend/issues"
|
||||
target="_blank"
|
||||
>
|
||||
GitHub <span className="icon icon-github" />
|
||||
Gitea
|
||||
</a>
|
||||
提出。
|
||||
</p>
|
||||
|
||||
@@ -271,6 +271,9 @@ class FlowItem extends PureComponent {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
info.allow_search && <span> 📢 </span>
|
||||
}
|
||||
<Time stamp={info.timestamp} short={!img_clickable} />
|
||||
</div>
|
||||
<div className="box-content">
|
||||
@@ -1170,7 +1173,7 @@ export class Flow extends PureComponent {
|
||||
}));
|
||||
})
|
||||
.catch(failed);
|
||||
} else if (this.state.mode === 'search') {
|
||||
} else if (this.state.mode === 'search' && this.state.search_param) {
|
||||
API.get_search(page, this.state.search_param, this.props.token)
|
||||
.then((json) => {
|
||||
const finished = json.data.length === 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { Time } from './Common';
|
||||
import { Time, API_BASE } from './Common';
|
||||
import { get_json } from './infrastructure/functions';
|
||||
|
||||
import './Message.css';
|
||||
@@ -26,7 +26,7 @@ export class MessageViewer extends PureComponent {
|
||||
},
|
||||
() => {
|
||||
fetch(
|
||||
'/_api/v1/systemlog',
|
||||
API_BASE + '/systemlog',
|
||||
{
|
||||
headers: {'User-Token': this.props.token},
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class ControlBar extends PureComponent {
|
||||
className="control-search"
|
||||
value={this.state.search_text}
|
||||
placeholder={
|
||||
this.props.mode === 'attention' ? '在关注列表中搜索' : '搜tag或 #树洞号, 如: 新手导引'}
|
||||
this.props.mode === 'attention' ? '在关注列表中搜索' : '关键词 / tag / #树洞号'}
|
||||
onChange={this.on_change_bound}
|
||||
onKeyPress={this.on_keypress_bound}
|
||||
/>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
.post-form-bar label {
|
||||
flex: 1;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.post-form-bar input[type=file] {
|
||||
|
||||
@@ -24,7 +24,7 @@ const MAX_IMG_DIAM = 8000;
|
||||
const MAX_IMG_PX = 5000000;
|
||||
const MAX_IMG_FILESIZE = 450000 * BASE64_RATE;
|
||||
|
||||
const REPOSITORY = 'https://github.com/newthuhole';
|
||||
const REPOSITORY = 'https://git.thu.monster/newthuhole/';
|
||||
const EMAIL = 'hole_thu@riseup.net';
|
||||
|
||||
export const TokenCtx = React.createContext({
|
||||
@@ -99,7 +99,7 @@ export function InfoSidebar(props) {
|
||||
</a>
|
||||
协议在{' '}
|
||||
<a href={REPOSITORY} target="_blank">
|
||||
GitHub
|
||||
Gitea
|
||||
</a>{' '}
|
||||
开源。
|
||||
</p>
|
||||
@@ -260,6 +260,7 @@ export class ReplyForm extends Component {
|
||||
on_submit(event) {
|
||||
if (event) event.preventDefault();
|
||||
if (this.state.loading_status === 'loading') return;
|
||||
if (!this.state.text) return;
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
});
|
||||
@@ -362,6 +363,7 @@ export class PostForm extends Component {
|
||||
this.state = {
|
||||
text: '',
|
||||
cw: '',
|
||||
allow_search: false,
|
||||
loading_status: 'done',
|
||||
img_tip: null,
|
||||
preview: false,
|
||||
@@ -369,6 +371,7 @@ export class PostForm extends Component {
|
||||
this.img_ref = React.createRef();
|
||||
this.area_ref = React.createRef();
|
||||
this.on_change_bound = this.on_change.bind(this);
|
||||
this.on_allow_search_change_bound = this.on_allow_search_change.bind(this);
|
||||
this.on_cw_change_bound = this.on_cw_change.bind(this);
|
||||
this.on_img_change_bound = this.on_img_change.bind(this);
|
||||
this.color_picker = new ColorPicker();
|
||||
@@ -378,6 +381,12 @@ export class PostForm extends Component {
|
||||
if (this.area_ref.current) this.area_ref.current.focus();
|
||||
}
|
||||
|
||||
on_allow_search_change(event) {
|
||||
this.setState({
|
||||
allow_search: event.target.checked,
|
||||
});
|
||||
}
|
||||
|
||||
on_cw_change(event) {
|
||||
this.setState({
|
||||
cw: event.target.value,
|
||||
@@ -394,6 +403,7 @@ export class PostForm extends Component {
|
||||
let data = new URLSearchParams();
|
||||
data.append('cw', this.state.cw);
|
||||
data.append('text', this.state.text);
|
||||
data.append('allow_search', this.state.allow_search ? '1' : '');
|
||||
data.append('type', img ? 'image' : 'text');
|
||||
if (img) data.append('data', img);
|
||||
|
||||
@@ -547,6 +557,7 @@ export class PostForm extends Component {
|
||||
on_submit(event) {
|
||||
if (event) event.preventDefault();
|
||||
if (this.state.loading_status === 'loading') return;
|
||||
if (!this.state.text) return;
|
||||
/*
|
||||
if (this.img_ref.current.files.length) {
|
||||
this.setState({
|
||||
@@ -628,6 +639,15 @@ export class PostForm extends Component {
|
||||
发表
|
||||
</button>
|
||||
)}
|
||||
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
onChange={this.on_allow_search_change_bound}
|
||||
/>
|
||||
允许被搜索
|
||||
</label>
|
||||
|
||||
</div>
|
||||
{!!this.state.img_tip && (
|
||||
<p className="post-form-img-tip">
|
||||
|
||||
Reference in New Issue
Block a user