zhangzengfei
2023-10-23 1db7db4bf02259e47d5d906d6b21ecc6451b0a09
src/pages/ai/FileUpload/btn.vue
New file
@@ -0,0 +1,69 @@
<template>
  <label class="uploader-btn" ref="btn" v-show="support">
    <slot></slot>
  </label>
</template>
<script>
import { uploaderMixin, supportMixin } from './common/mixins'
const COMPONENT_NAME = 'uploader-btn'
export default {
  name: COMPONENT_NAME,
  mixins: [uploaderMixin, supportMixin],
  props: {
    directory: {
      type: Boolean,
      default: false
    },
    single: {
      type: Boolean,
      default: false
    },
    attrs: {
      type: Object,
      default() {
        return {}
      }
    },
    sourceType: {
      type: Number,
    }
  },
  mounted() {
    this.uploader.uploader.assignBrowse(this.$refs.btn, this.directory, this.single, this.attrs)
    this.$nextTick(() => {
      let props = {accept:''};
      if(this.sourceType == 1){
        props.accept = '.mp4';
      }else if(this.sourceType == 2){
        props.accept = '.jpg,.jpeg,.png';
      }else if(this.sourceType == 3){
        props.accept = '.tar,.tar.gz,.gz';
      }
      this.uploader.uploader.assignBrowse(this.$refs.btn, this.directory, this.single, this.attrs)
    })
  }
}
</script>
<style>
.uploader-btn {
  display: inline-block;
  position: relative;
  padding: 4px 8px;
  font-size: 100%;
  line-height: 1.4;
  color: #666;
  border: 1px solid #666;
  cursor: pointer;
  border-radius: 2px;
  background: none;
  outline: none;
}
.uploader-btn:hover {
  /* background-color: rgba(0, 0, 0, 0.08); */
}
</style>