diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index fa211e6..aaaf141 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -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: 设置镜像标签 diff --git a/MP_verify_4E1dVbOcZ9KzTzoc.txt b/MP_verify_4E1dVbOcZ9KzTzoc.txt new file mode 100644 index 0000000..014f11c --- /dev/null +++ b/MP_verify_4E1dVbOcZ9KzTzoc.txt @@ -0,0 +1 @@ +4E1dVbOcZ9KzTzoc \ No newline at end of file diff --git a/components/TrafficCard.vue b/components/TrafficCard.vue index 1fe3692..6e7c95c 100644 --- a/components/TrafficCard.vue +++ b/components/TrafficCard.vue @@ -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); diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index feaff02..c8a8ada 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -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' diff --git a/docs/API.md b/docs/API.md index 4039e95..4ed0d18 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,4 +1,4 @@ -# BaseUrl: https://cmp-api.boss160.cn +# BaseUrl: https://cmp-api.xm-iot.cn 错误响应示例: { diff --git a/manifest.json b/manifest.json index 306b67b..a138b66 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "name" : "device-voice-h5", + "name" : "c-xmot-iot", "appid" : "__UNI__45F0251", "description" : "", "versionName" : "1.0.0", diff --git a/package-lock.json b/package-lock.json index cfd9a68..2b668f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "device-voice-h5", + "name": "c-xmot-iot", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/utils/env.js b/utils/env.js index c0f6995..4a2bc9f 100644 --- a/utils/env.js +++ b/utils/env.js @@ -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';