
import { toBase64 } from '@/utils/file'
import Vue from 'vue'

export const minIOSrc = (fileName) => {
  const baseUrl = window?.g?.VUE_APP_MINIO_PUBLIC_URL ?? process.env.VUE_APP_MINIO_PUBLIC_URL
  if (!baseUrl || !Vue.prototype.$previewApi) return ''
  const url = `${baseUrl.replace(/\/$/, '')}/${fileName}`
  return `${Vue.prototype.$previewApi}/onlinePreview?url=${encodeURIComponent(toBase64(url))}`
}
