(function(e){function t(t){for(var n,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 o=new minio__WEBPACK_IMPORTED_MODULE_19__["Client"](d);try{o.putObject(c,n,_,(function(o){o&&t(o);var r="".concat(s?"https://":"http://").concat(i).concat(f?":"+a:""),l="".concat(r,"/").concat(c,"/").concat(n);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 o=localStorage.getItem("imgHost");switch(!o&&localStorage.setItem("imgHost","default"),o){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){},"422a":function(e,t,o){"use strict";o("954c")},"4e00":function(e,t,o){"use strict";o.r(t),o.d(t,"utf16to8",(function(){return n})),o.d(t,"utf8to16",(function(){return r})),o.d(t,"base64encode",(function(){return s})),o.d(t,"base64decode",(function(){return c})),o.d(t,"safe64",(function(){return l}));o("ac1f"),o("5319");function n(e){var t,o,n,r;for(t="",n=e.length,o=0;o=1&&r<=127?t+=e.charAt(o):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,o,n,r,i,a;t="",n=e.length,o=0;while(o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=e.charAt(o-1);break;case 12:case 13:i=e.charCodeAt(o++),t+=String.fromCharCode((31&r)<<6|63&i);break;case 14:i=e.charCodeAt(o++),a=e.charCodeAt(o++),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,o,n,r,a,s;n=e.length,o=0,t="";while(o>2),t+=i.charAt((3&r)<<4),t+="==";break}if(a=e.charCodeAt(o++),o==n){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(o++),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,o,n,r,i,s,c;s=e.length,i=0,c="";while(i>4);do{if(n=255&e.charCodeAt(i++),61==n)return c;n=a[n]}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){o.opts=a(o.opts,e)},this.hasFootnotes=function(){return 0!==n.length},this.getRenderer=function(e){n=[],r=0,i=o.buildTheme(o.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("
")},t.blockquote=function(e){return e=e.replace(//g,"")),"
").concat(e,"
")},t.code=function(e,t){return t=b.a.getLanguage(t)?t:"plaintext",e=b.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,o){e=e.replace(/<\/*p.*?>/g,"");var n=e.split("<%s/>");if(!t)return e=n.join("• "),"");e=n[0];for(var r=1;r").concat(e,"")},t.image=function(e,t,o){var n="";o&&(n="").concat(o,""));var r=s("figure"),i=s("image");return"")},t.link=function(t,o,n){if(t.startsWith("https://mp.weixin.qq.com"))return'").concat(n,"");if(t===n)return n;if(e){var r=c(o||n,t);return"").concat(n,"[").concat(r,"]")}return"").concat(n,"")},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=g,v=o("56b3"),O=o.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=o("3835"),y=(o("e9c4"),o("4160"),o("159b"),o("498a"),o("4de4"),o("b64b"),o("fb6a"),o("2b3d"),o("9861"),o("a630"),o("caad"),o("2532"),o("00b4"),o("b0c0"),o("4fadc"),o("4e82"),o("466d"),"#3f3f3f"),S={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:y},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:y},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:y},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:y},ul:{"margin-left":"0","padding-left":"1em","list-style":"circle",color:y},footnotes:{margin:"0.5em 8px","font-size":"80%",color:y},figure:{margin:"1.5em 8px",color:y},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:y},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:y},thead:{background:"rgba(0, 0, 0, 0.05)","font-weight":"bold",color:y},td:{border:"1px solid #dfdfdf",padding:"0.25em 0.5em",color:y},footnote:{"font-size":"12px",color:y},figcaption:{"text-align":"center",color:"#888","font-size":"0.8em"}}},x=o("325b1"),M=o.n(x),D=o("4fc3"),T=o.n(D),j=o("d238"),P=o.n(j);function I(e){return function(t){var o=JSON.parse(JSON.stringify(e));return o.block.h1["border-bottom"]="2px solid ".concat(t),o.block.h2["background"]=t,o.block.h3["border-left"]="3px solid ".concat(t),o.block.h4["color"]=t,o.inline.strong["color"]=t,o}}var A=function(e,t){var o=JSON.parse(JSON.stringify(e));return o.block.h1["border-bottom"]="2px solid ".concat(t),o.block.h2["background"]=t,o.block.h3["border-left"]="3px solid ".concat(t),o.block.h4["color"]=t,o.inline.strong["color"]=t,o};function R(e){return function(t){var o=JSON.parse(JSON.stringify(e));return o.block.h1["font-size"]="".concat(1.14*t,"px"),o.block.h2["font-size"]="".concat(1.1*t,"px"),o.block.h3["font-size"]="".concat(t,"px"),o.block.h4["font-size"]="".concat(t,"px"),o}}var U=I(S),K=R(S);function L(e,t,o){var n=JSON.parse(JSON.stringify(o));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.block.h1=Object.assign(n.block.h1,e.h1),n.block.h2=Object.assign(n.block.h2,e.h2),n.block.h3=Object.assign(n.block.h3,e.h3),n.block.h4=Object.assign(n.block.h4,e.h4),n.block.code=Object.assign(n.block.code,e.code),n.block.p=Object.assign(n.block.p,e.p),n.block.hr=Object.assign(n.block.hr,e.hr),n.block.blockquote=Object.assign(n.block.blockquote,e.blockquote),n.block.blockquote_p=Object.assign(n.block.blockquote_p,e.blockquote_p),n.block.image=Object.assign(n.block.image,e.image),n.inline.strong=Object.assign(n.inline.strong,e.strong),n.inline.codespan=Object.assign(n.inline.codespan,e.codespan),n.inline.link=Object.assign(n.inline.link,e.link),n.inline.wx_link=Object.assign(n.inline.wx_link,e.wx_link),n.block.ul=Object.assign(n.block.ul,e.ul),n.block.ol=Object.assign(n.block.ol,e.ol),n.inline.listitem=Object.assign(n.inline.listitem,e.li),n}function B(e){var t,o;while(-1!==(t=e.indexOf("/*"))&&-1!==(o=e.indexOf("*/")))e=e.substring(0,t)+e.substring(o+2);var n={},r=function(){var t=e.indexOf("{"),o=e.indexOf("}");function r(e){var t={};return e.forEach((function(e){var o=e.indexOf(":"),n=e.substring(0,o).trim(),r=e.substring(o+1).trim();t[n]=r})),t}var i=e.substring(t+1,o).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){n[e]||(n[e]={}),Object.keys(i).forEach((function(t){n[e][t]=i[t]}))})),e=e.slice(o+1).trim()};while(e.length>0&&-1!==e.indexOf("{")&&-1!==e.indexOf("}"))r();return n}function $(e,t){var o=e.getValue(0);o?localStorage.setItem(t,o):localStorage.removeItem(t)}function q(e){var t=M.a.format(e,{parser:"markdown",plugins:[T.a]});return t}function W(e){var t=M.a.format(e,{parser:"css",plugins:[P.a]});return t}function F(e){var t=document.createElement("a");t.download="content.md",t.style.display="none";var o=new Blob([e]);t.href=URL.createObjectURL(o),document.body.appendChild(t),t.click(),document.body.removeChild(t)}function z(){var e=document.querySelector("#output");r(e);var t=e.innerHTML,o=document.createElement("a");o.download="content.html",o.style.display="none";var n=new Blob([''.concat(t,"
")]);function r(e){switch(!0){case t(e):case o(e):case n(e):e.setAttribute("style",V(e));default:}function t(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 n(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)}))}o.href=URL.createObjectURL(n),document.body.appendChild(o),o.click(),document.body.removeChild(o)}function H(e){for(var t=e.data,o=e.rows,n=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}var G=function(e){return new Promise((function(t,o){var n=new FileReader;n.readAsDataURL(e),n.onload=function(){return t(n.result.split(",").pop())},n.onerror=function(e){return o(e)}}))};function N(e){var t=/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(e.name);if(!t)return{ok:!1,msg:"请上传 JPG/PNG/GIF 格式的图片"};var o=10,n=e.size/1024/1024<=o;return n?{ok:!0}:{ok:!1,msg:"由于公众号限制,图片大小不能超过 ".concat(o,"M")}}function V(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height"],o=getComputedStyle(e,null);return Object.entries(o).filter((function(e){var n=Object(E["a"])(e,1),r=n[0];return o.getPropertyValue(r)&&!t.includes(r)})).map((function(e){var t=Object(E["a"])(e,2),o=t[0],n=t[1];return"".concat(o,":").concat(n,";")})).join("")}function Q(e){var t=e.split("\n"),o=t.filter((function(e){return e.trim()})).map((function(e){return e.match(/(^\s+)?/)[0].length})).sort((function(e,t){return e-t}))[0],n=t.map((function(e){return e.slice(o)})).join("\n");return 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:U(e.currentColor),fonts:e.currentFont,size:e.currentSize})},initEditorEntity:function(e){var t=document.getElementById("editor");t.value||(t.value=localStorage.getItem("__editor_content")||q(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=q(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=W(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 o=p["marked"].parse(e.editor.getValue(0));o=o.replace(/(style=".*?)"/,'$1;margin-top: 0"'),e.citeStatus&&(o+=e.wxRenderer.buildFootnotes(),o+=e.wxRenderer.buildAddition()),e.output=o}},Z=new _["a"].Store({state:J,mutations:Y,actions:{}}),X=o("5c96"),ee=o.n(X);o("0fae");r["default"].component(X["Message"].name,X["Message"]),r["default"].prototype.$loading=X["Loading"].service,r["default"].prototype.$message=X["Message"];o("a7be"),o("8d7e"),o("7b00"),o("959b"),o("10b2"),o("8c33"),o("31c5"),o("9b74"),o("111b");var te=o("8c4f"),oe=function(){var e=this,t=e.$createElement,o=e._self._c||t;return e.loading?o("transition",{attrs:{name:"fade"}},[o("loading")],1):o("codemirror-editor")},ne=[],re=(o("4795"),o("3a5e")),ie=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("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}]}},[o("el-container",[o("el-header",{staticClass:"editor__header"},[o("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),o("el-main",{staticClass:"main-body"},[o("el-row",{staticClass:"main-section"},[o("el-col",{ref:"codeMirrorWrapper",staticClass:"codeMirror-wrapper",attrs:{span:12},nativeOn:{contextmenu:function(t){return t.preventDefault(),e.openMenu(t)}}},[o("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)}}})]),o("el-col",{ref:"preview",staticClass:"preview-wrapper",class:{"preview-wrapper_night":e.nightMode&&e.isCoping},attrs:{span:12,id:"preview"}},[o("section",{class:{output_night:e.nightMode&&!e.backLight},attrs:{id:"output-wrapper"}},[o("div",{staticClass:"preview"},[o("section",{attrs:{id:"output"},domProps:{innerHTML:e._s(e.output)}}),e.nightMode&&e.isCoping?o("div",{staticClass:"loading-mask"},[o("div",{staticClass:"loading__img"}),o("span",[e._v("正在生成")])]):e._e()])])]),o("transition",{attrs:{name:"custom-classes-transition","enter-active-class":"bounceInRight"}},[o("el-col",{directives:[{name:"show",rawName:"v-show",value:e.showCssEditor,expression:"showCssEditor"}],staticClass:"cssEditor-wrapper",attrs:{id:"cssBox",span:12}},[o("textarea",{attrs:{id:"cssEditor",type:"textarea",placeholder:"Your custom css here."}})])],1)],1)],1)],1),o("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"}}),o("about-dialog",{model:{value:e.aboutDialogVisible,callback:function(t){e.aboutDialogVisible=t},expression:"aboutDialogVisible"}}),o("insert-form-dialog",{model:{value:e.dialogFormVisible,callback:function(t){e.dialogFormVisible=t},expression:"dialogFormVisible"}}),o("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=o("2909"),ce=o("c7eb"),le=o("b85c"),ue=o("1da1"),_e=o("668b"),de=(o("7db0"),o("a1f0"),o("18a5"),function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("el-container",{staticClass:"top is-dark"},[o("el-dialog",{attrs:{title:"发布",visible:e.form.dialogVisible},on:{"update:visible":function(t){return e.$set(e.form,"dialogVisible",t)}}},[o("div",{staticClass:"postInfo"},[o("el-form",{ref:"form",attrs:{model:e.form,"label-width":"80px"}},[o("el-form-item",{attrs:{label:"封面"}},[o("el-input",{attrs:{placeholder:"自动提取第一张图"},model:{value:e.form.thumb,callback:function(t){e.$set(e.form,"thumb",t)},expression:"form.thumb"}})],1),o("el-form-item",{attrs:{label:"标题"}},[o("el-input",{attrs:{placeholder:"自动提取第一个标题"},model:{value:e.form.title,callback:function(t){e.$set(e.form,"title",t)},expression:"form.title"}})],1),o("el-form-item",{attrs:{label:"描述"}},[o("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),o("el-form-item",[o("div",{staticClass:"info"},[e._v(" 注:此功能由第三方浏览器插件支持,本平台不保证安全性。 ")])])],1)],1),o("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[o("el-button",{on:{click:function(t){e.form.dialogVisible=!1}}},[e._v("取 消")]),o("el-button",{attrs:{type:"primary"},on:{click:e.post}},[e._v("确 定")])],1)]),o("div",{staticClass:"left-side"},[o("el-dropdown",[o("span",{staticClass:"el-dropdown-link"},[e._v(" 文件"),o("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),o("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[o("el-dropdown-item",{nativeOn:{click:function(t){return e.refClick.apply(null,arguments)}}},[o("i",{staticClass:"el-icon-upload2",attrs:{size:"medium"}}),e._v(" 导入 .md "),o("input",{ref:"fileInput",attrs:{hidden:"",type:"file",accept:".md"}})]),o("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("download")}}},[o("i",{staticClass:"el-icon-download",attrs:{size:"medium"}}),e._v(" 导出 .md ")]),o("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("export")}}},[o("i",{staticClass:"el-icon-document",attrs:{size:"medium"}}),e._v(" 导出 .html ")]),o("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.themeChanged.apply(null,arguments)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.nightMode?1:0}}),e._v(" 暗黑模式 ")])],1)],1),o("el-dropdown",[o("span",{staticClass:"el-dropdown-link"},[e._v(" 格式"),o("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),o("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[o("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","**")}}},[e._v(" 加粗 "),o("kbd",[e._v(" Ctrl + B ")])]),o("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","*")}}},[e._v(" 斜体 "),o("kbd",[e._v(" Ctrl + I ")])]),o("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("addFormat","~~")}}},[e._v(" 删除线 "),o("kbd",[e._v(" Alt + Shift + U ")])]),o("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){e.$emit("addFormat","[","]()")}}},[e._v(" 超链接 "),o("kbd",[e._v(" Alt + Shift + K ")])]),o("el-dropdown-item",{staticClass:"format-item",nativeOn:{click:function(t){return e.$emit("formatContent")}}},[e._v(" 格式化 "),o("kbd",[e._v(" Ctrl + Alt + L ")])]),o("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.statusChanged.apply(null,arguments)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.citeStatus?1:0}}),e._v(" 微信外链转底部引用 ")])],1)],1),o("el-dropdown",[o("span",{staticClass:"el-dropdown-link"},[e._v(" 编辑"),o("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),o("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[o("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-upload-img")}}},[o("i",{staticClass:"el-icon-upload",attrs:{size:"medium"}}),e._v(" 上传图片 ")]),o("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-form")}}},[o("i",{staticClass:"el-icon-s-grid",attrs:{size:"medium"}}),e._v(" 插入表格 ")])],1)],1),o("el-dropdown",[o("span",{staticClass:"el-dropdown-link"},[e._v(" 样式"),o("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),o("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[o("el-dropdown-item",{staticClass:"padding-left-3"},[o("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[o("div",{staticClass:"el-dropdown-link"},[e._v(" 字体 "),o("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),o("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.builtinFonts,(function(t){return o("el-dropdown-item",{key:t.value,style:{fontFamily:t.value},attrs:{label:t.label,value:t.value},nativeOn:{click:function(o){return e.fontChanged(t.value)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.selectFont===t.value?1:0}}),o("span",[e._v(e._s(t.label))]),o("span",{staticClass:"select-item-right"},[e._v("Abc")])])})),1)],1)],1),o("el-dropdown-item",{staticClass:"padding-left-3"},[o("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[o("div",{staticClass:"el-dropdown-link"},[e._v(" 字号 "),o("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),o("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.sizeOption,(function(t){return o("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(o){return e.sizeChanged(t.value)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.selectSize===t.value?1:0}}),o("span",[e._v(e._s(t.label))]),o("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),o("el-dropdown-item",{staticClass:"padding-left-3"},[o("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[o("div",{staticClass:"el-dropdown-link"},[e._v(" 颜色 "),o("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),o("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.colorOption,(function(t){return o("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(o){return e.colorChanged(t.value)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.selectColor===t.value?1:0}}),o("span",[e._v(e._s(t.label))]),o("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),o("el-dropdown-item",{staticClass:"padding-left-3"},[o("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[o("div",{staticClass:"el-dropdown-link"},[e._v(" 代码主题 "),o("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),o("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.config.codeThemeOption,(function(t){return o("el-dropdown-item",{key:t.value,attrs:{label:t.label,value:t.value},nativeOn:{click:function(o){return e.codeThemeChanged(t.value)}}},[o("i",{staticClass:"el-icon-check",style:{opacity:e.selectCodeTheme===t.value?1:0}}),o("span",[e._v(e._s(t.label))]),o("span",{staticClass:"select-item-right"},[e._v(e._s(t.desc))])])})),1)],1)],1),o("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){return e.showPicker()}}},[e._v(" 自定义颜色 "),o("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),o("el-dropdown-item",{staticClass:"padding-left-3",nativeOn:{click:function(t){return e.customStyle.apply(null,arguments)}}},[e._v(" 自定义 CSS ")]),o("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){e.showResetConfirm=!0}}},[e._v(" 重置 ")])],1)],1),o("el-dropdown",[o("span",{staticClass:"el-dropdown-link"},[e._v(" 帮助"),o("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),o("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[o("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-about-dialog")}}},[e._v(" 关于 ")])],1)],1)],1),o("div",{staticClass:"right-side"},[o("el-button",{attrs:{type:e.btnType,plain:"",size:"medium",placement:"bottom-start"},on:{click:e.copy}},[e._v("复制 ")]),o("el-button",{attrs:{type:e.btnType,plain:"",size:"medium",placement:"bottom-start"},on:{click:e.prePost}},[e._v("发布 ")])],1),o("resetDialog",{attrs:{showResetConfirm:e.showResetConfirm},on:{confirm:e.confirmReset,close:e.cancelReset}})],1)}),me=[],fe=o("466b"),pe=o.n(fe);function he(){for(var e=document.getElementById("output"),t=e.getElementsByTagName("img"),o=0;o {\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=N(e);if(!t.ok)return this.$message.error(t.msg),!1;var o=localStorage.getItem("imgHost");o=o||"default",localStorage.setItem("imgHost",o);var n=localStorage.getItem("".concat(o,"Config")),r="default"==o||n;return!!r||(this.$message.error("请先配置 ".concat(o," 图床参数")),!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=(o("8c8d"),Object(s["a"])(Qe,Ge,Ne,!1,null,"34793210",null)),Ye=Je.exports,Ze=o("3f5e");o("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(n["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(n["a"])({mdLocalToRemote:function(){var e=this,t=this.$refs.codeMirrorWrapper.$el;function o(e){return n.apply(this,arguments)}function n(){return n=Object(ue["a"])(Object(ce["a"])().mark((function e(t){var o;return Object(ce["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return o=t.list,e.abrupt("return",new Promise((function(e,t){var n=o.find((function(e){return e.path.match(/\.md$/)})),r=n.path,i=n.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)}))),n.apply(this,arguments)}function r(e){return i.apply(this,arguments)}function i(){return i=Object(ue["a"])(Object(ce["a"])().mark((function t(o){var n,r,i,a,s;return Object(ce["a"])().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return n=o.md,r=o.list,i=Object(se["a"])(n.str.matchAll(/!\[(.*?)\]\((.*?)\)/gm)||[]).filter((function(e){return e})),a=n.path.match(/.+?\//)[0],t.next=5,Promise.all(i.map((function(t){return new Promise((function(o,n){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){o({matchStr:s,url:e})}))}))})));case 5:s=t.sent,s.forEach((function(e){n.str=n.str.replace("](./".concat(e.matchStr,")"),"](".concat(e.url,")")).replace("](".concat(e.matchStr,")"),"](".concat(e.url,")"))})),e.editor.setValue(n.str),console.log("resList",s,n.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 o,n,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:o=[],n="",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(),$(e.cssEditor,"__css_content")}))},cssChanged:function(){var e=B(this.cssEditor.getValue(0)),t=K(this.currentSize.replace("px",""));t=L(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 o=document.createElement("link");o.setAttribute("type","text/css"),o.setAttribute("rel","stylesheet"),o.setAttribute("href",e),o.setAttribute("id","hljs"),document.head.appendChild(o)}},beforeUpload:function(e){var t=N(e);if(!t.ok)return this.$message.error(t.msg),!1;var o=localStorage.getItem("imgHost");o=o||"default",localStorage.setItem("imgHost",o);var n=localStorage.getItem("".concat(o,"Config")),r="default"==o||n;return!!r||(this.$message.error("请先配置 ".concat(o," 图床参数")),!1)},uploadImage:function(e,t){var o=this;this.isImgLoading=!0,G(e).then((function(n){Ze["a"].fileUpload(n,e).then((function(e){console.log(e),t?t(e):o.uploaded(e)}))["catch"]((function(e){o.$message.error(e.message)}))}))["catch"]((function(e){o.$message.error(e.message)})),this.isImgLoading=!1},uploaded:function(e){if(console.log("图片上传之后: ",e),e){this.dialogUploadImgVisible=!1;var t=this.editor.getCursor(),o=e,n="![](".concat(o,")");this.editor.replaceSelection("\n".concat(n,"\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",o),e.timeout=setTimeout((function(){e.editor.on("scroll",o)}),300)):"editor"===t&&(r=document.getElementsByClassName("CodeMirror-scroll")[0],i=e.$refs.preview.$el,i.removeEventListener("scroll",n,!1),e.timeout=setTimeout((function(){i.addEventListener("scroll",n,!1)}),300));var a=r.scrollTop/(r.scrollHeight-r.offsetHeight),s=a*(i.scrollHeight-i.offsetHeight);i.scrollTo(0,s)},o=function(){t("editor")},n=function(){t("preview")};this.$refs.preview.$el.addEventListener("scroll",n,!1),this.editor.on("scroll",o)},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,o,n=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