fix:百分比
Some checks failed
构建并部署前端到生产环境 / build-and-deploy (push) Has been cancelled

This commit is contained in:
sexygoat
2026-05-07 16:19:00 +08:00
parent 7dfbb2de3d
commit 92c5c4ed50
8 changed files with 32 additions and 18 deletions

View File

@@ -9,7 +9,7 @@ on:
env:
REGISTRY: registry.boss160.cn
IMAGE_NAME: registry.boss160.cn/junhong/device-voice-h5
IMAGE_NAME: registry.boss160.cn/junhong/c-xmot-iot
DEPLOY_DIR: /opt/device_voice_h5
jobs:
@@ -21,7 +21,7 @@ jobs:
run: |
export PATH="$HOME/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
export GIT_SSL_NO_VERIFY=1
git clone https://git.boss160.cn/luo/device-voice-h5.git .
git clone https://git.boss160.cn/luo/c-xmot-iot.git .
git checkout ${{ github.sha }}
- name: 设置镜像标签

View File

@@ -0,0 +1 @@
4E1dVbOcZ9KzTzoc

View File

@@ -64,10 +64,11 @@
// 流量数据
const usedMB = ref(0);
const realUsedMB = ref(0);
const totalMB = ref(0);
const remainMB = ref(0);
const toMB = (value) => Number(value) || 0;
// 格式化流量数据MB 转 GB
const formatTraffic = (mb) => {
if (!mb || mb === 0) {
@@ -104,13 +105,28 @@
// 使用百分比
const usedFlowPercent = computed(() => {
if (totalMB.value && realUsedMB.value) {
const percent = (realUsedMB.value / totalMB.value * 100);
if (totalMB.value > 0) {
const percent = (usedMB.value / totalMB.value * 100);
return Math.min(percent, 100).toFixed(2);
}
return '0.00';
});
const getTrafficMetrics = (data) => {
const enableVirtualData = !!data.enable_virtual_data;
const used = enableVirtualData ? toMB(data.virtual_used_mb) : toMB(data.real_used_mb);
const total = enableVirtualData ? toMB(data.virtual_limit_mb) : toMB(data.real_total_mb);
const remain = enableVirtualData ?
toMB(data.virtual_remain_mb ?? Math.max(total - used, 0)) :
Math.max(total - used, 0);
return {
used,
total,
remain
};
};
// 加载套餐流量数据
const loadPackageData = async () => {
const identifier = props.identifier || userStore.state.identifier;
@@ -120,16 +136,13 @@
const data = await assetApi.getInfo(identifier);
if (data.current_package_usage_id) {
const realUsed = data.real_used_mb || 0;
const realTotal = data.real_total_mb || 0;
usedMB.value = data.enable_virtual_data ? (data.virtual_used_mb || 0) : realUsed;
realUsedMB.value = realUsed;
totalMB.value = realTotal;
remainMB.value = Math.max(realTotal - realUsed, 0);
const metrics = getTrafficMetrics(data);
usedMB.value = metrics.used;
totalMB.value = metrics.total;
remainMB.value = metrics.remain;
emit('packageLoaded', data);
} else {
usedMB.value = 0;
realUsedMB.value = 0;
totalMB.value = 0;
remainMB.value = 0;
emit('packageLoaded', null);

View File

@@ -2,8 +2,8 @@ version: '3.8'
services:
web:
image: registry.boss160.cn/junhong/device-voice-h5:latest
container_name: junhong-device-voice-h5
image: registry.boss160.cn/junhong/c-xmot-iot:latest
container_name: junhong-c-xmot-iot
restart: unless-stopped
ports:
- '3003:80'

View File

@@ -1,4 +1,4 @@
# BaseUrl: https://cmp-api.boss160.cn
# BaseUrl: https://cmp-api.xm-iot.cn
错误响应示例:
{

View File

@@ -1,5 +1,5 @@
{
"name" : "device-voice-h5",
"name" : "c-xmot-iot",
"appid" : "__UNI__45F0251",
"description" : "",
"versionName" : "1.0.0",

2
package-lock.json generated
View File

@@ -1,5 +1,5 @@
{
"name": "device-voice-h5",
"name": "c-xmot-iot",
"lockfileVersion": 3,
"requires": true,
"packages": {

View File

@@ -1,3 +1,3 @@
export const BASE_URL = 'https://cmp-api.boss160.cn';
export const BASE_URL = 'https://cmp-api.xm-iot.cn';
export const APP_TYPE = 'official_account';