@cmstops/pro-compo 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ @radio-button-size: 32px;
2
+ .color-palette-container {
3
+ .color-radio-group {
4
+ overflow: hidden;
5
+ .arco-radio-button {
6
+ width: @radio-button-size;
7
+ height: @radio-button-size;
8
+ padding: 0;
9
+ font-size: 0 !important;
10
+ overflow: hidden !important;
11
+ background: transparent !important;
12
+ border-width: 0 !important;
13
+ box-shadow: none !important;
14
+ position: relative;
15
+ &.arco-radio-checked {
16
+ &::after {
17
+ box-sizing: content-box;
18
+ content: '';
19
+ border: 2px solid #fff;
20
+ border-left: 0;
21
+ border-top: 0;
22
+ height: 11px;
23
+ left: 12px;
24
+ position: absolute;
25
+ top: 7px;
26
+ transform: rotate(45deg) scaleY(1);
27
+ width: 5px;
28
+ transition: transform 0.15s ease-in 0.05s;
29
+ transform-origin: center;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ .color-picker-input {
35
+ width: @radio-button-size;
36
+ height: @radio-button-size;
37
+ padding: 0 2px;
38
+ border: none;
39
+ }
40
+ }
package/es/index.css CHANGED
@@ -3856,3 +3856,38 @@
3856
3856
  .doc-tags-thumb-popver .doc-tags-thumb-ul img + img {
3857
3857
  margin-left: 2px;
3858
3858
  }
3859
+ .color-palette-container .color-radio-group {
3860
+ overflow: hidden;
3861
+ }
3862
+ .color-palette-container .color-radio-group .arco-radio-button {
3863
+ width: 32px;
3864
+ height: 32px;
3865
+ padding: 0;
3866
+ font-size: 0 !important;
3867
+ overflow: hidden !important;
3868
+ background: transparent !important;
3869
+ border-width: 0 !important;
3870
+ box-shadow: none !important;
3871
+ position: relative;
3872
+ }
3873
+ .color-palette-container .color-radio-group .arco-radio-button.arco-radio-checked::after {
3874
+ box-sizing: content-box;
3875
+ content: '';
3876
+ border: 2px solid #fff;
3877
+ border-left: 0;
3878
+ border-top: 0;
3879
+ height: 11px;
3880
+ left: 12px;
3881
+ position: absolute;
3882
+ top: 7px;
3883
+ transform: rotate(45deg) scaleY(1);
3884
+ width: 5px;
3885
+ transition: transform 0.15s ease-in 0.05s;
3886
+ transform-origin: center;
3887
+ }
3888
+ .color-palette-container .color-picker-input {
3889
+ width: 32px;
3890
+ height: 32px;
3891
+ padding: 0 2px;
3892
+ border: none;
3893
+ }
package/es/index.d.ts CHANGED
@@ -19,3 +19,4 @@ export { default as selectThumb } from './selectThumb';
19
19
  export { default as editMetaInfo } from './editMetaInfo';
20
20
  export { default as baseFilter } from './baseFilter';
21
21
  export { default as dataTags } from './dataTags';
22
+ export { default as colorPalette } from './colorPalette';
package/es/index.js CHANGED
@@ -19,3 +19,4 @@ export { default as selectThumb } from "./selectThumb/index.js";
19
19
  export { default as editMetaInfo } from "./editMetaInfo/index.js";
20
20
  export { default as baseFilter } from "./baseFilter/index.js";
21
21
  export { default as dataTags } from "./dataTags/index.js";
22
+ export { default as colorPalette } from "./colorPalette/index.js";
package/es/index.less CHANGED
@@ -19,3 +19,4 @@
19
19
  @import './editMetaInfo/style/index.less';
20
20
  @import './baseFilter/style/index.less';
21
21
  @import './dataTags/style/index.less';
22
+ @import './colorPalette/style/index.less';
@@ -6,6 +6,7 @@ import _sfc_main$4 from "../imageCrop/component.js";
6
6
  import _sfc_main$1 from "./components/card.js";
7
7
  import _sfc_main$2 from "./components/colorPalette.js";
8
8
  import { DEFAULT_BASE_API } from "../config.js";
9
+ import { getThemeColor } from "../utils/index.js";
9
10
  const _hoisted_1 = {
10
11
  key: 0,
11
12
  class: "star"
@@ -279,9 +280,27 @@ const _sfc_main = defineComponent({
279
280
  styleData.value.data = temp;
280
281
  } else if (thumbBannerModel.value === "banner") {
281
282
  styleData.value.banner_url = data[0].url;
283
+ const getColors = getThemeColor(BASE_API, data[0].url);
284
+ getColors.then((themes) => {
285
+ styleData.value.banner_colorList = JSON.parse(JSON.stringify(themes));
286
+ styleData.value.banner_theme_color = `rgb(${themes[1]})`;
287
+ callback(styleData.value);
288
+ }).catch((e) => {
289
+ styleData.value.banner_theme_color = `rgb(255, 255, 255)`;
290
+ callback(styleData.value);
291
+ });
282
292
  } else {
283
293
  styleData.value.top_image_url = data[0].url;
284
294
  styleData.value.pc_banner_url = data[0].url;
295
+ const getColors = getThemeColor(BASE_API, data[0].url);
296
+ getColors.then((themes) => {
297
+ styleData.value.top_colorList = JSON.parse(JSON.stringify(themes));
298
+ styleData.value.top_theme_color = `rgb(${themes[1]})`;
299
+ callback(styleData.value);
300
+ }).catch((e) => {
301
+ styleData.value.top_theme_color = `rgb(255, 255, 255)`;
302
+ callback(styleData.value);
303
+ });
285
304
  }
286
305
  callback(styleData.value);
287
306
  dialogMediaSelectionShow.value = false;
@@ -11,3 +11,5 @@ export declare function replaceSuffix(str: string, insert: string): string;
11
11
  export declare const noCoverText: (item: any) => any;
12
12
  export declare const timeFormat: (value: any) => string;
13
13
  export declare const validateForm: (formRef: any) => Promise<unknown>;
14
+ export declare function getRealUrl(BASE_API: string, url: string): Promise<unknown>;
15
+ export declare function getThemeColor(BASE_API: string, src: string): Promise<unknown>;
package/es/utils/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import dayjs from "dayjs";
2
+ import ColorThief from "colorthief";
3
+ import { getFileRealUrl } from "../imageCrop/script/api.js";
4
+ import { DEFAULT_UPLOAD_URL } from "../config.js";
2
5
  const dateYYYYDDMMHHmm = (date) => {
3
6
  if (!date)
4
7
  return "--";
@@ -60,4 +63,48 @@ const validateForm = (formRef) => {
60
63
  }
61
64
  });
62
65
  };
63
- export { dateYYYYDDMMHHmm, generateUUID, noCoverText, replaceSuffix, timeFormat, to, validateForm };
66
+ function getRealUrl(BASE_API, url) {
67
+ return new Promise((resove, reject) => {
68
+ try {
69
+ const flag = !url.includes("/poplar/v2");
70
+ const cape = url.includes("cape/v1/upload");
71
+ const extented = !url.includes(BASE_API) && !url.includes(DEFAULT_UPLOAD_URL);
72
+ if (flag || extented || cape) {
73
+ resove(url);
74
+ } else {
75
+ getFileRealUrl(BASE_API, url).then((res) => {
76
+ resove(res.message);
77
+ });
78
+ }
79
+ } catch (e) {
80
+ reject(e);
81
+ }
82
+ });
83
+ }
84
+ function getThemeColor(BASE_API, src) {
85
+ return new Promise((resolve, reject) => {
86
+ const getUrl = getRealUrl(BASE_API, src);
87
+ getUrl.then((url) => {
88
+ const colorThief = new ColorThief();
89
+ const img = document.createElement("img");
90
+ img.crossOrigin = "Anonymous";
91
+ img.setAttribute("src", `${url}?t=${+new Date()}`);
92
+ img.onload = () => {
93
+ let themeColors = [];
94
+ const getResult = colorThief.getPalette(img);
95
+ if (getResult) {
96
+ themeColors = getResult.slice(0, 6);
97
+ } else {
98
+ themeColors = [[255, 255, 255]];
99
+ }
100
+ resolve(themeColors);
101
+ };
102
+ img.onerror = (e) => {
103
+ reject(e);
104
+ };
105
+ }).catch((e) => {
106
+ reject(e);
107
+ });
108
+ });
109
+ }
110
+ export { dateYYYYDDMMHHmm, generateUUID, getRealUrl, getThemeColor, noCoverText, replaceSuffix, timeFormat, to, validateForm };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var vue = require("vue");
3
+ var webVue = require("@arco-design/web-vue");
4
+ var colorPicker = require("./components/colorPicker.js");
5
+ const _hoisted_1 = {
6
+ key: 0,
7
+ class: "color-palette-container"
8
+ };
9
+ const _sfc_main = vue.defineComponent({
10
+ ...{ name: "colorPalette" },
11
+ __name: "component",
12
+ props: {
13
+ colorList: {},
14
+ color: {}
15
+ },
16
+ emits: ["change", "update:color"],
17
+ setup(__props, { emit: __emit }) {
18
+ const props = __props;
19
+ const emit = __emit;
20
+ const colorValue = vue.computed({
21
+ get() {
22
+ return props.color;
23
+ },
24
+ set(value) {
25
+ emit("update:color", value);
26
+ }
27
+ });
28
+ const colorChange = (_color) => {
29
+ if (_color) {
30
+ colorValue.value = _color.replace(/\s+/g, "");
31
+ }
32
+ };
33
+ return (_ctx, _cache) => {
34
+ return _ctx.colorList && _ctx.colorList.length ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
35
+ vue.createVNode(vue.unref(webVue.RadioGroup), {
36
+ modelValue: colorValue.value,
37
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => colorValue.value = $event),
38
+ class: "color-radio-group",
39
+ type: "button",
40
+ onChange: colorChange
41
+ }, {
42
+ default: vue.withCtx(() => [
43
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.colorList, (colr, index) => {
44
+ return vue.openBlock(), vue.createBlock(vue.unref(webVue.Radio), {
45
+ key: index,
46
+ style: vue.normalizeStyle({ background: `${colr} !important` }),
47
+ value: colr
48
+ }, null, 8, ["style", "value"]);
49
+ }), 128)),
50
+ vue.createVNode(colorPicker, {
51
+ modelValue: colorValue.value,
52
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => colorValue.value = $event),
53
+ onChange: colorChange
54
+ }, null, 8, ["modelValue"])
55
+ ]),
56
+ _: 1
57
+ }, 8, ["modelValue"])
58
+ ])) : vue.createCommentVNode("v-if", true);
59
+ };
60
+ }
61
+ });
62
+ module.exports = _sfc_main;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var vue = require("vue");
3
+ const _hoisted_1 = ["value"];
4
+ const _sfc_main = vue.defineComponent({
5
+ __name: "colorPicker",
6
+ props: {
7
+ modelValue: String
8
+ },
9
+ emits: ["update:modelValue", "change"],
10
+ setup(__props, { emit: __emit }) {
11
+ const props = __props;
12
+ const emit = __emit;
13
+ const color = vue.ref(props.modelValue || "#ffffff");
14
+ vue.watch(
15
+ () => props.modelValue,
16
+ () => {
17
+ if (props.modelValue) {
18
+ color.value = rgbToHex(props.modelValue);
19
+ }
20
+ },
21
+ { immediate: true }
22
+ );
23
+ vue.watch(color, (newColor) => {
24
+ emit("update:modelValue", newColor);
25
+ emit("change", newColor);
26
+ });
27
+ const updateColor = (event) => {
28
+ const hexColor = event.target.value;
29
+ const rgbColor = hexToRgb(hexColor);
30
+ color.value = rgbColor;
31
+ };
32
+ function hexToRgb(hex) {
33
+ const red = parseInt(hex.slice(1, 3), 16);
34
+ const green = parseInt(hex.slice(3, 5), 16);
35
+ const blue = parseInt(hex.slice(5, 7), 16);
36
+ return `rgb(${red}, ${green}, ${blue})`;
37
+ }
38
+ function rgbToHex(rgb) {
39
+ if (rgb.includes("NaN"))
40
+ return "";
41
+ if (rgb.includes("#"))
42
+ return rgb;
43
+ const [red, green, blue] = rgb.match(/\d+/g).map(Number);
44
+ return `#${((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1).toUpperCase()}`;
45
+ }
46
+ return (_ctx, _cache) => {
47
+ return vue.openBlock(), vue.createElementBlock("input", {
48
+ class: "color-picker-input",
49
+ type: "color",
50
+ value: color.value,
51
+ onInput: updateColor
52
+ }, null, 40, _hoisted_1);
53
+ };
54
+ }
55
+ });
56
+ module.exports = _sfc_main;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var component = require("./component.js");
3
+ const colorPalette = Object.assign(component, {
4
+ install: (app) => {
5
+ app.component(component.name, component);
6
+ }
7
+ });
8
+ module.exports = colorPalette;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ require("./index.css");
@@ -0,0 +1,35 @@
1
+ .color-palette-container .color-radio-group {
2
+ overflow: hidden;
3
+ }
4
+ .color-palette-container .color-radio-group .arco-radio-button {
5
+ width: 32px;
6
+ height: 32px;
7
+ padding: 0;
8
+ font-size: 0 !important;
9
+ overflow: hidden !important;
10
+ background: transparent !important;
11
+ border-width: 0 !important;
12
+ box-shadow: none !important;
13
+ position: relative;
14
+ }
15
+ .color-palette-container .color-radio-group .arco-radio-button.arco-radio-checked::after {
16
+ box-sizing: content-box;
17
+ content: '';
18
+ border: 2px solid #fff;
19
+ border-left: 0;
20
+ border-top: 0;
21
+ height: 11px;
22
+ left: 12px;
23
+ position: absolute;
24
+ top: 7px;
25
+ transform: rotate(45deg) scaleY(1);
26
+ width: 5px;
27
+ transition: transform 0.15s ease-in 0.05s;
28
+ transform-origin: center;
29
+ }
30
+ .color-palette-container .color-picker-input {
31
+ width: 32px;
32
+ height: 32px;
33
+ padding: 0 2px;
34
+ border: none;
35
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ require("./index.less");
@@ -0,0 +1,40 @@
1
+ @radio-button-size: 32px;
2
+ .color-palette-container {
3
+ .color-radio-group {
4
+ overflow: hidden;
5
+ .arco-radio-button {
6
+ width: @radio-button-size;
7
+ height: @radio-button-size;
8
+ padding: 0;
9
+ font-size: 0 !important;
10
+ overflow: hidden !important;
11
+ background: transparent !important;
12
+ border-width: 0 !important;
13
+ box-shadow: none !important;
14
+ position: relative;
15
+ &.arco-radio-checked {
16
+ &::after {
17
+ box-sizing: content-box;
18
+ content: '';
19
+ border: 2px solid #fff;
20
+ border-left: 0;
21
+ border-top: 0;
22
+ height: 11px;
23
+ left: 12px;
24
+ position: absolute;
25
+ top: 7px;
26
+ transform: rotate(45deg) scaleY(1);
27
+ width: 5px;
28
+ transition: transform 0.15s ease-in 0.05s;
29
+ transform-origin: center;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ .color-picker-input {
35
+ width: @radio-button-size;
36
+ height: @radio-button-size;
37
+ padding: 0 2px;
38
+ border: none;
39
+ }
40
+ }
package/lib/index.css CHANGED
@@ -3856,3 +3856,38 @@
3856
3856
  .doc-tags-thumb-popver .doc-tags-thumb-ul img + img {
3857
3857
  margin-left: 2px;
3858
3858
  }
3859
+ .color-palette-container .color-radio-group {
3860
+ overflow: hidden;
3861
+ }
3862
+ .color-palette-container .color-radio-group .arco-radio-button {
3863
+ width: 32px;
3864
+ height: 32px;
3865
+ padding: 0;
3866
+ font-size: 0 !important;
3867
+ overflow: hidden !important;
3868
+ background: transparent !important;
3869
+ border-width: 0 !important;
3870
+ box-shadow: none !important;
3871
+ position: relative;
3872
+ }
3873
+ .color-palette-container .color-radio-group .arco-radio-button.arco-radio-checked::after {
3874
+ box-sizing: content-box;
3875
+ content: '';
3876
+ border: 2px solid #fff;
3877
+ border-left: 0;
3878
+ border-top: 0;
3879
+ height: 11px;
3880
+ left: 12px;
3881
+ position: absolute;
3882
+ top: 7px;
3883
+ transform: rotate(45deg) scaleY(1);
3884
+ width: 5px;
3885
+ transition: transform 0.15s ease-in 0.05s;
3886
+ transform-origin: center;
3887
+ }
3888
+ .color-palette-container .color-picker-input {
3889
+ width: 32px;
3890
+ height: 32px;
3891
+ padding: 0 2px;
3892
+ border: none;
3893
+ }
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@ var index$g = require("./selectThumb/index.js");
21
21
  var index$h = require("./editMetaInfo/index.js");
22
22
  var index$i = require("./baseFilter/index.js");
23
23
  var index$j = require("./dataTags/index.js");
24
+ var index$k = require("./colorPalette/index.js");
24
25
  exports["default"] = components;
25
26
  exports.appCenter = index;
26
27
  exports.messageBox = index$1;
@@ -42,3 +43,4 @@ exports.selectThumb = index$g;
42
43
  exports.editMetaInfo = index$h;
43
44
  exports.baseFilter = index$i;
44
45
  exports.dataTags = index$j;
46
+ exports.colorPalette = index$k;
package/lib/index.less CHANGED
@@ -19,3 +19,4 @@
19
19
  @import './editMetaInfo/style/index.less';
20
20
  @import './baseFilter/style/index.less';
21
21
  @import './dataTags/style/index.less';
22
+ @import './colorPalette/style/index.less';
@@ -7,6 +7,7 @@ var component$1 = require("../imageCrop/component.js");
7
7
  var card = require("./components/card.js");
8
8
  var colorPalette = require("./components/colorPalette.js");
9
9
  var config = require("../config.js");
10
+ var index = require("../utils/index.js");
10
11
  const _hoisted_1 = {
11
12
  key: 0,
12
13
  class: "star"
@@ -236,14 +237,14 @@ const _sfc_main = vue.defineComponent({
236
237
  tempThumbFiles.value.push(data);
237
238
  submitCallback(tempThumbFiles.value);
238
239
  };
239
- const changeThumbType = (type, index) => {
240
+ const changeThumbType = (type, index2) => {
240
241
  tempThumbFiles.value = [];
241
242
  thumbBannerModel.value = type;
242
- thumbOptionIndex.value = index;
243
+ thumbOptionIndex.value = index2;
243
244
  };
244
- const openDialogMediaSelection = (type, index) => {
245
+ const openDialogMediaSelection = (type, index2) => {
245
246
  thumbBannerModel.value = type || "thumb";
246
- thumbOptionIndex.value = index || 0;
247
+ thumbOptionIndex.value = index2 || 0;
247
248
  dialogMediaSelectionShow.value = true;
248
249
  };
249
250
  const docSeriesShowTopThemeColor = vue.computed(() => {
@@ -280,9 +281,27 @@ const _sfc_main = vue.defineComponent({
280
281
  styleData.value.data = temp;
281
282
  } else if (thumbBannerModel.value === "banner") {
282
283
  styleData.value.banner_url = data[0].url;
284
+ const getColors = index.getThemeColor(BASE_API, data[0].url);
285
+ getColors.then((themes) => {
286
+ styleData.value.banner_colorList = JSON.parse(JSON.stringify(themes));
287
+ styleData.value.banner_theme_color = `rgb(${themes[1]})`;
288
+ callback(styleData.value);
289
+ }).catch((e) => {
290
+ styleData.value.banner_theme_color = `rgb(255, 255, 255)`;
291
+ callback(styleData.value);
292
+ });
283
293
  } else {
284
294
  styleData.value.top_image_url = data[0].url;
285
295
  styleData.value.pc_banner_url = data[0].url;
296
+ const getColors = index.getThemeColor(BASE_API, data[0].url);
297
+ getColors.then((themes) => {
298
+ styleData.value.top_colorList = JSON.parse(JSON.stringify(themes));
299
+ styleData.value.top_theme_color = `rgb(${themes[1]})`;
300
+ callback(styleData.value);
301
+ }).catch((e) => {
302
+ styleData.value.top_theme_color = `rgb(255, 255, 255)`;
303
+ callback(styleData.value);
304
+ });
286
305
  }
287
306
  callback(styleData.value);
288
307
  dialogMediaSelectionShow.value = false;
@@ -390,40 +409,40 @@ const _sfc_main = vue.defineComponent({
390
409
  ], 4)) : vue.createCommentVNode("v-if", true),
391
410
  vue.createElementVNode("div", _hoisted_3, [
392
411
  ["thumbs"].includes(_ctx.mode) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4, [
393
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(thumbsLengthList.value, (item, index) => {
412
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(thumbsLengthList.value, (item, index2) => {
394
413
  return vue.openBlock(), vue.createBlock(card, {
395
- key: index,
396
- id: `thumb-card-${index}`,
397
- data: thumbList.value[index],
398
- "onUpdate:data": ($event) => thumbList.value[index] = $event,
414
+ key: index2,
415
+ id: `thumb-card-${index2}`,
416
+ data: thumbList.value[index2],
417
+ "onUpdate:data": ($event) => thumbList.value[index2] = $event,
399
418
  parentRef: selectThumbRef.value,
400
- idx: index,
419
+ idx: index2,
401
420
  "preview-list": previewList.value,
402
421
  "thumb-model": "thumb",
403
422
  onFileForShowThumb: fileForShowThumb,
404
423
  onChangeThumbType: changeThumbType,
405
424
  onUploadLocal: _cache[0] || (_cache[0] = (cb) => _ctx.$emit("upload", cb)),
406
- onOpen: ($event) => openDialogMediaSelection($event, index)
425
+ onOpen: ($event) => openDialogMediaSelection($event, index2)
407
426
  }, null, 8, ["id", "data", "onUpdate:data", "parentRef", "idx", "preview-list", "onOpen"]);
408
427
  }), 128))
409
428
  ])) : currentModel.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
410
429
  vue.createCommentVNode(" \u5C01\u9762\u56FEcard "),
411
430
  vue.createElementVNode("div", _hoisted_5, [
412
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(currentModel.value.maxLength, (item, index) => {
431
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(currentModel.value.maxLength, (item, index2) => {
413
432
  return vue.openBlock(), vue.createBlock(card, {
414
- key: index,
415
- id: `thumb-card-${index}`,
416
- data: thumbList.value[index],
417
- "onUpdate:data": ($event) => thumbList.value[index] = $event,
433
+ key: index2,
434
+ id: `thumb-card-${index2}`,
435
+ data: thumbList.value[index2],
436
+ "onUpdate:data": ($event) => thumbList.value[index2] = $event,
418
437
  parentRef: selectThumbRef.value,
419
438
  model: model.value,
420
- idx: index,
439
+ idx: index2,
421
440
  "preview-list": previewList.value,
422
441
  "thumb-model": "thumb",
423
442
  onFileForShowThumb: fileForShowThumb,
424
443
  onChangeThumbType: changeThumbType,
425
444
  onUploadLocal: _cache[1] || (_cache[1] = (cb) => _ctx.$emit("upload", cb)),
426
- onOpen: ($event) => openDialogMediaSelection($event, index)
445
+ onOpen: ($event) => openDialogMediaSelection($event, index2)
427
446
  }, null, 8, ["id", "data", "onUpdate:data", "parentRef", "model", "idx", "preview-list", "onOpen"]);
428
447
  }), 128))
429
448
  ])
@@ -443,9 +462,9 @@ const _sfc_main = vue.defineComponent({
443
462
  onChange: modelChange
444
463
  }, {
445
464
  default: vue.withCtx(() => [
446
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(modelList.value, (item, index) => {
465
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(modelList.value, (item, index2) => {
447
466
  return vue.openBlock(), vue.createBlock(vue.unref(webVue.Radio), {
448
- key: index,
467
+ key: index2,
449
468
  value: item.value
450
469
  }, {
451
470
  default: vue.withCtx(() => [
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  var dayjs = require("dayjs");
4
+ var ColorThief = require("colorthief");
5
+ var api = require("../imageCrop/script/api.js");
6
+ var config = require("../config.js");
4
7
  function _interopDefaultLegacy(e) {
5
8
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
6
9
  }
7
10
  var dayjs__default = /* @__PURE__ */ _interopDefaultLegacy(dayjs);
11
+ var ColorThief__default = /* @__PURE__ */ _interopDefaultLegacy(ColorThief);
8
12
  const dateYYYYDDMMHHmm = (date) => {
9
13
  if (!date)
10
14
  return "--";
@@ -66,8 +70,54 @@ const validateForm = (formRef) => {
66
70
  }
67
71
  });
68
72
  };
73
+ function getRealUrl(BASE_API, url) {
74
+ return new Promise((resove, reject) => {
75
+ try {
76
+ const flag = !url.includes("/poplar/v2");
77
+ const cape = url.includes("cape/v1/upload");
78
+ const extented = !url.includes(BASE_API) && !url.includes(config.DEFAULT_UPLOAD_URL);
79
+ if (flag || extented || cape) {
80
+ resove(url);
81
+ } else {
82
+ api.getFileRealUrl(BASE_API, url).then((res) => {
83
+ resove(res.message);
84
+ });
85
+ }
86
+ } catch (e) {
87
+ reject(e);
88
+ }
89
+ });
90
+ }
91
+ function getThemeColor(BASE_API, src) {
92
+ return new Promise((resolve, reject) => {
93
+ const getUrl = getRealUrl(BASE_API, src);
94
+ getUrl.then((url) => {
95
+ const colorThief = new ColorThief__default["default"]();
96
+ const img = document.createElement("img");
97
+ img.crossOrigin = "Anonymous";
98
+ img.setAttribute("src", `${url}?t=${+new Date()}`);
99
+ img.onload = () => {
100
+ let themeColors = [];
101
+ const getResult = colorThief.getPalette(img);
102
+ if (getResult) {
103
+ themeColors = getResult.slice(0, 6);
104
+ } else {
105
+ themeColors = [[255, 255, 255]];
106
+ }
107
+ resolve(themeColors);
108
+ };
109
+ img.onerror = (e) => {
110
+ reject(e);
111
+ };
112
+ }).catch((e) => {
113
+ reject(e);
114
+ });
115
+ });
116
+ }
69
117
  exports.dateYYYYDDMMHHmm = dateYYYYDDMMHHmm;
70
118
  exports.generateUUID = generateUUID;
119
+ exports.getRealUrl = getRealUrl;
120
+ exports.getThemeColor = getThemeColor;
71
121
  exports.noCoverText = noCoverText;
72
122
  exports.replaceSuffix = replaceSuffix;
73
123
  exports.timeFormat = timeFormat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmstops/pro-compo",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "vue",