2022-04-22 01:16:02 +08:00
|
|
|
import dayjs from "dayjs"
|
2022-04-21 18:20:39 +08:00
|
|
|
|
|
|
|
/** 格式化时间 */
|
|
|
|
export const formatDateTime = (time: any) => {
|
2022-04-22 01:16:02 +08:00
|
|
|
if (time == null || time === "") {
|
|
|
|
return "N/A"
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
|
|
|
const date = new Date(time)
|
2022-04-22 01:16:02 +08:00
|
|
|
return dayjs(date).format("YYYY-MM-DD HH:mm:ss")
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
2022-05-25 21:53:38 +08:00
|
|
|
|
|
|
|
/** 将全局 css 导入 js 中使用 */
|
|
|
|
export const getCssVariableValue = (cssVariableName: string) => {
|
|
|
|
let cssVariableValue = ""
|
|
|
|
try {
|
|
|
|
// 没有拿到值时,会返回空串
|
|
|
|
cssVariableValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariableName)
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
}
|
|
|
|
return cssVariableValue
|
|
|
|
}
|