fix(proxy): wrap subscription info usage percentage with toFinite

This commit is contained in:
kunish 2023-09-17 21:18:23 +08:00
parent 5402fdb9cb
commit ed947f62a2
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
3 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import byteSize from 'byte-size' import byteSize from 'byte-size'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { toFinite } from 'lodash'
import type { SubscriptionInfo as ISubscriptionInfo } from '~/types' import type { SubscriptionInfo as ISubscriptionInfo } from '~/types'
const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => { const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => {
@ -9,10 +10,10 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => {
const used = byteSize(Download + Upload, { const used = byteSize(Download + Upload, {
units: 'iec', units: 'iec',
}) })
const percentage = (((Download + Upload) / Total) * 100).toFixed(2) const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2))
const expireStr = () => { const expireStr = () => {
if (subscriptionInfo.Expire === 0) { if (Expire === 0) {
return 'Null' return 'Null'
} }

View File

@ -422,6 +422,7 @@ export default () => {
{(cell) => { {(cell) => {
return ( return (
<td <td
class="py-2"
onContextMenu={(e) => { onContextMenu={(e) => {
e.preventDefault() e.preventDefault()

View File

@ -204,10 +204,10 @@ export default () => {
<tbody> <tbody>
<For each={table.getRowModel().rows}> <For each={table.getRowModel().rows}>
{(row) => ( {(row) => (
<tr class="hover"> <tr class="hover:!bg-primary hover:text-primary-content">
<For each={row.getVisibleCells()}> <For each={row.getVisibleCells()}>
{(cell) => ( {(cell) => (
<td> <td class="py-2">
{flexRender( {flexRender(
cell.column.columnDef.cell, cell.column.columnDef.cell,
cell.getContext(), cell.getContext(),