@cnc_cbz/usefultools-plugin-official 1.0.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.
- package/README.md +56 -0
- package/dist/base-converter.mjs +333 -0
- package/dist/case-converter.mjs +142 -0
- package/dist/chmod-calculator.mjs +286 -0
- package/dist/color-converter.mjs +211 -0
- package/dist/cron-expression.mjs +487 -0
- package/dist/cyber-chef.mjs +24885 -0
- package/dist/hash-generator.mjs +239 -0
- package/dist/html-entity.mjs +187 -0
- package/dist/image-compressor.mjs +337 -0
- package/dist/ip-subnet.mjs +222 -0
- package/dist/js-runner.mjs +39973 -0
- package/dist/json-diff.mjs +704 -0
- package/dist/json-formatter.mjs +1138 -0
- package/dist/json-yaml.mjs +256 -0
- package/dist/jwt-parser.mjs +405 -0
- package/dist/lorem-ipsum.mjs +246 -0
- package/dist/markdown-preview.mjs +184 -0
- package/dist/password-generator.mjs +254 -0
- package/dist/qr-generator.mjs +238 -0
- package/dist/regex-tester.mjs +424 -0
- package/dist/sql-formatter.mjs +242 -0
- package/dist/text-diff.mjs +940 -0
- package/dist/text-stats.mjs +205 -0
- package/dist/timestamp-converter.mjs +339 -0
- package/dist/translator.mjs +667 -0
- package/dist/url-codec.mjs +179 -0
- package/dist/uuid-generator.mjs +165 -0
- package/package.json +56 -0
- package/plugin.json +31 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { defineComponent, ref, openBlock, createElementBlock, createElementVNode, withDirectives, vModelText, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
+
const _hoisted_1 = { class: "flex flex-col h-full gap-4" };
|
|
3
|
+
const _hoisted_2 = { class: "flex-1 grid grid-cols-2 gap-4 min-h-0" };
|
|
4
|
+
const _hoisted_3 = { class: "bg-deep-charcoal border-4 border-black rounded-xl shadow-hard overflow-hidden flex flex-col" };
|
|
5
|
+
const _hoisted_4 = { class: "bg-deep-charcoal border-4 border-black rounded-xl shadow-hard overflow-hidden flex flex-col" };
|
|
6
|
+
const _hoisted_5 = { class: "flex items-center justify-between px-3 py-2 border-b-2 border-black" };
|
|
7
|
+
const _hoisted_6 = { class: "material-icons text-sm" };
|
|
8
|
+
const _hoisted_7 = { class: "flex-1 overflow-auto px-4 py-3 font-mono text-sm text-gray-100 whitespace-pre-wrap select-all" };
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
__name: "index",
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const input = ref("");
|
|
13
|
+
const output = ref("");
|
|
14
|
+
const copyField = ref("");
|
|
15
|
+
const keywords = [
|
|
16
|
+
"SELECT",
|
|
17
|
+
"FROM",
|
|
18
|
+
"WHERE",
|
|
19
|
+
"AND",
|
|
20
|
+
"OR",
|
|
21
|
+
"INSERT",
|
|
22
|
+
"INTO",
|
|
23
|
+
"VALUES",
|
|
24
|
+
"UPDATE",
|
|
25
|
+
"SET",
|
|
26
|
+
"DELETE",
|
|
27
|
+
"CREATE",
|
|
28
|
+
"TABLE",
|
|
29
|
+
"ALTER",
|
|
30
|
+
"DROP",
|
|
31
|
+
"JOIN",
|
|
32
|
+
"LEFT",
|
|
33
|
+
"RIGHT",
|
|
34
|
+
"INNER",
|
|
35
|
+
"OUTER",
|
|
36
|
+
"FULL",
|
|
37
|
+
"CROSS",
|
|
38
|
+
"ON",
|
|
39
|
+
"GROUP",
|
|
40
|
+
"BY",
|
|
41
|
+
"ORDER",
|
|
42
|
+
"HAVING",
|
|
43
|
+
"LIMIT",
|
|
44
|
+
"OFFSET",
|
|
45
|
+
"UNION",
|
|
46
|
+
"ALL",
|
|
47
|
+
"AS",
|
|
48
|
+
"IN",
|
|
49
|
+
"NOT",
|
|
50
|
+
"NULL",
|
|
51
|
+
"IS",
|
|
52
|
+
"LIKE",
|
|
53
|
+
"BETWEEN",
|
|
54
|
+
"EXISTS",
|
|
55
|
+
"CASE",
|
|
56
|
+
"WHEN",
|
|
57
|
+
"THEN",
|
|
58
|
+
"ELSE",
|
|
59
|
+
"END",
|
|
60
|
+
"DISTINCT",
|
|
61
|
+
"COUNT",
|
|
62
|
+
"SUM",
|
|
63
|
+
"AVG",
|
|
64
|
+
"MIN",
|
|
65
|
+
"MAX",
|
|
66
|
+
"ASC",
|
|
67
|
+
"DESC",
|
|
68
|
+
"WITH"
|
|
69
|
+
];
|
|
70
|
+
const majorKeywords = /* @__PURE__ */ new Set([
|
|
71
|
+
"SELECT",
|
|
72
|
+
"FROM",
|
|
73
|
+
"WHERE",
|
|
74
|
+
"JOIN",
|
|
75
|
+
"LEFT JOIN",
|
|
76
|
+
"RIGHT JOIN",
|
|
77
|
+
"INNER JOIN",
|
|
78
|
+
"OUTER JOIN",
|
|
79
|
+
"FULL JOIN",
|
|
80
|
+
"CROSS JOIN",
|
|
81
|
+
"GROUP BY",
|
|
82
|
+
"ORDER BY",
|
|
83
|
+
"HAVING",
|
|
84
|
+
"LIMIT",
|
|
85
|
+
"OFFSET",
|
|
86
|
+
"UNION",
|
|
87
|
+
"UNION ALL",
|
|
88
|
+
"INSERT INTO",
|
|
89
|
+
"VALUES",
|
|
90
|
+
"UPDATE",
|
|
91
|
+
"SET",
|
|
92
|
+
"DELETE FROM",
|
|
93
|
+
"CREATE TABLE",
|
|
94
|
+
"ALTER TABLE",
|
|
95
|
+
"DROP TABLE",
|
|
96
|
+
"WITH",
|
|
97
|
+
"AND",
|
|
98
|
+
"OR",
|
|
99
|
+
"ON"
|
|
100
|
+
]);
|
|
101
|
+
function formatSQL(sql) {
|
|
102
|
+
if (!sql.trim()) return "";
|
|
103
|
+
let s = sql.replace(/\s+/g, " ").trim();
|
|
104
|
+
for (const kw of keywords) {
|
|
105
|
+
const re = new RegExp(`\\b${kw}\\b`, "gi");
|
|
106
|
+
s = s.replace(re, kw);
|
|
107
|
+
}
|
|
108
|
+
s = s.replace(/\bLEFT\s+JOIN\b/g, "LEFT JOIN");
|
|
109
|
+
s = s.replace(/\bRIGHT\s+JOIN\b/g, "RIGHT JOIN");
|
|
110
|
+
s = s.replace(/\bINNER\s+JOIN\b/g, "INNER JOIN");
|
|
111
|
+
s = s.replace(/\bOUTER\s+JOIN\b/g, "OUTER JOIN");
|
|
112
|
+
s = s.replace(/\bFULL\s+JOIN\b/g, "FULL JOIN");
|
|
113
|
+
s = s.replace(/\bCROSS\s+JOIN\b/g, "CROSS JOIN");
|
|
114
|
+
s = s.replace(/\bGROUP\s+BY\b/g, "GROUP BY");
|
|
115
|
+
s = s.replace(/\bORDER\s+BY\b/g, "ORDER BY");
|
|
116
|
+
s = s.replace(/\bINSERT\s+INTO\b/g, "INSERT INTO");
|
|
117
|
+
s = s.replace(/\bDELETE\s+FROM\b/g, "DELETE FROM");
|
|
118
|
+
s = s.replace(/\bCREATE\s+TABLE\b/g, "CREATE TABLE");
|
|
119
|
+
s = s.replace(/\bALTER\s+TABLE\b/g, "ALTER TABLE");
|
|
120
|
+
s = s.replace(/\bDROP\s+TABLE\b/g, "DROP TABLE");
|
|
121
|
+
s = s.replace(/\bUNION\s+ALL\b/g, "UNION ALL");
|
|
122
|
+
for (const kw of majorKeywords) {
|
|
123
|
+
const re = new RegExp(`\\s+${kw.replace(/\s+/g, "\\s+")}\\b`, "g");
|
|
124
|
+
s = s.replace(re, `
|
|
125
|
+
${kw}`);
|
|
126
|
+
}
|
|
127
|
+
const lines = s.split("\n");
|
|
128
|
+
const result = [];
|
|
129
|
+
for (const line of lines) {
|
|
130
|
+
const trimmed = line.trim();
|
|
131
|
+
if (!trimmed) continue;
|
|
132
|
+
if (/^(AND|OR|ON)\b/.test(trimmed)) {
|
|
133
|
+
result.push(" " + trimmed);
|
|
134
|
+
} else if (/^(SELECT|FROM|WHERE|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|CROSS|GROUP|ORDER|HAVING|LIMIT|OFFSET|UNION|SET|VALUES)\b/.test(trimmed)) {
|
|
135
|
+
result.push(trimmed);
|
|
136
|
+
} else {
|
|
137
|
+
result.push(" ".repeat(1) + trimmed);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result.join("\n");
|
|
141
|
+
}
|
|
142
|
+
function format() {
|
|
143
|
+
output.value = formatSQL(input.value);
|
|
144
|
+
}
|
|
145
|
+
function loadSample() {
|
|
146
|
+
input.value = "SELECT u.id, u.name, u.email, COUNT(o.id) as order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.status = 'active' AND o.created_at > '2024-01-01' GROUP BY u.id, u.name, u.email HAVING COUNT(o.id) > 5 ORDER BY order_count DESC LIMIT 10";
|
|
147
|
+
format();
|
|
148
|
+
}
|
|
149
|
+
async function copy(text, field) {
|
|
150
|
+
await navigator.clipboard.writeText(text);
|
|
151
|
+
copyField.value = field;
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
copyField.value = "";
|
|
154
|
+
}, 1200);
|
|
155
|
+
}
|
|
156
|
+
return (_ctx, _cache) => {
|
|
157
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
158
|
+
createElementVNode("div", { class: "flex items-center justify-between" }, [
|
|
159
|
+
_cache[2] || (_cache[2] = createElementVNode(
|
|
160
|
+
"div",
|
|
161
|
+
{ class: "flex items-center gap-2" },
|
|
162
|
+
[
|
|
163
|
+
createElementVNode("span", { class: "material-icons text-primary text-lg" }, "storage"),
|
|
164
|
+
createElementVNode("span", { class: "text-sm font-bold text-gray-400 uppercase tracking-wider" }, "SQL 格式化")
|
|
165
|
+
],
|
|
166
|
+
-1
|
|
167
|
+
/* CACHED */
|
|
168
|
+
)),
|
|
169
|
+
createElementVNode("div", { class: "flex gap-2" }, [
|
|
170
|
+
createElementVNode("button", {
|
|
171
|
+
onClick: loadSample,
|
|
172
|
+
class: "h-8 px-3 bg-bg-dark text-gray-400 font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all text-xs"
|
|
173
|
+
}, " 加载示例 "),
|
|
174
|
+
createElementVNode("button", {
|
|
175
|
+
onClick: format,
|
|
176
|
+
class: "h-8 px-4 bg-primary text-black font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all text-xs"
|
|
177
|
+
}, " 格式化 ")
|
|
178
|
+
])
|
|
179
|
+
]),
|
|
180
|
+
createElementVNode("div", _hoisted_2, [
|
|
181
|
+
createElementVNode("div", _hoisted_3, [
|
|
182
|
+
_cache[3] || (_cache[3] = createElementVNode(
|
|
183
|
+
"div",
|
|
184
|
+
{ class: "px-3 py-2 border-b-2 border-black text-xs font-bold text-gray-500 uppercase" },
|
|
185
|
+
"输入 SQL",
|
|
186
|
+
-1
|
|
187
|
+
/* CACHED */
|
|
188
|
+
)),
|
|
189
|
+
withDirectives(createElementVNode(
|
|
190
|
+
"textarea",
|
|
191
|
+
{
|
|
192
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => input.value = $event),
|
|
193
|
+
onInput: format,
|
|
194
|
+
placeholder: "输入 SQL 语句...",
|
|
195
|
+
class: "flex-1 w-full bg-transparent text-gray-100 px-4 py-3 font-mono text-sm outline-none resize-none placeholder-gray-600"
|
|
196
|
+
},
|
|
197
|
+
null,
|
|
198
|
+
544
|
|
199
|
+
/* NEED_HYDRATION, NEED_PATCH */
|
|
200
|
+
), [
|
|
201
|
+
[vModelText, input.value]
|
|
202
|
+
])
|
|
203
|
+
]),
|
|
204
|
+
createElementVNode("div", _hoisted_4, [
|
|
205
|
+
createElementVNode("div", _hoisted_5, [
|
|
206
|
+
_cache[4] || (_cache[4] = createElementVNode(
|
|
207
|
+
"span",
|
|
208
|
+
{ class: "text-xs font-bold text-gray-500 uppercase" },
|
|
209
|
+
"格式化结果",
|
|
210
|
+
-1
|
|
211
|
+
/* CACHED */
|
|
212
|
+
)),
|
|
213
|
+
output.value ? (openBlock(), createElementBlock("button", {
|
|
214
|
+
key: 0,
|
|
215
|
+
onClick: _cache[1] || (_cache[1] = ($event) => copy(output.value, "output")),
|
|
216
|
+
class: "flex items-center gap-1 text-xs text-gray-500 hover:text-primary transition-colors"
|
|
217
|
+
}, [
|
|
218
|
+
createElementVNode(
|
|
219
|
+
"span",
|
|
220
|
+
_hoisted_6,
|
|
221
|
+
toDisplayString(copyField.value === "output" ? "check" : "content_copy"),
|
|
222
|
+
1
|
|
223
|
+
/* TEXT */
|
|
224
|
+
)
|
|
225
|
+
])) : createCommentVNode("v-if", true)
|
|
226
|
+
]),
|
|
227
|
+
createElementVNode(
|
|
228
|
+
"pre",
|
|
229
|
+
_hoisted_7,
|
|
230
|
+
toDisplayString(output.value),
|
|
231
|
+
1
|
|
232
|
+
/* TEXT */
|
|
233
|
+
)
|
|
234
|
+
])
|
|
235
|
+
])
|
|
236
|
+
]);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
export {
|
|
241
|
+
_sfc_main as default
|
|
242
|
+
};
|