Skip to content

Commit

Permalink
chore(release): v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Sep 22, 2022
1 parent 664c7ee commit c4d578d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "veact-admin",
"version": "1.8.0",
"version": "1.8.1",
"author": "Surmon",
"license": "MIT",
"repository": {
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Vote/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Tag, Table, Popover, Space } from 'antd'
import { Tag, Table, Button, Popover, Space } from 'antd'
import * as Icon from '@ant-design/icons'
import { UniversalText } from '@/components/common/UniversalText'
import { IPLocation } from '@/components/common/IPLocation'
Expand Down Expand Up @@ -50,7 +50,11 @@ export const VoteListTable: React.FC<VoteListTableProps> = (props) => {
{
title: '目标',
dataIndex: 'target_type',
render: (_, vote) => `${getVoteTargetText(vote.target_type)} #${vote.target_id}`,
render: (_, vote) => (
<Button type="link" onClick={() => props.onTargetID(vote.target_id)}>
{getVoteTargetText(vote.target_type)} #{vote.target_id}
</Button>
),
},
{
title: '态度',
Expand Down
62 changes: 22 additions & 40 deletions src/pages/Vote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import styles from './style.module.less'

const ALL_VALUE = 'ALL'
const DEFAULT_FILTER_PARAMS = Object.freeze({
target_id: ALL_VALUE as number | typeof ALL_VALUE,
target_id: void 0 as number | undefined,
target_type: ALL_VALUE as VoteTarget | typeof ALL_VALUE,
vote_type: ALL_VALUE as VoteType | typeof ALL_VALUE,
author_type: ALL_VALUE as VoteAuthorType | typeof ALL_VALUE,
Expand All @@ -53,12 +53,9 @@ export const VotePage: React.FC = () => {
pagination: void 0,
})

const filterParams = useReactive({
...DEFAULT_FILTER_PARAMS,
target_id: DEFAULT_FILTER_PARAMS.target_id,
})
const updateTargetID = (targetId: number | string) => {
filterParams.target_id = Number(targetId)
const filterParams = useReactive({ ...DEFAULT_FILTER_PARAMS })
const updateTargetID = (targetId: number | void | undefined) => {
filterParams.target_id = Number.isFinite(targetId) ? (targetId as number) : undefined
}

// 多选
Expand All @@ -74,8 +71,8 @@ export const VotePage: React.FC = () => {
const getParams: GetVotesParams = {
...params,
sort: filterParams.sort,
target_id: filterParams.target_id,
target_type: filterParams.target_type !== ALL_VALUE ? filterParams.target_type : void 0,
target_id: filterParams.target_id !== ALL_VALUE ? filterParams.target_id : void 0,
vote_type: filterParams.vote_type !== ALL_VALUE ? filterParams.vote_type : void 0,
author_type: filterParams.author_type !== ALL_VALUE ? filterParams.author_type : void 0,
}
Expand Down Expand Up @@ -133,38 +130,6 @@ export const VotePage: React.FC = () => {
>
<Space align="center" className={styles.toolbar}>
<Space>
<Select
className={styles.select}
loading={loading.state.value}
value={filterParams.target_id}
onChange={updateTargetID}
options={[
{
value: ALL_VALUE,
label: '所有表态',
},
{
value: 0,
label: '站点表态',
},
]}
dropdownRender={(menu) => (
<div>
{menu}
<div className={styles.targetIdInput}>
<Input.Search
allowClear={true}
size="small"
type="number"
className={styles.input}
placeholder="Target ID"
enterButton={<span>GO</span>}
onSearch={updateTargetID}
/>
</div>
</div>
)}
/>
<Select
className={styles.select}
loading={loading.state.value}
Expand All @@ -180,6 +145,23 @@ export const VotePage: React.FC = () => {
})),
]}
/>
<Input.Group compact>
<Button onClick={() => updateTargetID(void 0)}>All</Button>
<Input.Search
className={styles.targetIdInput}
placeholder="目标 ID"
type="number"
min={0}
step={1}
value={filterParams.target_id}
onSearch={(targetInput) => {
const targetId = targetInput !== '' && Number(targetInput)
Number.isFinite(targetId)
? updateTargetID(targetId as number)
: updateTargetID(void 0)
}}
/>
</Input.Group>
<Select
className={styles.select}
loading={loading.state.value}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Vote/style.module.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '@/styles/init.less';

.targetIdInput {
padding: 10px;
width: 120px;
input[type='number'] {
-moz-appearance: textfield;
&::-webkit-outer-spin-button,
Expand Down

0 comments on commit c4d578d

Please sign in to comment.