Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Prettier and StandardJS #388

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/components/hooks/useTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const useTable = (props) => {
const [page, setPage] = useState(payload.pageNum || 1)
const [pageSize, setPageSize] = useState(10)
const [cachePayload, setCachePayload] = useState({ ...payload })
const [loading, setLoading] = useState(dataInterface ? false : true)
const [loading, setLoading] = useState(!dataInterface)

const onChange = (page, pageSize) => {
setPage(page)
Expand All @@ -26,7 +26,7 @@ const useTable = (props) => {
}
dataInterface({
...(isPagination ? { pageNum: page, pageSize } : {}),
...other,
...other
}).then((resp) => {
if (resp && resp.status === 1) {
setPage(page)
Expand Down Expand Up @@ -71,12 +71,12 @@ const useTable = (props) => {
setCachePayload({ ...payload })
getTableList(dataInterface || props.dataInterface, {
...cachePayload,
...payload,
...payload
})
}

useEffect(() => {
if (!!implemented) {
if (implemented) {
resetTable()
setCachePayload({ ...payload })
getTableList(dataInterface, { ...payload })
Expand All @@ -85,29 +85,29 @@ const useTable = (props) => {

return {
tableConfig: {
loading: loading,
loading,
dataSource: [...dataSource],
pagination: isPagination
? {
total: total,
total,
size: 'default',
current: page,
pageSize: pageSize,
onChange: onChange,
pageSize,
onChange,
onShowSizeChange: onChange,
showQuickJumper: true,
showSizeChanger: true,
hideOnSinglePage: false,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>
}
: false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false
},
page,
pageSize,
rawData,
updateTable,
resetTable,
resetTable
}
}
export default useTable
Expand Down
10 changes: 5 additions & 5 deletions src/components/stateless/IntervalInput/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ const IntervalInput = ({ value = {}, onChange }) => {
minValue,
maxValue,
...value,
...changedValue,
...changedValue
})
}

const handleMinChange = (valueOps) => {
setMinValue(valueOps)
triggerChange({
minValue: valueOps,
minValue: valueOps
})
}

const handleMaxChange = (valueOts) => {
setMaxValue(valueOts)
triggerChange({
maxValue: valueOts,
maxValue: valueOts
})
}

Expand All @@ -38,7 +38,7 @@ const IntervalInput = ({ value = {}, onChange }) => {
status={minValue > maxValue ? 'error' : ''}
onChange={handleMinChange}
style={{ width: '100%' }}
placeholder=""
placeholder=''
/>
</Col>
<Col span={2} style={{ textAlign: 'center', lineHeight: '32px', color: '#fff' }}>
Expand All @@ -52,7 +52,7 @@ const IntervalInput = ({ value = {}, onChange }) => {
status={minValue > maxValue ? 'error' : ''}
onChange={handleMaxChange}
style={{ width: '100%' }}
placeholder=""
placeholder=''
/>
</Col>
</Row>
Expand Down
60 changes: 33 additions & 27 deletions src/components/stateless/SearchForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const SearchForm = forwardRef((props, ref) => {
<Form.Item
style={{
marginRight: name === last?.name ? 0 : '10px',
marginBottom: 10,
marginBottom: 10
}}
key={name}
name={name}
Expand All @@ -136,7 +136,7 @@ const SearchForm = forwardRef((props, ref) => {
...newValues,
[item.name]: newValues[item.name]
? moment(newValues[item.name]).format(item.format || 'YYYY-MM-DD')
: undefined,
: undefined
}
})
}
Expand All @@ -145,7 +145,7 @@ const SearchForm = forwardRef((props, ref) => {
checkboxes.forEach((item) => {
newValues = {
...newValues,
[item.name]: Number(newValues[item.name]) || undefined,
[item.name]: Number(newValues[item.name]) || undefined
}
})
}
Expand All @@ -169,7 +169,7 @@ const SearchForm = forwardRef((props, ref) => {
...newValues,
[item.name]: newValues[item.name]
? moment(newValues[item.name]).format(item.format || 'YYYY-MM-DD')
: undefined,
: undefined
}
})
}
Expand All @@ -178,7 +178,7 @@ const SearchForm = forwardRef((props, ref) => {
checkboxes.forEach((item) => {
newValues = {
...newValues,
[item.name]: Number(newValues[item.name]) || undefined,
[item.name]: Number(newValues[item.name]) || undefined
}
})
}
Expand Down Expand Up @@ -206,11 +206,11 @@ const SearchForm = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({ ...form }))

return (
<div className={'searchForm'}>
<div className='searchForm'>
<Form
form={form}
name="search"
layout="inline"
name='search'
layout='inline'
onFinish={onFinishInner}
onFieldsChange={onFieldsChange}
initialValues={initialValues}
Expand All @@ -219,25 +219,31 @@ const SearchForm = forwardRef((props, ref) => {
{dataSource.map((item, idx, self) => getFormItemHtml(item, self[self.length - 1]))}
<Form.Item style={{ marginRight: 0, marginLeft: 10 }}>
<Space>
{!automatic ? (
<Button type={loading ? 'default' : 'primary'} htmlType="submit" disabled={loading}>
{btnText}
</Button>
) : null}
{isReset ? (
<Button type="primary" onClick={() => reset()}>
{resetText}
</Button>
) : null}
{isExport ? (
<Button
type={exportLoading ? 'default' : 'primary'}
disabled={exportLoading}
onClick={() => exportResultInner()}
>
{exportText}
</Button>
) : null}
{!automatic
? (
<Button type={loading ? 'default' : 'primary'} htmlType='submit' disabled={loading}>
{btnText}
</Button>
)
: null}
{isReset
? (
<Button type='primary' onClick={() => reset()}>
{resetText}
</Button>
)
: null}
{isExport
? (
<Button
type={exportLoading ? 'default' : 'primary'}
disabled={exportLoading}
onClick={() => exportResultInner()}
>
{exportText}
</Button>
)
: null}
</Space>
</Form.Item>
</Form>
Expand Down
20 changes: 10 additions & 10 deletions src/utils/aidFn.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const getImgsUrl = (html) => {
export const customizeTimer = {
intervalTimer: null,
timeoutTimer: null,
setTimeout(cb, interval) {
setTimeout (cb, interval) {
const { now } = Date
const stime = now()
let etime = stime
Expand All @@ -80,10 +80,10 @@ export const customizeTimer = {
this.timeoutTimer = requestAnimationFrame(loop)
return this.timeoutTimer
},
clearTimeout() {
clearTimeout () {
cancelAnimationFrame(this.timeoutTimer)
},
setInterval(cb, interval) {
setInterval (cb, interval) {
const { now } = Date
let stime = now()
let etime = stime
Expand All @@ -99,9 +99,9 @@ export const customizeTimer = {
this.intervalTimer = requestAnimationFrame(loop)
return this.intervalTimer
},
clearInterval() {
clearInterval () {
cancelAnimationFrame(this.intervalTimer)
},
}
}

export const isDecimal = (value) => {
Expand Down Expand Up @@ -251,13 +251,13 @@ export const oneApiChat = (chatList, token, signal) =>
signal,
headers: {
Authorization: token,
'Content-Type': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: chatList,
stream: true,
}),
stream: true
})
})

export const getCurrentDate = () => {
Expand Down Expand Up @@ -285,7 +285,7 @@ export const saveHtmlToPng = async (eleHtml, successFun, errorFun) => {
try {
const ele = eleHtml ?? document.getElementById('image-wrapper')
const canvas = await html2canvas(ele, {
useCORS: true,
useCORS: true
})
const imgUrl = canvas.toDataURL('image/png')
const tempLink = document.createElement('a')
Expand Down Expand Up @@ -346,7 +346,7 @@ export const prettyObject = (msg) => {
// 导出
export const exportExcel = (res, fileName) => {
const blob = new Blob([res.data], {
type: 'application/vnd.ms-excel; charset=UTF-8',
type: 'application/vnd.ms-excel; charset=UTF-8'
})
const disposition = (res.headers && res.headers['content-disposition']) || `attachment;filename=${fileName}.xlsx`
const disName = decodeURI(disposition?.split('=')[1].replace(/'/g, '')).replace("utf-8''", '') || ''
Expand Down
Loading