vue-dialog-view 1.1.0 → 1.2.0
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/dist/dialog-view.es.js +8 -8
- package/dist/dialog-view.umd.js +2 -2
- package/obfuscate-classes.mjs +103 -0
- package/package.json +8 -3
- package/src/DialogView.obf.vue +8 -3
- package/src/DialogView.vue +7 -2
package/dist/dialog-view.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important;max-width:calc(100% - 2em);max-height:calc(100% - 2em)}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f[open]{display:flex;flex-direction:column}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f::backdrop{background:#00000080}.
|
|
2
|
-
import { defineComponent as v, ref as h, watch as w, nextTick as _, createElementBlock as l, openBlock as t, mergeProps as g, createCommentVNode as
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important;max-width:calc(100% - 2em);max-height:calc(100% - 2em);box-sizing:border-box;overflow:hidden}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f[open]{display:flex;flex-direction:column}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f::backdrop{background:#00000080}._f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619{display:flex;flex-direction:row;align-items:center;margin-bottom:.5em;min-height:24px;white-space:pre;overflow:hidden}._f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6{flex:1;text-align:center;font-weight:700;font-size:large;overflow:hidden;text-overflow:ellipsis}._2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c{margin-left:.5em;text-decoration:none;color:#666;font-size:1.5em;line-height:1;width:24px;height:24px;display:flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:none}._2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c:hover{color:#333;background-color:#f0f0f0;border-radius:3px}._3b2bdd19ddec80c5f0f162bc4b423dafa4f687f6f831e58742be40fb0e80838e{flex:1;overflow:auto;display:flex;flex-direction:column}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
|
|
2
|
+
import { defineComponent as v, ref as h, watch as w, nextTick as _, createElementBlock as l, openBlock as t, mergeProps as g, createCommentVNode as d, createElementVNode as n, renderSlot as f, withModifiers as B } from "vue";
|
|
3
3
|
const V = {
|
|
4
4
|
key: 0,
|
|
5
|
-
class: "
|
|
5
|
+
class: "_f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619"
|
|
6
6
|
}, C = { class: "_f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6" }, k = { class: "_3b2bdd19ddec80c5f0f162bc4b423dafa4f687f6f831e58742be40fb0e80838e" }, i = /* @__PURE__ */ v({
|
|
7
7
|
__name: "DialogView.obf",
|
|
8
8
|
props: {
|
|
@@ -14,7 +14,7 @@ const V = {
|
|
|
14
14
|
setup(o, { expose: u, emit: r }) {
|
|
15
15
|
const s = o, b = r, e = h(null), p = () => {
|
|
16
16
|
e.value && !e.value.open && e.value.showModal();
|
|
17
|
-
},
|
|
17
|
+
}, c = () => {
|
|
18
18
|
e.value && e.value.open && e.value.close();
|
|
19
19
|
}, m = () => {
|
|
20
20
|
s.modelValue && b("update:modelValue", !1);
|
|
@@ -23,7 +23,7 @@ const V = {
|
|
|
23
23
|
await _(), a ? e.value && !e.value.open && e.value.showModal() : e.value && e.value.open && e.value.close();
|
|
24
24
|
}), u({
|
|
25
25
|
open: p,
|
|
26
|
-
close:
|
|
26
|
+
close: c
|
|
27
27
|
}), (a, y) => (t(), l("dialog", g({
|
|
28
28
|
ref_key: "dialogRef",
|
|
29
29
|
ref: e,
|
|
@@ -39,9 +39,9 @@ const V = {
|
|
|
39
39
|
role: "button",
|
|
40
40
|
"aria-label": "Close the dialog",
|
|
41
41
|
class: "_2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c",
|
|
42
|
-
onClick: B(
|
|
43
|
-
}, "×")) :
|
|
44
|
-
])) :
|
|
42
|
+
onClick: B(c, ["prevent"])
|
|
43
|
+
}, "×")) : d("", !0)
|
|
44
|
+
])) : d("", !0),
|
|
45
45
|
n("div", k, [
|
|
46
46
|
f(a.$slots, "default")
|
|
47
47
|
])
|
package/dist/dialog-view.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important;max-width:calc(100% - 2em);max-height:calc(100% - 2em)}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f[open]{display:flex;flex-direction:column}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f::backdrop{background:#00000080}.
|
|
2
|
-
(function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue")):typeof define=="function"&&define.amd?define(["vue"],l):(e=typeof globalThis<"u"?globalThis:e||self,e.DialogView=l(e.Vue))})(this,(function(e){"use strict";const l={key:0,class:"
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f{padding:20px;border-radius:5px;border:1px solid gray;outline:0!important;max-width:calc(100% - 2em);max-height:calc(100% - 2em);box-sizing:border-box;overflow:hidden}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f[open]{display:flex;flex-direction:column}._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f::backdrop{background:#00000080}._f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619{display:flex;flex-direction:row;align-items:center;margin-bottom:.5em;min-height:24px;white-space:pre;overflow:hidden}._f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6{flex:1;text-align:center;font-weight:700;font-size:large;overflow:hidden;text-overflow:ellipsis}._2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c{margin-left:.5em;text-decoration:none;color:#666;font-size:1.5em;line-height:1;width:24px;height:24px;display:flex;align-items:center;justify-content:center;cursor:pointer;border:none;background:none}._2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c:hover{color:#333;background-color:#f0f0f0;border-radius:3px}._3b2bdd19ddec80c5f0f162bc4b423dafa4f687f6f831e58742be40fb0e80838e{flex:1;overflow:auto;display:flex;flex-direction:column}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
|
|
2
|
+
(function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue")):typeof define=="function"&&define.amd?define(["vue"],l):(e=typeof globalThis<"u"?globalThis:e||self,e.DialogView=l(e.Vue))})(this,(function(e){"use strict";const l={key:0,class:"_f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619"},c={class:"_f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6"},i={class:"_3b2bdd19ddec80c5f0f162bc4b423dafa4f687f6f831e58742be40fb0e80838e"},n=e.defineComponent({__name:"DialogView.obf",props:{modelValue:{type:Boolean},showTitleBar:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0}},emits:["update:modelValue"],setup(a,{expose:f,emit:r}){const s=a,u=r,o=e.ref(null),p=()=>{o.value&&!o.value.open&&o.value.showModal()},d=()=>{o.value&&o.value.open&&o.value.close()},m=()=>{s.modelValue&&u("update:modelValue",!1)};return e.watch(()=>s.modelValue,async t=>{await e.nextTick(),t?o.value&&!o.value.open&&o.value.showModal():o.value&&o.value.open&&o.value.close()}),f({open:p,close:d}),(t,b)=>(e.openBlock(),e.createElementBlock("dialog",e.mergeProps({ref_key:"dialogRef",ref:o,class:"_0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f"},t.$attrs,{onClose:m}),[a.showTitleBar?(e.openBlock(),e.createElementBlock("div",l,[e.createElementVNode("span",c,[e.renderSlot(t.$slots,"title")]),a.showCloseButton?(e.openBlock(),e.createElementBlock("a",{key:0,href:"javascript:void(0)",role:"button","aria-label":"Close the dialog",class:"_2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c",onClick:e.withModifiers(d,["prevent"])},"×")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",i,[e.renderSlot(t.$slots,"default")])],16))}});return n.install=a=>{a.component("DialogView",n)},n}));
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import crypto from 'crypto';
|
|
5
|
+
|
|
6
|
+
const SRC_DIR = path.resolve('./src');
|
|
7
|
+
const OBF_SUFFIX = '.obf.vue';
|
|
8
|
+
|
|
9
|
+
// ----------------------------
|
|
10
|
+
// 遍历 Vue 文件(跳过 .obf.vue)
|
|
11
|
+
// ----------------------------
|
|
12
|
+
function getVueFiles(dir) {
|
|
13
|
+
let files = [];
|
|
14
|
+
for (const item of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
15
|
+
const fullPath = path.join(dir, item.name);
|
|
16
|
+
if (item.isDirectory()) {
|
|
17
|
+
files = files.concat(getVueFiles(fullPath));
|
|
18
|
+
} else if (item.isFile() && item.name.endsWith('.vue') && !item.name.endsWith(OBF_SUFFIX)) {
|
|
19
|
+
files.push(fullPath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return files;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ----------------------------
|
|
26
|
+
// SHA256 混淆类名
|
|
27
|
+
// ----------------------------
|
|
28
|
+
function obfClass(name) {
|
|
29
|
+
return '_' + crypto.createHash('sha256').update(name).digest('hex')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ----------------------------
|
|
33
|
+
// 提取 template 内的 class
|
|
34
|
+
// ----------------------------
|
|
35
|
+
function extractClasses(template) {
|
|
36
|
+
const classes = new Set();
|
|
37
|
+
|
|
38
|
+
// class="..."
|
|
39
|
+
const classAttrRegex = /class\s*=\s*"([^"]+)"/g;
|
|
40
|
+
let match;
|
|
41
|
+
while ((match = classAttrRegex.exec(template)) !== null) {
|
|
42
|
+
match[1].split(/\s+/).forEach(cls => cls && classes.add(cls));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return classes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ----------------------------
|
|
49
|
+
// 替换模板和 style 中的 class
|
|
50
|
+
// ----------------------------
|
|
51
|
+
function replaceClasses(content, classMap) {
|
|
52
|
+
// 替换 class="..."
|
|
53
|
+
content = content.replace(/class\s*=\s*"([^"]+)"/g, (match, group1) => {
|
|
54
|
+
const replaced = group1.split(/\s+/).map(cls => classMap[cls] || cls).join(' ');
|
|
55
|
+
return `class="${replaced}"`;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 替换 <style> 中的类名
|
|
59
|
+
content = content.replace(/(\.)([\w-]+)/g, (match, dot, cls) => {
|
|
60
|
+
return classMap[cls] ? `.${classMap[cls]}` : match;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return content;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ----------------------------
|
|
67
|
+
// 主程序
|
|
68
|
+
// ----------------------------
|
|
69
|
+
function main() {
|
|
70
|
+
const vueFiles = getVueFiles(SRC_DIR);
|
|
71
|
+
const allClasses = new Set();
|
|
72
|
+
|
|
73
|
+
// 提取所有 template class
|
|
74
|
+
vueFiles.forEach(file => {
|
|
75
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
76
|
+
const templateMatch = content.match(/<template[^>]*>([\s\S]*?)<\/template>/);
|
|
77
|
+
if (!templateMatch) return;
|
|
78
|
+
const templateContent = templateMatch[1];
|
|
79
|
+
extractClasses(templateContent).forEach(cls => allClasses.add(cls));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// 按长度降序避免短类名覆盖长类名
|
|
83
|
+
const classList = Array.from(allClasses).sort((a, b) => b.length - a.length);
|
|
84
|
+
const classMap = {};
|
|
85
|
+
classList.forEach(cls => { classMap[cls] = obfClass(cls); });
|
|
86
|
+
|
|
87
|
+
console.log('🔹 类名混淆映射:');
|
|
88
|
+
console.table(classMap);
|
|
89
|
+
|
|
90
|
+
// 替换并生成 .obf.vue 文件
|
|
91
|
+
vueFiles.forEach(file => {
|
|
92
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
93
|
+
const replacedContent = replaceClasses(content, classMap);
|
|
94
|
+
|
|
95
|
+
const obfFile = path.join(path.dirname(file), path.basename(file, '.vue') + OBF_SUFFIX);
|
|
96
|
+
fs.writeFileSync(obfFile, replacedContent, 'utf-8');
|
|
97
|
+
console.log(`✅ ${file} -> ${obfFile}`);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log('🎉 所有文件混淆完成!');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-dialog-view",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A modern Vue 3 dialog component using native dialog element",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dialog-view.umd.js",
|
|
@@ -19,11 +19,15 @@
|
|
|
19
19
|
"README.md",
|
|
20
20
|
"tsconfig.json",
|
|
21
21
|
"vite.config.ts",
|
|
22
|
+
"obfuscate-classes.mjs",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
24
25
|
"scripts": {
|
|
25
26
|
"dev": "vite",
|
|
26
|
-
"
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"obfuscate": "node ./obfuscate-classes.mjs",
|
|
29
|
+
"build": "npm run clean && npm run obfuscate && npm run build-only",
|
|
30
|
+
"build-only": "vue-tsc --noEmit && vite build",
|
|
27
31
|
"preview": "vite preview"
|
|
28
32
|
},
|
|
29
33
|
"peerDependencies": {
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
38
|
+
"rimraf": "^6.0.1",
|
|
34
39
|
"typescript": "^5.9.3",
|
|
35
40
|
"vite": "^7.1.10",
|
|
36
41
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
@@ -51,4 +56,4 @@
|
|
|
51
56
|
"url": "https://github.com/shc0743/MyUtility/issues"
|
|
52
57
|
},
|
|
53
58
|
"homepage": "https://github.com/shc0743/MyUtility/tree/main/js/lib/vue-dialog-view#readme"
|
|
54
|
-
}
|
|
59
|
+
}
|
package/src/DialogView.obf.vue
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
@close="handleDialogClose"
|
|
7
7
|
>
|
|
8
|
-
<div v-if="showTitleBar" class="
|
|
8
|
+
<div v-if="showTitleBar" class="_f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619">
|
|
9
9
|
<span class="_f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6">
|
|
10
10
|
<slot name="title"></slot>
|
|
11
11
|
</span>
|
|
@@ -90,6 +90,8 @@ defineExpose({
|
|
|
90
90
|
outline: 0 !important;
|
|
91
91
|
max-width: calc(100% - 2em);
|
|
92
92
|
max-height: calc(100% - 2em);
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
overflow: hidden;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
._0e414b08e017324be9d8055e33e9e57a5d618fd64445845aa3d1c9c71a1cf19f[open] {
|
|
@@ -101,20 +103,23 @@ defineExpose({
|
|
|
101
103
|
background: rgba(0, 0, 0, 0.5);
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
.
|
|
106
|
+
._f1bcbda2e971453cc116bd5c6d4a303f38ac3e0618c26210b206271398b2f619 {
|
|
105
107
|
display: flex;
|
|
106
108
|
flex-direction: row;
|
|
107
109
|
align-items: center;
|
|
108
110
|
margin-bottom: 0.5em;
|
|
109
111
|
min-height: 24px;
|
|
110
112
|
white-space: pre;
|
|
113
|
+
overflow: hidden;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
._f365dae0582379d563ee03ab860c73c916d68f096a41a8bd34e05e566987b1f6 {
|
|
114
117
|
flex: 1;
|
|
115
118
|
text-align: center;
|
|
116
119
|
font-weight: bold;
|
|
117
|
-
font-size:
|
|
120
|
+
font-size: large;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
text-overflow: ellipsis;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
._2b0f1321796c8091f668958929ed738b53afcb63d79387dc52ddc75b55ffb46c {
|
package/src/DialogView.vue
CHANGED
|
@@ -82,7 +82,7 @@ defineExpose({
|
|
|
82
82
|
})
|
|
83
83
|
</script>
|
|
84
84
|
|
|
85
|
-
<style
|
|
85
|
+
<style>
|
|
86
86
|
.dialog-view {
|
|
87
87
|
padding: 20px;
|
|
88
88
|
border-radius: 5px;
|
|
@@ -90,6 +90,8 @@ defineExpose({
|
|
|
90
90
|
outline: 0 !important;
|
|
91
91
|
max-width: calc(100% - 2em);
|
|
92
92
|
max-height: calc(100% - 2em);
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
overflow: hidden;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
.dialog-view[open] {
|
|
@@ -108,13 +110,16 @@ defineExpose({
|
|
|
108
110
|
margin-bottom: 0.5em;
|
|
109
111
|
min-height: 24px;
|
|
110
112
|
white-space: pre;
|
|
113
|
+
overflow: hidden;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
.dialog-title {
|
|
114
117
|
flex: 1;
|
|
115
118
|
text-align: center;
|
|
116
119
|
font-weight: bold;
|
|
117
|
-
font-size:
|
|
120
|
+
font-size: large;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
text-overflow: ellipsis;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
.dialog-close-button {
|