@aplus-frontend/ui 7.10.3 → 7.10.4
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/src/business/ap-download/ap-download.vue.d.ts +2 -1
- package/es/src/business/ap-download/ap-download.vue.mjs +10 -10
- package/es/src/business/ap-image/ApImage.vue2.mjs +49 -46
- package/es/src/business/ap-image/hooks/useOss.d.ts +1 -1
- package/es/src/business/ap-image/hooks/useOss.mjs +30 -28
- package/es/src/business/ap-image/interface.d.ts +1 -1
- package/es/src/business/ap-upload/apUpload.vue.d.ts +1 -1
- package/es/src/config-provider/constants.d.ts +2 -2
- package/es/src/version.d.ts +1 -1
- package/es/src/version.mjs +1 -1
- package/lib/src/business/ap-download/ap-download.vue.d.ts +2 -1
- package/lib/src/business/ap-download/ap-download.vue.js +1 -1
- package/lib/src/business/ap-image/ApImage.vue2.js +1 -1
- package/lib/src/business/ap-image/hooks/useOss.d.ts +1 -1
- package/lib/src/business/ap-image/hooks/useOss.js +1 -1
- package/lib/src/business/ap-image/interface.d.ts +1 -1
- package/lib/src/business/ap-upload/apUpload.vue.d.ts +1 -1
- package/lib/src/config-provider/constants.d.ts +2 -2
- package/lib/src/version.d.ts +1 -1
- package/lib/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApDownLoadProps, downloadCallbackResponse } from './interface';
|
|
1
|
+
import { ApDownLoadProps, downloadCallbackResponse, ApDownLoadNeedNameModel } from './interface';
|
|
2
2
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
3
|
import { ButtonType } from '@aplus-frontend/antdv/es/button';
|
|
4
4
|
type __VLS_Props = ApDownLoadProps;
|
|
@@ -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
|
+
needName: ApDownLoadNeedNameModel;
|
|
22
23
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
23
24
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
24
25
|
export default _default;
|
|
@@ -40,20 +40,20 @@ const M = {
|
|
|
40
40
|
variant: {},
|
|
41
41
|
text: {},
|
|
42
42
|
fileName: {},
|
|
43
|
-
needName: { type: [Boolean, Object] },
|
|
43
|
+
needName: { type: [Boolean, Object], default: void 0 },
|
|
44
44
|
getOssAccess: {}
|
|
45
45
|
},
|
|
46
46
|
emits: ["downloadCallback"],
|
|
47
47
|
setup(C, { emit: N }) {
|
|
48
|
-
const r = N,
|
|
48
|
+
const r = N, l = z(!1), { lang: b } = G(), v = A(), w = s(() => b.value === "zh-cn" ? "zh_CN" : "en_US"), e = C, n = y("apUpload"), c = y(
|
|
49
49
|
"downloadCenterTriggerConfig"
|
|
50
|
-
), d = s(() => e.disabled),
|
|
50
|
+
), d = s(() => e.disabled), h = s(() => e.size), { getInnerWrapperClass: _ } = P(h, d), k = s(() => e.getOssAccess || n.value?.getOssAccess), B = async () => {
|
|
51
51
|
if (!e.disabled) {
|
|
52
|
-
|
|
52
|
+
l.value = !0;
|
|
53
53
|
try {
|
|
54
54
|
if (c.value?.trigger) {
|
|
55
55
|
let a = g(
|
|
56
|
-
e.needName ??
|
|
56
|
+
e.needName ?? n?.value?.needName,
|
|
57
57
|
e.fileName
|
|
58
58
|
).map((p) => ({
|
|
59
59
|
objectName: p.path,
|
|
@@ -63,10 +63,10 @@ const M = {
|
|
|
63
63
|
} else {
|
|
64
64
|
const a = await (await E(
|
|
65
65
|
k.value,
|
|
66
|
-
t(
|
|
66
|
+
t(w)
|
|
67
67
|
)).downloadFile(
|
|
68
68
|
g(
|
|
69
|
-
e.needName ??
|
|
69
|
+
e.needName ?? n?.value?.needName,
|
|
70
70
|
e.fileName
|
|
71
71
|
)
|
|
72
72
|
);
|
|
@@ -75,7 +75,7 @@ const M = {
|
|
|
75
75
|
} catch (o) {
|
|
76
76
|
console.error(o);
|
|
77
77
|
} finally {
|
|
78
|
-
|
|
78
|
+
l.value = !1;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
};
|
|
@@ -89,10 +89,10 @@ const M = {
|
|
|
89
89
|
m("div", {
|
|
90
90
|
class: j(t(_))
|
|
91
91
|
}, [
|
|
92
|
-
|
|
92
|
+
l.value ? (i(), f("span", M, [
|
|
93
93
|
I(t(U), { spin: !0 })
|
|
94
94
|
])) : u("", !0),
|
|
95
|
-
t(
|
|
95
|
+
t(v).icon ? (i(), f("span", R, [
|
|
96
96
|
F(o.$slots, "icon")
|
|
97
97
|
])) : u("", !0),
|
|
98
98
|
m("span", W, T(o.text), 1)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { DownloadOutlined as
|
|
3
|
-
import { Image as
|
|
4
|
-
import { omit as
|
|
1
|
+
import { defineComponent as S, computed as n, ref as j, watchEffect as B, createBlock as h, openBlock as i, unref as o, mergeProps as v, withCtx as E, renderSlot as F, normalizeProps as L, guardReactiveProps as U, createElementVNode as b, normalizeClass as W, createElementBlock as x, Fragment as D, renderList as P, resolveDynamicComponent as R, createVNode as T } from "vue";
|
|
2
|
+
import { DownloadOutlined as z } from "@ant-design/icons-vue";
|
|
3
|
+
import { Image as V } from "@aplus-frontend/antdv";
|
|
4
|
+
import { omit as $ } from "lodash-unified";
|
|
5
5
|
import "../../config-provider/index.mjs";
|
|
6
|
-
import { injectLocaleToOss as
|
|
6
|
+
import { injectLocaleToOss as G, getOssInstance as q, getSignatureUrl as H } from "./hooks/useOss.mjs";
|
|
7
7
|
import J from "./imgs/admin-fallback.jpg.mjs";
|
|
8
8
|
import K from "./imgs/user-fallback.jpg.mjs";
|
|
9
9
|
import Q from "./style/index.mjs";
|
|
10
10
|
import { useNamespace as X } from "../../config-provider/hooks/use-namespace.mjs";
|
|
11
|
-
import { useGlobalConfig as
|
|
11
|
+
import { useGlobalConfig as m } from "../../config-provider/hooks/use-global-config.mjs";
|
|
12
12
|
import { useLocale as Y } from "../../config-provider/hooks/use-locale.mjs";
|
|
13
|
-
const ue = /* @__PURE__ */
|
|
13
|
+
const ue = /* @__PURE__ */ S({
|
|
14
14
|
__name: "ApImage",
|
|
15
15
|
props: {
|
|
16
16
|
getOssAccess: {},
|
|
@@ -23,78 +23,81 @@ const ue = /* @__PURE__ */ M({
|
|
|
23
23
|
uiMode: {},
|
|
24
24
|
preview: { type: [Boolean, Object], default: !0 }
|
|
25
25
|
},
|
|
26
|
-
setup(
|
|
27
|
-
const { b:
|
|
26
|
+
setup(k) {
|
|
27
|
+
const { b: u } = X("ap-image"), p = Q("ap-image"), e = k, d = {
|
|
28
28
|
aplus: K,
|
|
29
29
|
admin: J
|
|
30
|
-
},
|
|
30
|
+
}, w = m("apImage", { uiMode: "aplus" }), C = m("apUpload"), f = m(
|
|
31
31
|
"downloadCenterTriggerConfig"
|
|
32
|
-
),
|
|
33
|
-
() => e.uiMode ||
|
|
34
|
-
), { t:
|
|
35
|
-
() => e.getOssAccess ||
|
|
36
|
-
),
|
|
37
|
-
() =>
|
|
38
|
-
),
|
|
39
|
-
|
|
32
|
+
), O = n(
|
|
33
|
+
() => e.uiMode || w.value?.uiMode
|
|
34
|
+
), { t: y, lang: A } = Y(), g = n(
|
|
35
|
+
() => e.getOssAccess || C.value?.getOssAccess
|
|
36
|
+
), N = n(
|
|
37
|
+
() => d[O.value] || d.aplus
|
|
38
|
+
), I = n(() => e?.fallback || N.value), s = j("");
|
|
39
|
+
G(y, A), B(async () => {
|
|
40
40
|
if (!e?.src) {
|
|
41
41
|
s.value = "";
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
44
|
+
if (e.src?.startsWith("http") || e.src?.startsWith("data:")) {
|
|
45
45
|
s.value = e.src;
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const a = e.src?.match(/^([^:]+):(.*)$/), r = a?.[1], t = a?.[2] ?? e.src, l = await q(
|
|
50
|
+
() => r ? g.value?.(r) : g.value?.(),
|
|
51
|
+
r
|
|
52
|
+
), c = await H({
|
|
53
|
+
oss: l,
|
|
54
|
+
fileName: t
|
|
52
55
|
});
|
|
53
|
-
|
|
56
|
+
c && (s.value = c);
|
|
54
57
|
} catch {
|
|
55
58
|
s.value = "";
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
|
-
async function
|
|
61
|
+
async function _() {
|
|
59
62
|
if (!e?.src)
|
|
60
63
|
return;
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
+
const a = e.src, r = e.fileName ?? e.src;
|
|
65
|
+
if (e.src?.startsWith("http") || e.src?.startsWith("data:")) {
|
|
66
|
+
M(a, r);
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
|
-
if (
|
|
67
|
-
let
|
|
69
|
+
if (f.value?.trigger) {
|
|
70
|
+
let t = [
|
|
68
71
|
{
|
|
69
|
-
objectName:
|
|
72
|
+
objectName: a,
|
|
70
73
|
fileName: r
|
|
71
74
|
}
|
|
72
75
|
];
|
|
73
|
-
await
|
|
76
|
+
await f.value?.trigger(t);
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
+
const M = (a, r) => {
|
|
80
|
+
const t = document.createElement("a");
|
|
81
|
+
t.href = a, t.rel = "noopener noreferrer", t.setAttribute("download", r), document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
79
82
|
};
|
|
80
|
-
return (
|
|
81
|
-
class: [
|
|
83
|
+
return (a, r) => (i(), h(o(V), v({
|
|
84
|
+
class: [o(u)(), o(p)]
|
|
82
85
|
}, {
|
|
83
|
-
...
|
|
84
|
-
fallback:
|
|
86
|
+
...o($)(e, ["src", "getOssAccess"]),
|
|
87
|
+
fallback: I.value,
|
|
85
88
|
src: s.value
|
|
86
89
|
}), {
|
|
87
|
-
toolbarRender:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class:
|
|
90
|
+
toolbarRender: E((t) => [
|
|
91
|
+
F(a.$slots, "toolbarRender", L(U({ ...t })), () => [
|
|
92
|
+
b("div", {
|
|
93
|
+
class: W([o(u)("toolbar"), o(p)])
|
|
91
94
|
}, [
|
|
92
|
-
(
|
|
93
|
-
|
|
95
|
+
(i(!0), x(D, null, P(t.originalNodes, (l, c) => (i(), h(R(l), v({ ref_for: !0 }, e, { key: c }), null, 16))), 128)),
|
|
96
|
+
b("div", {
|
|
94
97
|
class: "ant-image-preview-operations-operation",
|
|
95
|
-
onClick:
|
|
98
|
+
onClick: _
|
|
96
99
|
}, [
|
|
97
|
-
|
|
100
|
+
T(o(z))
|
|
98
101
|
])
|
|
99
102
|
], 2)
|
|
100
103
|
])
|
|
@@ -3,7 +3,7 @@ import { Ref } from 'vue';
|
|
|
3
3
|
import { Translator } from '../../../config-provider';
|
|
4
4
|
type GetOssAccess = () => Promise<accessCreate>;
|
|
5
5
|
export declare function injectLocaleToOss(tValue: Translator, langValue: Ref<string>): void;
|
|
6
|
-
export declare function getOssInstance(getOssAccess?: GetOssAccess): Promise<Oss>;
|
|
6
|
+
export declare function getOssInstance(getOssAccess?: GetOssAccess, bucket?: string): Promise<Oss>;
|
|
7
7
|
export declare function getSignatureUrl({ oss, fileName }: {
|
|
8
8
|
oss: Oss;
|
|
9
9
|
fileName: string;
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { createOssInstance as
|
|
2
|
-
const
|
|
3
|
-
let n,
|
|
4
|
-
function
|
|
5
|
-
n =
|
|
1
|
+
import { createOssInstance as u } from "@aplus-frontend/oss";
|
|
2
|
+
const g = 1e4;
|
|
3
|
+
let n, i;
|
|
4
|
+
function _(t, s) {
|
|
5
|
+
n = t, i = s;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const f = {
|
|
8
8
|
"zh-cn": "zh_CN",
|
|
9
9
|
en: "en_US"
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function m() {
|
|
12
|
+
return f[i.value] ?? "zh_CN";
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
async function
|
|
16
|
-
if (!
|
|
14
|
+
const c = /* @__PURE__ */ new Map();
|
|
15
|
+
async function w(t, s) {
|
|
16
|
+
if (!t)
|
|
17
17
|
throw new Error(`${n("ap.apUpload.pleasePass")}getOssAccess`);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const a = s || "ap_image_default_bucket";
|
|
19
|
+
let e = c.get(a);
|
|
20
|
+
return e?.createDate && e.createDate < Date.now() + g && e?.oss || (e = {
|
|
21
|
+
oss: new Promise((l, p) => {
|
|
22
|
+
const o = u();
|
|
23
|
+
o.initOssClient({
|
|
24
|
+
getOssAccess: t,
|
|
25
|
+
locale: m(),
|
|
26
|
+
onFailure: (r) => {
|
|
27
|
+
p(
|
|
28
|
+
typeof r?.message == "string" ? r.message : n("ap.apUpload.FailedToObtainOssTemporaryPermissions")
|
|
27
29
|
);
|
|
28
30
|
}
|
|
29
31
|
}).then(() => {
|
|
30
|
-
|
|
32
|
+
l(o);
|
|
31
33
|
});
|
|
32
34
|
}),
|
|
33
35
|
createDate: Date.now()
|
|
34
|
-
}),
|
|
36
|
+
}, c.set(a, e)), e.oss;
|
|
35
37
|
}
|
|
36
|
-
function
|
|
37
|
-
oss:
|
|
38
|
+
function U({
|
|
39
|
+
oss: t,
|
|
38
40
|
fileName: s
|
|
39
41
|
}) {
|
|
40
|
-
return
|
|
42
|
+
return t.getSignatureUrl(s);
|
|
41
43
|
}
|
|
42
44
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
w as getOssInstance,
|
|
46
|
+
U as getSignatureUrl,
|
|
47
|
+
_ as injectLocaleToOss
|
|
46
48
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { accessCreate } from '@aplus-frontend/oss';
|
|
2
2
|
import { UiModeType } from '../../config-provider';
|
|
3
3
|
export interface ApImageProps {
|
|
4
|
-
getOssAccess?: () => Promise<accessCreate>;
|
|
4
|
+
getOssAccess?: (bucket?: string) => Promise<accessCreate>;
|
|
5
5
|
width?: number | string;
|
|
6
6
|
height?: number | string;
|
|
7
7
|
alt?: string;
|
|
@@ -181,8 +181,8 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
|
|
|
181
181
|
value: string | unknown[] | Record<string, any>;
|
|
182
182
|
maxCount: number;
|
|
183
183
|
maxSize: number;
|
|
184
|
-
getOssAccess: GetOssAccess;
|
|
185
184
|
needName: boolean | Record<string, any>;
|
|
185
|
+
getOssAccess: GetOssAccess;
|
|
186
186
|
accept: string;
|
|
187
187
|
beforeUpload: BeforeUpload;
|
|
188
188
|
onRemove: Function;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultOptionType } from '@aplus-frontend/antdv/es/select';
|
|
2
|
-
import {
|
|
2
|
+
import { accessCreate } from '@aplus-frontend/oss';
|
|
3
3
|
import { InjectionKey, Ref, VNode } from 'vue';
|
|
4
4
|
import { Recordable } from '../type';
|
|
5
5
|
import { ConfigProviderProps } from './config-provider-props';
|
|
@@ -18,7 +18,7 @@ export type ApiType = {
|
|
|
18
18
|
};
|
|
19
19
|
export type ApUploadConfig = {
|
|
20
20
|
dirName?: string;
|
|
21
|
-
getOssAccess?:
|
|
21
|
+
getOssAccess?: (bucket?: string) => Promise<accessCreate>;
|
|
22
22
|
needName?: boolean | {
|
|
23
23
|
pathKey?: string;
|
|
24
24
|
nameKey?: string;
|
package/es/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.10.
|
|
1
|
+
declare const _default: "7.10.4";
|
|
2
2
|
export default _default;
|
package/es/src/version.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApDownLoadProps, downloadCallbackResponse } from './interface';
|
|
1
|
+
import { ApDownLoadProps, downloadCallbackResponse, ApDownLoadNeedNameModel } from './interface';
|
|
2
2
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
3
|
import { ButtonType } from '@aplus-frontend/antdv/es/button';
|
|
4
4
|
type __VLS_Props = ApDownLoadProps;
|
|
@@ -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
|
+
needName: ApDownLoadNeedNameModel;
|
|
22
23
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
23
24
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
24
25
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),k=require("@ant-design/icons-vue"),_=require("@aplus-frontend/antdv"),h=require("lodash-unified");require("../../config-provider/index.js");const w=require("./hooks/index.js"),B=require("./hooks/useStyle.js"),d=require("./utils/getFileInfo.js"),O=require("../../config-provider/hooks/use-locale.js"),u=require("../../config-provider/hooks/use-global-config.js"),q={key:0,class:"spin"},z={key:1,class:"icon"},S={class:"text"},I=e.defineComponent({name:"ApDownload",__name:"ap-download",props:{prefixCls:{},type:{default:"link"},htmlType:{},shape:{},size:{default:"middle"},loading:{type:[Boolean,Object]},disabled:{type:Boolean,default:!1},ghost:{type:Boolean},block:{type:Boolean},danger:{type:Boolean},icon:{},href:{},target:{},title:{},onClick:{},onMousedown:{},autoInsertSpace:{type:Boolean},iconPosition:{},color:{},variant:{},text:{},fileName:{},needName:{type:[Boolean,Object]},getOssAccess:{}},emits:["downloadCallback"],setup(p,{emit:f}){const l=f,s=e.ref(!1),{lang:m}=O.useLocale(),g=e.useSlots(),C=e.computed(()=>m.value==="zh-cn"?"zh_CN":"en_US"),t=p,a=u.useGlobalConfig("apUpload"),i=u.useGlobalConfig("downloadCenterTriggerConfig"),c=e.computed(()=>t.disabled),y=e.computed(()=>t.size),{getInnerWrapperClass:b}=B.useStyle(y,c),N=e.computed(()=>t.getOssAccess||a.value?.getOssAccess),v=async()=>{if(!t.disabled){s.value=!0;try{if(i.value?.trigger){let n=d.getFileInfo(t.needName??a?.value?.needName,t.fileName).map(r=>({objectName:r.path,fileName:r.fileName}));await i.value?.trigger(n),l("downloadCallback",n)}else{const n=await(await w.useOssInit(N.value,e.unref(C))).downloadFile(d.getFileInfo(t.needName??a?.value?.needName,t.fileName));l("downloadCallback",n)}}catch(o){console.error(o)}finally{s.value=!1}}};return(o,n)=>(e.openBlock(),e.createBlock(e.unref(_.Button),e.mergeProps(e.unref(h.omit)(t,["getOssAccess","fileName","needName"]),{type:t.type,size:t.size,disabled:c.value,onClick:v}),{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(b))},[s.value?(e.openBlock(),e.createElementBlock("span",q,[e.createVNode(e.unref(k.LoadingOutlined),{spin:!0})])):e.createCommentVNode("",!0),e.unref(g).icon?(e.openBlock(),e.createElementBlock("span",z,[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.createElementVNode("span",S,e.toDisplayString(o.text),1)],2)]),_:3},16,["type","size","disabled"]))}});exports.default=I;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),k=require("@ant-design/icons-vue"),_=require("@aplus-frontend/antdv"),h=require("lodash-unified");require("../../config-provider/index.js");const w=require("./hooks/index.js"),B=require("./hooks/useStyle.js"),d=require("./utils/getFileInfo.js"),O=require("../../config-provider/hooks/use-locale.js"),u=require("../../config-provider/hooks/use-global-config.js"),q={key:0,class:"spin"},z={key:1,class:"icon"},S={class:"text"},I=e.defineComponent({name:"ApDownload",__name:"ap-download",props:{prefixCls:{},type:{default:"link"},htmlType:{},shape:{},size:{default:"middle"},loading:{type:[Boolean,Object]},disabled:{type:Boolean,default:!1},ghost:{type:Boolean},block:{type:Boolean},danger:{type:Boolean},icon:{},href:{},target:{},title:{},onClick:{},onMousedown:{},autoInsertSpace:{type:Boolean},iconPosition:{},color:{},variant:{},text:{},fileName:{},needName:{type:[Boolean,Object],default:void 0},getOssAccess:{}},emits:["downloadCallback"],setup(p,{emit:f}){const l=f,s=e.ref(!1),{lang:m}=O.useLocale(),g=e.useSlots(),C=e.computed(()=>m.value==="zh-cn"?"zh_CN":"en_US"),t=p,a=u.useGlobalConfig("apUpload"),i=u.useGlobalConfig("downloadCenterTriggerConfig"),c=e.computed(()=>t.disabled),y=e.computed(()=>t.size),{getInnerWrapperClass:b}=B.useStyle(y,c),N=e.computed(()=>t.getOssAccess||a.value?.getOssAccess),v=async()=>{if(!t.disabled){s.value=!0;try{if(i.value?.trigger){let n=d.getFileInfo(t.needName??a?.value?.needName,t.fileName).map(r=>({objectName:r.path,fileName:r.fileName}));await i.value?.trigger(n),l("downloadCallback",n)}else{const n=await(await w.useOssInit(N.value,e.unref(C))).downloadFile(d.getFileInfo(t.needName??a?.value?.needName,t.fileName));l("downloadCallback",n)}}catch(o){console.error(o)}finally{s.value=!1}}};return(o,n)=>(e.openBlock(),e.createBlock(e.unref(_.Button),e.mergeProps(e.unref(h.omit)(t,["getOssAccess","fileName","needName"]),{type:t.type,size:t.size,disabled:c.value,onClick:v}),{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(b))},[s.value?(e.openBlock(),e.createElementBlock("span",q,[e.createVNode(e.unref(k.LoadingOutlined),{spin:!0})])):e.createCommentVNode("",!0),e.unref(g).icon?(e.openBlock(),e.createElementBlock("span",z,[e.renderSlot(o.$slots,"icon")])):e.createCommentVNode("",!0),e.createElementVNode("span",S,e.toDisplayString(o.text),1)],2)]),_:3},16,["type","size","disabled"]))}});exports.default=I;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("@ant-design/icons-vue"),_=require("@aplus-frontend/antdv"),I=require("lodash-unified");require("../../config-provider/index.js");const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),y=require("@ant-design/icons-vue"),_=require("@aplus-frontend/antdv"),I=require("lodash-unified");require("../../config-provider/index.js");const l=require("./hooks/useOss.js"),M=require("./imgs/admin-fallback.jpg.js"),A=require("./imgs/user-fallback.jpg.js"),B=require("./style/index.js"),S=require("../../config-provider/hooks/use-namespace.js"),u=require("../../config-provider/hooks/use-global-config.js"),j=require("../../config-provider/hooks/use-locale.js"),E=e.defineComponent({__name:"ApImage",props:{getOssAccess:{},width:{},height:{},alt:{},fallback:{},src:{},fileName:{},uiMode:{},preview:{type:[Boolean,Object],default:!0}},setup(g){const{b:i}=S.useNamespace("ap-image"),d=B.default("ap-image"),t=g,f={aplus:A.default,admin:M.default},b=u.useGlobalConfig("apImage",{uiMode:"aplus"}),v=u.useGlobalConfig("apUpload"),m=u.useGlobalConfig("downloadCenterTriggerConfig"),h=e.computed(()=>t.uiMode||b.value?.uiMode),{t:k,lang:C}=j.useLocale(),p=e.computed(()=>t.getOssAccess||v.value?.getOssAccess),w=e.computed(()=>f[h.value]||f.aplus),q=e.computed(()=>t?.fallback||w.value),o=e.ref("");l.injectLocaleToOss(k,C),e.watchEffect(async()=>{if(!t?.src){o.value="";return}if(t.src?.startsWith("http")||t.src?.startsWith("data:")){o.value=t.src;return}try{const r=t.src?.match(/^([^:]+):(.*)$/),s=r?.[1],a=r?.[2]??t.src,n=await l.getOssInstance(()=>s?p.value?.(s):p.value?.(),s),c=await l.getSignatureUrl({oss:n,fileName:a});c&&(o.value=c)}catch{o.value=""}});async function O(){if(!t?.src)return;const r=t.src,s=t.fileName??t.src;if(t.src?.startsWith("http")||t.src?.startsWith("data:")){N(r,s);return}if(m.value?.trigger){let a=[{objectName:r,fileName:s}];await m.value?.trigger(a)}}const N=(r,s)=>{const a=document.createElement("a");a.href=r,a.rel="noopener noreferrer",a.setAttribute("download",s),document.body.appendChild(a),a.click(),document.body.removeChild(a)};return(r,s)=>(e.openBlock(),e.createBlock(e.unref(_.Image),e.mergeProps({class:[e.unref(i)(),e.unref(d)]},{...e.unref(I.omit)(t,["src","getOssAccess"]),fallback:q.value,src:o.value}),{toolbarRender:e.withCtx(a=>[e.renderSlot(r.$slots,"toolbarRender",e.normalizeProps(e.guardReactiveProps({...a})),()=>[e.createElementVNode("div",{class:e.normalizeClass([e.unref(i)("toolbar"),e.unref(d)])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.originalNodes,(n,c)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n),e.mergeProps({ref_for:!0},t,{key:c}),null,16))),128)),e.createElementVNode("div",{class:"ant-image-preview-operations-operation",onClick:O},[e.createVNode(e.unref(y.DownloadOutlined))])],2)])]),_:3},16,["class"]))}});exports.default=E;
|
|
@@ -3,7 +3,7 @@ import { Ref } from 'vue';
|
|
|
3
3
|
import { Translator } from '../../../config-provider';
|
|
4
4
|
type GetOssAccess = () => Promise<accessCreate>;
|
|
5
5
|
export declare function injectLocaleToOss(tValue: Translator, langValue: Ref<string>): void;
|
|
6
|
-
export declare function getOssInstance(getOssAccess?: GetOssAccess): Promise<Oss>;
|
|
6
|
+
export declare function getOssInstance(getOssAccess?: GetOssAccess, bucket?: string): Promise<Oss>;
|
|
7
7
|
export declare function getSignatureUrl({ oss, fileName }: {
|
|
8
8
|
oss: Oss;
|
|
9
9
|
fileName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@aplus-frontend/oss"),p=1e4;let n,i;function O(t,s){n=t,i=s}const f={"zh-cn":"zh_CN",en:"en_US"};function m(){return f[i.value]??"zh_CN"}const c=new Map;async function T(t,s){if(!t)throw new Error(`${n("ap.apUpload.pleasePass")}getOssAccess`);const a=s||"ap_image_default_bucket";let e=c.get(a);return e?.createDate&&e.createDate<Date.now()+p&&e?.oss||(e={oss:new Promise((l,u)=>{const o=g.createOssInstance();o.initOssClient({getOssAccess:t,locale:m(),onFailure:r=>{u(typeof r?.message=="string"?r.message:n("ap.apUpload.FailedToObtainOssTemporaryPermissions"))}}).then(()=>{l(o)})}),createDate:Date.now()},c.set(a,e)),e.oss}function U({oss:t,fileName:s}){return t.getSignatureUrl(s)}exports.getOssInstance=T;exports.getSignatureUrl=U;exports.injectLocaleToOss=O;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { accessCreate } from '@aplus-frontend/oss';
|
|
2
2
|
import { UiModeType } from '../../config-provider';
|
|
3
3
|
export interface ApImageProps {
|
|
4
|
-
getOssAccess?: () => Promise<accessCreate>;
|
|
4
|
+
getOssAccess?: (bucket?: string) => Promise<accessCreate>;
|
|
5
5
|
width?: number | string;
|
|
6
6
|
height?: number | string;
|
|
7
7
|
alt?: string;
|
|
@@ -181,8 +181,8 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
|
|
|
181
181
|
value: string | unknown[] | Record<string, any>;
|
|
182
182
|
maxCount: number;
|
|
183
183
|
maxSize: number;
|
|
184
|
-
getOssAccess: GetOssAccess;
|
|
185
184
|
needName: boolean | Record<string, any>;
|
|
185
|
+
getOssAccess: GetOssAccess;
|
|
186
186
|
accept: string;
|
|
187
187
|
beforeUpload: BeforeUpload;
|
|
188
188
|
onRemove: Function;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultOptionType } from '@aplus-frontend/antdv/es/select';
|
|
2
|
-
import {
|
|
2
|
+
import { accessCreate } from '@aplus-frontend/oss';
|
|
3
3
|
import { InjectionKey, Ref, VNode } from 'vue';
|
|
4
4
|
import { Recordable } from '../type';
|
|
5
5
|
import { ConfigProviderProps } from './config-provider-props';
|
|
@@ -18,7 +18,7 @@ export type ApiType = {
|
|
|
18
18
|
};
|
|
19
19
|
export type ApUploadConfig = {
|
|
20
20
|
dirName?: string;
|
|
21
|
-
getOssAccess?:
|
|
21
|
+
getOssAccess?: (bucket?: string) => Promise<accessCreate>;
|
|
22
22
|
needName?: boolean | {
|
|
23
23
|
pathKey?: string;
|
|
24
24
|
nameKey?: string;
|
package/lib/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "7.10.
|
|
1
|
+
declare const _default: "7.10.4";
|
|
2
2
|
export default _default;
|
package/lib/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.10.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="7.10.4";exports.default=e;
|