@pubinfo/module-crypto 2.1.10 → 2.1.12

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.
@@ -0,0 +1,10 @@
1
+ declare function onOpen(edit: boolean, list: API.UrlEntry[], index?: number): Promise<void>;
2
+ declare const __VLS_export: import("vue").DefineComponent<{}, {
3
+ open: typeof onOpen;
4
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ submit: (...args: any[]) => void;
6
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
7
+ onSubmit?: ((...args: any[]) => any) | undefined;
8
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/module-crypto",
3
3
  "type": "module",
4
- "version": "2.1.10",
4
+ "version": "2.1.12",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "@ant-design/icons-vue": "^7.0.1",
24
24
  "@pubinfo/pro-components": "^1.8.2",
25
25
  "ant-design-vue": "^4.2.6",
26
- "pubinfo": "2.1.10"
26
+ "pubinfo": "2.1.12"
27
27
  },
28
28
  "dependencies": {
29
29
  "@vueuse/core": "^14.2.1",
@@ -36,7 +36,7 @@
36
36
  "@pubinfo/pro-components": "^1.8.2",
37
37
  "@types/crypto-js": "^4.2.2",
38
38
  "ant-design-vue": "^4.2.6",
39
- "pubinfo": "2.1.10"
39
+ "pubinfo": "2.1.12"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "pubinfo build -w --sourcemap",
package/src/index.ts CHANGED
@@ -58,3 +58,4 @@ export { setupAes } from './cryptoAlg/aes.ts';
58
58
  export { setupSm4Cbc } from './cryptoAlg/sm4-cbc.ts';
59
59
  export { setupSm4Ecb } from './cryptoAlg/sm4-ecb.ts';
60
60
  export * from './interface';
61
+ export { default as CryptoSettingPage } from './pages/setting.vue';
@@ -1,107 +0,0 @@
1
- import { i as __exportAll } from "./index.js";
2
- import { Button, Drawer, Form, FormItem, Input, Space, Textarea } from "ant-design-vue/es";
3
- import { createBlock, createTextVNode, createVNode, defineComponent, isRef, onMounted, openBlock, reactive, ref, shallowRef, toValue, unref, withCtx } from "vue";
4
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
5
- function useToggle(e = !1, t = {}) {
6
- let { truthyValue: n = !0, falsyValue: r = !1 } = t, i = isRef(e), a = shallowRef(e);
7
- function o(e) {
8
- if (arguments.length) return a.value = e, a.value;
9
- {
10
- let e = toValue(n);
11
- return a.value = a.value === e ? toValue(r) : e, a.value;
12
- }
13
- }
14
- return i ? o : [a, o];
15
- }
16
- var drawerCryptoUrl_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
17
- name: "DrawerCryptoUrl",
18
- __name: "drawerCryptoUrl",
19
- emits: ["submit"],
20
- setup(e, { expose: s, emit: c }) {
21
- let l = c, d = { url: [{
22
- required: !0,
23
- validator: b,
24
- trigger: ["blur", "change"]
25
- }] }, [f, m] = useToggle(!1), h = ref(), g = ref({}), _ = ref(!1), v = ref([]), y = ref(0);
26
- function b(e, t, n) {
27
- t ? /^\/(?!.*\*{3})(?:[\w-]+|:\w+|\*{1,2})(?:\/(?:[\w-]+|:\w+|\*{1,2}))*$/.test(t) ? n() : n(/* @__PURE__ */ Error("url格式不正确")) : n(/* @__PURE__ */ Error("请输入url"));
28
- }
29
- async function x(e, t, n) {
30
- m(!0), v.value = t || [], y.value = n || 0, e ? (_.value = !0, g.value = { ...t?.[n || 0] }) : (_.value = !1, g.value = {});
31
- }
32
- let [S, C] = useToggle(!1);
33
- function w() {
34
- h.value?.validate().then(() => {
35
- C(!0);
36
- let e = { ...g.value };
37
- _.value ? v.value[y.value] = e : v.value.push(e), C(!1), T(), l("submit", v.value);
38
- });
39
- }
40
- function T() {
41
- m(!1);
42
- }
43
- return s({ open: x }), (e, s) => {
44
- let c = Input, l = FormItem, u = Textarea, p = Form, m = Button, _ = Space, v = Drawer;
45
- return openBlock(), createBlock(v, {
46
- open: unref(f),
47
- "onUpdate:open": s[3] ||= (e) => isRef(f) ? f.value = e : null,
48
- title: "url信息",
49
- placement: "right",
50
- width: 600,
51
- "destroy-on-close": "",
52
- "footer-style": { textAlign: "right" },
53
- onClose: T
54
- }, {
55
- footer: withCtx(() => [createVNode(_, null, {
56
- default: withCtx(() => [createVNode(m, { onClick: T }, {
57
- default: withCtx(() => [...s[4] ||= [createTextVNode(" 取消 ", -1)]]),
58
- _: 1
59
- }), createVNode(m, {
60
- type: "primary",
61
- loading: unref(S),
62
- onClick: s[2] ||= (e) => w()
63
- }, {
64
- default: withCtx(() => [...s[5] ||= [createTextVNode(" 提交 ", -1)]]),
65
- _: 1
66
- }, 8, ["loading"])]),
67
- _: 1
68
- })]),
69
- default: withCtx(() => [createVNode(p, {
70
- ref_key: "formRef",
71
- ref: h,
72
- model: unref(g),
73
- rules: d,
74
- "label-col": { style: { width: "90px" } }
75
- }, {
76
- default: withCtx(() => [createVNode(l, {
77
- label: "url地址",
78
- name: "url",
79
- tooltip: "支持url通配符,示例:/api/v1/user/*,/api/login/**"
80
- }, {
81
- default: withCtx(() => [createVNode(c, {
82
- value: unref(g).url,
83
- "onUpdate:value": s[0] ||= (e) => unref(g).url = e,
84
- maxlength: 200
85
- }, null, 8, ["value"])]),
86
- _: 1
87
- }), createVNode(l, {
88
- label: "描述",
89
- name: "description"
90
- }, {
91
- default: withCtx(() => [createVNode(u, {
92
- value: unref(g).description,
93
- "onUpdate:value": s[1] ||= (e) => unref(g).description = e,
94
- rows: 3,
95
- "show-count": "",
96
- maxlength: 200
97
- }, null, 8, ["value"])]),
98
- _: 1
99
- })]),
100
- _: 1
101
- }, 8, ["model"])]),
102
- _: 1
103
- }, 8, ["open"]);
104
- };
105
- }
106
- }), drawerCryptoUrl_exports = /* @__PURE__ */ __exportAll({ default: () => drawerCryptoUrl_default }), drawerCryptoUrl_default = drawerCryptoUrl_vue_vue_type_script_setup_true_lang_default;
107
- export { drawerCryptoUrl_exports as n, useToggle as r, drawerCryptoUrl_default as t };
@@ -1,216 +0,0 @@
1
- import { n as getCryptoGetCryptoConfig, r as postCryptoEditCryptoConfig, t as ctx } from "./index.js";
2
- import { r as useToggle, t as drawerCryptoUrl_default } from "./drawerCryptoUrl-I-5m5_57.js";
3
- import { PubinfoIcon, useAuth } from "pubinfo";
4
- import { Button, CheckableTag, Form, FormItem, Space, Switch } from "ant-design-vue/es";
5
- import { createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, onMounted, openBlock, reactive, ref, resolveDirective, toDisplayString, unref, withCtx, withDirectives } from "vue";
6
- import { PlusCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons-vue";
7
- import { ProTable } from "@pubinfo/pro-components";
8
- import { Modal, message } from "ant-design-vue";
9
- import './setting.css';let ACTION = /* @__PURE__ */ function(e) {
10
- return e.ADD = "新增", e.EDIT = "编辑", e.REMOVE = "删除", e.ENABLE = "启用", e.DISABLE = "停用", e;
11
- }({});
12
- var _hoisted_1 = {
13
- "w-full": "",
14
- "h-full": "",
15
- "pt-10px": "",
16
- "px-10px": "",
17
- "overflow-auto": ""
18
- }, _hoisted_2 = {
19
- "h-full": "",
20
- "min-w-1130px": ""
21
- }, _hoisted_3 = { class: "pt-20px pl-20px h-161px flex flex-col bg-[#ffffff] box-border bg-[url('@/assets/images/crypto-setting-bg.png')] bg-cover text-[#4e5969] dark:text-[#C9CDD4]" }, _hoisted_4 = { class: "flex items-center" }, _hoisted_5 = { class: "p-5px bg-[#f2f3f5] rounded-5px flex items-center" }, _hoisted_6 = { class: "flex items-center ml-15px text-[#a3a4a8]" }, _hoisted_7 = { class: "h-[calc(100%-165px)]" }, _hoisted_8 = ["onClick"], _hoisted_9 = { class: "ml-4px" }, _hoisted_10 = ["onClick"], _hoisted_11 = { class: "ml-4px" }, setting_default = /* @__PURE__ */ ((e, t) => {
22
- let n = e.__vccOpts || e;
23
- for (let [e, r] of t) n[e] = r;
24
- return n;
25
- })(/* @__PURE__ */ defineComponent({
26
- __name: "setting",
27
- setup(s) {
28
- let p = ref(), m = ref(), h = ref(), g = { style: { width: "auto" } }, _ = { span: 24 }, { auth: v } = useAuth(), y = reactive({
29
- isCrypto: !0,
30
- mode: !0,
31
- whiteListUrls: []
32
- }), [b, x] = useToggle(!1);
33
- onMounted(S);
34
- async function S() {
35
- await getCryptoGetCryptoConfig().then((e) => {
36
- x(!1), e && e.data && e.success && (y.isCrypto = e.data.cryptoEnabled || !1, y.whiteListUrls = e.data.cryptoWhitePath, y.mode = e.data.cryptoMode === void 0 ? !0 : e.data.cryptoMode);
37
- });
38
- }
39
- function C(e, t) {
40
- t && (y.mode = e, w());
41
- }
42
- async function w() {
43
- if (!b.value) {
44
- x(!0);
45
- try {
46
- await m.value?.validate();
47
- let { isCrypto: e, mode: r, whiteListUrls: i } = y, a = {
48
- cryptoEnabled: e,
49
- cryptoMode: r,
50
- cryptoWhitePath: i
51
- }, { success: o } = await postCryptoEditCryptoConfig({ json: JSON.stringify(a) });
52
- o && (message.success("配置更改成功"), ctx.callAsync({
53
- ...ctx.use(),
54
- isCrypto: y.isCrypto,
55
- cryptoMode: y.mode,
56
- whiteListUrls: y.whiteListUrls
57
- }, () => {
58
- S();
59
- }));
60
- } catch {
61
- x(!1);
62
- }
63
- }
64
- }
65
- let T = [
66
- {
67
- minWidth: 60,
68
- hideInTable: !1,
69
- title: "url地址",
70
- dataIndex: "url"
71
- },
72
- {
73
- hideInSearch: !0,
74
- minWidth: 200,
75
- title: "描述",
76
- dataIndex: "description",
77
- ellipsis: !0
78
- },
79
- {
80
- hideInSearch: !0,
81
- title: "操作",
82
- dataIndex: "action",
83
- width: 200,
84
- fixed: "right",
85
- hideInTable() {
86
- return !v([
87
- "crypto_url_add",
88
- "crypto_url_edit",
89
- "crypto_url_delete"
90
- ]);
91
- }
92
- }
93
- ];
94
- function E(e, t) {
95
- if (!b.value) switch (e) {
96
- case ACTION.ADD:
97
- h.value.open(!1, y.whiteListUrls);
98
- break;
99
- case ACTION.EDIT:
100
- h.value.open(!0, y.whiteListUrls, t);
101
- break;
102
- case ACTION.REMOVE:
103
- D(y.whiteListUrls || [], t || 0);
104
- break;
105
- }
106
- }
107
- function D(e, t) {
108
- Modal.confirm({
109
- title: "删除",
110
- content: "确定要删除该条数据吗?",
111
- async onOk() {
112
- e.splice(t, 1), O(e);
113
- }
114
- });
115
- }
116
- function O(e) {
117
- y.whiteListUrls = e, w();
118
- }
119
- return (e, t) => {
120
- let n = Switch, r = FormItem, o = CheckableTag, s = Form, c = PlusCircleOutlined, l = Button, u = PubinfoIcon, d = Space, f = resolveDirective("auth");
121
- return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [createVNode(s, {
122
- ref_key: "formRef",
123
- ref: m,
124
- model: y,
125
- "label-col": g,
126
- "wrapper-col": _,
127
- class: "safe-rule-form"
128
- }, {
129
- default: withCtx(() => [createVNode(r, {
130
- label: "开启加密",
131
- name: "isCrypto"
132
- }, {
133
- default: withCtx(() => [createVNode(n, {
134
- checked: y.isCrypto,
135
- "onUpdate:checked": t[0] ||= (e) => y.isCrypto = e,
136
- disabled: unref(b),
137
- onChange: w
138
- }, null, 8, ["checked", "disabled"])]),
139
- _: 1
140
- }), createVNode(r, {
141
- label: "模式",
142
- name: "isCrypto"
143
- }, {
144
- default: withCtx(() => [createElementVNode("div", _hoisted_4, [createElementVNode("div", _hoisted_5, [createVNode(o, {
145
- checked: y.mode,
146
- disabled: unref(b),
147
- class: normalizeClass(unref(b) ? "cursor-not-allowed!" : ""),
148
- onChange: t[1] ||= (e) => !unref(b) && C(!0, e)
149
- }, {
150
- default: withCtx(() => [...t[4] ||= [createTextVNode(" 白名单 ", -1)]]),
151
- _: 1
152
- }, 8, [
153
- "checked",
154
- "disabled",
155
- "class"
156
- ]), createVNode(o, {
157
- checked: !y.mode,
158
- class: normalizeClass(["mr-0px!", unref(b) ? "cursor-not-allowed!" : ""]),
159
- onChange: t[2] ||= (e) => !unref(b) && C(!1, e)
160
- }, {
161
- default: withCtx(() => [...t[5] ||= [createTextVNode(" 黑名单 ", -1)]]),
162
- _: 1
163
- }, 8, ["checked", "class"])]), createElementVNode("div", _hoisted_6, [createVNode(unref(QuestionCircleOutlined), { class: "mr-5px" }), t[6] ||= createTextVNode("白名单模式下,仅不加密过滤列表中的接口;黑名单模式下,仅加密过滤列表中的接口。 ", -1)])])]),
164
- _: 1
165
- })]),
166
- _: 1
167
- }, 8, ["model"])]), createElementVNode("div", _hoisted_7, [createVNode(unref(ProTable), {
168
- ref_key: "tableRef",
169
- ref: p,
170
- "row-key": "id",
171
- "data-source": y.whiteListUrls,
172
- columns: T,
173
- "auto-height": "",
174
- search: !1,
175
- pagination: !1,
176
- scroll: { x: 1e3 }
177
- }, {
178
- toolbar: withCtx(() => [withDirectives((openBlock(), createBlock(l, {
179
- type: "primary",
180
- disabled: unref(b),
181
- onClick: t[3] ||= (e) => E(unref(ACTION).ADD)
182
- }, {
183
- default: withCtx(() => [createVNode(c), createTextVNode(" " + toDisplayString(unref(ACTION).ADD), 1)]),
184
- _: 1
185
- }, 8, ["disabled"])), [[f, "crypto_url_add"]])]),
186
- bodyCell: withCtx(({ column: e, index: t }) => [e.dataIndex === "action" ? (openBlock(), createBlock(d, { key: 0 }, {
187
- default: withCtx(() => [withDirectives((openBlock(), createElementBlock("a", {
188
- class: "flex items-center hover:opacity-80",
189
- onClick: (e) => E(unref(ACTION).EDIT, t)
190
- }, [createVNode(u, {
191
- name: "edit",
192
- class: "text-base"
193
- }), createElementVNode("span", _hoisted_9, toDisplayString(unref(ACTION).EDIT), 1)], 8, _hoisted_8)), [[f, "crypto_url_edit"]]), withDirectives((openBlock(), createElementBlock("span", {
194
- flex: "",
195
- "items-center": "",
196
- "text-red-500": "",
197
- "hover:cursor-pointer": "",
198
- "hover:text-red-500": "",
199
- "hover:opacity-80": "",
200
- onClick: (e) => E(unref(ACTION).REMOVE, t)
201
- }, [createVNode(u, {
202
- name: "remove",
203
- class: "text-base"
204
- }), createElementVNode("span", _hoisted_11, toDisplayString(unref(ACTION).REMOVE), 1)], 8, _hoisted_10)), [[f, "crypto_url_delete"]])]),
205
- _: 2
206
- }, 1024)) : createCommentVNode("", !0)]),
207
- _: 1
208
- }, 8, ["data-source"])])]), createVNode(drawerCryptoUrl_default, {
209
- ref_key: "drawerRef",
210
- ref: h,
211
- onSubmit: O
212
- }, null, 512)]);
213
- };
214
- }
215
- }), [["__scopeId", "data-v-89197708"]]);
216
- export { setting_default as default };
package/dist/setting.css DELETED
@@ -1 +0,0 @@
1
- .safe-rule-form .ant-input[data-v-89197708],.safe-rule-form .ant-select[data-v-89197708]{width:90%}.safe-rule-form[data-v-89197708] .ant-tag-checkable-checked{color:#1677ff;background:#fff;font-size:13px}.safe-rule-form[data-v-89197708] .ant-tag-checkable{font-size:13px}