free-fe-core-modules 0.0.41 → 0.0.42

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.
@@ -19,12 +19,11 @@
19
19
  </div>
20
20
  </template>
21
21
  </q-img>
22
- <!-- <q-icon v-else :name="ctx.config.defaultIcon">he</q-icon> -->
23
22
  </span>
24
23
  </template>
25
24
 
26
25
  <script>
27
- import { defineComponent } from 'vue';
26
+ import { ref, computed, defineComponent, getCurrentInstance, watchEffect, nextTick } from 'vue';
28
27
 
29
28
  export default defineComponent({
30
29
  name: 'EIcon',
@@ -36,28 +35,38 @@ export default defineComponent({
36
35
  hideError: { type: Boolean, default: false },
37
36
  defaultSize: { type: String, default: '@2x' },
38
37
  },
39
- computed: {
40
- isIcon() {
41
- return this.name && (typeof this.name === 'string') && (this.name.startsWith('img:') || this.name.indexOf('/') < 0);
42
- },
43
- imgPath() {
44
- if (typeof this.name !== 'string' || !this.name) return '';
38
+ setup(props) {
39
+ const { proxy:vm } = getCurrentInstance();
45
40
 
46
- if (this.name.startsWith('data:')) return this.name;
41
+ const imgPath = ref('');
42
+ watchEffect(() => {
43
+ if (typeof props.name !== 'string' || !props.name) return '';
47
44
 
48
- if (this.name.startsWith('http://')) return this.name;
45
+ if (props.name.startsWith('data:')) return props.name;
49
46
 
50
- if (this.name.startsWith('https://')) return this.name;
47
+ if (props.name.startsWith('http://')) return props.name;
51
48
 
52
- if (this.name.startsWith('blob:')) return this.name;
49
+ if (props.name.startsWith('https://')) return props.name;
50
+
51
+ if (props.name.startsWith('blob:')) return props.name;
53
52
 
54
53
  // TODO:默认使用二倍图?
55
- if (this.relative) return `images/${this.name}${this.defaultSize}.png`;
54
+ if (props.relative) return `images/${props.name}${props.defaultSize}.png`;
55
+
56
+ const ret = props.thumb
57
+ ? vm.$filter('serverThumb', props.name)
58
+ : vm.$filter('serverImage', props.name);
59
+
60
+ // 某些情况下不能及时显示缩略图,延迟设置图片路径
61
+ setTimeout(() => {
62
+ imgPath.value = ret;
63
+ }, 200);
64
+ })
56
65
 
57
- return this.thumb
58
- ? this.$filter('serverThumb', this.name)
59
- : this.$filter('serverImage', this.name);
60
- },
66
+ return {
67
+ isIcon: computed(() => props.name && (typeof props.name === 'string') && (props.name.startsWith('img:') || props.name.indexOf('/') < 0)),
68
+ imgPath,
69
+ };
61
70
  },
62
71
  });
63
72
  </script>
@@ -62,7 +62,7 @@
62
62
  >
63
63
  <q-uploader-add-trigger />
64
64
  </q-btn>
65
-
65
+
66
66
  <div v-else-if="(Field.onlyIcon || onlyIcon) && fieldData.value && fieldData.value[0]?.id">
67
67
  <q-img
68
68
  :src="$filter('serverThumb', `${fieldData.value[0].id}`)"
@@ -187,9 +187,9 @@
187
187
 
188
188
  <script>
189
189
  import { defineComponent, getCurrentInstance, ref } from 'vue';
190
- import { useFreeField, freeFieldProps } from '../composible/useFreeField';
191
- import { useFormValidator} from '../../composible/useFormValidator';
192
- import { useUploader } from '../composible/useUploader';
190
+ import { useFreeField, freeFieldProps } from 'free-fe-core-modules/free-field/composible/useFreeField';
191
+ import { useFormValidator} from 'free-fe-core-modules/composible/useFormValidator';
192
+ import { useUploader } from 'free-fe-core-modules/free-field/composible/useUploader';
193
193
 
194
194
  export default defineComponent({
195
195
  name: 'InputFieldImage',
@@ -333,17 +333,16 @@ export default defineComponent({
333
333
  factoryFn,
334
334
  uploaded,
335
335
 
336
- removeFile: () => {
336
+ removeFile: (files = []) => {
337
337
  setFieldData([], emit);
338
338
  selfValidate();
339
+
340
+ uploader.value.files = uploader.value.files.filter((f) => {
341
+ return files.findIndex((file) => file.name === f.name && file.size === f.size) < 0;
342
+ });
339
343
  },
340
344
  };
341
345
  },
342
- // methods: {
343
- // fileAdded(files) {
344
- // this.$refs.uploader.files = files;
345
- // },
346
- // },
347
346
  });
348
347
  </script>
349
348
 
@@ -340,10 +340,14 @@ export default defineComponent({
340
340
  return fieldData.value?.length < props.Field?.Options?.MaxCount;
341
341
  }),
342
342
  dense: computed(() => props.Field?.dense || props.Field?.Options?.Dense),
343
- removeFile: (files) => {
343
+ removeFile: (files = []) => {
344
344
  localFiles.value = localFiles.value.filter((f) => !files.includes(f));
345
345
  setFieldData(fieldData.value.filter((f) => !files.includes(f)), emit);
346
346
  selfValidate();
347
+
348
+ uploader.value.files = uploader.value.files.filter((f) => {
349
+ return files.findIndex((file) => file.name === f.name && file.size === f.size) < 0;
350
+ });
347
351
  },
348
352
  };
349
353
  },
@@ -297,6 +297,9 @@ export function useUploader(props, ctx) {
297
297
  filePreview,
298
298
 
299
299
  filesRejected (rejectedEntries) {
300
+ // 忽略duplicate错误
301
+ rejectedEntries = rejectedEntries.filter((entry) => entry.failedPropValidation !== 'duplicate');
302
+
300
303
  if (rejectedEntries && rejectedEntries.length > 0) {
301
304
  const fName = rejectedEntries[0] && rejectedEntries[0].file && rejectedEntries[0].file.name;
302
305
  const fSize = fileSizeNumberToStr(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",