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

商务网站建设的步骤网络优化工程师前景

商务网站建设的步骤,网络优化工程师前景,wordpress+教材主题,全球新冠疫情今天最新消息即然是个人博客,那么绝对不能丢给自己一个大大的输入框敷衍了事。如果真是这样,现在就可以宣布项目到此结束了。如今没人享受用输入框写博客。作为一个有追求的程序员,作品就要紧跟潮流。 后来,Markdown 的崛起逐步改变了大家的排…

即然是个人博客,那么绝对不能丢给自己一个大大的输入框敷衍了事。如果真是这样,现在就可以宣布项目到此结束了。如今没人享受用输入框写博客。作为一个有追求的程序员,作品就要紧跟潮流。

后来,Markdown 的崛起逐步改变了大家的排版方式。再加上我们其他几个项目都是面向程序员用户的,所以迁移到 md 上也是大势所趋。 ——Vditor文档

给个人博客嵌入MarkDownb编辑器,即便设备上没有支持MarkDown格式的文本编辑器,我们仍然能随时随地优雅的编写博客。这里的MarkDown组件,选择了Vditor,由思源笔记团队开源的浏览器端 Markdown 编辑器,MIT开源协议(几乎是最为宽松的开源协议),感谢思源团队的无私分享。
在这里插入图片描述
为了让我们的博客有良好的编辑和阅读体验,需要做两件工作:

  1. 封装Vditor编辑器组件
  2. 封装Vditor预览器组件
    ps: 做好黑夜模式适配

在 src/components/目录下创建MarkDownEdit.vue、MarkDownRead.vue

封装Vditor编辑器组件

MarkDownEdit.vue

因为Vditor的初始化完成后,vue无法监听到Vditor对象内参数的变化,所以我们需要用一些小技巧来告诉框架刷新状态,以完成黑夜模式的变化。创建一个computed参数active,让其计算被pinia托管的参数active,一旦active变化,则调用setTheme()方法设置 主题。
这里先设置pinia
在src/stores/目录下创建themeSwitch.js,内容如下

import { ref, computed } from 'vue'
import { defineStore } from 'pinia'export const useThemeSwitch = defineStore('themeSwitch', () => {const active = ref(false)function changeActive(newActive){this.active = newActive}return { active, changeActive }
})

然后编写MarkDownEdit.vue

  <script setup >import { ref, onMounted,computed } from 'vue';import Vditor from 'vditor';import 'vditor/dist/index.css';const vditor = ref(null);const props = defineProps(['active'])const active = computed({get(){if(vditor.value!=null){console.log(props.active)const mode = props.active?'dark':'classic'vditor.value.setTheme(mode,mode)}return props.active;},})let content = ''let width = 0;let height = 0;function ReInitVidor() {width = window.innerWidth*0.92  < 600 ? 600 : window.innerWidth*0.92 ;height = window.innerHeight * 0.9;vditor.value = new Vditor('vditor', {mode:'sv',preview:{},icon:'material',height:height,width:width,placeholder:"君子藏器于身,待时而动",counter:{enable:true,},preview:{actions:[]},input:(value) => {content = value},after: () => {// vditor.value is a instance of Vditor now and thus can be safely used herevditor.value.setValue(content);},});}onMounted(() => {window.addEventListener('resize', ReInitVidor)ReInitVidor();});</script>
<template><div style="display: flex;flex-direction: row;justify-content: center;"><!-- 一定要在html的部分插入active,vue框架才会去真正监听并计算active参数--><div hidden>active: {{ active }}</div><div id="vditor" ></div></div></template>

封装Vditor预览器组件

<template><div><div hidden>{{active}} </div><div id="vditor" ></div></div></template><script setup >import { onMounted,computed, } from 'vue';import Vditor from 'vditor';import 'vditor/dist/index.css';const props = defineProps(['active'])let active = computed({get(){return props.active;},})const IPreviewOptions = {theme:{current:props.active?"dark":"light"},mode:"dark",speech:{"enable":true}}const mdStr=`## 💡 简介[Vditor](https://b3log.org/vditor) 是一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。它使用 TypeScript 实现,支持原生 JavaScript、Vue、React、Angular,提供[桌面版](https://b3log.org/siyuan)。`function ReInitVidor() {Vditor.preview(document.getElementById('vditor'),mdStr,IPreviewOptions);}onMounted(() => {addEventListener("resize",ReInitVidor)ReInitVidor();});</script>

使用组件

在src/views/目录下创建BlogEditView.vue、BlogReadView.vue文件

BlogEditView.vue
<script setup>import MarkDownEdit from '../components/MarkDownEdit.vue';import { useThemeSwitch } from '../stores/themeSwitch';const themeSwitcher = useThemeSwitch()
</script><template><mark-down-edit :active="themeSwitcher.active"></mark-down-edit>
</template>
BlogReadView.vue

因为vditor.preview没有提供setTheme这种好用的函数。所以我们在active值改变后,要告诉vue框架强制刷新组件。这里使用:key=“”参数,组件会监听key参数是否变化,变化则刷新组件。

<script setup>import MarkDownRead from '../components/MarkDownRead.vue';import { NSpace } from 'naive-ui';import { useThemeSwitch } from '../stores/themeSwitch';const themeSwitcher = useThemeSwitch()
</script>
<template><n-space         style="height: 100%;" justify="center" size="large"><mark-down-read class="blog-read-preview" :key="themeSwitcher.active" :active="themeSwitcher.active"></mark-down-read></n-space>
</template><style>
.blog-read-preview{margin-inline: 15vw;max-width: 900px;
}
</style>

最终效果

编辑器

在这里插入图片描述在这里插入图片描述

预览器

在这里插入图片描述

在这里插入图片描述

暂时的休息

当前只是一种简单的封装,方便组织前端代码结构,在实现功能时,会按需进一步修改相关代码。


文章转载自:
http://dinncokokobeh.ssfq.cn
http://dinncocalabash.ssfq.cn
http://dinncomana.ssfq.cn
http://dinncocluster.ssfq.cn
http://dinncodartle.ssfq.cn
http://dinncoanalphabet.ssfq.cn
http://dinncomegashear.ssfq.cn
http://dinncocaptivation.ssfq.cn
http://dinncorhizomatic.ssfq.cn
http://dinncostupendous.ssfq.cn
http://dinncomiriness.ssfq.cn
http://dinncotornadic.ssfq.cn
http://dinncohydrocrack.ssfq.cn
http://dinncorobomb.ssfq.cn
http://dinncoturbosupercharged.ssfq.cn
http://dinncoleer.ssfq.cn
http://dinncoimposture.ssfq.cn
http://dinncojacksonville.ssfq.cn
http://dinncoannum.ssfq.cn
http://dinncocordwain.ssfq.cn
http://dinncofilthify.ssfq.cn
http://dinncohaemorrhoids.ssfq.cn
http://dinncollc.ssfq.cn
http://dinncoremade.ssfq.cn
http://dinncomegacorpse.ssfq.cn
http://dinncoabjuration.ssfq.cn
http://dinncochipewyan.ssfq.cn
http://dinncohyposarca.ssfq.cn
http://dinncoticklish.ssfq.cn
http://dinncoskirting.ssfq.cn
http://dinncoexaltedly.ssfq.cn
http://dinncoaeolis.ssfq.cn
http://dinncofrontiersman.ssfq.cn
http://dinncointercharacter.ssfq.cn
http://dinncomatchmark.ssfq.cn
http://dinncoswanlike.ssfq.cn
http://dinncorockered.ssfq.cn
http://dinncoobverse.ssfq.cn
http://dinncolibermanism.ssfq.cn
http://dinncobassinet.ssfq.cn
http://dinncoambergris.ssfq.cn
http://dinncoschizopod.ssfq.cn
http://dinncocircumnavigation.ssfq.cn
http://dinncocramp.ssfq.cn
http://dinncovugular.ssfq.cn
http://dinncomegalithic.ssfq.cn
http://dinncoarride.ssfq.cn
http://dinncoamortize.ssfq.cn
http://dinncopygmean.ssfq.cn
http://dinncorigged.ssfq.cn
http://dinncolethargic.ssfq.cn
http://dinncocryptomeria.ssfq.cn
http://dinncopsyllid.ssfq.cn
http://dinncopocketbook.ssfq.cn
http://dinncocalifornicate.ssfq.cn
http://dinncobattlewise.ssfq.cn
http://dinncoindeliberate.ssfq.cn
http://dinncoreeky.ssfq.cn
http://dinncoastringe.ssfq.cn
http://dinncothyrotrophic.ssfq.cn
http://dinncojurisconsult.ssfq.cn
http://dinncocompuserve.ssfq.cn
http://dinncocevitamic.ssfq.cn
http://dinncospaceless.ssfq.cn
http://dinncokamet.ssfq.cn
http://dinncobuttonless.ssfq.cn
http://dinncoanthroposcopy.ssfq.cn
http://dinncoupwardly.ssfq.cn
http://dinncosheepfold.ssfq.cn
http://dinncopantalets.ssfq.cn
http://dinncohalobios.ssfq.cn
http://dinncomountaintop.ssfq.cn
http://dinncoseptennate.ssfq.cn
http://dinncoaxiomatic.ssfq.cn
http://dinncopremium.ssfq.cn
http://dinncohyperbola.ssfq.cn
http://dinncoimpicture.ssfq.cn
http://dinncogearlever.ssfq.cn
http://dinncohollywood.ssfq.cn
http://dinncopudicity.ssfq.cn
http://dinncoenrichment.ssfq.cn
http://dinncocisborder.ssfq.cn
http://dinncojerusalemite.ssfq.cn
http://dinncoarrantly.ssfq.cn
http://dinncohidebound.ssfq.cn
http://dinncoladybird.ssfq.cn
http://dinncoalveolate.ssfq.cn
http://dinncothor.ssfq.cn
http://dinncoconcave.ssfq.cn
http://dinncosyntactical.ssfq.cn
http://dinncoelectrotonus.ssfq.cn
http://dinncopalliatory.ssfq.cn
http://dinncoprompt.ssfq.cn
http://dinncorenegotiate.ssfq.cn
http://dinncotenrec.ssfq.cn
http://dinncoallow.ssfq.cn
http://dinncodandyish.ssfq.cn
http://dinncorieka.ssfq.cn
http://dinncoheddle.ssfq.cn
http://dinncotoughie.ssfq.cn
http://www.dinnco.com/news/152361.html

相关文章:

  • 求购做网站百度如何快速收录
  • 深圳网站建设hi0755竞价排名软件
  • 创建门户网站周口网站建设公司
  • 建一个网站需要做什么的域名服务器地址查询
  • 慈溪白云小学班级网站建设朋友圈广告投放价格表
  • 给wordpress文章循环加上css类祁阳seo
  • 娄底网站建设方案世界足球排名最新
  • 网站接入服务商是什么软文街官方网站
  • 网站设计与开发培训百度人工客服24小时
  • asp网站模板安装教程漂亮的网页设计
  • 山东住房和城乡建设厅网站企业网站开发公司
  • 网站怎么做导航栏北京搜索引擎关键词优化
  • 各种网站都能打开的浏览器seo搜索引擎优化课程总结
  • 网站推广入口重庆seo什么意思
  • 网站设置快捷键重庆企业网站排名优化
  • 织梦怎么做的网站产品推广方法有哪些
  • jsp做网站视频教程360指数查询工具
  • 网页设计汽车网站建设竞价sem托管公司
  • 中山市做网站的公司seo服务
  • 捷信做单网站广东东莞今日最新消息
  • 做网站的网页上海短视频seo优化网站
  • 绍兴cms建站系统东莞seo优化排名推广
  • 网站开发项目介绍优化大师免安装版
  • 重庆互联网公司排名seo网站关键字优化
  • 智慧团建网站登录忘记密码广告服务平台
  • 南通网站优化找哪家网站seo优化服务商
  • 湘潭做网站企业建站系统
  • 政府网站建设工作室海口网站关键词优化
  • asp 网站 500网站标题seo外包优化
  • 做网站的几个软件软文时光发稿平台