Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cc722da3
authored
Dec 11, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化渠道余额显示
parent
1aeb4917
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
web/src/components/ChannelsTable.js
+3
-3
web/src/helpers/render.js
+28
-0
No files found.
web/src/components/ChannelsTable.js
View file @
cc722da3
...
@@ -13,7 +13,7 @@ import {
...
@@ -13,7 +13,7 @@ import {
}
from
'../helpers'
;
}
from
'../helpers'
;
import
{
CHANNEL_OPTIONS
,
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
CHANNEL_OPTIONS
,
ITEMS_PER_PAGE
}
from
'../constants'
;
import
{
renderGroup
,
renderNumber
,
renderQuota
,
renderQuotaWithPrompt
}
from
'../helpers/render'
;
import
{
renderGroup
,
renderNumber
,
render
NumberWithPoint
,
render
Quota
,
renderQuotaWithPrompt
}
from
'../helpers/render'
;
import
{
import
{
Avatar
,
Avatar
,
Tag
,
Tag
,
...
@@ -142,8 +142,8 @@ const ChannelsTable = () => {
...
@@ -142,8 +142,8 @@ const ChannelsTable = () => {
<
Tooltip
content
=
{
'已用额度'
}
>
<
Tooltip
content
=
{
'已用额度'
}
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
>
{
renderQuota
(
record
.
used_quota
)}
<
/Tag
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
>
{
renderQuota
(
record
.
used_quota
)}
<
/Tag
>
<
/Tooltip
>
<
/Tooltip
>
<
Tooltip
content
=
{
'剩余额度,点击更新'
}
>
<
Tooltip
content
=
{
'剩余额度
'
+
record
.
balance
+
'
,点击更新'
}
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
onClick
=
{()
=>
{
updateChannelBalance
(
record
)}}
>
$
{
re
cord
.
balance
.
toFixed
(
2
)}
<
/Tag
>
<
Tag
color
=
'white'
type
=
'ghost'
size
=
'large'
onClick
=
{()
=>
{
updateChannelBalance
(
record
)}}
>
$
{
re
nderNumberWithPoint
(
record
.
balance
)}
<
/Tag
>
<
/Tooltip
>
<
/Tooltip
>
<
/Space
>
<
/Space
>
<
/div
>
<
/div
>
...
...
web/src/helpers/render.js
View file @
cc722da3
...
@@ -42,6 +42,34 @@ export function renderNumber(num) {
...
@@ -42,6 +42,34 @@ export function renderNumber(num) {
}
}
}
}
export
function
renderNumberWithPoint
(
num
)
{
num
=
num
.
toFixed
(
2
);
if
(
num
>=
100000
)
{
// Convert number to string to manipulate it
let
numStr
=
num
.
toString
();
// Find the position of the decimal point
let
decimalPointIndex
=
numStr
.
indexOf
(
'.'
);
let
wholePart
=
numStr
;
let
decimalPart
=
''
;
// If there is a decimal point, split the number into whole and decimal parts
if
(
decimalPointIndex
!==
-
1
)
{
wholePart
=
numStr
.
slice
(
0
,
decimalPointIndex
);
decimalPart
=
numStr
.
slice
(
decimalPointIndex
);
}
// Take the first two and last two digits of the whole number part
let
shortenedWholePart
=
wholePart
.
slice
(
0
,
2
)
+
'..'
+
wholePart
.
slice
(
-
2
);
// Return the formatted number
return
shortenedWholePart
+
decimalPart
;
}
// If the number is less than 100,000, return it unmodified
return
num
;
}
export
function
getQuotaPerUnit
()
{
export
function
getQuotaPerUnit
()
{
let
quotaPerUnit
=
localStorage
.
getItem
(
'quota_per_unit'
);
let
quotaPerUnit
=
localStorage
.
getItem
(
'quota_per_unit'
);
quotaPerUnit
=
parseFloat
(
quotaPerUnit
);
quotaPerUnit
=
parseFloat
(
quotaPerUnit
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment