mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-11 05:26:39 +08:00
Merge branch 'master' into clean-mobile-table
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<transition name="slide-fade" appear>
|
||||
<div>
|
||||
<div v-if="monitor">
|
||||
<h1> {{ monitor.name }}</h1>
|
||||
<p class="url">
|
||||
<a v-if="monitor.type === 'http' || monitor.type === 'keyword' " :href="monitor.url" target="_blank">{{ monitor.url }}</a>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<template>
|
||||
<MonitorList />
|
||||
<transition name="slide-fade" appear>
|
||||
<MonitorList />
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
24
src/util.ts
24
src/util.ts
@@ -1,4 +1,3 @@
|
||||
// @ts-nocheck
|
||||
// Common Util for frontend and backend
|
||||
// Backend uses the compiled file util.js
|
||||
// Frontend uses util.ts
|
||||
@@ -13,7 +12,7 @@ export const DOWN = 0;
|
||||
export const UP = 1;
|
||||
export const PENDING = 2;
|
||||
|
||||
export function flipStatus(s) {
|
||||
export function flipStatus(s: number) {
|
||||
if (s === UP) {
|
||||
return DOWN;
|
||||
}
|
||||
@@ -25,7 +24,7 @@ export function flipStatus(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
export function sleep(ms) {
|
||||
export function sleep(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
@@ -33,8 +32,8 @@ export function sleep(ms) {
|
||||
* PHP's ucfirst
|
||||
* @param str
|
||||
*/
|
||||
export function ucfirst(str) {
|
||||
if (! str) {
|
||||
export function ucfirst(str: string) {
|
||||
if (!str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -42,12 +41,15 @@ export function ucfirst(str) {
|
||||
return firstLetter.toUpperCase() + str.substr(1);
|
||||
}
|
||||
|
||||
export function debug(msg) {
|
||||
export function debug(msg: any) {
|
||||
if (isDev) {
|
||||
console.log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare global { interface String { replaceAll(str: string, newStr: string): string; } }
|
||||
|
||||
export function polyfill() {
|
||||
/**
|
||||
* String.prototype.replaceAll() polyfill
|
||||
@@ -56,7 +58,7 @@ export function polyfill() {
|
||||
* @license MIT
|
||||
*/
|
||||
if (!String.prototype.replaceAll) {
|
||||
String.prototype.replaceAll = function (str, newStr) {
|
||||
String.prototype.replaceAll = function (str: string, newStr: string) {
|
||||
|
||||
// If a regex pattern
|
||||
if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") {
|
||||
@@ -71,11 +73,13 @@ export function polyfill() {
|
||||
}
|
||||
|
||||
export class TimeLogger {
|
||||
startTime: number;
|
||||
|
||||
constructor() {
|
||||
this.startTime = dayjs().valueOf();
|
||||
}
|
||||
|
||||
print(name) {
|
||||
print(name: string) {
|
||||
if (isDev) {
|
||||
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms")
|
||||
}
|
||||
@@ -85,7 +89,7 @@ export class TimeLogger {
|
||||
/**
|
||||
* Returns a random number between min (inclusive) and max (exclusive)
|
||||
*/
|
||||
export function getRandomArbitrary(min, max) {
|
||||
export function getRandomArbitrary(min: number, max: number) {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
||||
@@ -98,7 +102,7 @@ export function getRandomArbitrary(min, max) {
|
||||
* lower than max if max isn't an integer).
|
||||
* Using Math.round() will give you a non-uniform distribution!
|
||||
*/
|
||||
export function getRandomInt(min, max) {
|
||||
export function getRandomInt(min: number, max: number) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
Reference in New Issue
Block a user