6 changed files with 37 additions and 11 deletions
@ -24,7 +24,7 @@ const MAX_IMG_DIAM = 8000; |
|||||||
const MAX_IMG_PX = 5000000; |
const MAX_IMG_PX = 5000000; |
||||||
const MAX_IMG_FILESIZE = 450000 * BASE64_RATE; |
const MAX_IMG_FILESIZE = 450000 * BASE64_RATE; |
||||||
|
|
||||||
const REPOSITORY = 'https://github.com/newthuhole'; |
const REPOSITORY = 'https://git.thu.monster/newthuhole/'; |
||||||
const EMAIL = '[email protected]'; |
const EMAIL = '[email protected]'; |
||||||
|
|
||||||
export const TokenCtx = React.createContext({ |
export const TokenCtx = React.createContext({ |
||||||
@ -99,7 +99,7 @@ export function InfoSidebar(props) { |
|||||||
</a> |
</a> |
||||||
协议在{' '} |
协议在{' '} |
||||||
<a href={REPOSITORY} target="_blank"> |
<a href={REPOSITORY} target="_blank"> |
||||||
GitHub |
Gitea |
||||||
</a>{' '} |
</a>{' '} |
||||||
开源。 |
开源。 |
||||||
</p> |
</p> |
||||||
@ -260,6 +260,7 @@ export class ReplyForm extends Component { |
|||||||
on_submit(event) { |
on_submit(event) { |
||||||
if (event) event.preventDefault(); |
if (event) event.preventDefault(); |
||||||
if (this.state.loading_status === 'loading') return; |
if (this.state.loading_status === 'loading') return; |
||||||
|
if (!this.state.text) return; |
||||||
this.setState({ |
this.setState({ |
||||||
loading_status: 'loading', |
loading_status: 'loading', |
||||||
}); |
}); |
||||||
@ -362,6 +363,7 @@ export class PostForm extends Component { |
|||||||
this.state = { |
this.state = { |
||||||
text: '', |
text: '', |
||||||
cw: '', |
cw: '', |
||||||
|
allow_search: false, |
||||||
loading_status: 'done', |
loading_status: 'done', |
||||||
img_tip: null, |
img_tip: null, |
||||||
preview: false, |
preview: false, |
||||||
@ -369,6 +371,7 @@ export class PostForm extends Component { |
|||||||
this.img_ref = React.createRef(); |
this.img_ref = React.createRef(); |
||||||
this.area_ref = React.createRef(); |
this.area_ref = React.createRef(); |
||||||
this.on_change_bound = this.on_change.bind(this); |
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_cw_change_bound = this.on_cw_change.bind(this); |
||||||
this.on_img_change_bound = this.on_img_change.bind(this); |
this.on_img_change_bound = this.on_img_change.bind(this); |
||||||
this.color_picker = new ColorPicker(); |
this.color_picker = new ColorPicker(); |
||||||
@ -378,6 +381,12 @@ export class PostForm extends Component { |
|||||||
if (this.area_ref.current) this.area_ref.current.focus(); |
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) { |
on_cw_change(event) { |
||||||
this.setState({ |
this.setState({ |
||||||
cw: event.target.value, |
cw: event.target.value, |
||||||
@ -394,6 +403,7 @@ export class PostForm extends Component { |
|||||||
let data = new URLSearchParams(); |
let data = new URLSearchParams(); |
||||||
data.append('cw', this.state.cw); |
data.append('cw', this.state.cw); |
||||||
data.append('text', this.state.text); |
data.append('text', this.state.text); |
||||||
|
data.append('allow_search', this.state.allow_search ? '1' : ''); |
||||||
data.append('type', img ? 'image' : 'text'); |
data.append('type', img ? 'image' : 'text'); |
||||||
if (img) data.append('data', img); |
if (img) data.append('data', img); |
||||||
|
|
||||||
@ -547,6 +557,7 @@ export class PostForm extends Component { |
|||||||
on_submit(event) { |
on_submit(event) { |
||||||
if (event) event.preventDefault(); |
if (event) event.preventDefault(); |
||||||
if (this.state.loading_status === 'loading') return; |
if (this.state.loading_status === 'loading') return; |
||||||
|
if (!this.state.text) return; |
||||||
/* |
/* |
||||||
if (this.img_ref.current.files.length) { |
if (this.img_ref.current.files.length) { |
||||||
this.setState({ |
this.setState({ |
||||||
@ -628,6 +639,15 @@ export class PostForm extends Component { |
|||||||
发表 |
发表 |
||||||
</button> |
</button> |
||||||
)} |
)} |
||||||
|
|
||||||
|
<label> |
||||||
|
<input |
||||||
|
type="checkbox" |
||||||
|
onChange={this.on_allow_search_change_bound} |
||||||
|
/> |
||||||
|
允许被搜索 |
||||||
|
</label> |
||||||
|
|
||||||
</div> |
</div> |
||||||
{!!this.state.img_tip && ( |
{!!this.state.img_tip && ( |
||||||
<p className="post-form-img-tip"> |
<p className="post-form-img-tip"> |
||||||
|
Loading…
Reference in new issue