-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathString.ts
121 lines (102 loc) · 2.77 KB
/
String.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
interface String {
// RJS 渲染相關
/**
* 創建 RJS 渲染實例
* @param body 配置選項,當前字串會作為 id
* @returns RJS 實例
*/
RJS(body: Record<string, any>): RJS;
// JSON 處理
/**
* 將字串解析為 JSON 物件
* @readonly
* @returns 解析後的物件,解析失敗返回 undefined
*/
readonly $json: Record<string, any> | undefined;
/**
* 檢查字串是否為有效的 JSON 格式
* @readonly
*/
readonly $$json: boolean;
// 字串操作
/**
* 複製字串到系統剪貼板
* @returns Promise<void>
*/
copy(): Promise<void>;
/**
* 將字串轉換為正則表達式
* @param flags 正則表達式旗標
* @param force 是否自動轉義特殊字符
*/
$regexp(flags?: string, force?: boolean): RegExp;
/**
* 將 base64 字串轉換為 Blob 物件
* @param mimeType MIME 類型
*/
$base64(mimeType: string): Blob;
/**
* 檢查字串匹配
* @param value 要匹配的字串或正則表達式
* @returns 是否匹配
*/
$$(value?: RegExp | string): boolean;
// HTML 相關
/**
* 將字串轉換為 HTML 安全的實體編碼
* @readonly
*/
readonly $html: string;
// URL 相關
/**
* 將字串解析為 URL 物件
* @readonly
*/
readonly $url: URL;
// 獲取 URL 的所有查詢參數
readonly $queryAll: Record<string, string>;
// 將字串轉換為 Image 物件
readonly $img: Promise<Image>;
/**
* 檢查 URL 可訪問性
* @param isImage 是否作為圖片處理
*/
$$200(isImage?: boolean): Promise<any>;
/**
* 發送 HTTP 請求
* @param body 請求體數據
*/
$req(body: Record<string, any>): void;
/**
* 獲取 URL 查詢參數
* @param key 參數名
*/
$query(key?: string): string;
// URL 歷史記錄操作
// 添加歷史記錄
_history(title?: string | number): URL;
// 替換歷史記錄
__history(title?: string | number): URL;
// URL 查詢參數操作
// 更新查詢參數
_query(value?: Record<string, string | number>): URL;
// 重置查詢參數
__query(value?: Record<string, string | number>): URL;
// 刪除指定查詢參數
query_(value?: string | string[]): URL;
// 清除所有查詢參數
query__(): URL;
// DOM 元素操作
// 建立 Font Awesome 圖標
readonly _fa: Element;
// 選擇單個 DOM 元素
readonly $: Element;
// 選擇多個 DOM 元素
readonly $all: Element[];
/**
* 創建 DOM 元素
* @param val0 屬性或內容
* @param val1 內容(如果 val0 為屬性)
*/
_(val0?: any, val1?: any): Element;
}