admin 管理员组

文章数量: 887021


const onlineViewFile = (url) => {
  if (url) {
    // 获取文件格式
    const getFileFormatFun = (getFileFormatFunUrl) => {
      console.log(175555, getFileFormatFunUrl);
      const getInUrl = getFileFormatFunUrl;
      const urlArr = (getInUrl || '').split('/') || [];
      const urlArrLast = urlArr[urlArr.length - 1] || '';
      const urlArrLastArr = (urlArrLast || '').split('.') || [];
      const fileFormatStr = urlArrLastArr[urlArrLastArr.length - 1] || '';
      return fileFormatStr;
    };
    if (['doc', 'docx', 'xlsx', 'xls'].includes(getFileFormatFun(url))) {
      const officeUrl = `https://view.officeapps.live/op/view.aspx?src=${url}`;
      window.open(officeUrl, url, 'width=1100,height=768');
      console.log(18666, officeUrl);
    } else {
      window.open(url, url, 'width=800,height=700');
    }
  } else {
    console.error('缺少查看文件地址', url);
  }
};




export {
  onlineViewFile
}

本文标签: 在线 浏览器 常见 格式