@cldemo/ui-kit 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
declare class CommonBrowserProgress {
|
|
3
2
|
private static _isRouteStarted;
|
|
4
3
|
private static _pending;
|
|
5
4
|
private static _routeStartTime;
|
|
6
5
|
private static _routeMinTimer;
|
|
6
|
+
private static _isStyleInjected;
|
|
7
|
+
/** 注入 NProgress 基础样式(幂等) */
|
|
8
|
+
private static _ensureBaseStyle;
|
|
7
9
|
/** 全局配置 */
|
|
8
10
|
static configure(opts?: {
|
|
9
11
|
color?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const s=require("nprogress"),d="#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:solid 2px transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .spinner,.nprogress-custom-parent #nprogress .bar{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}";class u{static _isRouteStarted=!1;static _pending=0;static _routeStartTime=0;static _routeMinTimer=null;static _isStyleInjected=!1;static _ensureBaseStyle(){if(this._isStyleInjected||typeof document>"u")return;const t=document.createElement("style");t.textContent=d,document.head.appendChild(t),this._isStyleInjected=!0}static configure(t){const{color:e,height:i,showSpinner:o,speed:a,trickleSpeed:p}=t||{};if(this._ensureBaseStyle(),e||i){const n=document.createElement("style");let r="";e&&(r+=`#nprogress .bar{background:${e}!important}`),i&&(r+=`#nprogress .bar{height:${i}px!important}`),r&&(n.textContent=r,document.head.appendChild(n))}s.configure({showSpinner:o??!1,speed:a??300,trickleSpeed:p??200,minimum:.2})}static startRoute(){this._ensureBaseStyle(),this._isRouteStarted||(this._routeStartTime=Date.now()),this._isRouteStarted=!0,this._routeMinTimer&&(clearTimeout(this._routeMinTimer),this._routeMinTimer=null),s.start()}static doneRoute(){this._isRouteStarted=!1,this._tryDone()}static _tryDone(){if(this._isRouteStarted||this._pending>0)return;const t=Date.now()-this._routeStartTime,e=100;if(t<e){this._routeMinTimer||(this._routeMinTimer=setTimeout(()=>{this._routeMinTimer=null,this._tryDone()},e-t));return}s.done()}static startRequest(){this._ensureBaseStyle(),this._pending++,s.isStarted()||s.start()}static doneRequest(){this._pending=Math.max(0,this._pending-1),this._tryDone()}}module.exports=u;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import r from "nprogress";
|
|
2
|
+
const d = "#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:solid 2px transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .spinner,.nprogress-custom-parent #nprogress .bar{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}";
|
|
3
|
+
class h {
|
|
3
4
|
// 路由级别,不计数
|
|
4
5
|
static _isRouteStarted = !1;
|
|
5
6
|
// API 请求计数器:第一个请求 start,最后一个 done
|
|
@@ -7,24 +8,32 @@ class d {
|
|
|
7
8
|
// 最小可见时间:路由太快时进度条至少显示 400ms
|
|
8
9
|
static _routeStartTime = 0;
|
|
9
10
|
static _routeMinTimer = null;
|
|
11
|
+
// 基础样式只注入一次,避免重复调用 configure() 时堆积 <style>
|
|
12
|
+
static _isStyleInjected = !1;
|
|
13
|
+
/** 注入 NProgress 基础样式(幂等) */
|
|
14
|
+
static _ensureBaseStyle() {
|
|
15
|
+
if (this._isStyleInjected || typeof document > "u") return;
|
|
16
|
+
const t = document.createElement("style");
|
|
17
|
+
t.textContent = d, document.head.appendChild(t), this._isStyleInjected = !0;
|
|
18
|
+
}
|
|
10
19
|
/** 全局配置 */
|
|
11
|
-
static configure(
|
|
12
|
-
const { color:
|
|
13
|
-
if (
|
|
20
|
+
static configure(t) {
|
|
21
|
+
const { color: e, height: i, showSpinner: o, speed: a, trickleSpeed: p } = t || {};
|
|
22
|
+
if (this._ensureBaseStyle(), e || i) {
|
|
14
23
|
const n = document.createElement("style");
|
|
15
24
|
let s = "";
|
|
16
|
-
|
|
25
|
+
e && (s += `#nprogress .bar{background:${e}!important}`), i && (s += `#nprogress .bar{height:${i}px!important}`), s && (n.textContent = s, document.head.appendChild(n));
|
|
17
26
|
}
|
|
18
|
-
|
|
27
|
+
r.configure({
|
|
19
28
|
showSpinner: o ?? !1,
|
|
20
29
|
speed: a ?? 300,
|
|
21
|
-
trickleSpeed:
|
|
30
|
+
trickleSpeed: p ?? 200,
|
|
22
31
|
minimum: 0.2
|
|
23
32
|
});
|
|
24
33
|
}
|
|
25
34
|
/** 路由导航开始 */
|
|
26
35
|
static startRoute() {
|
|
27
|
-
this._isRouteStarted || (this._routeStartTime = Date.now()), this._isRouteStarted = !0, this._routeMinTimer && (clearTimeout(this._routeMinTimer), this._routeMinTimer = null),
|
|
36
|
+
this._ensureBaseStyle(), this._isRouteStarted || (this._routeStartTime = Date.now()), this._isRouteStarted = !0, this._routeMinTimer && (clearTimeout(this._routeMinTimer), this._routeMinTimer = null), r.start();
|
|
28
37
|
}
|
|
29
38
|
/** 路由导航完成(等 API 也完成后才真正关闭,且至少显示 400ms) */
|
|
30
39
|
static doneRoute() {
|
|
@@ -33,18 +42,18 @@ class d {
|
|
|
33
42
|
/** 尝试关闭——确保最小可见时间和无 pending 请求 */
|
|
34
43
|
static _tryDone() {
|
|
35
44
|
if (this._isRouteStarted || this._pending > 0) return;
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
45
|
+
const t = Date.now() - this._routeStartTime, e = 100;
|
|
46
|
+
if (t < e) {
|
|
38
47
|
this._routeMinTimer || (this._routeMinTimer = setTimeout(() => {
|
|
39
48
|
this._routeMinTimer = null, this._tryDone();
|
|
40
|
-
},
|
|
49
|
+
}, e - t));
|
|
41
50
|
return;
|
|
42
51
|
}
|
|
43
|
-
|
|
52
|
+
r.done();
|
|
44
53
|
}
|
|
45
54
|
/** API 请求开始 */
|
|
46
55
|
static startRequest() {
|
|
47
|
-
this._pending++,
|
|
56
|
+
this._ensureBaseStyle(), this._pending++, r.isStarted() || r.start();
|
|
48
57
|
}
|
|
49
58
|
/** API 请求完成 */
|
|
50
59
|
static doneRequest() {
|
|
@@ -52,5 +61,5 @@ class d {
|
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
export {
|
|
55
|
-
|
|
64
|
+
h as default
|
|
56
65
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import 'nprogress/nprogress.css';
|
|
2
1
|
declare class CommonBrowserProgress {
|
|
3
2
|
private static _isRouteStarted;
|
|
4
3
|
private static _pending;
|
|
5
4
|
private static _routeStartTime;
|
|
6
5
|
private static _routeMinTimer;
|
|
6
|
+
private static _isStyleInjected;
|
|
7
|
+
/** 注入 NProgress 基础样式(幂等) */
|
|
8
|
+
private static _ensureBaseStyle;
|
|
7
9
|
/** 全局配置 */
|
|
8
10
|
static configure(opts?: {
|
|
9
11
|
color?: string;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:solid 2px transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .spinner,.nprogress-custom-parent #nprogress .bar{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|