From 02e1daa4191cdff344b525e7f88c291e66fee258 Mon Sep 17 00:00:00 2001 From: sszdot Date: Fri, 13 Dec 2024 16:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=20=E7=A7=92=E6=95=B0?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=87=BD=E6=95=B0=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=88=90=2000:00=20=E6=A0=BC=E5=BC=8F=20?= =?UTF-8?q?=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- utils/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/utils/index.js b/utils/index.js index d368ab0..28feac5 100644 --- a/utils/index.js +++ b/utils/index.js @@ -75,6 +75,23 @@ export function formatTime(value) { return `(${period})${hour}:${minute}` } + +/** + * 格式化秒数为 mm:ss 的格式 + * @param {number} seconds 总秒数 + * @returns {string} 格式化后的时间字符串 + */ +export function formatSeconds(seconds) { + if (seconds < 0) return '00:00' // 如果秒数为负,则返回 00:00 + + let minutes = Math.floor(seconds / 60) + let remainingSeconds = seconds % 60 + + minutes = minutes.toString().padStart(2, '0') + remainingSeconds = remainingSeconds.toString().padStart(2, '0') + + return `${minutes}:${remainingSeconds}` +} /** * 过滤价格数值 超过小数点两位得 保留两位 * @param {string} value @@ -257,7 +274,7 @@ function initMqtt() { const topic = `refreshOrderList/${store.state.userInfo.topic_prefix}` mqtt.doSubscribe(topic, (res) => { if (res.topic.indexOf(topic) > -1) { - store.dispatch('fetchOrderList').then(()=>{ + store.dispatch('fetchOrderList').then(() => { console.log('有订单更新') }) //更新订单 }