mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-21 02:34:11 +08:00
Fix dayjs (#5923)
This commit is contained in:
11
src/util.ts
11
src/util.ts
@@ -9,9 +9,9 @@
|
||||
// Frontend uses util.ts
|
||||
*/
|
||||
|
||||
import * as dayjs from "dayjs";
|
||||
import dayjsFrontend from "dayjs";
|
||||
|
||||
// For loading dayjs plugins, don't remove event though it is not used in this file
|
||||
// For dayjs plugins' type checking, don't remove event though it is not used in this file
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import * as timezone from "dayjs/plugin/timezone";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@@ -21,6 +21,13 @@ import * as jsonata from "jsonata";
|
||||
|
||||
export const isDev = process.env.NODE_ENV === "development";
|
||||
export const isNode = typeof process !== "undefined" && process?.versions?.node;
|
||||
|
||||
/**
|
||||
* Smarter dayjs import that supports both frontend and backend
|
||||
* @returns {dayjs.Dayjs} dayjs instance
|
||||
*/
|
||||
const dayjs = (isNode) ? require("dayjs") : dayjsFrontend;
|
||||
|
||||
export const appName = "Uptime Kuma";
|
||||
export const DOWN = 0;
|
||||
export const UP = 1;
|
||||
|
Reference in New Issue
Block a user