(function(e){function t(t){for(var o,a,s=t[0],c=t[1],l=t[2],_=0,d=[];_0&&80!==m&&443!==m,f&&(d.port=m),e.abrupt("return",new Promise((function(e,t){var n=new minio__WEBPACK_IMPORTED_MODULE_19__["Client"](d);try{n.putObject(c,o,_,(function(n){n&&t(n);var r="".concat(s?"https://":"http://").concat(i).concat(f?":"+a:""),l="".concat(r,"/").concat(c,"/").concat(o);e(l)}))}catch(r){t(r)}})));case 8:case"end":return e.stop()}}),e)}))),_minioFileUpload.apply(this,arguments)}function formCustomUpload(e,t){return _formCustomUpload.apply(this,arguments)}function _formCustomUpload(){return _formCustomUpload=Object(_home_runner_work_md_md_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_1__["a"])(Object(_home_runner_work_md_md_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_0__["a"])().mark((function _callee7(content,file){var str;return Object(_home_runner_work_md_md_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_0__["a"])().wrap((function _callee7$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:return str="\n async (CUSTOM_ARG) => {\n ".concat(localStorage.getItem("formCustomConfig"),"\n }\n "),_context7.abrupt("return",new Promise((function(resolve,reject){var exportObj={content:content,file:file,util:{axios:_fetch__WEBPACK_IMPORTED_MODULE_15__["a"],CryptoJS:crypto_js__WEBPACK_IMPORTED_MODULE_17___default.a,OSS:ali_oss__WEBPACK_IMPORTED_MODULE_18___default.a,COS:cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_20___default.a,Buffer:buffer_from__WEBPACK_IMPORTED_MODULE_21___default.a,uuidv4:uuid__WEBPACK_IMPORTED_MODULE_22__["a"],qiniu:qiniu_js__WEBPACK_IMPORTED_MODULE_23__,tokenTools:_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_24__,getDir:getDir,getDateFilename:getDateFilename},okCb:resolve,errCb:reject};eval(str)(exportObj)["catch"]((function(e){console.error(e),reject(e)}))})));case 2:case"end":return _context7.stop()}}),_callee7)}))),_formCustomUpload.apply(this,arguments)}function fileUpload(e,t){var n=localStorage.getItem("imgHost");switch(!n&&localStorage.setItem("imgHost","default"),n){case"aliOSS":return aliOSSFileUpload(e,t.name);case"minio":return minioFileUpload(e,t.name);case"txCOS":return txCOSFileUpload(t);case"qiniu":return qiniuUpload(t);case"gitee":return giteeUpload(e,t.name);case"github":return ghFileUpload(e,t.name);case"formCustom":return formCustomUpload(e,t);default:return ghFileUpload(e,t.name)}}__webpack_exports__["a"]={fileUpload:fileUpload}},4:function(e,t){},"4a2b":function(e,t,n){},"4e00":function(e,t,n){"use strict";n.r(t),n.d(t,"utf16to8",(function(){return o})),n.d(t,"utf8to16",(function(){return r})),n.d(t,"base64encode",(function(){return s})),n.d(t,"base64decode",(function(){return c})),n.d(t,"safe64",(function(){return l}));n("ac1f"),n("5319");function o(e){var t,n,o,r;for(t="",o=e.length,n=0;n=1&&r<=127?t+=e.charAt(n):r>2047?(t+=String.fromCharCode(224|r>>12&15),t+=String.fromCharCode(128|r>>6&63),t+=String.fromCharCode(128|r>>0&63)):(t+=String.fromCharCode(192|r>>6&31),t+=String.fromCharCode(128|r>>0&63));return t}function r(e){var t,n,o,r,i,a;t="",o=e.length,n=0;while(n>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=e.charAt(n-1);break;case 12:case 13:i=e.charCodeAt(n++),t+=String.fromCharCode((31&r)<<6|63&i);break;case 14:i=e.charCodeAt(n++),a=e.charCodeAt(n++),t+=String.fromCharCode((15&r)<<12|(63&i)<<6|(63&a)<<0);break}return t}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",a=new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);function s(e){var t,n,o,r,a,s;o=e.length,n=0,t="";while(n>2),t+=i.charAt((3&r)<<4),t+="==";break}if(a=e.charCodeAt(n++),n==o){t+=i.charAt(r>>2),t+=i.charAt((3&r)<<4|(240&a)>>4),t+=i.charAt((15&a)<<2),t+="=";break}s=e.charCodeAt(n++),t+=i.charAt(r>>2),t+=i.charAt((3&r)<<4|(240&a)>>4),t+=i.charAt((15&a)<<2|(192&s)>>6),t+=i.charAt(63&s)}return t}function c(e){var t,n,o,r,i,s,c;s=e.length,i=0,c="";while(i>4);do{if(o=255&e.charCodeAt(i++),61==o)return c;o=a[o]}while(i>2);do{if(r=255&e.charCodeAt(i++),61==r)return c;r=a[r]}while(i['.concat(e[0],"]: ").concat(e[1],"
"):'['.concat(e[0],"] ").concat(e[1],": ").concat(e[2],"
")}));return e.length?"

引用链接

").concat(e.join("\n"),"

"):""},this.buildAddition=function(){return"\n \n "},this.setOptions=function(e){n.opts=a(n.opts,e)},this.hasFootnotes=function(){return 0!==o.length},this.getRenderer=function(e){o=[],r=0,i=n.buildTheme(n.opts.theme);var t=new p["Renderer"];return t.heading=function(e,t){switch(t){case 1:return"

").concat(e,"

");case 2:return"

").concat(e,"

");case 3:return"

").concat(e,"

");default:return"

").concat(e,"

")}},t.paragraph=function(e){return-1!=e.indexOf("").concat(e,"

")},t.blockquote=function(e){return e=e.replace(//g,"

")),"

").concat(e,"
")},t.code=function(e,t){return t=g.a.getLanguage(t)?t:"plaintext",e=g.a.highlight(e,{language:t}).value,e=e.replace(/\r\n/g,"
").replace(/\n/g,"
").replace(/(>[^<]+)|(^[^<]+)/g,(function(e){return e.replace(/\s/g," ")})),'
").concat(e,"
")},t.codespan=function(e,t){return"").concat(e,"")},t.listitem=function(e){return"
  • <%s/>").concat(e,"
  • ")},t.list=function(e,t,n){e=e.replace(/<\/*p.*?>/g,"");var o=e.split("<%s/>");if(!t)return e=o.join("• "),"
      ").concat(e,"
    ");e=o[0];for(var r=1;r").concat(e,"")},t.image=function(e,t,n){var o="";n&&(o="
    ").concat(n,"
    "));var r=s("figure"),i=s("image");return"
    ').concat(n,'').concat(o,"
    ")},t.link=function(t,n,o){if(t.startsWith("https://mp.weixin.qq.com"))return'").concat(o,"");if(t===o)return o;if(e){var r=c(n||o,t);return"").concat(o,"[").concat(r,"]")}return"").concat(o,"")},t.strong=function(e){return"").concat(e,"")},t.em=function(e){return''.concat(e,"")},t.table=function(e,t){return'
    ").concat(e,"").concat(t,"
    ")},t.tablecell=function(e,t){return"").concat(e,"")},t.hr=function(){return"
    ")},t}})),C=b,v=n("56b3"),O=n.n(v),k='# 示例文章:Google 搜索的即时自动补全功能究竟是如何“工作”的?\n\n> Google 搜索**自动补全功能**的强大,相信不少朋友都能感受到,它帮助我们更快地“补全”我们所要输入的搜索关键字。那么,它怎么知道我们要输入什么内容?它又是如何工作的?在这篇文章里,我们一起来看看。\n\n## 使用自动补全\n\nGoogle 搜索的自动补全功能可以在 Google 搜索应用的大多数位置使用,包括 [Google](https://www.google.com/) 主页、适用于 IOS 和 Android 的 Google 应用,我们只需要在 Google 搜索框上开始键入关键字,就可以看到联想词了。\n\n![](https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303019705-c161ce00-d245-446a-b81c-42ec91474a40.gif)\n\n在上图示例中,我们可以看到,输入关键字 `juej`,Google 搜索会联想到“掘金”、“掘金小册”、“绝句”等等,好处就是,我们无须输入完整的关键字即可轻松完成针对这些 topics 的搜索。\n\n谷歌搜索的自动补全功能对于使用移动设备的用户来说特别有用,用户可以轻松在难以键入的小屏幕上完成搜索。当然,对于移动设备用户和台式机用户而言,这都节省了大量的时间。根据 Google 官方报告,自动补全功能可以减少大约 25% 的打字,累积起来,预计每天可以节省 200 多年的打字时间。是的,每天!\n\n> 注意,本文所提到的“**联想词**”与“**预测**”,是同一个意思。\n\n## 基于“预测”而非“建议”\n\nGoogle 官方将自动补全功能称之为“预测”,而不是“建议”,为什么呢?其实是有充分理由的。自动补全功能是为了**帮助用户完成他们打算进行的搜索**,而不是建议用户要执行什么搜索。\n\n那么,Google 是如何确定这些“预测”的?其实,Google 会根据趋势搜索 [trends](https://trends.google.com/trends/?geo=US) 给到我们这些“预测”。简单来说,哪个热门、哪个搜索频率高,就更可能推给我们。当然,这也与我们当前所处的位置以及我们的搜索历史相关。\n\n另外,这些“预测”也会随着我们键入的关键字的变更而更改。例如,当我们把键入的关键字从 `juej` 更改为 `juex` 时,与“掘金”相关的预测会“消失”,同时,与“觉醒”、“决心”相关联的词会出现。\n\n![](https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303068169-386a99cb-143b-4ded-a859-1b7a4c4b5bd3.gif)\n\n## 为什么看不到某些联想词?\n\n如果我们在输入某个关键字时看不到联想词,那么表明 Google 的算法可能检测到:\n\n- 这个关键字不是热门字词;\n- 搜索的字词太新了,我们可能需要等待几天或几周才能看到联想词;\n- 这是一个侮辱性或敏感字词,这个搜索字词违反了 Google 的相关政策。更加详细的情况,可以了解 [Google 搜索自动补全政策](https://support.google.com/websearch/answer/7368877)。\n\n## 为什么会看到某些不当的联想词?\n\nGoogle 拥有专门设计的系统,可以自动捕获不适当的预测结果而不显示出来。然而,Google 每天需要处理数十亿次搜索,这意味着 Google 每天会显示数十亿甚至上百亿条预测。再好的系统,也可能存在缺陷,不正确的预测也可能随时会出现。\n\n我们作为 Google 搜索的用户,如果认定某条预测违反了相关的搜索自动补全政策,可以进行举报反馈,点击右下角“**举报不当的联想查询**”并勾选相关选项即可。\n\n![](https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303098026-cac215dc-42c9-462a-a359-dcfb12ed3234.gif)\n\n## 如何实现自动补全算法?\n\n目前,Google 官方似乎并没有公开搜索自动补全的算法实现,但是业界在这方面已经有了不少研究。\n\n一个好的自动补全器必须是快速的,并且在用户键入下一个字符后立即更新联想词列表。**自动补全器的核心是一个函数,它接受输入的前缀,并搜索以给定前缀开头的词汇或语句列表**。通常来说,只需要返回少量的数目即可。\n\n接下来,我们先从一个简单且低效的实现开始,并在此基础上逐步构建更高效的方法。\n\n### 词汇表实现\n\n一个**简单粗暴的实现方式**是:顺序查找词汇表,依次检查每个词汇,看它是否以给定的前缀开头。\n\n但是,此方法需要将前缀与每个词汇进行匹配检查,若词汇量较少,这种方式可能勉强行得通。但是,如果词汇量规模较大,效率就太低了。\n\n一个**更好的实现方式是**:让词汇按字典顺序排序。借助二分搜索算法,可以快速搜索有序词汇表中的前缀。由于二分搜索的每一步都会将搜索的范围减半,因此,总的搜索时间与词汇表中单词数量的对数成正比,即时间复杂度是 `O(log N)`。二分搜索的性能很好,但有没有更好的实现呢?当然有,往下看。\n\n### 前缀树实现\n\n通常来说,许多词汇都以相同的前缀开头,比如 `need`、`nested` 都以 `ne` 开头,`seed`、`speed` 都以 `s` 开头。要是为每个单词分别存储公共前缀似乎很浪费。\n\n\n![](https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303128008-93cf798d-2662-4eec-8f80-2e07436aebfe.png)\n\n\n前缀树是一种利用公共前缀来加速补全速度的数据结构。前缀树在节点树中排列一组单词,单词沿着从根节点到叶子节点的路径存储,树的层次对应于前缀的字母位置。\n\n前缀的补全是顺着前缀定义的路径来查找的。例如,在上图的前缀树中,前缀 `ne` 对应于从子节点取左边缘 `N` 和唯一边缘 `E` 的路径。然后可以通过继续遍历从 `E` 节点可以达到的所有叶节点来生成补全列表。在图中,`ne` 的补全可以是两个分支:`-ed` 和 `-sted`。如果在数中找不到由前缀定义的路径,则说明词汇表中不包含以该前缀开头的单词。\n\n### 有限状态自动机(DFA)实现\n\n前缀树可以有效处理公共前缀,但是,对于其他共享词部分,仍会分别存储在每个分支中。比如,后缀 `ed`、`ing`、`tion` 在英文单词中特别常见。在上一个例子中,`e`、`d` 分别存放在了每一个分支上。\n\n有没有一种方法可以更加节省存储空间呢?有的,那就是 DFA。\n\n
    \n
    \n\n在上面的例子中,单词 `need`、`nested`、`seed` 和 `speed` 仅由 9 个节点组成,而上一张图中的前缀树包含了 17 个节点。\n\n可以看出,最小化前缀树 DFA 可以在很大程度上减少数据结构的大小。即使词汇量很大,最小化 DFA 通常也适合在内存中存储,避免昂贵的磁盘访问是实现快速自动补全的关键。\n\n### 一些扩展\n\n上面介绍了如何利用合理的数据结构实现基本的自动补全功能。这些数据结构可以通过多种方式进行扩展,从而改善用户体验。\n\n通常,满足特定前缀的词汇可能很多,而用户界面上能够显示的却不多,我们更希望能显示最常搜索或者最有价值的词汇。这通常可以通过为词汇表中的每个单词增加一个代表单词值的**权重** `weight`,并且按照权重高低来排序自动补全列表。\n\n- 对于排序后的词汇表来说,在词汇表每个元素上增加 `weight` 属性并不难;\n- 对于前缀树来说,将 `weight` 存储在叶子节点中,也是很简单的一个实现;\n- 对于 `DFA` 来说,则较为复杂。因为一个叶子节点可以通过多条路径到达。一种解决方案是将权重关联到路径而不是叶子节点。\n\n目前有不少开源库都提供了这个功能,比如主流的搜索引擎框架 [Elasticsearch](https://www.elastic.co/products/elasticsearch)、[Solr](https://lucene.apache.org/solr/) 等,基于此,我们可以实现高效而强大的自动补全功能。\n\n#### 推荐阅读\n\n- [阿里又一个 20k+ stars 开源项目诞生,恭喜 fastjson!](https://mp.weixin.qq.com/s/RNKDCK2KoyeuMeEs6GUrow)\n- [刷掉 90% 候选人的互联网大厂海量数据面试题(附题解 + 方法总结)](https://mp.weixin.qq.com/s/rjGqxUvrEqJNlo09GrT1Dw)\n- [好用!期待已久的文本块功能究竟如何在 Java 13 中发挥作用?](https://mp.weixin.qq.com/s/kalGv5T8AZGxTnLHr2wDsA)\n- [2019 GitHub 开源贡献排行榜新鲜出炉!微软谷歌领头,阿里跻身前 12!](https://mp.weixin.qq.com/s/_q812aGD1b9QvZ2WFI0Qgw)\n\n---\n\n欢迎关注我的公众号“**Doocs**”,原创技术文章第一时间推送。\n\n
    \n \n
    \n',w="/*\n 按Ctrl+F可格式化\n*/\n/* 一级标题样式 */\nh1 {\n}\n/* 二级标题样式 */\nh2 {\n}\n/* 三级标题样式 */\nh3 {\n}\n/* 四级标题样式 */\nh4 {\n}\n/* 图片样式 */\nimage {\n}\n/* 引用样式 */\nblockquote {\n}\n/* 引用段落样式 */\nblockquote_p {\n}\n/* 段落样式 */\np {\n}\n/* 分割线样式 */\nhr {\n}\n/* 行内代码样式 */\ncodespan {\n}\n/* 粗体样式 */\nstrong {\n}\n/* 链接样式 */\nlink {\n}\n/* 微信链接样式 */\nwx_link {\n}\n/* 有序列表样式 */\nol {\n}\n/* 无序列表样式 */\nul {\n}\n/* 列表项样式 */\nli {\n}\n/* 代码块样式 */\ncode {\n}\n",E=n("3835"),y=(n("e9c4"),n("4160"),n("159b"),n("498a"),n("4de4"),n("b64b"),n("fb6a"),n("2b3d"),n("9861"),n("4fadc"),n("caad"),n("2532"),n("a630"),n("00b4"),n("b0c0"),n("4e82"),n("466d"),n("325b1")),S=n.n(y),x=n("d238"),M=n.n(x),D=n("4fc3"),T=n.n(D),j="#3f3f3f",P={BASE:{"text-align":"left","line-height":"1.75"},block:{h1:{"font-size":"1.2em","text-align":"center","font-weight":"bold",display:"table",margin:"2em auto 1em",padding:"0 1em","border-bottom":"2px solid rgba(0, 152, 116, 0.9)",color:j},h2:{"font-size":"1.2em","text-align":"center","font-weight":"bold",display:"table",margin:"4em auto 2em",padding:"0 0.2em",background:"rgba(0, 152, 116, 0.9)",color:"#fff"},h3:{"font-weight":"bold","font-size":"1.1em",margin:"2em 8px 0.75em 0","line-height":"1.2","padding-left":"8px","border-left":"3px solid rgba(0, 152, 116, 0.9)",color:j},h4:{"font-weight":"bold","font-size":"1em",margin:"2em 8px 0.5em",color:"rgba(66, 185, 131, 0.9)"},p:{margin:"1.5em 8px","letter-spacing":"0.1em",color:j},blockquote:{"font-style":"normal","border-left":"none",padding:"1em","border-radius":"8px",color:"rgba(0,0,0,0.5)",background:"#f7f7f7",margin:"2em 8px"},blockquote_p:{"letter-spacing":"0.1em",color:"rgb(80, 80, 80)","font-size":"1em",display:"block"},code_pre:{"font-size":"14px","overflow-x":"auto","border-radius":"8px",padding:"1em","line-height":"1.5",margin:"10px 8px"},code:{margin:0,"white-space":"nowrap","font-family":"Menlo, Operator Mono, Consolas, Monaco, monospace"},image:{"border-radius":"4px",display:"block",margin:"0.1em auto 0.5em",width:"100% !important"},ol:{"margin-left":"0","padding-left":"1em",color:j},ul:{"margin-left":"0","padding-left":"1em","list-style":"circle",color:j},footnotes:{margin:"0.5em 8px","font-size":"80%",color:j},figure:{margin:"1.5em 8px",color:j},hr:{"border-style":"solid","border-width":"1px 0 0","border-color":"rgba(0,0,0,0.1)","-webkit-transform-origin":"0 0","-webkit-transform":"scale(1, 0.5)","transform-origin":"0 0",transform:"scale(1, 0.5)"}},inline:{listitem:{"text-indent":"-1em",display:"block",margin:"0.2em 8px",color:j},codespan:{"font-size":"90%",color:"#d14",background:"rgba(27,31,35,.05)",padding:"3px 5px","border-radius":"4px","word-break":"break-all"},link:{color:"#576b95"},wx_link:{color:"#576b95","text-decoration":"none"},strong:{color:"rgba(15, 76, 129, 0.9)","font-weight":"bold"},table:{"border-collapse":"collapse","text-align":"center",margin:"1em 8px",color:j},thead:{background:"rgba(0, 0, 0, 0.05)","font-weight":"bold",color:j},td:{border:"1px solid #dfdfdf",padding:"0.25em 0.5em",color:j},footnote:{"font-size":"12px",color:j},figcaption:{"text-align":"center",color:"#888","font-size":"0.8em"}}},I=function(e,t){var n=JSON.parse(JSON.stringify(e));return n.block.h1["border-bottom"]="2px solid ".concat(t),n.block.h2["background"]=t,n.block.h3["border-left"]="3px solid ".concat(t),n.block.h4["color"]=t,n.inline.strong["color"]=t,n};function A(e){return function(t){return I(e,t)}}function R(e,t){return I(e,t)}function U(e){return function(t){var n=JSON.parse(JSON.stringify(e));return n.block.h1["font-size"]="".concat(1.14*t,"px"),n.block.h2["font-size"]="".concat(1.1*t,"px"),n.block.h3["font-size"]="".concat(t,"px"),n.block.h4["font-size"]="".concat(t,"px"),n}}var K=A(P),L=U(P);function B(e,t,n){var o=I(n,t);return o.block.h1=Object.assign(o.block.h1,e.h1),o.block.h2=Object.assign(o.block.h2,e.h2),o.block.h3=Object.assign(o.block.h3,e.h3),o.block.h4=Object.assign(o.block.h4,e.h4),o.block.code=Object.assign(o.block.code,e.code),o.block.p=Object.assign(o.block.p,e.p),o.block.hr=Object.assign(o.block.hr,e.hr),o.block.blockquote=Object.assign(o.block.blockquote,e.blockquote),o.block.blockquote_p=Object.assign(o.block.blockquote_p,e.blockquote_p),o.block.image=Object.assign(o.block.image,e.image),o.inline.strong=Object.assign(o.inline.strong,e.strong),o.inline.codespan=Object.assign(o.inline.codespan,e.codespan),o.inline.link=Object.assign(o.inline.link,e.link),o.inline.wx_link=Object.assign(o.inline.wx_link,e.wx_link),o.block.ul=Object.assign(o.block.ul,e.ul),o.block.ol=Object.assign(o.block.ol,e.ol),o.inline.listitem=Object.assign(o.inline.listitem,e.li),o}function $(e){var t,n;while(-1!==(t=e.indexOf("/*"))&&-1!==(n=e.indexOf("*/")))e=e.substring(0,t)+e.substring(n+2);var o={},r=function(){var t=e.indexOf("{"),n=e.indexOf("}");function r(e){var t={};return e.forEach((function(e){var n=e.indexOf(":"),o=e.substring(0,n).trim();t[o]=e.substring(n+1).trim()})),t}var i=e.substring(t+1,n).split(";").map((function(e){return e.trim()})).filter((function(e){return e.length>0}));i=r(i);var a=e.substring(0,t).split(",").map((function(e){return e.trim()}));a.forEach((function(e){o[e]||(o[e]={}),Object.keys(i).forEach((function(t){o[e][t]=i[t]}))})),e=e.slice(n+1).trim()};while(e.length>0&&-1!==e.indexOf("{")&&-1!==e.indexOf("}"))r();return o}function q(e,t){var n=e.getValue(0);n?localStorage.setItem(t,n):localStorage.removeItem(t)}function W(e){return S.a.format(e,{parser:"markdown",plugins:[T.a]})}function F(e){return S.a.format(e,{parser:"css",plugins:[M.a]})}function z(e){var t=document.createElement("a");t.download="content.md",t.style.display="none";var n=new Blob([e]);t.href=URL.createObjectURL(n),document.body.appendChild(t),t.click(),document.body.removeChild(t)}function H(){var e=document.querySelector("#output");r(e);var t=e.innerHTML,n=document.createElement("a");n.download="content.html",n.style.display="none";var o=new Blob(['
    '.concat(t,"
    ")]);function r(e){function t(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height"],n=getComputedStyle(e,null);return Object.entries(n).filter((function(e){var o=Object(E["a"])(e,1),r=o[0];return n.getPropertyValue(r)&&!t.includes(r)})).map((function(e){var t=Object(E["a"])(e,2),n=t[0],o=t[1];return"".concat(n,":").concat(o,";")})).join("")}switch(!0){case n(e):case o(e):case i(e):e.setAttribute("style",t(e));default:}function n(e){return"PRE"===e.tagName&&Array.from(e.classList).includes("code__pre")}function o(e){return"CODE"===e.tagName&&Array.from(e.classList).includes("prettyprint")}function i(e){return"SPAN"===e.tagName&&(o(e.parentElement)||o(e.parentElement.parentElement))}e.children.length&&Array.from(e.children).forEach((function(e){return r(e)}))}n.href=URL.createObjectURL(o),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function G(e){for(var t=e.data,n=e.rows,o=e.cols,r="",i=0;i1?i-1:i;a.push(1===i?"---":t["k_".concat(c,"_").concat(s)]||" ")}r+=a.join(" | "),r+=" |\n"}return r}function N(e){return new Promise((function(t,n){var o=new FileReader;o.readAsDataURL(e),o.onload=function(){return t(o.result.split(",").pop())},o.onerror=function(e){return n(e)}}))}function V(e){var t=/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(e.name);if(!t)return{ok:!1,msg:"请上传 JPG/PNG/GIF 格式的图片"};var n=10,o=e.size/1024/1024<=n;return o?{ok:!0}:{ok:!1,msg:"由于公众号限制,图片大小不能超过 ".concat(n,"M")}}function Q(e){var t=e.split("\n"),n=t.filter((function(e){return e.trim()})).map((function(e){return e.match(/(^\s+)?/)[0].length})).sort((function(e,t){return e-t}))[0];return t.map((function(e){return e.slice(n)})).join("\n")}r["default"].use(_["a"]);var J={wxRenderer:null,output:"",html:"",editor:null,cssEditor:null,currentFont:"",currentSize:"",currentColor:"",citeStatus:0,nightMode:!1,codeTheme:d.codeThemeOption[0].value,rightClickMenuVisible:!1},Y={setEditorValue:function(e,t){e.editor.setValue(t)},setCssEditorValue:function(e,t){e.cssEditor.setValue(t)},setWxRendererOptions:function(e,t){e.wxRenderer.setOptions(t)},setCiteStatus:function(e,t){e.citeStatus=t,localStorage.setItem("citeStatus",t)},setCurrentFont:function(e,t){e.currentFont=t,localStorage.setItem("fonts",t)},setCurrentSize:function(e,t){e.currentSize=t,localStorage.setItem("size",t)},setCurrentColor:function(e,t){e.currentColor=t,localStorage.setItem("color",t)},setCurrentCodeTheme:function(e,t){e.codeTheme=t,localStorage.setItem("codeTheme",t)},setRightClickMenuVisible:function(e,t){e.rightClickMenuVisible=t},themeChanged:function(e){e.nightMode=!e.nightMode,localStorage.setItem("nightMode",e.nightMode)},initEditorState:function(e){e.currentFont=localStorage.getItem("fonts")||d.builtinFonts[0].value,e.currentColor=localStorage.getItem("color")||d.colorOption[0].value,e.currentSize=localStorage.getItem("size")||d.sizeOption[2].value,e.codeTheme=localStorage.getItem("codeTheme")||d.codeThemeOption[0].value,e.citeStatus="true"===localStorage.getItem("citeStatus"),e.nightMode="true"===localStorage.getItem("nightMode"),e.wxRenderer=new C({theme:K(e.currentColor),fonts:e.currentFont,size:e.currentSize})},initEditorEntity:function(e){var t=document.getElementById("editor");t.value||(t.value=localStorage.getItem("__editor_content")||W(k)),e.editor=O.a.fromTextArea(t,{mode:"text/x-markdown",theme:"xq-light",lineNumbers:!1,lineWrapping:!0,styleActiveLine:!0,autoCloseBrackets:!0,extraKeys:{"Ctrl-F":function(e){var t=W(e.getValue(0));localStorage.setItem("__editor_content",t),e.setValue(t)},"Ctrl-S":function(e){},"Ctrl-B":function(e){var t=e.getSelection();e.replaceSelection("**".concat(t,"**"))},"Ctrl-D":function(e){var t=e.getSelection();e.replaceSelection("~~".concat(t,"~~"))},"Ctrl-I":function(e){var t=e.getSelection();e.replaceSelection("*".concat(t,"*"))}}})},initCssEditorEntity:function(e){var t=document.getElementById("cssEditor");t.value||(t.value=localStorage.getItem("__css_content")||w),e.cssEditor=O.a.fromTextArea(t,{mode:"css",theme:"style-mirror",lineNumbers:!1,lineWrapping:!0,matchBrackets:!0,autofocus:!0,extraKeys:{"Ctrl-F":function(e){var t=F(e.getValue(0));localStorage.setItem("__css_content",t),e.setValue(t)},"Ctrl-S":function(e){}}})},editorRefresh:function(e){var t=e.wxRenderer.getRenderer(e.citeStatus);p["marked"].setOptions({renderer:t});var n=p["marked"].parse(e.editor.getValue(0));n=n.replace(/(style=".*?)"/,'$1;margin-top: 0"'),e.citeStatus&&(n+=e.wxRenderer.buildFootnotes(),n+=e.wxRenderer.buildAddition()),e.output=n}},Z=new _["a"].Store({state:J,mutations:Y,actions:{}}),X=n("5c96"),ee=n.n(X);n("0fae");r["default"].component(X["Message"].name,X["Message"]),r["default"].prototype.$loading=X["Loading"].service,r["default"].prototype.$message=X["Message"];n("a7be"),n("8d7e"),n("7b00"),n("959b"),n("10b2"),n("8c33"),n("31c5"),n("9b74"),n("111b");var te=n("8c4f"),ne=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.loading?n("transition",{attrs:{name:"fade"}},[n("loading")],1):n("codemirror-editor")},oe=[],re=(n("4795"),n("3a5e")),ie=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"container",class:{container_night:e.nightMode},on:{keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"k",void 0,t.key,void 0)?null:t.altKey&&t.shiftKey?void e.addFormat("[","]()"):null},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"u",void 0,t.key,void 0)?null:t.altKey&&t.shiftKey?e.addFormat("~~"):null},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"l",void 0,t.key,void 0)?null:t.ctrlKey&&t.altKey?e.formatContent():null}]}},[n("el-container",[n("el-header",{staticClass:"editor__header"},[n("editor-header",{ref:"header",on:{addFormat:e.addFormat,formatContent:e.formatContent,refresh:e.onEditorRefresh,cssChanged:e.cssChanged,"import-md":e.importMD,download:e.downloadEditorContent,export:e.exportEditorContent,showCssEditor:function(t){e.showCssEditor=!e.showCssEditor},"show-about-dialog":function(t){e.aboutDialogVisible=!0},"show-dialog-form":function(t){e.dialogFormVisible=!0},"show-dialog-upload-img":function(t){e.dialogUploadImgVisible=!0},startCopy:function(t){e.isCoping=!0,e.backLight=!0},endCopy:e.endCopy}})],1),n("el-main",{staticClass:"main-body"},[n("el-row",{staticClass:"main-section"},[n("el-col",{ref:"codeMirrorWrapper",staticClass:"codeMirror-wrapper",attrs:{span:12},nativeOn:{contextmenu:function(t){return t.preventDefault(),e.openMenu(t)}}},[n("textarea",{directives:[{name:"model",rawName:"v-model",value:e.source,expression:"source"}],attrs:{id:"editor",type:"textarea",placeholder:"Your markdown text here."},domProps:{value:e.source},on:{input:function(t){t.target.composing||(e.source=t.target.value)}}})]),n("el-col",{ref:"preview",staticClass:"preview-wrapper",class:{"preview-wrapper_night":e.nightMode&&e.isCoping},attrs:{span:12,id:"preview"}},[n("section",{class:{output_night:e.nightMode&&!e.backLight},attrs:{id:"output-wrapper"}},[n("div",{staticClass:"preview"},[n("section",{attrs:{id:"output"},domProps:{innerHTML:e._s(e.output)}}),e.nightMode&&e.isCoping?n("div",{staticClass:"loading-mask"},[n("div",{staticClass:"loading__img"}),n("span",[e._v("正在生成")])]):e._e()])])]),n("transition",{attrs:{name:"custom-classes-transition","enter-active-class":"bounceInRight"}},[n("el-col",{directives:[{name:"show",rawName:"v-show",value:e.showCssEditor,expression:"showCssEditor"}],staticClass:"cssEditor-wrapper",attrs:{id:"cssBox",span:12}},[n("textarea",{attrs:{id:"cssEditor",type:"textarea",placeholder:"Your custom css here."}})])],1)],1)],1)],1),n("upload-img-dialog",{on:{close:function(t){e.dialogUploadImgVisible=!1},beforeUpload:e.beforeUpload,uploadImage:e.uploadImage,uploaded:e.uploaded},model:{value:e.dialogUploadImgVisible,callback:function(t){e.dialogUploadImgVisible=t},expression:"dialogUploadImgVisible"}}),n("about-dialog",{model:{value:e.aboutDialogVisible,callback:function(t){e.aboutDialogVisible=t},expression:"aboutDialogVisible"}}),n("insert-form-dialog",{model:{value:e.dialogFormVisible,callback:function(t){e.dialogFormVisible=t},expression:"dialogFormVisible"}}),n("right-click-menu",{attrs:{left:e.mouseLeft,top:e.mouseTop},on:{menuTick:e.onMenuEvent,closeMenu:e.closeRightClickMenu},model:{value:e.rightClickMenuVisible,callback:function(t){e.rightClickMenuVisible=t},expression:"rightClickMenuVisible"}})],1)},ae=[],se=n("2909"),ce=n("c7eb"),le=n("b85c"),ue=n("1da1"),_e=n("668b"),de=(n("7db0"),n("a1f0"),n("18a5"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-container",{staticClass:"top is-dark"},[n("el-dialog",{attrs:{title:"发布",visible:e.form.dialogVisible},on:{"update:visible":function(t){return e.$set(e.form,"dialogVisible",t)}}},[n("div",{staticClass:"postInfo"},[n("el-form",{ref:"form",attrs:{model:e.form,"label-width":"80px"}},[n("el-form-item",{attrs:{label:"封面"}},[n("el-input",{attrs:{placeholder:"自动提取第一张图"},model:{value:e.form.thumb,callback:function(t){e.$set(e.form,"thumb",t)},expression:"form.thumb"}})],1),n("el-form-item",{attrs:{label:"标题"}},[n("el-input",{attrs:{placeholder:"自动提取第一个标题"},model:{value:e.form.title,callback:function(t){e.$set(e.form,"title",t)},expression:"form.title"}})],1),n("el-form-item",{attrs:{label:"描述"}},[n("el-input",{attrs:{type:"textarea",rows:4,placeholder:"自动提取第一个段落"},model:{value:e.form.desc,callback:function(t){e.$set(e.form,"desc",t)},expression:"form.desc"}})],1),n("el-form-item",[n("div",{staticClass:"info"},[e._v(" 注:此功能由第三方浏览器插件支持,本平台不保证安全性。 ")])])],1)],1),n("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{on:{click:function(t){e.form.dialogVisible=!1}}},[e._v("取 消")]),n("el-button",{attrs:{type:"primary"},on:{click:e.post}},[e._v("确 定")])],1)]),n("div",{staticClass:"left-side"},[n("el-dropdown",[n("span",{staticClass:"el-dropdown-link"},[e._v(" 文件"),n("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),n("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[n("el-dropdown-item",{nativeOn:{click:function(t){return e.refClick.apply(null,arguments)}}},[n("i",{staticClass:"el-icon-upload2",attrs:{size:"medium"}}),e._v(" 导入 .md "),n("input",{ref:"fileInput",attrs:{hidden:"",type:"file",accept:".md"}})]),n("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("download")}}},[n("i",{staticClass:"el-icon-download",attrs:{size:"medium"}}),e._v(" 导出 .md ")]),n("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("export")}}},[n("i",{staticClass:"el-icon-document",attrs:{size:"medium"}}),e._v(" 导出 .html ")]),n("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.themeChanged.apply(null,arguments)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.nightMode?1:0}}),e._v(" 暗黑模式 ")])],1)],1),n("el-dropdown",[n("span",{staticClass:"el-dropdown-link"},[e._v(" 格式"),n("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),n("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[n("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","**")}}},[e._v(" 加粗 "),n("kbd",[e._v(" Ctrl + B ")])]),n("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","*")}}},[e._v(" 斜体 "),n("kbd",[e._v(" Ctrl + I ")])]),n("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","~~")}}},[e._v(" 删除线 "),n("kbd",[e._v(" Alt + Shift + U ")])]),n("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){e.$emit("addFormat","[","]()")}}},[e._v(" 超链接 "),n("kbd",[e._v(" Alt + Shift + K ")])]),n("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("formatContent")}}},[e._v(" 格式化 "),n("kbd",[e._v(" Ctrl + Alt + L ")])]),n("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.statusChanged.apply(null,arguments)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.citeStatus?1:0}}),e._v(" 微信外链转底部引用 ")])],1)],1),n("el-dropdown",[n("span",{staticClass:"el-dropdown-link"},[e._v(" 编辑"),n("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),n("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[n("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-upload-img")}}},[n("i",{staticClass:"el-icon-upload",attrs:{size:"medium"}}),e._v(" 上传图片 ")]),n("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-form")}}},[n("i",{staticClass:"el-icon-s-grid",attrs:{size:"medium"}}),e._v(" 插入表格 ")])],1)],1),n("el-dropdown",[n("span",{staticClass:"el-dropdown-link"},[e._v(" 样式"),n("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),n("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[n("el-dropdown-item",{staticClass:"padding-left-3"},[n("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[n("div",{staticClass:"el-dropdown-link"},[e._v(" 字体 "),n("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),n("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.builtinFonts,(function(t){return n("el-dropdown-item",{key:t.value,style:{fontFamily:t.value},attrs:{label:t.label,value:t.value},nativeOn:{click:function(n){return e.fontChanged(t.value)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.selectFont===t.value?1:0}}),n("span",[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v("Abc")])])})),1)],1)],1),n("el-dropdown-item",{staticClass:"padding-left-3"},[n("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[n("div",{staticClass:"el-dropdown-link"},[e._v(" 字号 "),n("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),n("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.sizeOption,(function(t){return n("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(n){return e.sizeChanged(t.value)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.selectSize===t.value?1:0}}),n("span",[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),n("el-dropdown-item",{staticClass:"padding-left-3"},[n("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[n("div",{staticClass:"el-dropdown-link"},[e._v(" 颜色 "),n("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),n("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.colorOption,(function(t){return n("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(n){return e.colorChanged(t.value)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.selectColor===t.value?1:0}}),n("span",[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),n("el-dropdown-item",{staticClass:"padding-left-3"},[n("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[n("div",{staticClass:"el-dropdown-link"},[e._v(" 代码主题 "),n("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),n("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.codeThemeOption,(function(t){return n("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(n){return e.codeThemeChanged(t.value)}}},[n("i",{staticClass:"el-icon-check",style:{opacity:e.selectCodeTheme===t.value?1:0}}),n("span",[e._v(e._s(t.label))]),n("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),n("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){return e.showPicker()}}},[e._v(" 自定义颜色 "),n("el-color-picker",{ref:"colorPicker",staticStyle:{float:"right","margin-top":"3px"},attrs:{"show-alpha":"",size:"mini"},on:{change:e.colorChanged},model:{value:e.selectColor,callback:function(t){e.selectColor=t},expression:"selectColor"}})],1),n("el-dropdown-item",{staticClass:"padding-left-3",nativeOn:{click:function(t){return e.customStyle.apply(null,arguments)}}},[e._v(" 自定义 CSS ")]),n("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){e.showResetConfirm=!0}}},[e._v(" 重置 ")])],1)],1),n("el-dropdown",[n("span",{staticClass:"el-dropdown-link"},[e._v(" 帮助"),n("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),n("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[n("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-about-dialog")}}},[e._v(" 关于 ")])],1)],1)],1),n("div",{staticClass:"right-side"},[n("el-button",{attrs:{type:e.btnType,plain:"",size:"medium",placement:"bottom-start"},on:{click:e.copy}},[e._v("复制 ")]),n("el-button",{attrs:{type:e.btnType,plain:"",size:"medium",placement:"bottom-start"},on:{click:e.prePost}},[e._v("发布 ")])],1),n("resetDialog",{attrs:{showResetConfirm:e.showResetConfirm},on:{confirm:e.confirmReset,close:e.cancelReset}})],1)}),me=[],fe=n("466b"),pe=n.n(fe);function he(){for(var e=document.getElementById("output"),t=e.getElementsByTagName("img"),n=0;n {\n okCb(res.url)\n }).catch(err => {\n errCb(err)\n })\n ")).trim(),editor:void 0},options:[{value:"default",label:"默认"},{value:"github",label:"GitHub"},{value:"aliOSS",label:"阿里云"},{value:"txCOS",label:"腾讯云"},{value:"qiniu",label:"七牛云"},{value:"minio",label:"MinIO"},{value:"formCustom",label:"自定义代码"}],imgHost:"default"}},created:function(){localStorage.getItem("githubConfig")&&(this.formGitHub=JSON.parse(localStorage.getItem("githubConfig"))),localStorage.getItem("aliOSSConfig")&&(this.formAliOSS=JSON.parse(localStorage.getItem("aliOSSConfig"))),localStorage.getItem("minioConfig")&&(this.minioOSS=JSON.parse(localStorage.getItem("minioConfig"))),localStorage.getItem("txCOSConfig")&&(this.formTxCOS=JSON.parse(localStorage.getItem("txCOSConfig"))),localStorage.getItem("imgHost")&&(this.imgHost=localStorage.getItem("imgHost"))},methods:{changeImgHost:function(){localStorage.setItem("imgHost",this.imgHost),this.$message.success("已成功切换图床")},saveGitHubConfiguration:function(){if(this.formGitHub.repo&&this.formGitHub.accessToken)localStorage.setItem("githubConfig",JSON.stringify(this.formGitHub)),this.$message.success("保存成功");else{var e=this.formGitHub.repo?"token":"GitHub 仓库";this.$message.error("参数「".concat(e,"」不能为空"))}},saveAliOSSConfiguration:function(){this.formAliOSS.accessKeyId&&this.formAliOSS.accessKeySecret&&this.formAliOSS.bucket&&this.formAliOSS.region?(localStorage.setItem("aliOSSConfig",JSON.stringify(this.formAliOSS)),this.$message.success("保存成功")):this.$message.error("阿里云 OSS 参数配置不全")},saveMinioOSSConfiguration:function(){this.minioOSS.endpoint&&this.minioOSS.bucket&&this.minioOSS.accessKey&&this.minioOSS.secretKey?(localStorage.setItem("minioConfig",JSON.stringify(this.minioOSS)),this.$message.success("保存成功")):this.$message.error("MinIO 参数配置不全")},saveTxCOSConfiguration:function(){this.formTxCOS.secretId&&this.formTxCOS.secretKey&&this.formTxCOS.bucket&&this.formTxCOS.region?(localStorage.setItem("txCOSConfig",JSON.stringify(this.formTxCOS)),this.$message.success("保存成功")):this.$message.error("腾讯云 COS 参数配置不全")},saveQiniuConfiguration:function(){this.formQiniu.accessKey&&this.formQiniu.secretKey&&this.formQiniu.bucket&&this.formQiniu.domain&&this.formQiniu.region?(localStorage.setItem("qiniuConfig",JSON.stringify(this.formQiniu)),this.$message.success("保存成功")):this.$message.error("七牛云 Kodo 参数配置不全")},formCustomSave:function(){var e=this.formCustom.editor.getValue();localStorage.setItem("formCustomConfig",e),this.$message.success("保存成功")},beforeImageUpload:function(e){var t=V(e);if(!t.ok)return this.$message.error(t.msg),!1;var n=localStorage.getItem("imgHost");n=n||"default",localStorage.setItem("imgHost",n);var o=localStorage.getItem("".concat(n,"Config")),r="default"==n||o;return!!r||(this.$message.error("请先配置 ".concat(n," 图床参数")),!1)},uploadImage:function(e){this.$emit("uploadImage",e.file)}},watch:{activeName:{immediate:!0,handler:function(e){var t=this;"formCustom"===e&&this.$nextTick((function(){var e=t.$refs.formCustomElInput.$el.querySelector("textarea");t.formCustom.editor=t.formCustom.editor||O.a.fromTextArea(e,{mode:"javascript"}),t.formCustom.editor.setValue(t.formCustom.code)}))}}},mounted:function(){}},Qe=Ve,Je=(n("1db6"),Object(s["a"])(Qe,Ge,Ne,!1,null,"bc372ca2",null)),Ye=Je.exports,Ze=n("3f5e");n("f9d4");var Xe={data:function(){return{showCssEditor:!1,aboutDialogVisible:!1,dialogUploadImgVisible:!1,dialogFormVisible:!1,isCoping:!1,isImgLoading:!1,backLight:!1,timeout:null,changeTimer:null,source:"",mouseLeft:0,mouseTop:0}},components:{editorHeader:xe,aboutDialog:Ie,insertFormDialog:Be,rightClickMenu:He,uploadImgDialog:Ye},computed:Object(o["a"])({},Object(_["c"])({wxRenderer:function(e){return e.wxRenderer},output:function(e){return e.output},editor:function(e){return e.editor},cssEditor:function(e){return e.cssEditor},currentSize:function(e){return e.currentSize},currentColor:function(e){return e.currentColor},nightMode:function(e){return e.nightMode},rightClickMenuVisible:function(e){return e.rightClickMenuVisible},codeTheme:function(e){return e.codeTheme}})),created:function(){var e=this;this.initEditorState(),this.$nextTick((function(){e.initEditor(),e.initCssEditor(),e.onEditorRefresh(),e.mdLocalToRemote()}))},methods:Object(o["a"])({mdLocalToRemote:function(){var e=this,t=this.$refs.codeMirrorWrapper.$el;function n(e){return o.apply(this,arguments)}function o(){return o=Object(ue["a"])(Object(ce["a"])().mark((function e(t){var n;return Object(ce["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.list,e.abrupt("return",new Promise((function(e,t){var o=n.find((function(e){return e.path.match(/\.md$/)})),r=o.path,i=o.file,a=new FileReader;a.readAsText(i,"UTF-8"),a.onload=function(t){e({str:t.target.result,file:i,path:r})}})));case 2:case"end":return e.stop()}}),e)}))),o.apply(this,arguments)}function r(e){return i.apply(this,arguments)}function i(){return i=Object(ue["a"])(Object(ce["a"])().mark((function t(n){var o,r,i,a,s;return Object(ce["a"])().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return o=n.md,r=n.list,i=Object(se["a"])(o.str.matchAll(/!\[(.*?)\]\((.*?)\)/gm)||[]).filter((function(e){return e})),a=o.path.match(/.+?\//)[0],t.next=5,Promise.all(i.map((function(t){return new Promise((function(n,o){var i=Object(E["a"])(t,3),s=i[2];s=s.replace(/^.\//,"");var c=r.find((function(e){return e.path==="".concat(a).concat(s)}))||{},l=c.file;e.uploadImage(l,(function(e){n({matchStr:s,url:e})}))}))})));case 5:s=t.sent,s.forEach((function(e){o.str=o.str.replace("](./".concat(e.matchStr,")"),"](".concat(e.url,")")).replace("](".concat(e.matchStr,")"),"](".concat(e.url,")"))})),e.editor.setValue(o.str),console.log("resList",s,o.str);case 9:case"end":return t.stop()}}),t)}))),i.apply(this,arguments)}function a(e){return s.apply(this,arguments)}function s(){return s=Object(ue["a"])(Object(ce["a"])().mark((function e(t){var n,o,r,i,a,s,c,l,u,_,d,m,f;return Object(ce["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:n=[],o="",e.prev=2,r=[t],i=0,a=r;case 5:if(!(i=65&&t.keyCode<=90||189===t.keyCode)&&e.showHint(t)})),this.cssEditor.on("update",(function(t){e.cssChanged(),q(e.cssEditor,"__css_content")}))},cssChanged:function(){var e=$(this.cssEditor.getValue(0)),t=L(this.currentSize.replace("px",""));t=B(e,this.currentColor,t),this.setWxRendererOptions({theme:t}),this.onEditorRefresh()},codeThemeChanged:function(){var e=this.codeTheme,t=document.getElementById("hljs");if(void 0!=t)t.setAttribute("href",e);else{var n=document.createElement("link");n.setAttribute("type","text/css"),n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),n.setAttribute("id","hljs"),document.head.appendChild(n)}},beforeUpload:function(e){var t=V(e);if(!t.ok)return this.$message.error(t.msg),!1;var n=localStorage.getItem("imgHost");n=n||"default",localStorage.setItem("imgHost",n);var o=localStorage.getItem("".concat(n,"Config")),r="default"==n||o;return!!r||(this.$message.error("请先配置 ".concat(n," 图床参数")),!1)},uploadImage:function(e,t){var n=this;this.isImgLoading=!0,N(e).then((function(o){Ze["a"].fileUpload(o,e).then((function(e){console.log(e),t?t(e):n.uploaded(e)}))["catch"]((function(e){n.$message.error(e.message)}))}))["catch"]((function(e){n.$message.error(e.message)})),this.isImgLoading=!1},uploaded:function(e){if(console.log("图片上传之后: ",e),e){this.dialogUploadImgVisible=!1;var t=this.editor.getCursor(),n=e,o="![](".concat(n,")");this.editor.replaceSelection("\n".concat(o,"\n"),t),this.$message.success("图片上传成功"),this.onEditorRefresh()}else this.$message.error("上传图片未知异常")},leftAndRightScroll:function(){var e=this,t=function(t){var r,i;clearTimeout(e.timeout),"preview"===t?(r=e.$refs.preview.$el,i=document.getElementsByClassName("CodeMirror-scroll")[0],e.editor.off("scroll",n),e.timeout=setTimeout((function(){e.editor.on("scroll",n)}),300)):"editor"===t&&(r=document.getElementsByClassName("CodeMirror-scroll")[0],i=e.$refs.preview.$el,i.removeEventListener("scroll",o,!1),e.timeout=setTimeout((function(){i.addEventListener("scroll",o,!1)}),300));var a=r.scrollTop/(r.scrollHeight-r.offsetHeight),s=a*(i.scrollHeight-i.offsetHeight);i.scrollTo(0,s)},n=function(){t("editor")},o=function(){t("preview")};this.$refs.preview.$el.addEventListener("scroll",o,!1),this.editor.on("scroll",n)},onEditorRefresh:function(){this.codeThemeChanged(this.codeTheme),this.editorRefresh(),setTimeout((function(){return window.PR.prettyPrint()}),0)},endCopy:function(){var e=this;this.backLight=!1,setTimeout((function(){e.isCoping=!1}),800)},addFormat:function(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=this.editor.doc.sel.ranges[0],i=r.head,a=r.anchor;i.line===a.line?i.ch