zhi-device
Advanced tools
Comparing version 2.2.0 to 2.3.0
var P = Object.defineProperty; | ||
var g = (t, e, i) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; | ||
var s = (t, e, i) => (g(t, typeof e != "symbol" ? e + "" : e, i), i); | ||
var g = (a, e, i) => e in a ? P(a, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[e] = i; | ||
var s = (a, e, i) => (g(a, typeof e != "symbol" ? e + "" : e, i), i); | ||
const p = class { | ||
@@ -39,5 +39,5 @@ /** | ||
return ""; | ||
const i = window.location.href, a = i.indexOf("?"); | ||
if (a !== -1) { | ||
const o = i.indexOf("#", a), d = o !== -1 ? i.substring(a + 1, o) : i.substring(a + 1), m = new URLSearchParams(d).get(e); | ||
const i = window.location.href, t = i.indexOf("?"); | ||
if (t !== -1) { | ||
const o = i.indexOf("#", t), d = o !== -1 ? i.substring(t + 1, o) : i.substring(t + 1), m = new URLSearchParams(d).get(e); | ||
if (m) | ||
@@ -70,9 +70,9 @@ return m; | ||
*/ | ||
s(n, "replaceUrlParam", (e, i, a) => { | ||
a == null && (a = ""); | ||
s(n, "replaceUrlParam", (e, i, t) => { | ||
t == null && (t = ""); | ||
const r = new RegExp("\\b(" + i + "=).*?(&|#|$)"); | ||
if (e.search(r) >= 0) | ||
return e.replace(r, "$1" + a + "$2"); | ||
return e.replace(r, "$1" + t + "$2"); | ||
const [o, d] = e.split("#"), [l, m] = o.split("?"), f = new URLSearchParams(m); | ||
f.set(i, a); | ||
f.set(i, t); | ||
const y = f.toString(), b = l + (y ? "?" + y : ""); | ||
@@ -87,9 +87,9 @@ return d ? b + "#" + d : b; | ||
*/ | ||
s(n, "setUrlParameter", (e, i, a) => { | ||
s(n, "setUrlParameter", (e, i, t) => { | ||
if (e.includes(i)) | ||
return p.replaceUrlParam(e, i, a); | ||
return p.replaceUrlParam(e, i, t); | ||
const r = e.split("#"); | ||
let o = r[0]; | ||
const d = r[1]; | ||
return o.includes("?") ? o += `&${i}=${a}` : o += `?${i}=${a}`, d && (o += "#" + d), o; | ||
return o.includes("?") ? o += `&${i}=${t}` : o += `?${i}=${t}`, d && (o += "#" + d), o; | ||
}), /** | ||
@@ -101,16 +101,18 @@ * 重新加载指定tab | ||
*/ | ||
s(n, "reloadTabPage", (e, i = 200) => { | ||
s(n, "reloadTabPage", (e, i) => { | ||
setTimeout(function() { | ||
if (p.isInBrowser) { | ||
const a = window.location.href; | ||
window.location.href = p.setUrlParameter(a, "tab", e); | ||
const t = window.location.href; | ||
window.location.href = p.setUrlParameter(t, "tab", e); | ||
} | ||
}, i); | ||
}, i ?? 200); | ||
}), /** | ||
* 刷新当前tab页面 | ||
* | ||
* @param t - 延迟时间 | ||
*/ | ||
s(n, "reloadPage", () => { | ||
s(n, "reloadPage", (e) => { | ||
setTimeout(function() { | ||
p.isInBrowser && window.location.reload(); | ||
}, 200); | ||
}, e ?? 200); | ||
}), /** | ||
@@ -121,9 +123,10 @@ * 刷新当前tab页面 | ||
* @param cb - 回调 | ||
* @param t - 延迟时间 | ||
*/ | ||
s(n, "reloadPageWithMessageCallback", (e, i) => { | ||
s(n, "reloadPageWithMessageCallback", (e, i, t) => { | ||
i && i(e), setTimeout(function() { | ||
p.isInBrowser && window.location.reload(); | ||
}, 200); | ||
}, t ?? 200); | ||
}); | ||
var h = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(h || {}); | ||
var h = /* @__PURE__ */ ((a) => (a.BasePathType_Appearance = "Appearance", a.BasePathType_Data = "Data", a.BasePathType_Themes = "Themes", a.BasePathType_ZhiTheme = "ZhiTheme", a.BasePathType_None = "None", a))(h || {}); | ||
const c = class { | ||
@@ -156,15 +159,15 @@ /** | ||
static async importJs(e, i) { | ||
let a = e; | ||
let t = e; | ||
switch (i) { | ||
case h.BasePathType_Appearance: | ||
a = this.browserJoinPath(this.siyuanAppearanceRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanAppearanceRelativePath(), e); | ||
break; | ||
case h.BasePathType_Data: | ||
a = this.browserJoinPath(this.siyuanDataRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanDataRelativePath(), e); | ||
break; | ||
case h.BasePathType_Themes: | ||
a = this.browserJoinPath(this.siyuanThemeRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanThemeRelativePath(), e); | ||
break; | ||
case h.BasePathType_ZhiTheme: | ||
a = this.browserJoinPath(this.zhiThemeRelativePath(), e); | ||
t = this.browserJoinPath(this.zhiThemeRelativePath(), e); | ||
break; | ||
@@ -176,3 +179,3 @@ default: | ||
/* @vite-ignore */ | ||
a | ||
t | ||
); | ||
@@ -369,3 +372,3 @@ return r; | ||
*/ | ||
s(u, "requireLib", (e, i = !0, a = h.BasePathType_None) => { | ||
s(u, "requireLib", (e, i = !0, t = h.BasePathType_None) => { | ||
if (!n.hasNodeEnv()) | ||
@@ -375,3 +378,3 @@ throw new Error("require ony works on node env"); | ||
if (!i) | ||
switch (a) { | ||
switch (t) { | ||
case h.BasePathType_Appearance: | ||
@@ -418,3 +421,3 @@ r = c.joinPath(c.siyuanAppearancePath(), e); | ||
s(u, "requireZhiThemeLib", (e) => c.requireLib(e, !1, h.BasePathType_ZhiTheme)); | ||
var w = /* @__PURE__ */ ((t) => (t.DeviceType_Mobile_Device = "Mobile", t.DeviceType_Siyuan_Widget = "Siyuan_Widget", t.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", t.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", t.DeviceType_Siyuan_Browser = "Siyuan_Browser", t.DeviceType_Chrome_Extension = "Chrome_Extension", t.DeviceType_Chrome_Browser = "Chrome_Browser", t.DeviceType_Node = "Node", t))(w || {}); | ||
var w = /* @__PURE__ */ ((a) => (a.DeviceType_Mobile_Device = "Mobile", a.DeviceType_Siyuan_Widget = "Siyuan_Widget", a.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", a.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", a.DeviceType_Siyuan_Browser = "Siyuan_Browser", a.DeviceType_Chrome_Extension = "Chrome_Extension", a.DeviceType_Chrome_Browser = "Chrome_Browser", a.DeviceType_Node = "Node", a))(w || {}); | ||
class T { | ||
@@ -421,0 +424,0 @@ /** |
var P = Object.defineProperty; | ||
var g = (t, e, i) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; | ||
var s = (t, e, i) => (g(t, typeof e != "symbol" ? e + "" : e, i), i); | ||
var g = (a, e, i) => e in a ? P(a, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[e] = i; | ||
var s = (a, e, i) => (g(a, typeof e != "symbol" ? e + "" : e, i), i); | ||
const p = class { | ||
@@ -39,5 +39,5 @@ /** | ||
return ""; | ||
const i = window.location.href, a = i.indexOf("?"); | ||
if (a !== -1) { | ||
const o = i.indexOf("#", a), d = o !== -1 ? i.substring(a + 1, o) : i.substring(a + 1), m = new URLSearchParams(d).get(e); | ||
const i = window.location.href, t = i.indexOf("?"); | ||
if (t !== -1) { | ||
const o = i.indexOf("#", t), d = o !== -1 ? i.substring(t + 1, o) : i.substring(t + 1), m = new URLSearchParams(d).get(e); | ||
if (m) | ||
@@ -70,9 +70,9 @@ return m; | ||
*/ | ||
s(n, "replaceUrlParam", (e, i, a) => { | ||
a == null && (a = ""); | ||
s(n, "replaceUrlParam", (e, i, t) => { | ||
t == null && (t = ""); | ||
const r = new RegExp("\\b(" + i + "=).*?(&|#|$)"); | ||
if (e.search(r) >= 0) | ||
return e.replace(r, "$1" + a + "$2"); | ||
return e.replace(r, "$1" + t + "$2"); | ||
const [o, d] = e.split("#"), [l, m] = o.split("?"), f = new URLSearchParams(m); | ||
f.set(i, a); | ||
f.set(i, t); | ||
const y = f.toString(), b = l + (y ? "?" + y : ""); | ||
@@ -87,9 +87,9 @@ return d ? b + "#" + d : b; | ||
*/ | ||
s(n, "setUrlParameter", (e, i, a) => { | ||
s(n, "setUrlParameter", (e, i, t) => { | ||
if (e.includes(i)) | ||
return p.replaceUrlParam(e, i, a); | ||
return p.replaceUrlParam(e, i, t); | ||
const r = e.split("#"); | ||
let o = r[0]; | ||
const d = r[1]; | ||
return o.includes("?") ? o += `&${i}=${a}` : o += `?${i}=${a}`, d && (o += "#" + d), o; | ||
return o.includes("?") ? o += `&${i}=${t}` : o += `?${i}=${t}`, d && (o += "#" + d), o; | ||
}), /** | ||
@@ -101,16 +101,18 @@ * 重新加载指定tab | ||
*/ | ||
s(n, "reloadTabPage", (e, i = 200) => { | ||
s(n, "reloadTabPage", (e, i) => { | ||
setTimeout(function() { | ||
if (p.isInBrowser) { | ||
const a = window.location.href; | ||
window.location.href = p.setUrlParameter(a, "tab", e); | ||
const t = window.location.href; | ||
window.location.href = p.setUrlParameter(t, "tab", e); | ||
} | ||
}, i); | ||
}, i ?? 200); | ||
}), /** | ||
* 刷新当前tab页面 | ||
* | ||
* @param t - 延迟时间 | ||
*/ | ||
s(n, "reloadPage", () => { | ||
s(n, "reloadPage", (e) => { | ||
setTimeout(function() { | ||
p.isInBrowser && window.location.reload(); | ||
}, 200); | ||
}, e ?? 200); | ||
}), /** | ||
@@ -121,9 +123,10 @@ * 刷新当前tab页面 | ||
* @param cb - 回调 | ||
* @param t - 延迟时间 | ||
*/ | ||
s(n, "reloadPageWithMessageCallback", (e, i) => { | ||
s(n, "reloadPageWithMessageCallback", (e, i, t) => { | ||
i && i(e), setTimeout(function() { | ||
p.isInBrowser && window.location.reload(); | ||
}, 200); | ||
}, t ?? 200); | ||
}); | ||
var h = /* @__PURE__ */ ((t) => (t.BasePathType_Appearance = "Appearance", t.BasePathType_Data = "Data", t.BasePathType_Themes = "Themes", t.BasePathType_ZhiTheme = "ZhiTheme", t.BasePathType_None = "None", t))(h || {}); | ||
var h = /* @__PURE__ */ ((a) => (a.BasePathType_Appearance = "Appearance", a.BasePathType_Data = "Data", a.BasePathType_Themes = "Themes", a.BasePathType_ZhiTheme = "ZhiTheme", a.BasePathType_None = "None", a))(h || {}); | ||
const c = class { | ||
@@ -156,15 +159,15 @@ /** | ||
static async importJs(e, i) { | ||
let a = e; | ||
let t = e; | ||
switch (i) { | ||
case h.BasePathType_Appearance: | ||
a = this.browserJoinPath(this.siyuanAppearanceRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanAppearanceRelativePath(), e); | ||
break; | ||
case h.BasePathType_Data: | ||
a = this.browserJoinPath(this.siyuanDataRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanDataRelativePath(), e); | ||
break; | ||
case h.BasePathType_Themes: | ||
a = this.browserJoinPath(this.siyuanThemeRelativePath(), e); | ||
t = this.browserJoinPath(this.siyuanThemeRelativePath(), e); | ||
break; | ||
case h.BasePathType_ZhiTheme: | ||
a = this.browserJoinPath(this.zhiThemeRelativePath(), e); | ||
t = this.browserJoinPath(this.zhiThemeRelativePath(), e); | ||
break; | ||
@@ -176,3 +179,3 @@ default: | ||
/* @vite-ignore */ | ||
a | ||
t | ||
); | ||
@@ -369,3 +372,3 @@ return r; | ||
*/ | ||
s(u, "requireLib", (e, i = !0, a = h.BasePathType_None) => { | ||
s(u, "requireLib", (e, i = !0, t = h.BasePathType_None) => { | ||
if (!n.hasNodeEnv()) | ||
@@ -375,3 +378,3 @@ throw new Error("require ony works on node env"); | ||
if (!i) | ||
switch (a) { | ||
switch (t) { | ||
case h.BasePathType_Appearance: | ||
@@ -418,3 +421,3 @@ r = c.joinPath(c.siyuanAppearancePath(), e); | ||
s(u, "requireZhiThemeLib", (e) => c.requireLib(e, !1, h.BasePathType_ZhiTheme)); | ||
var w = /* @__PURE__ */ ((t) => (t.DeviceType_Mobile_Device = "Mobile", t.DeviceType_Siyuan_Widget = "Siyuan_Widget", t.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", t.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", t.DeviceType_Siyuan_Browser = "Siyuan_Browser", t.DeviceType_Chrome_Extension = "Chrome_Extension", t.DeviceType_Chrome_Browser = "Chrome_Browser", t.DeviceType_Node = "Node", t))(w || {}); | ||
var w = /* @__PURE__ */ ((a) => (a.DeviceType_Mobile_Device = "Mobile", a.DeviceType_Siyuan_Widget = "Siyuan_Widget", a.DeviceType_Siyuan_NewWin = "Siyuan_NewWindow", a.DeviceType_Siyuan_MainWin = "Siyuan_MainWindow", a.DeviceType_Siyuan_Browser = "Siyuan_Browser", a.DeviceType_Chrome_Extension = "Chrome_Extension", a.DeviceType_Chrome_Browser = "Chrome_Browser", a.DeviceType_Node = "Node", a))(w || {}); | ||
class T { | ||
@@ -421,0 +424,0 @@ /** |
@@ -77,4 +77,6 @@ /** | ||
* 刷新当前tab页面 | ||
* | ||
* @param t - 延迟时间 | ||
*/ | ||
static reloadPage: () => void; | ||
static reloadPage: (t?: number) => void; | ||
/** | ||
@@ -85,5 +87,6 @@ * 刷新当前tab页面 | ||
* @param cb - 回调 | ||
* @param t - 延迟时间 | ||
*/ | ||
static reloadPageWithMessageCallback: (msg: string, cb: any) => void; | ||
static reloadPageWithMessageCallback: (msg: string, cb?: any, t?: number) => void; | ||
} | ||
export default BrowserUtil; |
{ | ||
"name": "zhi-device", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
{ | ||
"name": "zhi-device", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"type": "module", | ||
@@ -24,5 +24,5 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@terwer/tsconfig": "0.0.7", | ||
"@terwer/vite-config-custom": "0.7.6", | ||
"@terwer/eslint-config-custom": "1.3.6" | ||
"@terwer/eslint-config-custom": "1.3.6", | ||
"@terwer/tsconfig": "0.0.7" | ||
}, | ||
@@ -29,0 +29,0 @@ "publishConfig": { |
44614
1247