xshell 1.2.75 → 1.2.76
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.
- package/package.json +1 -1
- package/utils.browser.d.ts +9 -0
- package/utils.browser.js +32 -0
package/package.json
CHANGED
package/utils.browser.d.ts
CHANGED
|
@@ -2,3 +2,12 @@ import './prototype.browser.ts';
|
|
|
2
2
|
import './platform.browser.ts';
|
|
3
3
|
export * from './utils.common.ts';
|
|
4
4
|
export declare function pause(milliseconds?: number): Promise<void>;
|
|
5
|
+
/** 切换所有已选择的 items 中是否包含当前 item */
|
|
6
|
+
export declare function switch_selecteds<TItem>(selecteds: TItem[], item: TItem): TItem[];
|
|
7
|
+
export declare function apply_css(css: string): void;
|
|
8
|
+
export declare function to_option(value: string): {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function download_url(name: string, url: string): void;
|
|
13
|
+
export declare function download(name: string, data: string | Uint8Array, mime_type?: string): void;
|
package/utils.browser.js
CHANGED
|
@@ -7,4 +7,36 @@ export async function pause(milliseconds = 3000) {
|
|
|
7
7
|
debugger;
|
|
8
8
|
}
|
|
9
9
|
globalThis.pause = pause;
|
|
10
|
+
/** 切换所有已选择的 items 中是否包含当前 item */
|
|
11
|
+
export function switch_selecteds(selecteds, item) {
|
|
12
|
+
return selecteds.includes(item) ?
|
|
13
|
+
selecteds.filter(s => s !== item)
|
|
14
|
+
:
|
|
15
|
+
[...selecteds, item];
|
|
16
|
+
}
|
|
17
|
+
export function apply_css(css) {
|
|
18
|
+
let $style = document.createElement('style');
|
|
19
|
+
$style.appendChild(document.createTextNode(css));
|
|
20
|
+
document.head.appendChild($style);
|
|
21
|
+
}
|
|
22
|
+
export function to_option(value) {
|
|
23
|
+
return { label: value, value };
|
|
24
|
+
}
|
|
25
|
+
export function download_url(name, url) {
|
|
26
|
+
// 创建一个隐藏的 <a> 元素
|
|
27
|
+
const a = document.createElement('a');
|
|
28
|
+
a.style.display = 'none';
|
|
29
|
+
a.href = url;
|
|
30
|
+
a.download = name;
|
|
31
|
+
// 将 <a> 元素添加到 DOM 中
|
|
32
|
+
document.body.appendChild(a);
|
|
33
|
+
// 触发下载
|
|
34
|
+
a.click();
|
|
35
|
+
// 下载完成后移除 <a> 元素和 URL 对象
|
|
36
|
+
document.body.removeChild(a);
|
|
37
|
+
URL.revokeObjectURL(url);
|
|
38
|
+
}
|
|
39
|
+
export function download(name, data, mime_type) {
|
|
40
|
+
download_url(name, URL.createObjectURL(new Blob([data], { type: mime_type })));
|
|
41
|
+
}
|
|
10
42
|
//# sourceMappingURL=utils.browser.js.map
|