@pubinfo-nightly/module-crypto 2025.12.9 → 2025.12.25

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.
@@ -1,4 +1,4 @@
1
- import { RequestInstance } from 'pubinfo-nightly';
1
+ import type { RequestInstance } from 'pubinfo-nightly';
2
2
  export interface CryptoOptions {
3
3
  /**
4
4
  * 接口请求实例
@@ -0,0 +1,216 @@
1
+ import { n as getCryptoGetCryptoConfig, r as postCryptoEditCryptoConfig, t as ctx } from "./index.js";
2
+ import { n as useToggle, t as drawerCryptoUrl_default } from "./drawerCryptoUrl-CKgf1Uxz.js";
3
+ import { PubinfoIcon, useAuth } from "pubinfo-nightly";
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, E) => {
22
+ let D = e.__vccOpts || e;
23
+ for (let [e, O] of E) D[e] = O;
24
+ return D;
25
+ })(/* @__PURE__ */ defineComponent({
26
+ __name: "setting",
27
+ setup(M) {
28
+ let R = ref(), z = ref(), B = ref(), V = { style: { width: "auto" } }, H = { span: 24 }, { auth: U } = useAuth(), W = reactive({
29
+ isCrypto: !0,
30
+ mode: !0,
31
+ whiteListUrls: []
32
+ }), [G, K] = useToggle(!1);
33
+ onMounted(q);
34
+ async function q() {
35
+ await getCryptoGetCryptoConfig().then((e) => {
36
+ K(!1), e && e.data && e.success && (W.isCrypto = e.data.cryptoEnabled || !1, W.whiteListUrls = e.data.cryptoWhitePath, W.mode = e.data.cryptoMode === void 0 ? !0 : e.data.cryptoMode);
37
+ });
38
+ }
39
+ function J(e, E) {
40
+ E && (W.mode = e, Y());
41
+ }
42
+ async function Y() {
43
+ if (!G.value) {
44
+ K(!0);
45
+ try {
46
+ await z.value?.validate();
47
+ let { isCrypto: e, mode: O, whiteListUrls: k } = W, A = {
48
+ cryptoEnabled: e,
49
+ cryptoMode: O,
50
+ cryptoWhitePath: k
51
+ }, { success: j } = await postCryptoEditCryptoConfig({ json: JSON.stringify(A) });
52
+ j && (message.success("配置更改成功"), ctx.callAsync({
53
+ ...ctx.use(),
54
+ isCrypto: W.isCrypto,
55
+ cryptoMode: W.mode,
56
+ whiteListUrls: W.whiteListUrls
57
+ }, () => {
58
+ q();
59
+ }));
60
+ } catch {
61
+ K(!1);
62
+ }
63
+ }
64
+ }
65
+ let X = [
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 !U([
87
+ "crypto_url_add",
88
+ "crypto_url_edit",
89
+ "crypto_url_delete"
90
+ ]);
91
+ }
92
+ }
93
+ ];
94
+ function Z(e, E) {
95
+ if (!G.value) switch (e) {
96
+ case ACTION.ADD:
97
+ B.value.open(!1, W.whiteListUrls);
98
+ break;
99
+ case ACTION.EDIT:
100
+ B.value.open(!0, W.whiteListUrls, E);
101
+ break;
102
+ case ACTION.REMOVE:
103
+ Q(W.whiteListUrls || [], E || 0);
104
+ break;
105
+ }
106
+ }
107
+ function Q(e, E) {
108
+ Modal.confirm({
109
+ title: "删除",
110
+ content: "确定要删除该条数据吗?",
111
+ async onOk() {
112
+ e.splice(E, 1), $(e);
113
+ }
114
+ });
115
+ }
116
+ function $(e) {
117
+ W.whiteListUrls = e, Y();
118
+ }
119
+ return (e, E) => {
120
+ let D = Switch, O = FormItem, j = CheckableTag, M = Form, N = PlusCircleOutlined, P = Button, F = PubinfoIcon, I = Space, L = resolveDirective("auth");
121
+ return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("div", _hoisted_3, [createVNode(M, {
122
+ ref_key: "formRef",
123
+ ref: z,
124
+ model: W,
125
+ "label-col": V,
126
+ "wrapper-col": H,
127
+ class: "safe-rule-form"
128
+ }, {
129
+ default: withCtx(() => [createVNode(O, {
130
+ label: "开启加密",
131
+ name: "isCrypto"
132
+ }, {
133
+ default: withCtx(() => [createVNode(D, {
134
+ checked: W.isCrypto,
135
+ "onUpdate:checked": E[0] ||= (e) => W.isCrypto = e,
136
+ disabled: unref(G),
137
+ onChange: Y
138
+ }, null, 8, ["checked", "disabled"])]),
139
+ _: 1
140
+ }), createVNode(O, {
141
+ label: "模式",
142
+ name: "isCrypto"
143
+ }, {
144
+ default: withCtx(() => [createElementVNode("div", _hoisted_4, [createElementVNode("div", _hoisted_5, [createVNode(j, {
145
+ checked: W.mode,
146
+ disabled: unref(G),
147
+ class: normalizeClass(unref(G) ? "cursor-not-allowed!" : ""),
148
+ onChange: E[1] ||= (e) => !unref(G) && J(!0, e)
149
+ }, {
150
+ default: withCtx(() => [...E[4] ||= [createTextVNode(" 白名单 ", -1)]]),
151
+ _: 1
152
+ }, 8, [
153
+ "checked",
154
+ "disabled",
155
+ "class"
156
+ ]), createVNode(j, {
157
+ checked: !W.mode,
158
+ class: normalizeClass(["mr-0px!", unref(G) ? "cursor-not-allowed!" : ""]),
159
+ onChange: E[2] ||= (e) => !unref(G) && J(!1, e)
160
+ }, {
161
+ default: withCtx(() => [...E[5] ||= [createTextVNode(" 黑名单 ", -1)]]),
162
+ _: 1
163
+ }, 8, ["checked", "class"])]), createElementVNode("div", _hoisted_6, [createVNode(unref(QuestionCircleOutlined), { class: "mr-5px" }), E[6] ||= createTextVNode("白名单模式下,仅不加密过滤列表中的接口;黑名单模式下,仅加密过滤列表中的接口。 ", -1)])])]),
164
+ _: 1
165
+ })]),
166
+ _: 1
167
+ }, 8, ["model"])]), createElementVNode("div", _hoisted_7, [createVNode(unref(ProTable), {
168
+ ref_key: "tableRef",
169
+ ref: R,
170
+ "row-key": "id",
171
+ "data-source": W.whiteListUrls,
172
+ columns: X,
173
+ "auto-height": "",
174
+ search: !1,
175
+ pagination: !1,
176
+ scroll: { x: 1e3 }
177
+ }, {
178
+ toolbar: withCtx(() => [withDirectives((openBlock(), createBlock(P, {
179
+ type: "primary",
180
+ disabled: unref(G),
181
+ onClick: E[3] ||= (e) => Z(unref(ACTION).ADD)
182
+ }, {
183
+ default: withCtx(() => [createVNode(N), createTextVNode(" " + toDisplayString(unref(ACTION).ADD), 1)]),
184
+ _: 1
185
+ }, 8, ["disabled"])), [[L, "crypto_url_add"]])]),
186
+ bodyCell: withCtx(({ column: e, index: E }) => [e.dataIndex === "action" ? (openBlock(), createBlock(I, { key: 0 }, {
187
+ default: withCtx(() => [withDirectives((openBlock(), createElementBlock("a", {
188
+ class: "flex items-center hover:opacity-80",
189
+ onClick: (e) => Z(unref(ACTION).EDIT, E)
190
+ }, [createVNode(F, {
191
+ name: "edit",
192
+ class: "text-base"
193
+ }), createElementVNode("span", _hoisted_9, toDisplayString(unref(ACTION).EDIT), 1)], 8, _hoisted_8)), [[L, "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) => Z(unref(ACTION).REMOVE, E)
201
+ }, [createVNode(F, {
202
+ name: "remove",
203
+ class: "text-base"
204
+ }), createElementVNode("span", _hoisted_11, toDisplayString(unref(ACTION).REMOVE), 1)], 8, _hoisted_10)), [[L, "crypto_url_delete"]])]),
205
+ _: 2
206
+ }, 1024)) : createCommentVNode("", !0)]),
207
+ _: 1
208
+ }, 8, ["data-source"])])]), createVNode(drawerCryptoUrl_default, {
209
+ ref_key: "drawerRef",
210
+ ref: B,
211
+ onSubmit: $
212
+ }, null, 512)]);
213
+ };
214
+ }
215
+ }), [["__scopeId", "data-v-89197708"]]);
216
+ export { setting_default as default };
package/dist/setting.css CHANGED
@@ -1 +1 @@
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{background:#fff;color:#1677ff;font-size:13px}.safe-rule-form[data-v-89197708] .ant-tag-checkable{font-size:13px}
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}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo-nightly/module-crypto",
3
3
  "type": "module",
4
- "version": "2025.12.09",
4
+ "version": "2025.12.25",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -23,10 +23,10 @@
23
23
  "@ant-design/icons-vue": "^7.0.1",
24
24
  "@pubinfo/pro-components": "^1.8.0",
25
25
  "ant-design-vue": "^4.2.6",
26
- "pubinfo-nightly": "2025.12.09"
26
+ "pubinfo-nightly": "2025.12.25"
27
27
  },
28
28
  "dependencies": {
29
- "@vueuse/core": "^13.7.0",
29
+ "@vueuse/core": "^14.1.0",
30
30
  "crypto-js": "^4.2.0",
31
31
  "gm-crypto": "^0.1.12",
32
32
  "jsencrypt": "^3.3.2"
@@ -36,7 +36,7 @@
36
36
  "@pubinfo/pro-components": "^1.8.0",
37
37
  "@types/crypto-js": "^4.2.2",
38
38
  "ant-design-vue": "^4.2.6",
39
- "pubinfo-nightly": "2025.12.09"
39
+ "pubinfo-nightly": "2025.12.25"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "pubinfo build -w --sourcemap",
@@ -48,7 +48,7 @@ async function encryptMethod(method: RequestMethod, fun: (arg0: string) => Promi
48
48
  }
49
49
  if (method.config.meta && method.config.meta.pathParams) {
50
50
  for (const item of method.config.meta.pathParams) {
51
- method.url = method.url.replace(item, await fun(item));
51
+ method.url = method.url.replace(item, await fun(`${item}`));
52
52
  }
53
53
  }
54
54
  }
package/src/index.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import type { ModuleOptions, RequestMethod } from 'pubinfo-nightly';
2
2
  import type { CryptoOptions } from './interface';
3
- import { defineIconModule, defineRouteModule } from 'pubinfo-nightly';
4
- import modules from 'virtual:pubinfo-resolver';
5
3
  import { getCryptoGetPublicKeyAndConfig } from './api/modules/crypto';
6
4
  import { apictx } from './apiContext';
7
5
  import { ctx } from './context';
@@ -14,9 +12,6 @@ export function crypto(options: CryptoOptions): ModuleOptions {
14
12
  const { request, cryptoSetting } = options;
15
13
  apictx.set({ request });
16
14
  ctx.set({ isCrypto: false, cryptoMode: false, cryptoSetting: setupAes() });
17
- defineRouteModule('crypto', modules.pages);
18
- defineIconModule('crypto', modules.icons);
19
-
20
15
  return {
21
16
  name: 'pubinfo-nightly:crypto',
22
17
  enforce: 'pre',
@@ -1,4 +0,0 @@
1
- import { _ as f } from "./drawerCryptoUrl.vue_vue_type_script_setup_true_lang-CztdWly1.js";
2
- export {
3
- f as default
4
- };
@@ -1,136 +0,0 @@
1
- import { Drawer as L, Form as N, FormItem as O, Input as W, Textarea as $, Space as q, Button as A } from "ant-design-vue/es";
2
- import { isRef as I, shallowRef as j, toValue as h, defineComponent as z, ref as f, createBlock as H, openBlock as J, unref as u, withCtx as l, createVNode as r, createTextVNode as k } from "vue";
3
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
4
- // @__NO_SIDE_EFFECTS__
5
- function U(c = !1, d = {}) {
6
- const {
7
- truthyValue: _ = !0,
8
- falsyValue: v = !1
9
- } = d, g = I(c), o = j(c);
10
- function i(p) {
11
- if (arguments.length)
12
- return o.value = p, o.value;
13
- {
14
- const t = h(_);
15
- return o.value = o.value === t ? h(v) : t, o.value;
16
- }
17
- }
18
- return g ? i : [o, i];
19
- }
20
- const P = /* @__PURE__ */ z({
21
- name: "DrawerCryptoUrl",
22
- __name: "drawerCryptoUrl",
23
- emits: ["submit"],
24
- setup(c, { expose: d, emit: _ }) {
25
- const v = _, g = {
26
- url: [{ required: !0, validator: S, trigger: ["blur", "change"] }]
27
- }, [o, i] = /* @__PURE__ */ U(!1), p = f(), t = f({}), w = f(!1), m = f([]), x = f(0);
28
- function S(a, e, n) {
29
- e ? /^\/(?!.*\*{3})(?:[\w-]+|:\w+|\*{1,2})(?:\/(?:[\w-]+|:\w+|\*{1,2}))*$/.test(e) ? n() : n(new Error("url格式不正确")) : n(new Error("请输入url"));
30
- }
31
- async function T(a, e, n) {
32
- i(!0), m.value = e || [], x.value = n || 0, a ? (w.value = !0, t.value = { ...e?.[n || 0] }) : (w.value = !1, t.value = {});
33
- }
34
- const [V, C] = /* @__PURE__ */ U(!1);
35
- function B() {
36
- p.value?.validate().then(() => {
37
- C(!0);
38
- const a = {
39
- ...t.value
40
- };
41
- w.value ? m.value[x.value] = a : m.value.push(a), C(!1), y(), v("submit", m.value);
42
- });
43
- }
44
- function y() {
45
- i(!1);
46
- }
47
- return d({
48
- open: T
49
- }), (a, e) => {
50
- const n = W, b = O, E = $, D = N, R = A, F = q, G = L;
51
- return J(), H(G, {
52
- open: u(o),
53
- "onUpdate:open": e[3] || (e[3] = (s) => I(o) ? o.value = s : null),
54
- title: "url信息",
55
- placement: "right",
56
- width: 600,
57
- "destroy-on-close": "",
58
- "footer-style": { textAlign: "right" },
59
- onClose: y
60
- }, {
61
- footer: l(() => [
62
- r(F, null, {
63
- default: l(() => [
64
- r(R, { onClick: y }, {
65
- default: l(() => e[4] || (e[4] = [
66
- k(" 取消 ")
67
- ])),
68
- _: 1,
69
- __: [4]
70
- }),
71
- r(R, {
72
- type: "primary",
73
- loading: u(V),
74
- onClick: e[2] || (e[2] = (s) => B())
75
- }, {
76
- default: l(() => e[5] || (e[5] = [
77
- k(" 提交 ")
78
- ])),
79
- _: 1,
80
- __: [5]
81
- }, 8, ["loading"])
82
- ]),
83
- _: 1
84
- })
85
- ]),
86
- default: l(() => [
87
- r(D, {
88
- ref_key: "formRef",
89
- ref: p,
90
- model: u(t),
91
- rules: g,
92
- "label-col": { style: { width: "90px" } }
93
- }, {
94
- default: l(() => [
95
- r(b, {
96
- label: "url地址",
97
- name: "url",
98
- tooltip: "支持url通配符,示例:/api/v1/user/*,/api/login/**"
99
- }, {
100
- default: l(() => [
101
- r(n, {
102
- value: u(t).url,
103
- "onUpdate:value": e[0] || (e[0] = (s) => u(t).url = s),
104
- maxlength: 200
105
- }, null, 8, ["value"])
106
- ]),
107
- _: 1
108
- }),
109
- r(b, {
110
- label: "描述",
111
- name: "description"
112
- }, {
113
- default: l(() => [
114
- r(E, {
115
- value: u(t).description,
116
- "onUpdate:value": e[1] || (e[1] = (s) => u(t).description = s),
117
- rows: 3,
118
- "show-count": "",
119
- maxlength: 200
120
- }, null, 8, ["value"])
121
- ]),
122
- _: 1
123
- })
124
- ]),
125
- _: 1
126
- }, 8, ["model"])
127
- ]),
128
- _: 1
129
- }, 8, ["open"]);
130
- };
131
- }
132
- });
133
- export {
134
- P as _,
135
- U as u
136
- };