Commit 00e7b90d by 杨明

init

1 parent b36ec43b
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-24 17:28:02
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 15:21:13
* @FilePath: \rollup_demo\src\main.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import Request from './modules/request'
const request = new Request('https://www.xxx.com', 'ajax')
console.log(request.url)
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-27 11:13:22
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 15:24:39
* @FilePath: \rollup_demo\src\modules\request.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { requestType } from 'request'
class Request {
public url: string
public method: requestType
constructor(url: string, method: requestType) {
this.url = url
this.method = method
}
}
export default Request
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-28 14:10:03
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 14:11:42
* @FilePath: \glsx-tracker-javascript\src\types\request.d.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
declare module 'request' {
export type requestType = 'ajax' | 'image' | 'fetch' | 'beacon'
}
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-28 14:32:54
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 15:25:12
* @FilePath: \glsx-tracker-miniprogram\src\utils\helper.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
export default {
dateFormat (timestamp: number|string|Date, format = 'YYYY-MM-DD HH:mm:ss'): string {
var date = new Date(timestamp)
function fixedTwo (value: number): string {
return value < 10 ? '0' + value : String(value)
}
var showTime = format
if (showTime.includes('SSS')) {
const S = date.getMilliseconds()
showTime = showTime.replace('SSS', '0'.repeat(3 - String(S).length) + S)
}
if (showTime.includes('YY')) {
const Y = date.getFullYear()
showTime = showTime.includes('YYYY') ? showTime.replace('YYYY', String(Y)) : showTime.replace('YY', String(Y).slice(2, 4))
}
if (showTime.includes('M')) {
const M = date.getMonth() + 1
showTime = showTime.includes('MM') ? showTime.replace('MM', fixedTwo(M)) : showTime.replace('M', String(M))
}
if (showTime.includes('D')) {
const D = date.getDate()
showTime = showTime.includes('DD') ? showTime.replace('DD', fixedTwo(D)) : showTime.replace('D', String(D))
}
if (showTime.includes('H')) {
const H = date.getHours()
showTime = showTime.includes('HH') ? showTime.replace('HH', fixedTwo(H)) : showTime.replace('H', String(H))
}
if (showTime.includes('m')) {
var m = date.getMinutes()
showTime = showTime.includes('mm') ? showTime.replace('mm', fixedTwo(m)) : showTime.replace('m', String(m))
}
if (showTime.includes('s')) {
var s = date.getSeconds()
showTime = showTime.includes('ss') ? showTime.replace('ss', fixedTwo(s)) : showTime.replace('s', String(s))
}
return showTime
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!