From 9688e9b3a6bb25a250db07fc901974f8443d3819 Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:57:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(format):=20=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=92=8C=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ItemList 组件中添加 formatNumber 函数,用于将数字格式化为 "250XX" 格式 - 调整 login 页面背景图片布局,使其居底显示 - 优化 login 页面验证码输入框,提高用户体验 - 移除 nuxt.config.js 中的 https 配置项 --- app/pages/home/components/ItemList/index.vue | 22 +++++++++++++++++++- app/pages/login/index.vue | 20 +++++++++++++++--- nuxt.config.js | 2 +- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/pages/home/components/ItemList/index.vue b/app/pages/home/components/ItemList/index.vue index aeb1145..81f6b29 100644 --- a/app/pages/home/components/ItemList/index.vue +++ b/app/pages/home/components/ItemList/index.vue @@ -40,6 +40,26 @@ const openShow = async (item) => { localState.value.showDetail = true currentItem.value = item } +/** + * 将数字格式化为"250XX"格式,其中XX是两位数 + * @param {number} num - 要格式化的数字 + * @return {string} - 格式化后的字符串 + */ + function formatNumber(num) { + // 确保输入是有效数字 + if (typeof num !== 'number' && isNaN(Number(num))) { + throw new Error('输入必须是有效数字'); + } + + // 转换为数字类型(以防输入是字符串数字) + const number = Number(num); + + // 数字部分格式化为两位数,不足补0 + const formattedNum = number.toString().padStart(2, '0'); + + // 添加前缀"250"并返回结果 + return `250${formattedNum}`; +}