chore: 初始化项目 — uni-app + Vue3 + TypeScript 脚手架

This commit is contained in:
jacobxu666
2026-06-14 17:16:18 +08:00
commit 046e84a564
37 changed files with 13763 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
const formatNumber = (n: number): string => {
const str = n.toString()
return str[1] ? str : '0' + str
}
function formatTime(date: Date | number | string): string {
const d = new Date(date)
const year = d.getFullYear()
const month = d.getMonth() + 1
const day = d.getDate()
const hour = d.getHours()
const minute = d.getMinutes()
const second = d.getSeconds()
return `${year}/${month}/${day} ${[hour, minute, second].map(formatNumber).join(':')}`
}
function showToast(title: string, icon: 'success' | 'loading' | 'error' | 'none' = 'none'): void {
uni.showToast({
title,
icon,
duration: 2000
})
}
function navigateTo(url: string): void {
uni.navigateTo({ url })
}
function redirectTo(url: string): void {
uni.redirectTo({ url })
}
function switchTab(url: string): void {
uni.switchTab({ url })
}
export {
formatTime,
formatNumber,
showToast,
navigateTo,
redirectTo,
switchTab
}