@aplus-frontend/ui 7.10.6 → 7.11.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/es/index.mjs +93 -91
- package/es/src/ag-grid/editable/form-item.vue.mjs +75 -63
- package/es/src/ag-grid/editable/index.vue.mjs +80 -72
- package/es/src/ag-grid/editable/interface.d.ts +2 -1
- package/es/src/ag-grid/editable/utils.d.ts +7 -0
- package/es/src/ag-grid/editable/utils.mjs +32 -17
- package/es/src/ap-form/ap-form.vue2.mjs +144 -153
- package/es/src/ap-form/utils/transform.d.ts +6 -0
- package/es/src/ap-form/utils/transform.mjs +30 -0
- package/es/src/ap-pro-card/components/card/index.vue.d.ts +1 -1
- package/es/src/business/ap-appendix/ap-appendix.vue2.mjs +129 -93
- package/es/src/business/ap-appendix/interface.d.ts +4 -0
- package/es/src/business/ap-appendix/style/index.mjs +56 -34
- package/es/src/business/ap-attachment/ApAttachment.mjs +112 -89
- package/es/src/business/ap-attachment/style/index.mjs +21 -7
- package/es/src/business/ap-download/ap-download.vue.d.ts +1 -0
- package/es/src/business/ap-download/ap-download.vue.mjs +86 -45
- package/es/src/business/ap-download/interface.d.ts +4 -0
- package/es/src/business/ap-download/style/index.mjs +8 -4
- package/es/src/business/ap-file-preview/ap-file-preview.vue.d.ts +4 -0
- package/es/src/business/ap-file-preview/ap-file-preview.vue.mjs +4 -0
- package/es/src/business/ap-file-preview/ap-file-preview.vue2.mjs +104 -0
- package/es/src/business/ap-file-preview/components/error-result/index.vue.d.ts +6 -0
- package/es/src/business/ap-file-preview/components/error-result/index.vue.mjs +4 -0
- package/es/src/business/ap-file-preview/components/error-result/index.vue2.mjs +40 -0
- package/es/src/business/ap-file-preview/icons/not-exist-icon.vue.d.ts +3 -0
- package/es/src/business/ap-file-preview/icons/not-exist-icon.vue.mjs +20 -0
- package/es/src/business/ap-file-preview/icons/not-preview-icon.vue.d.ts +3 -0
- package/es/src/business/ap-file-preview/icons/not-preview-icon.vue.mjs +20 -0
- package/es/src/business/ap-file-preview/index.d.ts +7 -0
- package/es/src/business/ap-file-preview/index.mjs +8 -0
- package/es/src/business/ap-file-preview/interface.d.ts +45 -0
- package/es/src/business/ap-file-preview/style/index.d.ts +5 -0
- package/es/src/business/ap-file-preview/style/index.mjs +46 -0
- package/es/src/business/ap-file-preview/utils/create-file-preview-modal.d.ts +2 -0
- package/es/src/business/ap-file-preview/utils/create-file-preview-modal.mjs +18 -0
- package/es/src/business/ap-file-preview/utils/default-parser-plugin.d.ts +4 -0
- package/es/src/business/ap-file-preview/utils/default-parser-plugin.mjs +48 -0
- package/es/src/business/ap-image/ApImage.vue2.mjs +16 -16
- package/es/src/business/ap-upload/apUpload.vue.d.ts +1 -1
- package/es/src/business/ap-upload/apUploadTypes.d.ts +2 -2
- package/es/src/business/ap-upload/components/MultipleFile.vue2.mjs +94 -82
- package/es/src/business/ap-upload/style/multiple-file.mjs +6 -3
- package/es/src/business/index.d.ts +1 -0
- package/es/src/business/index.mjs +16 -14
- package/es/src/config-provider/config-provider-props.d.ts +6 -0
- package/es/src/config-provider/config-provider-props.mjs +6 -2
- package/es/src/config-provider/config-provider.d.ts +17 -1
- package/es/src/config-provider/config-provider.mjs +24 -23
- package/es/src/config-provider/hooks/use-global-config.d.ts +7 -0
- package/es/src/config-provider/index.d.ts +31 -3
- package/es/src/index.mjs +74 -72
- package/es/src/locale/lang/en.mjs +5 -0
- package/es/src/locale/lang/zh-cn.mjs +5 -0
- package/es/src/version.d.ts +1 -1
- package/es/src/version.mjs +1 -1
- package/lib/index.js +1 -1
- package/lib/src/ag-grid/editable/form-item.vue.js +1 -1
- package/lib/src/ag-grid/editable/index.vue.js +1 -1
- package/lib/src/ag-grid/editable/interface.d.ts +2 -1
- package/lib/src/ag-grid/editable/utils.d.ts +7 -0
- package/lib/src/ag-grid/editable/utils.js +1 -1
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/utils/transform.d.ts +6 -0
- package/lib/src/ap-form/utils/transform.js +1 -0
- package/lib/src/ap-pro-card/components/card/index.vue.d.ts +1 -1
- package/lib/src/business/ap-appendix/ap-appendix.vue2.js +1 -1
- package/lib/src/business/ap-appendix/interface.d.ts +4 -0
- package/lib/src/business/ap-appendix/style/index.js +1 -1
- package/lib/src/business/ap-attachment/ApAttachment.js +1 -1
- package/lib/src/business/ap-attachment/style/index.js +1 -1
- package/lib/src/business/ap-download/ap-download.vue.d.ts +1 -0
- package/lib/src/business/ap-download/ap-download.vue.js +1 -1
- package/lib/src/business/ap-download/interface.d.ts +4 -0
- package/lib/src/business/ap-download/style/index.js +1 -1
- package/lib/src/business/ap-file-preview/ap-file-preview.vue.d.ts +4 -0
- package/lib/src/business/ap-file-preview/ap-file-preview.vue.js +1 -0
- package/lib/src/business/ap-file-preview/ap-file-preview.vue2.js +1 -0
- package/lib/src/business/ap-file-preview/components/error-result/index.vue.d.ts +6 -0
- package/lib/src/business/ap-file-preview/components/error-result/index.vue.js +1 -0
- package/lib/src/business/ap-file-preview/components/error-result/index.vue2.js +1 -0
- package/lib/src/business/ap-file-preview/icons/not-exist-icon.vue.d.ts +3 -0
- package/lib/src/business/ap-file-preview/icons/not-exist-icon.vue.js +1 -0
- package/lib/src/business/ap-file-preview/icons/not-preview-icon.vue.d.ts +3 -0
- package/lib/src/business/ap-file-preview/icons/not-preview-icon.vue.js +1 -0
- package/lib/src/business/ap-file-preview/index.d.ts +7 -0
- package/lib/src/business/ap-file-preview/index.js +1 -0
- package/lib/src/business/ap-file-preview/interface.d.ts +45 -0
- package/lib/src/business/ap-file-preview/style/index.d.ts +5 -0
- package/lib/src/business/ap-file-preview/style/index.js +1 -0
- package/lib/src/business/ap-file-preview/utils/create-file-preview-modal.d.ts +2 -0
- package/lib/src/business/ap-file-preview/utils/create-file-preview-modal.js +1 -0
- package/lib/src/business/ap-file-preview/utils/default-parser-plugin.d.ts +4 -0
- package/lib/src/business/ap-file-preview/utils/default-parser-plugin.js +1 -0
- package/lib/src/business/ap-image/ApImage.vue2.js +1 -1
- package/lib/src/business/ap-upload/apUpload.vue.d.ts +1 -1
- package/lib/src/business/ap-upload/apUploadTypes.d.ts +2 -2
- package/lib/src/business/ap-upload/components/MultipleFile.vue2.js +1 -1
- package/lib/src/business/ap-upload/style/multiple-file.js +1 -1
- package/lib/src/business/index.d.ts +1 -0
- package/lib/src/business/index.js +1 -1
- package/lib/src/config-provider/config-provider-props.d.ts +6 -0
- package/lib/src/config-provider/config-provider-props.js +1 -1
- package/lib/src/config-provider/config-provider.d.ts +17 -1
- package/lib/src/config-provider/config-provider.js +1 -1
- package/lib/src/config-provider/hooks/use-global-config.d.ts +7 -0
- package/lib/src/config-provider/index.d.ts +31 -3
- package/lib/src/index.js +1 -1
- package/lib/src/locale/lang/en.js +1 -1
- package/lib/src/locale/lang/zh-cn.js +1 -1
- package/lib/src/version.d.ts +1 -1
- package/lib/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,121 +1,144 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { LoadingOutlined as
|
|
3
|
-
import { Tooltip as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { defineComponent as j, ref as g, useSlots as M, computed as i, cloneVNode as R, toRaw as w, unref as B, createVNode as e, createTextVNode as D } from "vue";
|
|
2
|
+
import { LoadingOutlined as N } from "@ant-design/icons-vue";
|
|
3
|
+
import { Tooltip as A, Popover as G } from "@aplus-frontend/antdv";
|
|
4
|
+
import { IconApAdLineDownload as H } from "@aplus-frontend/icon";
|
|
5
|
+
import { debounce as q, isArray as E } from "lodash-unified";
|
|
6
|
+
import { useToken as J } from "../../config-provider/hooks/use-token.mjs";
|
|
7
|
+
import { warning as Q } from "../../utils/warning.mjs";
|
|
7
8
|
import "../../config-provider/index.mjs";
|
|
8
|
-
import { useOssInit as
|
|
9
|
-
import { getHexWithOpacity as
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
9
|
+
import { useOssInit as X } from "../ap-download/hooks/index.mjs";
|
|
10
|
+
import { getHexWithOpacity as Y, getFileInfo as L } from "../ap-download/utils/getFileInfo.mjs";
|
|
11
|
+
import { ApFilePreview as Z } from "../ap-file-preview/index.mjs";
|
|
12
|
+
import { ApAttachmentProps as $ } from "./constans.mjs";
|
|
13
|
+
import ee from "./style/index.mjs";
|
|
14
|
+
import { useNamespace as te } from "../../config-provider/hooks/use-namespace.mjs";
|
|
13
15
|
import { useGlobalConfig as T } from "../../config-provider/hooks/use-global-config.mjs";
|
|
14
|
-
import { useLocale as
|
|
15
|
-
const
|
|
16
|
+
import { useLocale as ae } from "../../config-provider/hooks/use-locale.mjs";
|
|
17
|
+
const Ne = /* @__PURE__ */ j({
|
|
16
18
|
name: "ApAttachment",
|
|
17
|
-
props:
|
|
18
|
-
setup(
|
|
19
|
-
emit:
|
|
19
|
+
props: $(),
|
|
20
|
+
setup(t, {
|
|
21
|
+
emit: y
|
|
20
22
|
}) {
|
|
21
23
|
const {
|
|
22
|
-
b:
|
|
23
|
-
e:
|
|
24
|
-
} =
|
|
25
|
-
token:
|
|
26
|
-
} =
|
|
27
|
-
lang:
|
|
28
|
-
t:
|
|
29
|
-
} =
|
|
24
|
+
b: P,
|
|
25
|
+
e: l
|
|
26
|
+
} = te("ap-attachment"), C = ee("ap-attachment"), d = T("apUpload"), F = T("downloadCenterTriggerConfig"), {
|
|
27
|
+
token: x
|
|
28
|
+
} = J(), {
|
|
29
|
+
lang: I,
|
|
30
|
+
t: c
|
|
31
|
+
} = ae(), r = g(!1), u = g(""), f = M(), K = i(() => I.value === "zh-cn" ? "zh_CN" : "en_US"), s = i(() => t.needName ?? (d?.value?.needName === !0 ? {
|
|
30
32
|
nameKey: "fileName",
|
|
31
33
|
pathKey: "path"
|
|
32
|
-
} :
|
|
34
|
+
} : d?.value?.needName ?? {
|
|
33
35
|
nameKey: "fileName",
|
|
34
36
|
pathKey: "filePath"
|
|
35
|
-
})),
|
|
36
|
-
"--download-main-color":
|
|
37
|
-
"--download-main-color-opacity":
|
|
38
|
-
})),
|
|
39
|
-
const
|
|
40
|
-
return
|
|
37
|
+
})), p = i(() => t.attachmentList.length === 1), b = i(() => s.value ? t.attachmentList.length > 0 && s.value && s.value?.nameKey ? t.attachmentList[0][s.value.nameKey] : "" : t.attachmentList.length > 0 ? t.attachmentList[0].fileName : ""), S = i(() => p.value ? b.value : c("ap.apAttachment.downloadall")), k = i(() => ({
|
|
38
|
+
"--download-main-color": x.value?.colorLink,
|
|
39
|
+
"--download-main-color-opacity": Y(x.value?.colorLink, 0.6)
|
|
40
|
+
})), U = i(() => t.getOssAccess || d.value?.getOssAccess), V = i(() => {
|
|
41
|
+
const a = f.default ? f.default()[0] : null;
|
|
42
|
+
return a ? R(a, {
|
|
41
43
|
style: {
|
|
42
44
|
"font-size": "16px"
|
|
43
45
|
}
|
|
44
46
|
}) : null;
|
|
45
|
-
}), h =
|
|
46
|
-
if (!
|
|
47
|
-
|
|
47
|
+
}), v = g(!1), h = q(async (a, n) => {
|
|
48
|
+
if (!t.disabled) {
|
|
49
|
+
r.value = !0, n && (u.value = n);
|
|
48
50
|
try {
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
const m =
|
|
52
|
-
objectName:
|
|
53
|
-
fileName:
|
|
51
|
+
const o = E(w(a)) ? w(a) : [w(a)];
|
|
52
|
+
if (F.value?.trigger) {
|
|
53
|
+
const m = L(s.value, o).map((O) => ({
|
|
54
|
+
objectName: O.path,
|
|
55
|
+
fileName: O.fileName
|
|
54
56
|
}));
|
|
55
|
-
|
|
57
|
+
F.value?.trigger(m), y("downloadCallback", m);
|
|
56
58
|
} else {
|
|
57
|
-
const m = await (await
|
|
58
|
-
|
|
59
|
+
const m = await (await X(U.value, B(K))).downloadFile(L(s.value, o));
|
|
60
|
+
y("downloadCallback", m);
|
|
59
61
|
}
|
|
60
|
-
} catch (
|
|
61
|
-
|
|
62
|
+
} catch (o) {
|
|
63
|
+
Q(!1, o);
|
|
62
64
|
} finally {
|
|
63
|
-
|
|
65
|
+
r.value = !1, u.value = "";
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
}, 500),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}, [
|
|
68
|
+
}, 500), z = (a) => {
|
|
69
|
+
const n = L(s.value, a)?.[0];
|
|
70
|
+
Z.createFilePreviewModal({
|
|
71
|
+
src: n.path,
|
|
72
|
+
fileName: n.fileName
|
|
73
|
+
}), v.value = !1;
|
|
74
|
+
}, W = (a) => a && a.length > 0 ? e("ul", {
|
|
75
|
+
class: [l("file-list"), C.value],
|
|
76
|
+
style: k.value
|
|
77
|
+
}, [a.map((n, o) => e("li", {
|
|
78
|
+
key: o,
|
|
79
|
+
class: [l("file-item")]
|
|
80
|
+
}, [r.value && u.value === o + 1 ? e("span", {
|
|
81
|
+
class: [l("spin")]
|
|
82
|
+
}, [e(N, {
|
|
76
83
|
spin: !0
|
|
77
|
-
}, null)]) : null,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
}, null)]) : null, e(A, {
|
|
85
|
+
title: c("ap.apAppendix.previewFile")
|
|
86
|
+
}, {
|
|
87
|
+
default: () => [e("span", {
|
|
88
|
+
class: [l("file-item-text")],
|
|
89
|
+
onClick: () => z(n)
|
|
90
|
+
}, [n.fileName])]
|
|
91
|
+
}), e(A, {
|
|
92
|
+
title: c("ap.apAppendix.downloadFile")
|
|
93
|
+
}, {
|
|
94
|
+
default: () => [e("span", {
|
|
95
|
+
class: [l("file-item-download")],
|
|
96
|
+
onClick: () => h(n, o + 1)
|
|
97
|
+
}, [e(H, null, null)])]
|
|
98
|
+
})])), e("li", {
|
|
99
|
+
class: [l("download-all")],
|
|
100
|
+
onClick: () => h(t.attachmentList, "all")
|
|
101
|
+
}, [r.value && u.value === "all" ? e("span", {
|
|
102
|
+
class: [l("spin")]
|
|
103
|
+
}, [e(N, {
|
|
83
104
|
spin: !0
|
|
84
|
-
}, null)]) : null,
|
|
85
|
-
return () =>
|
|
86
|
-
class: [
|
|
87
|
-
style: [
|
|
88
|
-
}, [
|
|
89
|
-
title:
|
|
90
|
-
placement:
|
|
91
|
-
color:
|
|
105
|
+
}, null)]) : null, c("ap.apAttachment.downloadall")])]) : null;
|
|
106
|
+
return () => t.attachmentList?.length > 0 && e("div", {
|
|
107
|
+
class: [P(), C.value],
|
|
108
|
+
style: [k.value]
|
|
109
|
+
}, [e(A, {
|
|
110
|
+
title: S.value,
|
|
111
|
+
placement: t.textToolTipPlacement,
|
|
112
|
+
color: t.toolTipBgColor
|
|
92
113
|
}, {
|
|
93
|
-
default: () => [
|
|
94
|
-
class: [
|
|
95
|
-
onClick: () => h(
|
|
96
|
-
}, [
|
|
97
|
-
class: [
|
|
98
|
-
}, [
|
|
114
|
+
default: () => [e("div", {
|
|
115
|
+
class: [l("content")],
|
|
116
|
+
onClick: () => h(p.value ? t.attachmentList[0] : t.attachmentList, "global")
|
|
117
|
+
}, [r.value && u.value === "global" ? e("div", {
|
|
118
|
+
class: [l("spin")]
|
|
119
|
+
}, [e(N, {
|
|
99
120
|
spin: !0
|
|
100
|
-
}, null)]) : null, f.default ?
|
|
101
|
-
class: [
|
|
102
|
-
}, [
|
|
103
|
-
class: [
|
|
121
|
+
}, null)]) : null, f.default ? e("div", {
|
|
122
|
+
class: [l("text-render")]
|
|
123
|
+
}, [V.value, D(" ")]) : null, e("div", {
|
|
124
|
+
class: [l("text-inner")],
|
|
104
125
|
style: {
|
|
105
|
-
"max-width":
|
|
126
|
+
"max-width": t.maxWidth ? t.maxWidth + "px" : "auto"
|
|
106
127
|
}
|
|
107
|
-
}, [
|
|
108
|
-
}),
|
|
109
|
-
content:
|
|
110
|
-
placement:
|
|
111
|
-
color: "#fff"
|
|
128
|
+
}, [b.value])])]
|
|
129
|
+
}), e(G, {
|
|
130
|
+
content: W(t.attachmentList),
|
|
131
|
+
placement: t.fileMorePopoverPlacement,
|
|
132
|
+
color: "#fff",
|
|
133
|
+
open: v.value,
|
|
134
|
+
"onUpdate:open": (a) => v.value = a
|
|
112
135
|
}, {
|
|
113
|
-
default: () => [!
|
|
114
|
-
class: [
|
|
115
|
-
}, [
|
|
136
|
+
default: () => [!p.value && e("div", {
|
|
137
|
+
class: [l("more")]
|
|
138
|
+
}, [c("ap.apAttachment.more")])]
|
|
116
139
|
})]);
|
|
117
140
|
}
|
|
118
141
|
});
|
|
119
142
|
export {
|
|
120
|
-
|
|
143
|
+
Ne as default
|
|
121
144
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { genComponentStyleHook as e } from "../../../utils/cssinjs/index.mjs";
|
|
2
|
-
const
|
|
2
|
+
const a = (o) => {
|
|
3
3
|
const { componentCls: r } = o;
|
|
4
4
|
return {
|
|
5
5
|
[r]: {
|
|
@@ -59,10 +59,24 @@ const n = (o) => {
|
|
|
59
59
|
wordWrap: "break-word",
|
|
60
60
|
marginBlockEnd: o.spaceLG,
|
|
61
61
|
fontSize: o.fontSize,
|
|
62
|
-
color:
|
|
63
|
-
cursor: "pointer",
|
|
62
|
+
color: o.textColor1,
|
|
64
63
|
"&:hover": {
|
|
65
|
-
|
|
64
|
+
[`${r}__file-item-download`]: {
|
|
65
|
+
opacity: 1
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"&-text": {
|
|
69
|
+
cursor: "pointer",
|
|
70
|
+
"&:hover": {
|
|
71
|
+
color: "var(--download-main-color)"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"&-download": {
|
|
75
|
+
cursor: "pointer",
|
|
76
|
+
color: "var(--download-main-color)",
|
|
77
|
+
marginLeft: o.space,
|
|
78
|
+
opacity: 0,
|
|
79
|
+
fontSize: o.fontSizeXL
|
|
66
80
|
}
|
|
67
81
|
},
|
|
68
82
|
[`${r}__download-all`]: {
|
|
@@ -76,13 +90,13 @@ const n = (o) => {
|
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
};
|
|
79
|
-
},
|
|
93
|
+
}, n = e(
|
|
80
94
|
"ApAttachment",
|
|
81
|
-
(o) => [
|
|
95
|
+
(o) => [a(o)],
|
|
82
96
|
{
|
|
83
97
|
apAttachmentListMaxWidth: 312
|
|
84
98
|
}
|
|
85
99
|
);
|
|
86
100
|
export {
|
|
87
|
-
|
|
101
|
+
n as default
|
|
88
102
|
};
|
|
@@ -19,6 +19,7 @@ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, Comp
|
|
|
19
19
|
size: "small" | "large" | "middle";
|
|
20
20
|
type: ButtonType;
|
|
21
21
|
disabled: boolean;
|
|
22
|
+
preview: boolean;
|
|
22
23
|
needName: ApDownLoadNeedNameModel;
|
|
23
24
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
24
25
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { LoadingOutlined as
|
|
3
|
-
import { Button as
|
|
4
|
-
import {
|
|
1
|
+
import { defineComponent as I, ref as P, useSlots as T, computed as l, unref as t, createBlock as j, openBlock as n, mergeProps as V, withCtx as s, createElementVNode as C, normalizeClass as D, createElementBlock as p, createCommentVNode as m, createVNode as r, renderSlot as M, createSlots as U, toDisplayString as b, createTextVNode as E, withModifiers as G } from "vue";
|
|
2
|
+
import { LoadingOutlined as R } from "@ant-design/icons-vue";
|
|
3
|
+
import { Button as W, Tooltip as k } from "@aplus-frontend/antdv";
|
|
4
|
+
import { IconApAdLineDownload as $ } from "@aplus-frontend/icon";
|
|
5
|
+
import { isArray as q, omit as H } from "lodash-unified";
|
|
5
6
|
import "../../config-provider/index.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
7
|
+
import { ApFilePreview as J } from "../ap-file-preview/index.mjs";
|
|
8
|
+
import { useOssInit as K } from "./hooks/index.mjs";
|
|
9
|
+
import { useStyle as Q } from "./hooks/useStyle.mjs";
|
|
10
|
+
import { getFileInfo as f } from "./utils/getFileInfo.mjs";
|
|
11
|
+
import { useLocale as X } from "../../config-provider/hooks/use-locale.mjs";
|
|
12
|
+
import { useGlobalConfig as h } from "../../config-provider/hooks/use-global-config.mjs";
|
|
13
|
+
const Y = {
|
|
12
14
|
key: 0,
|
|
13
15
|
class: "spin"
|
|
14
|
-
},
|
|
16
|
+
}, Z = {
|
|
15
17
|
key: 1,
|
|
16
18
|
class: "icon"
|
|
17
|
-
},
|
|
19
|
+
}, ee = { class: "text" }, fe = /* @__PURE__ */ I({
|
|
18
20
|
name: "ApDownload",
|
|
19
21
|
__name: "ap-download",
|
|
20
22
|
props: {
|
|
@@ -41,61 +43,100 @@ const M = {
|
|
|
41
43
|
text: {},
|
|
42
44
|
fileName: {},
|
|
43
45
|
needName: { type: [Boolean, Object], default: void 0 },
|
|
44
|
-
getOssAccess: {}
|
|
46
|
+
getOssAccess: {},
|
|
47
|
+
preview: { type: Boolean, default: !1 }
|
|
45
48
|
},
|
|
46
49
|
emits: ["downloadCallback"],
|
|
47
|
-
setup(
|
|
48
|
-
const
|
|
50
|
+
setup(_, { emit: A }) {
|
|
51
|
+
const u = A, c = P(!1), { lang: B, t: g } = X(), O = T(), z = l(() => B.value === "zh-cn" ? "zh_CN" : "en_US"), e = _, i = h("apUpload"), v = h(
|
|
49
52
|
"downloadCenterTriggerConfig"
|
|
50
|
-
),
|
|
53
|
+
), w = l(() => e.disabled), x = l(() => e.size), d = l(
|
|
54
|
+
() => e.preview && (q(e.fileName) ? e.fileName.length === 1 : !0)
|
|
55
|
+
), { getInnerWrapperClass: F } = Q(x, w), L = l(() => e.getOssAccess || i.value?.getOssAccess), S = () => {
|
|
56
|
+
const o = f(
|
|
57
|
+
e.needName ?? i?.value?.needName,
|
|
58
|
+
e.fileName
|
|
59
|
+
)?.[0];
|
|
60
|
+
J.createFilePreviewModal({
|
|
61
|
+
src: o.path,
|
|
62
|
+
fileName: o.fileName
|
|
63
|
+
});
|
|
64
|
+
}, N = async () => {
|
|
51
65
|
if (!e.disabled) {
|
|
52
|
-
|
|
66
|
+
c.value = !0;
|
|
53
67
|
try {
|
|
54
|
-
if (
|
|
55
|
-
let a =
|
|
56
|
-
e.needName ??
|
|
68
|
+
if (v.value?.trigger) {
|
|
69
|
+
let a = f(
|
|
70
|
+
e.needName ?? i?.value?.needName,
|
|
57
71
|
e.fileName
|
|
58
|
-
).map((
|
|
59
|
-
objectName:
|
|
60
|
-
fileName:
|
|
72
|
+
).map((y) => ({
|
|
73
|
+
objectName: y.path,
|
|
74
|
+
fileName: y.fileName
|
|
61
75
|
}));
|
|
62
|
-
await
|
|
76
|
+
await v.value?.trigger(a), u("downloadCallback", a);
|
|
63
77
|
} else {
|
|
64
|
-
const a = await (await
|
|
65
|
-
|
|
66
|
-
t(
|
|
78
|
+
const a = await (await K(
|
|
79
|
+
L.value,
|
|
80
|
+
t(z)
|
|
67
81
|
)).downloadFile(
|
|
68
|
-
|
|
69
|
-
e.needName ??
|
|
82
|
+
f(
|
|
83
|
+
e.needName ?? i?.value?.needName,
|
|
70
84
|
e.fileName
|
|
71
85
|
)
|
|
72
86
|
);
|
|
73
|
-
|
|
87
|
+
u("downloadCallback", a);
|
|
74
88
|
}
|
|
75
89
|
} catch (o) {
|
|
76
90
|
console.error(o);
|
|
77
91
|
} finally {
|
|
78
|
-
|
|
92
|
+
c.value = !1;
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
};
|
|
82
|
-
return (o, a) => (
|
|
96
|
+
return (o, a) => (n(), j(t(W), V(t(H)(e, ["getOssAccess", "fileName", "needName"]), {
|
|
83
97
|
type: e.type,
|
|
84
98
|
size: e.size,
|
|
85
|
-
disabled:
|
|
86
|
-
onClick:
|
|
99
|
+
disabled: w.value,
|
|
100
|
+
onClick: a[0] || (a[0] = () => (d.value ? S : N)())
|
|
87
101
|
}), {
|
|
88
|
-
default:
|
|
89
|
-
|
|
90
|
-
class:
|
|
102
|
+
default: s(() => [
|
|
103
|
+
C("div", {
|
|
104
|
+
class: D(t(F))
|
|
91
105
|
}, [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
])) :
|
|
95
|
-
t(
|
|
96
|
-
|
|
97
|
-
])) :
|
|
98
|
-
|
|
106
|
+
c.value ? (n(), p("span", Y, [
|
|
107
|
+
r(t(R), { spin: !0 })
|
|
108
|
+
])) : m("", !0),
|
|
109
|
+
t(O).icon ? (n(), p("span", Z, [
|
|
110
|
+
M(o.$slots, "icon")
|
|
111
|
+
])) : m("", !0),
|
|
112
|
+
r(t(k), null, U({
|
|
113
|
+
default: s(() => [
|
|
114
|
+
C("span", ee, b(o.text), 1)
|
|
115
|
+
]),
|
|
116
|
+
_: 2
|
|
117
|
+
}, [
|
|
118
|
+
d.value ? {
|
|
119
|
+
name: "title",
|
|
120
|
+
fn: s(() => [
|
|
121
|
+
E(b(t(g)("ap.apAppendix.previewFile")), 1)
|
|
122
|
+
]),
|
|
123
|
+
key: "0"
|
|
124
|
+
} : void 0
|
|
125
|
+
]), 1024),
|
|
126
|
+
d.value ? (n(), p("span", {
|
|
127
|
+
key: 2,
|
|
128
|
+
class: "preview-icon",
|
|
129
|
+
onClick: G(N, ["stop"])
|
|
130
|
+
}, [
|
|
131
|
+
r(t(k), {
|
|
132
|
+
title: t(g)("ap.apAppendix.downloadFile")
|
|
133
|
+
}, {
|
|
134
|
+
default: s(() => [
|
|
135
|
+
r(t($))
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
}, 8, ["title"])
|
|
139
|
+
])) : m("", !0)
|
|
99
140
|
], 2)
|
|
100
141
|
]),
|
|
101
142
|
_: 3
|
|
@@ -103,5 +144,5 @@ const M = {
|
|
|
103
144
|
}
|
|
104
145
|
});
|
|
105
146
|
export {
|
|
106
|
-
|
|
147
|
+
fe as default
|
|
107
148
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { genComponentStyleHook as l } from "../../../utils/cssinjs/index.mjs";
|
|
2
2
|
const r = (o) => {
|
|
3
|
-
const { componentCls: e, textColor3:
|
|
3
|
+
const { componentCls: e, textColor3: i } = o, n = `${e}-inner-wrapper`;
|
|
4
4
|
return {
|
|
5
5
|
[e]: {
|
|
6
6
|
"&-wrapper": {
|
|
@@ -8,7 +8,7 @@ const r = (o) => {
|
|
|
8
8
|
display: "inline-block"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
|
-
[
|
|
11
|
+
[n]: {
|
|
12
12
|
display: "flex",
|
|
13
13
|
color: "var(--download-main-color)",
|
|
14
14
|
cursor: "pointer",
|
|
@@ -24,6 +24,10 @@ const r = (o) => {
|
|
|
24
24
|
".text": {
|
|
25
25
|
color: "var(--download-main-color)"
|
|
26
26
|
},
|
|
27
|
+
".preview-icon": {
|
|
28
|
+
fontSize: o.fontSizeXL,
|
|
29
|
+
marginLeft: o.space
|
|
30
|
+
},
|
|
27
31
|
"&:hover": {
|
|
28
32
|
color: "var(--download-main-color-opacity)"
|
|
29
33
|
},
|
|
@@ -40,10 +44,10 @@ const r = (o) => {
|
|
|
40
44
|
fontSize: o.fontSizeSM
|
|
41
45
|
},
|
|
42
46
|
"&--disabled": {
|
|
43
|
-
color:
|
|
47
|
+
color: i,
|
|
44
48
|
cursor: "not-allowed",
|
|
45
49
|
"&:hover": {
|
|
46
|
-
color:
|
|
50
|
+
color: i
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
53
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ApFilePreviewProps } from './interface';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
declare const _default: DefineComponent<ApFilePreviewProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApFilePreviewProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { defineComponent as E, ref as w, computed as c, watch as L, createElementBlock as m, openBlock as r, normalizeClass as C, unref as l, createBlock as i, Fragment as p, createCommentVNode as x, resolveDynamicComponent as B, h as R } from "vue";
|
|
2
|
+
import { Spin as W } from "@aplus-frontend/antdv";
|
|
3
|
+
import { createOssInstance as I } from "@aplus-frontend/oss";
|
|
4
|
+
import "../../config-provider/index.mjs";
|
|
5
|
+
import "./components/error-result/index.vue.mjs";
|
|
6
|
+
import $ from "./style/index.mjs";
|
|
7
|
+
import { defaultParserPlugins as j } from "./utils/default-parser-plugin.mjs";
|
|
8
|
+
import { useGlobalConfig as _ } from "../../config-provider/hooks/use-global-config.mjs";
|
|
9
|
+
import { useNamespace as D } from "../../config-provider/hooks/use-namespace.mjs";
|
|
10
|
+
import { useLocale as G } from "../../config-provider/hooks/use-locale.mjs";
|
|
11
|
+
import b from "./components/error-result/index.vue2.mjs";
|
|
12
|
+
const ee = /* @__PURE__ */ E({
|
|
13
|
+
__name: "ap-file-preview",
|
|
14
|
+
props: {
|
|
15
|
+
src: {},
|
|
16
|
+
fileName: {},
|
|
17
|
+
format: {},
|
|
18
|
+
parserPlugin: {},
|
|
19
|
+
getOssAccess: { type: Function }
|
|
20
|
+
},
|
|
21
|
+
setup(k) {
|
|
22
|
+
const e = k, P = _("apUpload"), N = _("apFilePreview"), { b: f } = D("ap-file-preview"), O = $("ap-file-preview"), { lang: S } = G(), U = {
|
|
23
|
+
"zh-cn": "zh_CN",
|
|
24
|
+
en: "en_US"
|
|
25
|
+
}, t = w(), o = w(!1), v = c(
|
|
26
|
+
() => e.getOssAccess || P.value?.getOssAccess
|
|
27
|
+
), s = c(() => e?.format ?? e?.src?.split(".").pop()), A = c(() => [
|
|
28
|
+
...j,
|
|
29
|
+
...N.value?.parserPlugin ?? [],
|
|
30
|
+
...e?.parserPlugin ?? []
|
|
31
|
+
]), g = c(() => s.value ? A.value?.findLast(
|
|
32
|
+
(a) => s.value && a.format.includes(s.value)
|
|
33
|
+
) : void 0), F = async () => {
|
|
34
|
+
try {
|
|
35
|
+
if (o.value = !0, t.value = void 0, !e?.src)
|
|
36
|
+
return;
|
|
37
|
+
if (e.src?.startsWith("http") || e.src?.startsWith("data:") || e.src?.startsWith("blob:")) {
|
|
38
|
+
t.value = e.src;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const a = e.src?.match(/^([^:]+):(.*)$/), u = a?.[1], h = a?.[2] ?? e.src, d = I();
|
|
42
|
+
await d.initOssClient({
|
|
43
|
+
getOssAccess: () => u ? v.value?.(u) : v.value?.(),
|
|
44
|
+
locale: U[S.value] ?? "zh_CN",
|
|
45
|
+
onFailure: (n) => {
|
|
46
|
+
throw new Error(
|
|
47
|
+
typeof n?.message == "string" ? n.message : "oss create error"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const y = await d.getSignatureUrl(
|
|
52
|
+
h,
|
|
53
|
+
3600,
|
|
54
|
+
e?.fileName ?? h
|
|
55
|
+
);
|
|
56
|
+
if (y) {
|
|
57
|
+
const n = await fetch(y).then((z) => z.blob());
|
|
58
|
+
t.value = URL.createObjectURL(n);
|
|
59
|
+
} else
|
|
60
|
+
throw new Error("oss getSignatureUrl error");
|
|
61
|
+
} finally {
|
|
62
|
+
o.value = !1;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return L(
|
|
66
|
+
() => [e.src],
|
|
67
|
+
() => {
|
|
68
|
+
F();
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
immediate: !0
|
|
72
|
+
}
|
|
73
|
+
), (a, u) => (r(), m("div", {
|
|
74
|
+
class: C([l(f)(), l(O)])
|
|
75
|
+
}, [
|
|
76
|
+
o.value ? (r(), i(l(W), {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: C([l(f)("spin")])
|
|
79
|
+
}, null, 8, ["class"])) : !o.value && t.value && e.src ? (r(), m(p, { key: 1 }, [
|
|
80
|
+
g.value && s.value ? (r(), m(p, { key: 0 }, [
|
|
81
|
+
t.value ? (r(), i(B(
|
|
82
|
+
R(p, [
|
|
83
|
+
g.value?.parser?.({
|
|
84
|
+
src: t.value,
|
|
85
|
+
originalSrc: e.src,
|
|
86
|
+
format: s.value,
|
|
87
|
+
fileName: e.fileName
|
|
88
|
+
})
|
|
89
|
+
])
|
|
90
|
+
), { key: 0 })) : x("", !0)
|
|
91
|
+
], 64)) : (r(), i(b, {
|
|
92
|
+
key: 1,
|
|
93
|
+
type: "notPreview"
|
|
94
|
+
}))
|
|
95
|
+
], 64)) : (r(), i(b, {
|
|
96
|
+
key: 2,
|
|
97
|
+
type: "notExist"
|
|
98
|
+
}))
|
|
99
|
+
], 2));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
export {
|
|
103
|
+
ee as default
|
|
104
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
type?: 'notExist' | 'notPreview';
|
|
4
|
+
};
|
|
5
|
+
declare const _default: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
6
|
+
export default _default;
|