@antv/dumi-theme-antv 0.7.10 → 0.8.0-alpha.3
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/builtins/Playground/index.js +1 -1
- package/dist/builtins/Playground/index.module.less +0 -1
- package/dist/common/styles/Common.js +1 -1
- package/dist/common/styles/theme.js +1 -1
- package/dist/components/AI/HomeDialog/AntVBanner/index.js +4 -0
- package/dist/components/AI/HomeDialog/AntVBanner/index.module.less +35 -0
- package/dist/components/AI/HomeDialog/ModeSelector/ModeSelectorDropdown.js +42 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.js +32 -0
- package/dist/components/AI/HomeDialog/ModeSelector/index.module.less +289 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.js +62 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/ChooseLib/index.module.less +4 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.js +25 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/DatasourceCard/index.module.less +42 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/SendButton.js +23 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/SendButton.module.less +9 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/Uploader/DataUploader.js +225 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.js +172 -0
- package/dist/components/AI/HomeDialog/PromptTextarea/index.module.less +128 -0
- package/dist/components/AI/HomeDialog/RecommendCase/Card.js +80 -0
- package/dist/components/AI/HomeDialog/RecommendCase/card.module.less +131 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.js +130 -0
- package/dist/components/AI/HomeDialog/RecommendCase/index.module.less +45 -0
- package/dist/components/AI/HomeDialog/RecommendCase/recommend.json +66 -0
- package/dist/components/AI/HomeDialog/index.js +62 -0
- package/dist/components/AI/HomeDialog/index.module.less +3 -0
- package/dist/components/AI/constant.js +37 -0
- package/dist/components/AI/index.js +1 -0
- package/dist/components/AI/types.js +1 -0
- package/dist/components/AI/utils.js +38 -0
- package/dist/components/Login/Captcha/index.js +185 -0
- package/dist/components/Login/Captcha/index.less +91 -0
- package/dist/components/Login/CheckCode/index.js +244 -0
- package/dist/components/Login/CheckCode/index.less +137 -0
- package/dist/components/Login/CountDownButton/index.js +109 -0
- package/dist/components/Login/CountDownButton/index.less +8 -0
- package/dist/components/Login/LoginForm.js +239 -0
- package/dist/components/Login/LoginForm.less +408 -0
- package/dist/components/Login/index.js +24 -0
- package/dist/components/Login/openAuthWindow.js +54 -0
- package/dist/components/Login/types.js +5 -0
- package/dist/components/Login/utils.js +47 -0
- package/dist/hooks/useProducts.js +39 -0
- package/dist/hooks/useStreamingText.js +139 -0
- package/dist/hooks/useTypewriter.js +69 -0
- package/dist/hooks/useVisionsnapSdk.js +159 -0
- package/dist/layouts/DocLayout.js +2 -2
- package/dist/layouts/GlobalLayout/index.js +22 -0
- package/dist/locales/en.json +132 -1
- package/dist/locales/zh.json +132 -1
- package/dist/model/AIChat.js +313 -0
- package/dist/model/auth.js +147 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +176 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.module.less +46 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +97 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.module.less +13 -0
- package/dist/pages/AIPlayground/components/MarkdownComponent/index.js +50 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.js +407 -0
- package/dist/pages/AIPlayground/components/MsgBox/index.module.less +43 -0
- package/dist/pages/AIPlayground/components/MsgBox/useAutoScroll.js +46 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +62 -0
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +37 -0
- package/dist/pages/AIPlayground/components/TaskBox/generateCode.js +230 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.js +101 -0
- package/dist/pages/AIPlayground/components/TaskBox/index.module.less +9 -0
- package/dist/pages/AIPlayground/demo.js +34 -0
- package/dist/pages/AIPlayground/index.js +12 -0
- package/dist/pages/AIPlayground/index.module.less +5 -0
- package/dist/pages/Examples/components/Accouncement/index.module.less +1 -1
- package/dist/pages/Examples/index.module.less +11 -11
- package/dist/pages/Index/components/Cases/index.module.less +8 -8
- package/dist/pages/Index/components/Companies/index.module.less +4 -3
- package/dist/pages/Index/components/Features/FeatureCard.module.less +4 -5
- package/dist/pages/Index/components/Features/index.module.less +5 -5
- package/dist/pages/Index/components/_.less +9 -9
- package/dist/pages/Index/index.js +1 -1
- package/dist/plugin/index.js +14 -6
- package/dist/slots/Banner/Notification.module.less +8 -8
- package/dist/slots/Banner/index.module.less +10 -9
- package/dist/slots/CodeEditor/Toolbar.js +23 -27
- package/dist/slots/CodeEditor/Toolbar.module.less +7 -0
- package/dist/slots/CodeEditor/index.js +67 -5
- package/dist/slots/CodeEditor/index.module.less +24 -0
- package/dist/slots/CodeEditor/utils.js +2 -1
- package/dist/slots/CodePreview/index.module.less +0 -3
- package/dist/slots/CodeRunner/index.js +24 -11
- package/dist/slots/ContentTable/index.module.less +2 -1
- package/dist/{pages/Index/components → slots}/Detail/News.js +1 -1
- package/dist/{pages/Index/components → slots}/Detail/News.module.less +9 -9
- package/dist/{pages/Index/components → slots}/Detail/index.js +13 -29
- package/dist/{pages/Index/components → slots}/Detail/index.module.less +23 -20
- package/dist/slots/ExampleSider/index.module.less +3 -4
- package/dist/slots/Footer/index.module.less +2 -2
- package/dist/slots/Header/Products/Product.module.less +2 -2
- package/dist/slots/Header/Products/getProducts.js +20 -26
- package/dist/slots/Header/Products/index.js +20 -16
- package/dist/slots/Header/Search/SearchResult.js +53 -14
- package/dist/slots/Header/Search/SearchResult.module.less +1 -0
- package/dist/slots/Header/Search/index.js +2 -1
- package/dist/slots/Header/index.js +72 -30
- package/dist/slots/Header/index.module.less +14 -6
- package/dist/slots/LiveExample/index.js +1 -1
- package/dist/slots/LiveExample/index.module.less +1 -1
- package/dist/slots/Loading/index.module.less +30 -28
- package/dist/slots/ManualContent/index.module.less +14 -17
- package/dist/slots/_.less +9 -9
- package/dist/static/user.svg +3 -0
- package/dist/typings.d.ts +11 -0
- package/dist/utils/analytics.js +16 -0
- package/dist/utils/code.js +35 -0
- package/dist/utils/env.js +63 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/request.js +42 -0
- package/package.json +31 -15
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
.card {
|
|
2
|
+
padding: 16px;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
border-radius: 16px;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
position: relative;
|
|
10
|
+
aspect-ratio: 292 / 208;
|
|
11
|
+
background: rgba(22, 119, 255, 6%);
|
|
12
|
+
|
|
13
|
+
.typeTag {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
width: fit-content;
|
|
18
|
+
padding: 2px 8px;
|
|
19
|
+
border-radius: 6px;
|
|
20
|
+
box-shadow: inset 1px 1px 4px 0 rgba(0, 0, 0, 4%),
|
|
21
|
+
1px 1px 1px rgba(255, 255, 255, 40%);
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
line-height: 20px;
|
|
24
|
+
margin-bottom: 12px;
|
|
25
|
+
|
|
26
|
+
.typeIcon {
|
|
27
|
+
display: flex;
|
|
28
|
+
|
|
29
|
+
svg {
|
|
30
|
+
width: 14px;
|
|
31
|
+
height: 14px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.typeText {
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.title {
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
color: #1d2129e3;
|
|
43
|
+
line-height: 20px;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
.textEllipsis();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.imageContainer {
|
|
49
|
+
position: relative;
|
|
50
|
+
margin-top: 16px;
|
|
51
|
+
|
|
52
|
+
.image0,
|
|
53
|
+
.image1 {
|
|
54
|
+
width: 80%;
|
|
55
|
+
position: absolute;
|
|
56
|
+
object-fit: cover;
|
|
57
|
+
border-radius: 12px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.image0 {
|
|
61
|
+
transform: translate(24%, 24px);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.image1 {
|
|
65
|
+
transform: translate(4%, 0) rotate(-4deg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.hoverMask {
|
|
71
|
+
position: absolute;
|
|
72
|
+
left: 0;
|
|
73
|
+
right: 0;
|
|
74
|
+
bottom: 0;
|
|
75
|
+
height: 40px;
|
|
76
|
+
background: linear-gradient(
|
|
77
|
+
to top,
|
|
78
|
+
rgba(255, 255, 255, 40%) 0%,
|
|
79
|
+
rgba(255, 255, 255, 20%) 36%,
|
|
80
|
+
transparent 100%
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.popoverOverlay {
|
|
85
|
+
:global {
|
|
86
|
+
.ant-popover-inner {
|
|
87
|
+
border: 1px solid rgba(31, 59, 99, 10%);
|
|
88
|
+
background: #fff;
|
|
89
|
+
border-radius: 16px;
|
|
90
|
+
box-shadow: 0 9px 20px 8px #000a1a0d;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ant-popover-inner-content {
|
|
94
|
+
padding: 16px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.ant-popover-arrow {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.popoverContent {
|
|
103
|
+
max-width: 800px;
|
|
104
|
+
|
|
105
|
+
.popoverItem {
|
|
106
|
+
display: flex;
|
|
107
|
+
gap: 4px;
|
|
108
|
+
align-items: baseline;
|
|
109
|
+
|
|
110
|
+
.popoverLabel {
|
|
111
|
+
font-size: 12px;
|
|
112
|
+
color: #1d2129e6;
|
|
113
|
+
line-height: 22px;
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
min-width: 80px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.popoverValue {
|
|
119
|
+
font-size: 12px;
|
|
120
|
+
color: #1d2129cc;
|
|
121
|
+
line-height: 20px;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.textEllipsis {
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
text-overflow: ellipsis;
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { Spin } from 'antd';
|
|
12
|
+
import React, { useEffect, useState } from 'react';
|
|
13
|
+
import { Card } from "./Card";
|
|
14
|
+
import styles from "./index.module.less";
|
|
15
|
+
import { ReloadOutlined } from "@ant-design/icons";
|
|
16
|
+
import RecommendJson from "./recommend.json";
|
|
17
|
+
import classnames from "classnames";
|
|
18
|
+
import { FormattedMessage, useSiteData } from 'dumi';
|
|
19
|
+
import { sample, sampleSize } from "lodash-es";
|
|
20
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
21
|
+
import { useAntVConfig } from "../../../../hooks/useProducts";
|
|
22
|
+
import { getBaseSiteDataUrl } from "../../../../utils/env";
|
|
23
|
+
export var RecommendCase = function RecommendCase(props) {
|
|
24
|
+
var _useState = useState(false),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
loading = _useState2[0],
|
|
27
|
+
setLoading = _useState2[1];
|
|
28
|
+
var _useSiteData = useSiteData(),
|
|
29
|
+
themeConfig = _useSiteData.themeConfig;
|
|
30
|
+
var _useState3 = useState([]),
|
|
31
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
+
list = _useState4[0],
|
|
33
|
+
setList = _useState4[1];
|
|
34
|
+
var _useAntVConfig = useAntVConfig(),
|
|
35
|
+
_useAntVConfig$data = _useAntVConfig.data,
|
|
36
|
+
_useAntVConfig$data2 = _useAntVConfig$data === void 0 ? {
|
|
37
|
+
library: []
|
|
38
|
+
} : _useAntVConfig$data,
|
|
39
|
+
_useAntVConfig$data2$ = _useAntVConfig$data2.library,
|
|
40
|
+
library = _useAntVConfig$data2$ === void 0 ? [] : _useAntVConfig$data2$;
|
|
41
|
+
var fetchList = /*#__PURE__*/function () {
|
|
42
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
43
|
+
var _themeConfig$ai, data, url;
|
|
44
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
_context.prev = 0;
|
|
48
|
+
setLoading(true);
|
|
49
|
+
data = [];
|
|
50
|
+
url = themeConfig.isAntVSite && library.length ? "".concat(getBaseSiteDataUrl(), "/").concat(sample(library).toLowerCase(), "/recommend.json") : (themeConfig === null || themeConfig === void 0 || (_themeConfig$ai = themeConfig.ai) === null || _themeConfig$ai === void 0 ? void 0 : _themeConfig$ai.recommend) || "".concat(getBaseSiteDataUrl(), "/").concat(themeConfig.title, "/recommend.json");
|
|
51
|
+
if (!url) {
|
|
52
|
+
_context.next = 10;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
_context.next = 7;
|
|
56
|
+
return fetch(url).then(function (res) {
|
|
57
|
+
return res.json();
|
|
58
|
+
});
|
|
59
|
+
case 7:
|
|
60
|
+
data = _context.sent;
|
|
61
|
+
_context.next = 11;
|
|
62
|
+
break;
|
|
63
|
+
case 10:
|
|
64
|
+
data = RecommendJson;
|
|
65
|
+
case 11:
|
|
66
|
+
setList(sampleSize(data, 4));
|
|
67
|
+
_context.next = 18;
|
|
68
|
+
break;
|
|
69
|
+
case 14:
|
|
70
|
+
_context.prev = 14;
|
|
71
|
+
_context.t0 = _context["catch"](0);
|
|
72
|
+
setList(RecommendJson);
|
|
73
|
+
console.log(_context.t0);
|
|
74
|
+
case 18:
|
|
75
|
+
_context.prev = 18;
|
|
76
|
+
setLoading(false);
|
|
77
|
+
return _context.finish(18);
|
|
78
|
+
case 21:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee, null, [[0, 14, 18, 21]]);
|
|
83
|
+
}));
|
|
84
|
+
return function fetchList() {
|
|
85
|
+
return _ref.apply(this, arguments);
|
|
86
|
+
};
|
|
87
|
+
}();
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
if (library.length) {
|
|
90
|
+
fetchList();
|
|
91
|
+
}
|
|
92
|
+
}, [themeConfig.isAntVSite, library.length]);
|
|
93
|
+
if (!list.length) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
97
|
+
className: styles.container
|
|
98
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
className: styles.title
|
|
100
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
101
|
+
className: styles.quickStart
|
|
102
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
103
|
+
id: "ai.recommend.title"
|
|
104
|
+
})), (list === null || list === void 0 ? void 0 : list.length) > 4 ? /*#__PURE__*/React.createElement("span", {
|
|
105
|
+
className: styles.refresh,
|
|
106
|
+
onClick: function onClick() {
|
|
107
|
+
return fetchList();
|
|
108
|
+
}
|
|
109
|
+
}, /*#__PURE__*/React.createElement(ReloadOutlined, null), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
110
|
+
id: "ai.recommend.refresh"
|
|
111
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(Spin, {
|
|
112
|
+
spinning: loading,
|
|
113
|
+
wrapperClassName: classnames(styles.listContainer, props.className)
|
|
114
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
115
|
+
className: styles.list
|
|
116
|
+
}, list.map(function (item, index) {
|
|
117
|
+
return /*#__PURE__*/React.createElement(Card, {
|
|
118
|
+
key: item.caseId,
|
|
119
|
+
item: item,
|
|
120
|
+
index: index,
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
var _props$onClick;
|
|
123
|
+
(_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, item);
|
|
124
|
+
if (item.tag) {
|
|
125
|
+
AIChatStore.mode = item.tag;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}))));
|
|
130
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
position: relative;
|
|
3
|
+
margin-top: 32px;
|
|
4
|
+
margin-left: auto;
|
|
5
|
+
margin-right: auto;
|
|
6
|
+
z-index: 10;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: end;
|
|
12
|
+
margin-bottom: 24px;
|
|
13
|
+
width: 760px;
|
|
14
|
+
margin-left: auto;
|
|
15
|
+
margin-right: auto;
|
|
16
|
+
|
|
17
|
+
.quickStart {
|
|
18
|
+
font-size: 20px;
|
|
19
|
+
color: #1d2129e3;
|
|
20
|
+
line-height: 30px;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
flex: 1;
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.refresh {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
line-height: 20px;
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 2px;
|
|
31
|
+
align-items: center;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
color: rgba(78, 89, 105, 60%);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.listContainer {
|
|
38
|
+
width: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.list {
|
|
42
|
+
display: grid;
|
|
43
|
+
grid-template-columns: repeat(4, 1fr);
|
|
44
|
+
gap: 16px;
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"caseId": "1",
|
|
4
|
+
"tag": "implement",
|
|
5
|
+
"query": {
|
|
6
|
+
"zh": "你有一份公司多产品线销售数据:data = [ {month: '1月', productA: 12000, productB: 8500, productC: 15200}, {month: '2月', productA: 13500, productB: 9200, productC: 14800}, {month: '3月', productA: 15200, productB: 10800, productC: 16500}, {month: '4月', productA: 14800, productB: 11500, productC: 17200}, {month: '5月', productA: 16500, productB: 12200, productC: 18800}, {month: '6月', productA: 18200, productB: 13800, productC: 19500}, {month: '7月', productA: 19800, productB: 14500, productC: 20200}, {month: '8月', productA: 21500, productB: 15200, productC: 21800}, {month: '9月', productA: 20200, productB: 16800, productC: 22500}, {month: '10月', productA: 22800, productB: 17500, productC: 23200}, {month: '11月', productA: 24500, productB: 18200, productC: 24800}, {month: '12月', productA: 26200, productB: 19800, productC: 25500} ], 请绘制一个多折线图展示三条产品线的销售趋势变化,通过不同线型和颜色清晰区分各产品表现。 同时在最高点进行数据标注。",
|
|
7
|
+
"en": "You have multi-product line sales data for a company: data = [ {month: 'January', productA: 12000, productB: 8500, productC: 15200}, {month: 'February', productA: 13500, productB: 9200, productC: 14800}, {month: 'March', productA: 15200, productB: 10800, productC: 16500}, {month: 'April', productA: 14800, productB: 11500, productC: 17200}, {month: 'May', productA: 16500, productB: 12200, productC: 18800}, {month: 'June', productA: 18200, productB: 13800, productC: 19500}, {month: 'July', productA: 19800, productB: 14500, productC: 20200}, {month: 'August', productA: 21500, productB: 15200, productC: 21800}, {month: 'September', productA: 20200, productB: 16800, productC: 22500}, {month: 'October', productA: 22800, productB: 17500, productC: 23200}, {month: 'November', productA: 24500, productB: 18200, productC: 24800}, {month: 'December', productA: 26200, productB: 19800, productC: 25500} ]. Please draw a multi-line chart to show the sales trend changes of the three product lines, clearly distinguishing each product's performance through different line styles and colors. Also add data annotations at the highest points."
|
|
8
|
+
},
|
|
9
|
+
"description": {
|
|
10
|
+
"zh": "自然语言描述需求,生成可视化代码",
|
|
11
|
+
"en": "Natural language description of requirements, generate visualization code"
|
|
12
|
+
},
|
|
13
|
+
"imageUrls": [
|
|
14
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*zUKtR4U75fcAAAAAROAAAAgAemJ7AQ/original",
|
|
15
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*zUKtR4U75fcAAAAAROAAAAgAemJ7AQ/original"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"caseId": "2",
|
|
20
|
+
"tag": "implement",
|
|
21
|
+
"query": {
|
|
22
|
+
"zh": "一家咖啡店的饮品销售比例为:咖啡 60%,茶 25%,果汁 15%。请用环图可视化这些饮品销售数据,并将色板调整为橙色系。",
|
|
23
|
+
"en": "A coffee shop's beverage sales ratio is: Coffee 60%, Tea 25%, Juice 15%. Please visualize these beverage sales data with a donut chart and adjust the color palette to orange tones."
|
|
24
|
+
},
|
|
25
|
+
"description": {
|
|
26
|
+
"zh": "自然语言描述需求,生成可视化代码",
|
|
27
|
+
"en": "Natural language description of requirements, generate visualization code"
|
|
28
|
+
},
|
|
29
|
+
"imageUrls": [
|
|
30
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*oMezTK-Yf2EAAAAAQmAAAAgAemJ7AQ/original",
|
|
31
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*oMezTK-Yf2EAAAAAQmAAAAgAemJ7AQ/original"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"caseId": "3",
|
|
36
|
+
"tag": "solve",
|
|
37
|
+
"query": {
|
|
38
|
+
"zh": "为什么配置了 state 没有生效?",
|
|
39
|
+
"en": "Why is the configured state not taking effect?"
|
|
40
|
+
},
|
|
41
|
+
"description": {
|
|
42
|
+
"zh": "精准定位并提供针对渲染异常、性能瓶颈及数据不匹配等问题的解决方案。",
|
|
43
|
+
"en": "Precisely locate and provide solutions for rendering anomalies, performance bottlenecks, and data mismatches."
|
|
44
|
+
},
|
|
45
|
+
"imageUrls": [
|
|
46
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*15mgQ4lA5CUAAAAASzAAAAgAemJ7AQ/original",
|
|
47
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*15mgQ4lA5CUAAAAASzAAAAgAemJ7AQ/original"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"caseId": "4",
|
|
52
|
+
"tag": "solve",
|
|
53
|
+
"query": {
|
|
54
|
+
"zh": "数据标签互相遮挡了怎么办?",
|
|
55
|
+
"en": "What to do when data labels overlap each other?"
|
|
56
|
+
},
|
|
57
|
+
"description": {
|
|
58
|
+
"zh": "精准定位并提供针对渲染异常、性能瓶颈及数据不匹配等问题的解决方案。",
|
|
59
|
+
"en": "Precisely locate and provide solutions for rendering anomalies, performance bottlenecks, and data mismatches."
|
|
60
|
+
},
|
|
61
|
+
"imageUrls": [
|
|
62
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*thpQQIB3LG4AAAAASMAAAAgAemJ7AQ/original",
|
|
63
|
+
"https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*thpQQIB3LG4AAAAASMAAAAgAemJ7AQ/original"
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import styles from "./index.module.less";
|
|
9
|
+
import { AntVBanner } from "./AntVBanner";
|
|
10
|
+
import { PromptTextarea } from "./PromptTextarea";
|
|
11
|
+
import { RecommendCase } from "./RecommendCase";
|
|
12
|
+
import { ModeSelector } from "./ModeSelector";
|
|
13
|
+
import classnames from 'classnames';
|
|
14
|
+
import { useLocale } from 'dumi';
|
|
15
|
+
import { AIChatStore, createNewSession } from "../../../model/AIChat";
|
|
16
|
+
import { useSnapshot } from "valtio";
|
|
17
|
+
export function HomeDialog(props) {
|
|
18
|
+
var locale = useLocale();
|
|
19
|
+
var lang = locale.id === 'zh' ? 'zh' : 'en';
|
|
20
|
+
var snap = useSnapshot(AIChatStore);
|
|
21
|
+
var _useState = useState(''),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
promptText = _useState2[0],
|
|
24
|
+
setPromptText = _useState2[1];
|
|
25
|
+
var _useState3 = useState(''),
|
|
26
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
27
|
+
fileSummary = _useState4[0],
|
|
28
|
+
setFileSummary = _useState4[1];
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: classnames(styles.content, props.className),
|
|
31
|
+
style: props.style
|
|
32
|
+
}, /*#__PURE__*/React.createElement(AntVBanner, null), /*#__PURE__*/React.createElement(ModeSelector, {
|
|
33
|
+
onChange: function onChange(v) {
|
|
34
|
+
AIChatStore.mode = v;
|
|
35
|
+
},
|
|
36
|
+
value: snap.mode
|
|
37
|
+
}), /*#__PURE__*/React.createElement(PromptTextarea, {
|
|
38
|
+
value: promptText,
|
|
39
|
+
onChange: function onChange(val) {
|
|
40
|
+
setPromptText(val);
|
|
41
|
+
},
|
|
42
|
+
onConfirm: function onConfirm() {
|
|
43
|
+
createNewSession({
|
|
44
|
+
promptText: promptText,
|
|
45
|
+
mode: snap.mode,
|
|
46
|
+
jump: true,
|
|
47
|
+
context: fileSummary,
|
|
48
|
+
lang: locale.id,
|
|
49
|
+
entry_point: 'home'
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
style: props.promptTextareaStyle,
|
|
53
|
+
onDataSummaryChange: setFileSummary
|
|
54
|
+
}), /*#__PURE__*/React.createElement(RecommendCase, {
|
|
55
|
+
className: props.recommendCaseClassName,
|
|
56
|
+
onClick: function onClick(val) {
|
|
57
|
+
if (val !== null && val !== void 0 && val.query) {
|
|
58
|
+
setPromptText(val.query[lang]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BarChartOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
2
|
+
import React from "react";
|
|
3
|
+
export var AIMode = {
|
|
4
|
+
implement: 'implement',
|
|
5
|
+
solve: 'solve'
|
|
6
|
+
};
|
|
7
|
+
export var AIModeMeta = {
|
|
8
|
+
implement: {
|
|
9
|
+
name: 'ai.mode.implement',
|
|
10
|
+
icon: /*#__PURE__*/React.createElement(BarChartOutlined, null),
|
|
11
|
+
shortName: 'ai.mode.implement.short'
|
|
12
|
+
},
|
|
13
|
+
solve: {
|
|
14
|
+
name: 'ai.mode.solve',
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
16
|
+
shortName: 'ai.mode.solve.short'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// 循环取这几个颜色
|
|
21
|
+
export var COLORS = [{
|
|
22
|
+
color: '#5792E6',
|
|
23
|
+
backgroundColor: 'rgba(22,119,255,0.06)'
|
|
24
|
+
}, {
|
|
25
|
+
color: '#66cf85',
|
|
26
|
+
backgroundColor: 'rgba(44,208,119,0.06)'
|
|
27
|
+
}, {
|
|
28
|
+
color: '#f99542',
|
|
29
|
+
backgroundColor: 'rgba(231,173,69,0.08)'
|
|
30
|
+
}, {
|
|
31
|
+
color: '#5761f3',
|
|
32
|
+
backgroundColor: 'rgba(22,55,255,0.06)'
|
|
33
|
+
}];
|
|
34
|
+
export var FileIcons = {
|
|
35
|
+
FILE: 'https://mdn.alipayobjects.com/huamei_2yzvel/afts/img/A*bc2KQq259ucAAAAAAAAAAAAAeriAAQ/original',
|
|
36
|
+
IMAGE: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*6I-zQKAmDUsAAAAAQBAAAAgAemJ7AQ/original'
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./HomeDialog";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function getFileExtension(filename) {
|
|
2
|
+
// 查找最后一个点的位置
|
|
3
|
+
var dotIndex = filename.lastIndexOf('.');
|
|
4
|
+
|
|
5
|
+
// 如果没有找到点,返回空字符串
|
|
6
|
+
if (dotIndex === -1) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 提取后缀名,并返回
|
|
11
|
+
return filename.slice(dotIndex + 1);
|
|
12
|
+
}
|
|
13
|
+
export function formatFileSize(fileSize) {
|
|
14
|
+
if (!fileSize) {
|
|
15
|
+
return '0B';
|
|
16
|
+
}
|
|
17
|
+
var units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
18
|
+
var size = fileSize;
|
|
19
|
+
var unitIndex = 0;
|
|
20
|
+
|
|
21
|
+
// 当文件大小大于等于1024且还有更大的单位可用时,进行转换
|
|
22
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
23
|
+
size /= 1024;
|
|
24
|
+
unitIndex++;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 如果小于1MB,强制使用KB为单位
|
|
28
|
+
if (unitIndex === 0 && fileSize >= 1024) {
|
|
29
|
+
size = fileSize / 1024;
|
|
30
|
+
unitIndex = 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 保留一位小数
|
|
34
|
+
size = Number(size.toFixed(1));
|
|
35
|
+
|
|
36
|
+
// 如果小数部分为0,则去掉小数部分
|
|
37
|
+
return "".concat(size % 1 === 0 ? Math.floor(size) : size).concat(units[unitIndex]);
|
|
38
|
+
}
|