当前位置: 首页 > wzjs >正文

wordpress删除页头页尾seo报名在线咨询

wordpress删除页头页尾,seo报名在线咨询,医院网站源码asp,新手学做网站cs5版视频目录 前言 1.安装库 2.预览文件子组件代码 3、新建store/system.ts 4、父页面进行使用 总结 前言 纯前端处理文件预览,包含excel、word、ppt、txt等格式,不需要后端服务器进行部署,并且内网也可以使用。 1.安装库 npm install vue-offi…

目录

前言

1.安装库

2.预览文件子组件代码

3、新建store/system.ts

4、父页面进行使用

总结


前言

 纯前端处理文件预览,包含excel、word、ppt、txt等格式,不需要后端服务器进行部署,并且内网也可以使用。

 


1.安装

npm install @vue-office/docx @vue-office/excel @vue-office/pdf
# 或
yarn add @vue-office/docx @vue-office/excel @vue-office/pdf

2.预览文件子组件代码

<template><div class="fileView"><n-modal v-model:show="fileViewVisible"><n-cardstyle="width: 65%;position: fixed;top: 50px;left: 50%;transform: translateX(-50%);":title="sysStore.fileViewInfo.name":bordered="true"size="medium"role="dialog"aria-modal="true"><template #header-extra><n-button circle @click="fileViewVisible = false"><template #icon><n-icon><Close /></n-icon></template></n-button></template><div><iframev-if="sysStore.fileViewInfo.fileType === 'txt'"style="width: 100%; height: calc(100vh - 190px)":src="sysStore.fileViewInfo.viewUrl"frameborder="0"></iframe><vue-office-pdfv-if="sysStore.fileViewInfo.fileType === 'pdf'"style="width: 100%; height: calc(100vh - 180px)":src="sysStore.fileViewInfo.viewUrl"frameborder="0"></vue-office-pdf><vue-office-docxv-if="sysStore.fileViewInfo.fileType === 'doc'"style="width: 100%; height: calc(100vh - 180px)":src="sysStore.fileViewInfo.viewUrl"frameborder="0"></vue-office-docx><vue-office-excelv-if="sysStore.fileViewInfo.fileType === 'xlsx'"style="width: 100%; height: calc(100vh - 180px)":src="sysStore.fileViewInfo.viewUrl"frameborder="0"></vue-office-excel></div></n-card></n-modal></div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import useSystemStore from "@/store/system";
import { Close } from "@vicons/ionicons5";
// 引入VueOffice组件
import VueOfficeDocx from "@vue-office/docx";
import VueOfficeExcel from "@vue-office/excel";
import VueOfficePdf from "@vue-office/pdf";
// 引入相关样式
import "@vue-office/docx/lib/index.css";
import "@vue-office/excel/lib/index.css";const sysStore = useSystemStore();const fileViewVisible = ref(false);const show = () => {fileViewVisible.value = true;
};// 监听外部变化
watch(() => props.visible, (newVal) => {fileViewVisible.value = newValue
}, {immediate: true
})
// 暴漏show给父组件使用
defineExpose({show,
});
</script>
<style lang="less" scoped></style>

 

3、新建store/system.ts

代码如下:

import { defineStore } from "pinia";interface State {fileViewInfo: any; // 文件预览信息
}const useSystemStore = defineStore("system", {state: (): State => ({fileViewInfo: {},}),actions: {setFileViewInfo(val: any) {this.fileViewInfo = val;},},
});export default useSystemStore;

4、父页面进行使用

<template><n-space class="file-view" style="gap: 8px 8px" :inline="true"><divclass="file-item"v-for="(file, index) in fileComp":key="index"@click="fileView(file)"><div class="file-icon"><img width="28" :src="file.iconIamge" alt="" /></div></div></n-space><FilePreviewDialog v-model:visible="obj.showDialog" ref="filePreviewDialogRef" />
</template>
<script lang="ts" setup>import { computed, ref } from "vue";
// 以下icon是不同后缀名的文件图片 可要可不要
import excelImg from "@/assets/images/fileIcon/excel.png";
import pdfImg from "@/assets/images/fileIcon/pdf.png";
import wordImg from "@/assets/images/fileIcon/word.png";
import textImg from "@/assets/images/fileIcon/text.png";
import unknownImg from "@/assets/images/fileIcon/unknown.png";
import { getFileSize } from "@/utils/useFunc";
import useSystemStore from "@/store/system";
import FilePreviewDialog from "@/components/FilePreviewDialog.vue";const filePreviewDialogRef = ref<any>();
const props = defineProps({files: {type: [Object,Array],required: true,},role: {type: String,},
});// 引入vuex
const sysStore = useSystemStore();// 文件信息
const obj = reactive({showDialog: false, // 是否展示附件fileUrl: [] // 附件地址
})const getIcon = (type: string) => {type = type.toLowerCase();let fileType: "doc" | "pdf" | "xlsx" | "txt" | "" = "";let iconIamge = "";const docMap = ["doc","docx","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document",];const pdfMap = ["application/pdf", "pdf"];const xlsxMap = ["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","xls","xlsx",];const textMap = ["txt", "text/plain", "text"];if (docMap.includes(type)) {fileType = "doc";iconIamge = wordImg;} else if (pdfMap.includes(type)) {fileType = "pdf";iconIamge = pdfImg;} else if (xlsxMap.includes(type)) {fileType = "xlsx";iconIamge = excelImg;} else if (textMap.includes(type)) {fileType = "txt";iconIamge = textImg;} else {fileType = "";iconIamge = unknownImg;}return {fileType,iconIamge: iconIamge,};
};// 获取文件数据
const fileView = async(item) => {
const {id} = item
const res = await getPolicy(id)
const {url,name,size,mime_type} = res.data
// 这里拿到的数据:url:完整的url文件流地址// name: 文件名//size: 文件字节大小// mime_type: 文件对应的类型 譬如txt对应 text/plain
// 获取文件后缀类型
const {fileType} = getIcon(mime_type)
const fileInfo = {name,fileType,type: mime_type,size,viewUrl: url
}// 更新文件信息sysStore.setFileViewInfo(fileInfo);
// 先关闭
obj.showDialog = false
// 确保dom更新后再次打卡
await nextTick()
obj.showDialog = true
};</script><style lang="less" scoped>
.file-view {.file-item {display: flex;align-items: center;border: 1px solid var(--baseColor);padding: 8px;cursor: pointer;min-width: 240px;max-width: 300px;border-radius: 5px;.file-icon {margin-right: 5px;}.file-info {max-width: calc(100% - 28px);.file-size {font-size: var(--fontSizeSmall);}}}
}
</style>

总结

记录一下 希望能帮助到你

http://www.dtcms.com/wzjs/218221.html

相关文章:

  • 网站如何做域名解析镇海seo关键词优化费用
  • 网站有权重但是没访问海外引流推广平台
  • 宁波网络推广运营公司电话长沙百度首页优化排名
  • 烟台专业做网站的公司网站推广的方法
  • 网站做编辑赚钱竞价推广账户竞价托管公司
  • 关于网站建设新闻临沂seo公司
  • 阳泉网站建设公司卖友情链接赚钱
  • 西安网站开发培训杭州seo关键词优化公司
  • 中山市网站建设公司深圳网站开发技术
  • 视频网站 移动 模板网络推广都有什么方式
  • 网站开发求职信成都新闻最新消息
  • 网站封面制作实体店怎么引流推广
  • 什么是单页网站宁波抖音seo搜索优化软件
  • 襄阳微网站建设企业网络推广最简单方法
  • 做seo推广网站在线咨询小广告模板
  • 简述网站建设基本流程中文域名的网站
  • 中铁建设集团官方网站产品推广营销
  • sem论坛论坛优化seo
  • 网站建设通知产品代理推广方案
  • 建设银行新版网站上线百度seo优化教程
  • 网站页面结构苏州网站建设制作公司
  • 澳门网站开发招聘今日热点头条
  • 自己做网站怎么挣钱人工智能培训班
  • 网站如何做响应式布局灯塔网站seo
  • 班级网站建设毕业设计开题报告成人教育培训机构
  • 网站建设方案策划书广州网站优化公司
  • java做网站好吗网络广告发布
  • 论坛型网站 建站知乎怎么申请关键词推广
  • net域名大网站推广普通话手抄报内容50字
  • b2b做外贸网站seo关键词外包