fetch(modify):修复BUG
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m27s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m27s
This commit is contained in:
47
src/utils/codeGenerator.ts
Normal file
47
src/utils/codeGenerator.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 编码生成工具
|
||||
*/
|
||||
|
||||
/**
|
||||
* 生成套餐系列编码
|
||||
* 规则: PS + 年月日时分秒 + 4位随机数
|
||||
* 示例: PS20260203143025ABCD
|
||||
*/
|
||||
export function generateSeriesCode(): string {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getDate()).padStart(2, '0')
|
||||
const hours = String(now.getHours()).padStart(2, '0')
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
||||
|
||||
// 生成4位随机大写字母
|
||||
const randomChars = Array.from({ length: 4 }, () =>
|
||||
String.fromCharCode(65 + Math.floor(Math.random() * 26))
|
||||
).join('')
|
||||
|
||||
return `PS${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成套餐编码
|
||||
* 规则: PKG + 年月日时分秒 + 4位随机数
|
||||
* 示例: PKG20260203143025ABCD
|
||||
*/
|
||||
export function generatePackageCode(): string {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getDate()).padStart(2, '0')
|
||||
const hours = String(now.getHours()).padStart(2, '0')
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
||||
|
||||
// 生成4位随机大写字母
|
||||
const randomChars = Array.from({ length: 4 }, () =>
|
||||
String.fromCharCode(65 + Math.floor(Math.random() * 26))
|
||||
).join('')
|
||||
|
||||
return `PKG${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
Reference in New Issue
Block a user