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

format code with prettier and standardjs #156

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
24 changes: 13 additions & 11 deletions src/components/container/musicPlayer/Controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,33 @@ const Controls = ({
currentSongs,
handlePlayPause,
handlePrevSong,
handleNextSong,
handleNextSong
}) => (
<div className="flex items-center justify-around md:w-36 lg:w-52 2xl:w-80">
<div className='flex items-center justify-around md:w-36 lg:w-52 2xl:w-80'>
<BsArrowRepeat
size={20}
color={repeat ? 'red' : 'white'}
onClick={() => setRepeat((prev) => !prev)}
className="hidden sm:block cursor-pointer"
className='hidden sm:block cursor-pointer'
/>
{currentSongs?.length > 0 && (
<MdSkipPrevious size={30} color="#FFF" className="cursor-pointer" onClick={handlePrevSong} />
)}
{isPlaying ? (
<BsFillPauseFill size={45} color="#FFF" onClick={handlePlayPause} className="cursor-pointer" />
) : (
<BsFillPlayFill size={45} color="#FFF" onClick={handlePlayPause} className="cursor-pointer" />
<MdSkipPrevious size={30} color='#FFF' className='cursor-pointer' onClick={handlePrevSong} />
)}
{isPlaying
? (
<BsFillPauseFill size={45} color='#FFF' onClick={handlePlayPause} className='cursor-pointer' />
)
: (
<BsFillPlayFill size={45} color='#FFF' onClick={handlePlayPause} className='cursor-pointer' />
)}
{currentSongs?.length > 0 && (
<MdSkipNext size={30} color="#FFF" className="cursor-pointer" onClick={handleNextSong} />
<MdSkipNext size={30} color='#FFF' className='cursor-pointer' onClick={handleNextSong} />
)}
<BsShuffle
size={20}
color={shuffle ? 'red' : 'white'}
onClick={() => setShuffle((prev) => !prev)}
className="hidden sm:block cursor-pointer"
className='hidden sm:block cursor-pointer'
/>
</div>
)
Expand Down
24 changes: 12 additions & 12 deletions src/service/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const initOptions = {
method: 'GET', // POST, *GET, PUT, DELETE, PATCH, [HEAD, CONNECT, OPTIONS, TRACE]
headers: {
// Accept: 'application/json',
'Content-Type': 'application/json;charset=utf-8', // text/plain;charset=UTF-8 *application/json;charset=utf-8 application/x-www-form-urlencoded
'Content-Type': 'application/json;charset=utf-8' // text/plain;charset=UTF-8 *application/json;charset=utf-8 application/x-www-form-urlencoded
// Authorization: getToken() ? `Bearer ${getToken()}` : null,
},
signal: null,
credentials: 'include', // include *same-origin
credentials: 'include' // include *same-origin
// mode: 'cors', // no-cors, cors, *same-origin
// redirect: 'follow', // manual, *follow, error
// referrer: 'no-referrer', // no-referrer *client,
Expand Down Expand Up @@ -92,7 +92,7 @@ const handleFetchData = (url, options) => {
fetch('http://localhost:5200/apis', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: url.split('?')[0], delay }),
body: JSON.stringify({ url: url.split('?')[0], delay })
})
.then((res) => res.json())
.then((data) => console.log(data))
Expand All @@ -116,7 +116,7 @@ const handleFetchData = (url, options) => {
.arrayBuffer()
.then((resBuffer) => {
const blob = new Blob([resBuffer], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const disposition = response.headers.get('content-disposition')
const fileName = decodeURI(disposition?.split('=')[1].replace(/'/g, '')).replace("utf-8''", '') || ''
Expand Down Expand Up @@ -163,19 +163,19 @@ export const reqFetch = (
headers = null,
isShowError = true,
timeout = 20000,
controller = null,
controller = null
} = params

const defaultOptions = {
...initOptions,
method,
headers: {
...initOptions.headers,
...headers,
...headers
},
controller,
timeout,
isShowError,
isShowError
}

// POST, *GET, PUT, DELETE, PATCH, [HEAD, CONNECT, OPTIONS, TRACE]
Expand All @@ -199,29 +199,29 @@ export const reqFetch = (
export const getFetch = (url, params) =>
reqFetch(url, {
method: 'GET',
...params,
...params
})

export const postFetch = (url, params) =>
reqFetch(url, {
method: 'POST',
...params,
...params
})

export const putFetch = (url, params) =>
reqFetch(url, {
method: 'PUT',
...params,
...params
})

export const deleteFetch = (url, params) =>
reqFetch(url, {
method: 'DELETE',
...params,
...params
})

export const patchFetch = (url, params) =>
reqFetch(url, {
method: 'PATCH',
...params,
...params
})
12 changes: 6 additions & 6 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 @@ -208,7 +208,7 @@ export const hasFocus = (element) => element === document.activeElement
export const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b)
export const randomString = () => Math.random().toString(36).slice(2)
export const escape = (str) =>
str.replace(/[&<>"']/g, (m) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[m]))
str.replace(/[&<>"']/g, (m) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[m])
export const toCamelCase = (str) => str.trim().replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))
export const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min)
export const randomColor = () => `#${Math.random().toString(16).slice(2, 8).padEnd(6, '0')}`
Expand Down