diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SseTestApi.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SseTestApi.java index 6e1e7a3..a41cd68 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SseTestApi.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/SseTestApi.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/sse-test") -@ConditionalOnProperty(prefix = "ruoyi",name = "dev",havingValue = "true") +@Dev @Slf4j public class SseTestApi extends SseApiSupport { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Dev.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Dev.java index efaeebd..7b2cfa2 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Dev.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Dev.java @@ -1,9 +1,12 @@ package com.ruoyi.common.annotation; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; + import java.lang.annotation.*; -@Target(ElementType.METHOD) +@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited +@ConditionalOnProperty(prefix = "ruoyi", name = "dev", havingValue = "true") public @interface Dev { } diff --git a/uniapp/src/util/modules/util.js b/uniapp/src/util/modules/util.js index e03db42..ad3d56a 100644 --- a/uniapp/src/util/modules/util.js +++ b/uniapp/src/util/modules/util.js @@ -1,5 +1,54 @@ +export const sleep = (time) => { + return new Promise((resove, reject) => { + setTimeout(() => { + resove(); + }, time); + }); +} + + +//计算两点距离 +export const commonDistance = function (lat1, lng1, lat2, lng2) { + let f = ((lat1 + lat2) / 2) * Math.PI / 180.0; + let g = ((lat1 - lat2) / 2) * Math.PI / 180.0; + let l = ((lng1 - lng2) / 2) * Math.PI / 180.0; + let sg = Math.sin(g); + let sl = Math.sin(l); + let sf = Math.sin(f); + let s, c, w, r, d, h1, h2; + let a = 6378137.0; //地球的直径 + let fl = 1 / 298.257; + sg = sg * sg; + sl = sl * sl; + sf = sf * sf; + s = sg * (1 - sl) + (1 - sf) * sl; + c = (1 - sg) * (1 - sl) + sf * sl; + w = Math.atan(Math.sqrt(s / c)); + r = Math.sqrt(s * c) / w; + d = 2 * w * a; + h1 = (3 * r - 1) / 2 / c; + h2 = (3 * r + 1) / 2 / s; + let num = d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg)) + + return num || 0; +} +export const distanceShow = (num) => { + // 换算单位 + if (!num) { + return "0.0 m" + } + if (num < 1000) { + return num.toFixed(1) + "m" + } else if (num > 1000) { + return (num / 1000).toFixed(1) + "km" + } +} +// px转upx +export const px2upx = function (n) { + return n / (uni.upx2px(n) / n); +} // 判断两时间段之间活动状态、判断活动还有多长时间开始、多长时间结束----添加定时器运行此方法可倒计时