mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
This commit is contained in:
parent
87768d4bd1
commit
ca15f0af36
@ -14,11 +14,12 @@ import NotFound from '../404'
|
||||
import SEO from '../../components/SEO'
|
||||
import LongButton from '../../components/LongButton'
|
||||
import { git, Status } from '../../utils/Constants'
|
||||
import { Fetch, formatNumber } from '../../utils'
|
||||
import { Fetch } from '../../utils'
|
||||
import { formatNumber } from '../../utils/Tools'
|
||||
import Advertisement from '../../components/Advertisement'
|
||||
import Link from 'next/link'
|
||||
|
||||
const Bots: NextPage<BotsProps> = ({ data, date, votes }) => {
|
||||
const Bots: NextPage<BotsProps> = ({ data, date }) => {
|
||||
if (!data.id) return <NotFound />
|
||||
return (
|
||||
<Container paddingTop className="py-10">
|
||||
@ -78,7 +79,7 @@ const Bots: NextPage<BotsProps> = ({ data, date, votes }) => {
|
||||
<i className="fas fa-heart text-red-600" /> 하트 추가
|
||||
</h4>
|
||||
<span className="ml-1 px-2 py-1 text-center text-black dark:text-gray-400 text-sm bg-little-white-hover dark:bg-very-black rounded-lg">
|
||||
{votes}
|
||||
{formatNumber(data.votes)}
|
||||
</span>
|
||||
</LongButton>
|
||||
</div>
|
||||
@ -206,8 +207,7 @@ export const getServerSideProps = async (ctx: Context) => {
|
||||
return {
|
||||
props: {
|
||||
data,
|
||||
date: SnowflakeUtil.deconstruct(data.id ?? '0').date.toJSON(),
|
||||
votes: formatNumber(data.votes ?? 0, 3),
|
||||
date: SnowflakeUtil.deconstruct(data.id ?? '0').date.toJSON()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +1,18 @@
|
||||
import { UserPemissionFlags } from '../types'
|
||||
import { perms } from './Constants'
|
||||
|
||||
function formatNumber(num: number, digits = 1) {
|
||||
const si = [
|
||||
{ value: 1, symbol: '' },
|
||||
{ value: 1e3, symbol: '천' },
|
||||
{ value: 1e4, symbol: '만' },
|
||||
{ value: 1e8, symbol: '억' },
|
||||
{ value: 1e12, symbol: '조' },
|
||||
{ value: 1e16, symbol: '해' },
|
||||
]
|
||||
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/
|
||||
let i
|
||||
for (i = si.length - 1; i > 0; i--) {
|
||||
if (num >= si[i].value) {
|
||||
break
|
||||
}
|
||||
function formatNumber(value: number):string {
|
||||
const suffixes = ['', '만', '억', '조','해']
|
||||
const suffixNum = Math.floor((''+value).length/4)
|
||||
let shortValue:string|number = parseFloat((suffixNum != 0 ? (value / Math.pow(10000,suffixNum)) : value).toPrecision(2))
|
||||
if (shortValue % 1 != 0) {
|
||||
shortValue = shortValue.toFixed(1)
|
||||
}
|
||||
return (num / si[i].value).toFixed(digits).replace(rx, '$1') + si[i].symbol
|
||||
if(suffixNum === 1 && shortValue < 1) return Number(shortValue) * 10 + '천'
|
||||
return shortValue+suffixes[suffixNum]
|
||||
}
|
||||
|
||||
function checkPerm(base: number, required: number | UserPemissionFlags) {
|
||||
function checkPerm(base: number, required: number | UserPemissionFlags):boolean {
|
||||
required = typeof required === 'number' ? required : perms[required]
|
||||
if (typeof required !== 'number' && !required) throw new Error('올바르지 않은 권한입니다.')
|
||||
return (base & required) === required
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import * as Query from './Query'
|
||||
import { formatNumber } from './Tools'
|
||||
import { } from './Tools'
|
||||
import ResponseWrapper from './ResponseWrapper'
|
||||
import Fetch from './Fetch'
|
||||
|
||||
export { Query, Fetch, ResponseWrapper, formatNumber }
|
||||
export { Query, Fetch, ResponseWrapper }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user