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: env:
REGISTRY: registry.boss160.cn 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 DEPLOY_DIR: /opt/device_voice_h5
jobs: jobs:
@@ -21,7 +21,7 @@ jobs:
run: | run: |
export PATH="$HOME/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:$PATH" export PATH="$HOME/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
export GIT_SSL_NO_VERIFY=1 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 }} git checkout ${{ github.sha }}
- name: 设置镜像标签 - name: 设置镜像标签

View File

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

View File

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

View File

@@ -2,8 +2,8 @@ version: '3.8'
services: services:
web: web:
image: registry.boss160.cn/junhong/device-voice-h5:latest image: registry.boss160.cn/junhong/c-xmot-iot:latest
container_name: junhong-device-voice-h5 container_name: junhong-c-xmot-iot
restart: unless-stopped restart: unless-stopped
ports: ports:
- '3003:80' - '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", "appid" : "__UNI__45F0251",
"description" : "", "description" : "",
"versionName" : "1.0.0", "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, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "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'; export const APP_TYPE = 'official_account';