md/js/app.bca6b906.js
2023-07-28 06:30:53 +00:00

3 lines
84 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(e){function t(t){for(var i,r,a=t[0],l=t[1],c=t[2],u=0,m=[];u<a.length;u++)r=a[u],Object.prototype.hasOwnProperty.call(n,r)&&n[r]&&m.push(n[r][0]),n[r]=0;for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(e[i]=l[i]);d&&d(t);while(m.length)m.shift()();return s.push.apply(s,c||[]),o()}function o(){for(var e,t=0;t<s.length;t++){for(var o=s[t],i=!0,a=1;a<o.length;a++){var l=o[a];0!==n[l]&&(i=!1)}i&&(s.splice(t--,1),e=r(r.s=o[0]))}return e}var i={},n={app:0},s=[];function r(t){if(i[t])return i[t].exports;var o=i[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=i,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(o,i,function(t){return e[t]}.bind(null,i));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/md/";var a=window["webpackJsonp"]=window["webpackJsonp"]||[],l=a.push.bind(a);a.push=t,a=a.slice();for(var c=0;c<a.length;c++)t(a[c]);var d=l;s.push([0,"chunk-vendors"]),o()})({0:function(e,t,o){e.exports=o("3479")},1:function(e,t){},10:function(e,t){},"107b":function(e,t,o){},11:function(e,t){},12:function(e,t){},13:function(e,t){},14:function(e,t){},15:function(e,t){},"1cd3":function(e,t,o){"use strict";var i=o("9ad5"),n=o.n(i);const s=n.a.create({baseURL:"",timeout:3e4});s.interceptors.request.use(e=>(/^(post)|(put)|(delete)$/i.test(e.method)&&e.data&&e.data.upload&&(e.headers["Content-Type"]="multipart/form-data"),e),e=>{Promise.reject(e)}),s.interceptors.response.use(e=>e.data?e.data:Promise.reject(e),e=>Promise.reject(e)),t["a"]=s},2:function(e,t){},"202b":function(e,t,o){},"24f4":function(e,t,o){"use strict";o("2c25")},"2c25":function(e,t,o){},"2dab":function(e,t,o){},3:function(e,t){},3479:function(e,t,o){"use strict";o.r(t);var i=o("ff9b"),n=function(){var e=this,t=e._self._c;return t("div",{attrs:{id:"app"}},[t("router-view")],1)},s=[],r=(o("f961"),o("24f4"),o("2b5f")),a={},l=Object(r["a"])(a,n,s,!1,null,null,null),c=l.exports,d=o("358c"),u={builtinFonts:[{label:"无衬线",value:"-apple-system-font,BlinkMacSystemFont, Helvetica Neue, PingFang SC, Hiragino Sans GB , Microsoft YaHei UI , Microsoft YaHei ,Arial,sans-serif",desc:"Abc"},{label:"衬线",value:"Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif",desc:"Abc"}],sizeOption:[{label:"12px",value:"12px",desc:"更小"},{label:"13px",value:"13px",desc:"稍小"},{label:"14px",value:"14px",desc:"推荐"},{label:"15px",value:"15px",desc:"稍大"},{label:"16px",value:"16px",desc:"更大"}],colorOption:[{label:"经典蓝",value:"rgba(15, 76, 129, 1)",desc:"最新流行"},{label:"翡翠绿",value:"rgba(0, 152, 116, 1)",desc:"优雅清新"},{label:"活力橘",value:"rgba(250, 81, 81, 1)",desc:"热情活泼"}],codeThemeOption:[{label:"github",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/github.min.css",desc:"light"},{label:"solarized-light",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/solarized-light.min.css",desc:"light"},{label:"atom-one-dark",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/atom-one-dark.min.css",desc:"dark"},{label:"obsidian",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/obsidian.min.css",desc:"dark"},{label:"vs2015",value:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/highlight.js@11.5.1/styles/vs2015.min.css",desc:"dark"}],form:{rows:1,cols:1}},m=(o("aa9c"),o("c6de")),p=o("57c9"),f=o.n(p);class h{constructor(e){this.opts=e;let t=[],o=0,i=new Map,n=(e,t)=>Object.assign({},e,t);this.buildTheme=e=>{let t={},o=n(e.BASE,{"font-family":this.opts.fonts,"font-size":this.opts.size});for(let s in e.inline)if(e.inline.hasOwnProperty(s)){let o=e.inline[s];t[s]=n(e.BASE,o)}let i=n(o,{});for(let s in e.block)if(e.block.hasOwnProperty(s)){let o=e.block[s];t[s]=n(i,o)}return t};let s=(e,t)=>{let o=[],n=i[e];if(!n)return"";for(const i in n)o.push(i+":"+n[i]);return`style="${o.join(";")+(t||"")}"`},r=(e,i)=>(t.push([++o,e,i]),o);this.buildFootnotes=()=>{let e=t.map(e=>e[1]===e[2]?`<code style="font-size: 90%; opacity: 0.6;">[${e[0]}]</code>: <i>${e[1]}</i><br/>`:`<code style="font-size: 90%; opacity: 0.6;">[${e[0]}]</code> ${e[1]}: <i>${e[2]}</i><br/>`);return e.length?`<h4 ${s("h4")}>引用链接</h4><p ${s("footnotes")}>${e.join("\n")}</p>`:""},this.buildAddition=()=>"\n <style>\n .preview-wrapper pre::before {\n position: absolute;\n top: 0;\n right: 0;\n color: #ccc;\n text-align: center;\n font-size: 0.8em;\n padding: 5px 10px 0;\n line-height: 15px;\n height: 15px;\n font-weight: 600;\n }\n </style>\n ",this.setOptions=e=>{this.opts=n(this.opts,e)},this.hasFootnotes=()=>0!==t.length,this.getRenderer=e=>{t=[],o=0,i=this.buildTheme(this.opts.theme);let n=new m["Renderer"];return n.heading=(e,t)=>{switch(t){case 1:return`<h1 ${s("h1")}>${e}</h1>`;case 2:return`<h2 ${s("h2")}>${e}</h2>`;case 3:return`<h3 ${s("h3")}>${e}</h3>`;default:return`<h4 ${s("h4")}>${e}</h4>`}},n.paragraph=e=>-1!=e.indexOf("<figure")&&-1!=e.indexOf("<img")?e:""===e.replace(/ /g,"")?"":`<p ${s("p")}>${e}</p>`,n.blockquote=e=>(e=e.replace(/<p.*?>/g,`<p ${s("blockquote_p")}>`),`<blockquote ${s("blockquote")}>${e}</blockquote>`),n.code=(e,t)=>(t=f.a.getLanguage(t)?t:"plaintext",e=f.a.highlight(e,{language:t}).value,e=e.replace(/\r\n/g,"<br/>").replace(/\n/g,"<br/>").replace(/(>[^<]+)|(^[^<]+)/g,(function(e){return e.replace(/\s/g,"&nbsp;")})),`<pre class="hljs code__pre" ${s("code_pre")}><code class="prettyprint language-${t}" ${s("code")}>${e}</code></pre>`),n.codespan=(e,t)=>`<code ${s("codespan")}>${e}</code>`,n.listitem=e=>`<li ${s("listitem")}><span><%s/></span>${e}</li>`,n.list=(e,t,o)=>{e=e.replace(/<\/*p .*?>/g,"").replace(/<\/*p>/g,"");let i=e.split("<%s/>");if(!t)return e=i.join("• "),`<ul ${s("ul")}>${e}</ul>`;e=i[0];for(let n=1;n<i.length;n++)e=e+n+". "+i[n];return`<ol ${s("ol")}>${e}</ol>`},n.image=(e,t,o)=>{let i="";o&&(i=`<figcaption ${s("figcaption")}>${o}</figcaption>`);let n=s("figure"),r=s("image");return`<figure ${n}><img ${r} src="${e}" title="${t}" alt="${o}"/>${i}</figure>`},n.link=(t,o,i)=>{if(t.startsWith("https://mp.weixin.qq.com"))return`<a href="${t}" title="${o||i}" ${s("wx_link")}>${i}</a>`;if(t===i)return i;if(e){let e=r(o||i,t);return`<span ${s("link")}>${i}<sup>[${e}]</sup></span>`}return`<span ${s("link")}>${i}</span>`},n.strong=e=>`<strong ${s("strong")}>${e}</strong>`,n.em=e=>`<span style="font-style: italic;">${e}</span>`,n.table=(e,t)=>`<section style="padding:0 8px;"><table class="preview-table"><thead ${s("thead")}>${e}</thead><tbody>${t}</tbody></table></section>`,n.tablecell=(e,t)=>`<td ${s("td")}>${e}</td>`,n.hr=()=>`<hr ${s("hr")}>`,n}}}var g=h,b=o("f14e"),_=o.n(b),C='# 示例文章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<center>\n<img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303158478-66a96e2d-6424-43d6-8cb3-2f7a39f960b8.gif" style="width: 50%;"></center>\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<center>\n <img src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303220922-7e14aefa-816e-44c1-8604-ade709ca1c69.png" style="width: 100px;">\n</center>\n',y="/*\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",S=o("2658"),k=o.n(S),O=o("53da"),w=o.n(O),v=o("a305"),x=o.n(v);let $="#3f3f3f";var E={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:$},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:$},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:$},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:$},ul:{"margin-left":"0","padding-left":"1em","list-style":"circle",color:$},footnotes:{margin:"0.5em 8px","font-size":"80%",color:$},figure:{margin:"1.5em 8px",color:$},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:$},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:$},thead:{background:"rgba(0, 0, 0, 0.05)","font-weight":"bold",color:$},td:{border:"1px solid #dfdfdf",padding:"0.25em 0.5em",color:$},footnote:{"font-size":"12px",color:$},figcaption:{"text-align":"center",color:"#888","font-size":"0.8em"}}};const M=(e,t)=>{const o=JSON.parse(JSON.stringify(e));return o.block.h1["border-bottom"]="2px solid "+t,o.block.h2["background"]=t,o.block.h3["border-left"]="3px solid "+t,o.block.h4["color"]=t,o.inline.strong["color"]=t,o};function T(e){return t=>M(e,t)}function I(e,t){return M(e,t)}function D(e){return function(t){const o=JSON.parse(JSON.stringify(e));return o.block.h1["font-size"]=1.14*t+"px",o.block.h2["font-size"]=1.1*t+"px",o.block.h3["font-size"]=t+"px",o.block.h4["font-size"]=t+"px",o}}const A=T(E),P=D(E);function R(e,t,o){const i=M(o,t);return i.block.h1=Object.assign(i.block.h1,e.h1),i.block.h2=Object.assign(i.block.h2,e.h2),i.block.h3=Object.assign(i.block.h3,e.h3),i.block.h4=Object.assign(i.block.h4,e.h4),i.block.code=Object.assign(i.block.code,e.code),i.block.p=Object.assign(i.block.p,e.p),i.block.hr=Object.assign(i.block.hr,e.hr),i.block.blockquote=Object.assign(i.block.blockquote,e.blockquote),i.block.blockquote_p=Object.assign(i.block.blockquote_p,e.blockquote_p),i.block.image=Object.assign(i.block.image,e.image),i.inline.strong=Object.assign(i.inline.strong,e.strong),i.inline.codespan=Object.assign(i.inline.codespan,e.codespan),i.inline.link=Object.assign(i.inline.link,e.link),i.inline.wx_link=Object.assign(i.inline.wx_link,e.wx_link),i.block.ul=Object.assign(i.block.ul,e.ul),i.block.ol=Object.assign(i.block.ol,e.ol),i.inline.listitem=Object.assign(i.inline.listitem,e.li),i}function K(e){let t,o;while(-1!==(t=e.indexOf("/*"))&&-1!==(o=e.indexOf("*/")))e=e.substring(0,t)+e.substring(o+2);let i={};while(e.length>0&&-1!==e.indexOf("{")&&-1!==e.indexOf("}")){const t=e.indexOf("{"),o=e.indexOf("}");function n(e){let t={};return e.forEach(e=>{const o=e.indexOf(":"),i=e.substring(0,o).trim();t[i]=e.substring(o+1).trim()}),t}let s=e.substring(t+1,o).split(";").map(e=>e.trim()).filter(e=>e.length>0);s=n(s);let r=e.substring(0,t).split(",").map(e=>e.trim());r.forEach(e=>{i[e]||(i[e]={}),Object.keys(s).forEach(t=>{i[e][t]=s[t]})}),e=e.slice(o+1).trim()}return i}function j(e,t){const o=e.getValue(0);o?localStorage.setItem(t,o):localStorage.removeItem(t)}function B(e){return k.a.format(e,{parser:"markdown",plugins:[x.a]})}function L(e){return k.a.format(e,{parser:"css",plugins:[w.a]})}function U(e){const t=document.createElement("a");t.download="content.md",t.style.display="none";const o=new Blob([e]);t.href=URL.createObjectURL(o),document.body.appendChild(t),t.click(),document.body.removeChild(t)}function q(){const e=document.querySelector("#output");n(e);const t=e.innerHTML,o=document.createElement("a");o.download="content.html",o.style.display="none";let i=new Blob([`<html><head><meta charset="utf-8" /></head><body><div style="width: 750px; margin: auto;">${t}</div></body></html>`]);function n(e){function t(e,t=["width","height"]){const o=getComputedStyle(e,null);return Object.entries(o).filter(([e])=>o.getPropertyValue(e)&&!t.includes(e)).map(([e,t])=>`${e}:${t};`).join("")}switch(!0){case o(e):case i(e):case s(e):e.setAttribute("style",t(e));default:}function o(e){return"PRE"===e.tagName&&Array.from(e.classList).includes("code__pre")}function i(e){return"CODE"===e.tagName&&Array.from(e.classList).includes("prettyprint")}function s(e){return"SPAN"===e.tagName&&(i(e.parentElement)||i(e.parentElement.parentElement))}e.children.length&&Array.from(e.children).forEach(e=>n(e))}o.href=URL.createObjectURL(i),document.body.appendChild(o),o.click(),document.body.removeChild(o)}function F({data:e,rows:t,cols:o}){let i="";for(let n=0;n<t+2;++n){i+="| ";const t=[];for(let i=0;i<o;++i){const o=n>1?n-1:n;t.push(1===n?"---":e[`k_${o}_${i}`]||" ")}i+=t.join(" | "),i+=" |\n"}return i}function z(e){return new Promise((t,o)=>{const i=new FileReader;i.readAsDataURL(e),i.onload=()=>t(i.result.split(",").pop()),i.onerror=e=>o(e)})}function H(e){const t=/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(e.name);if(!t)return{ok:!1,msg:"请上传 JPG/PNG/GIF 格式的图片"};const o=10,i=e.size/1024/1024<=o;return i?{ok:!0}:{ok:!1,msg:`由于公众号限制,图片大小不能超过 ${o}M`}}function G(e){const t=e.split("\n"),o=t.filter(e=>e.trim()).map(e=>e.match(/(^\s+)?/)[0].length).sort((e,t)=>e-t)[0];return t.map(e=>e.slice(o)).join("\n")}i["default"].use(d["a"]);const N={wxRenderer:null,output:"",html:"",editor:null,cssEditor:null,currentFont:"",currentSize:"",currentColor:"",citeStatus:!1,nightMode:!1,codeTheme:u.codeThemeOption[2].value,isMacCodeBlock:!0},W={setEditorValue(e,t){e.editor.setValue(t)},setCssEditorValue(e,t){e.cssEditor.setValue(t)},setWxRendererOptions(e,t){e.wxRenderer.setOptions(t)},setCiteStatus(e,t){e.citeStatus=t,localStorage.setItem("citeStatus",t)},setCurrentFont(e,t){e.currentFont=t,localStorage.setItem("fonts",t)},setCurrentSize(e,t){e.currentSize=t,localStorage.setItem("size",t)},setCurrentColor(e,t){e.currentColor=t,localStorage.setItem("color",t)},setCurrentCodeTheme(e,t){e.codeTheme=t,localStorage.setItem("codeTheme",t)},setIsMacCodeBlock(e,t){e.isMacCodeBlock=t,localStorage.setItem("isMacCodeBlock",t)},themeChanged(e){e.nightMode=!e.nightMode,localStorage.setItem("nightMode",e.nightMode)},initEditorState(e){e.currentFont=localStorage.getItem("fonts")||u.builtinFonts[0].value,e.currentColor=localStorage.getItem("color")||u.colorOption[0].value,e.currentSize=localStorage.getItem("size")||u.sizeOption[2].value,e.codeTheme=localStorage.getItem("codeTheme")||u.codeThemeOption[2].value,e.citeStatus="true"===localStorage.getItem("citeStatus"),e.nightMode="true"===localStorage.getItem("nightMode"),e.isMacCodeBlock=!("false"===localStorage.getItem("isMacCodeBlock")),e.wxRenderer=new g({theme:A(e.currentColor),fonts:e.currentFont,size:e.currentSize})},initEditorEntity(e){const t=document.getElementById("editor");t.value||(t.value=localStorage.getItem("__editor_content")||B(C)),e.editor=_.a.fromTextArea(t,{mode:"text/x-markdown",theme:"xq-light",lineNumbers:!1,lineWrapping:!0,styleActiveLine:!0,autoCloseBrackets:!0,extraKeys:{"Ctrl-F":function(e){const t=B(e.getValue(0));localStorage.setItem("__editor_content",t),e.setValue(t)},"Ctrl-S":function(e){},"Ctrl-B":function(e){const t=e.getSelection();e.replaceSelection(`**${t}**`)},"Ctrl-D":function(e){const t=e.getSelection();e.replaceSelection(`~~${t}~~`)},"Ctrl-I":function(e){const t=e.getSelection();e.replaceSelection(`*${t}*`)}}})},initCssEditorEntity(e){const t=document.getElementById("cssEditor");t.value||(t.value=localStorage.getItem("__css_content")||y),e.cssEditor=_.a.fromTextArea(t,{mode:"css",theme:"style-mirror",lineNumbers:!1,lineWrapping:!0,matchBrackets:!0,autofocus:!0,extraKeys:{"Ctrl-F":function(e){const t=L(e.getValue(0));localStorage.setItem("__css_content",t),e.setValue(t)},"Ctrl-S":function(e){}}})},editorRefresh(e){const t=e.wxRenderer.getRenderer(e.citeStatus);m["marked"].setOptions({renderer:t});let o=m["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.isMacCodeBlock&&(o+="\n <style>\n .hljs.code__pre::before {\n position: initial;\n padding: initial;\n content: '';\n display: block;\n height: 25px;\n background-color: transparent;\n background-image: url(\"https://doocs.oss-cn-shenzhen.aliyuncs.com/img/123.svg\");\n background-position: 14px 10px;\n background-repeat: no-repeat;\n background-size: 40px;\n }\n\n .hljs.code__pre {\n padding: 0!important;\n }\n\n .hljs.code__pre code {\n display: -webkit-box;\n padding: 0.5em 1em 1em;\n overflow-x: auto;\n text-indent: 0;\n }\n </style>\n "),e.output=o}};var V=new d["a"].Store({state:N,mutations:W,actions:{}}),Q=o("ccbf"),J=o.n(Q);o("b6f4");i["default"].component(Q["Message"].name,Q["Message"]),i["default"].prototype.$loading=Q["Loading"].service,i["default"].prototype.$message=Q["Message"];o("e3f8"),o("8128"),o("a6e0"),o("7fa7"),o("697d"),o("beaf"),o("6864"),o("8d07"),o("a176");var Y=o("fe87"),Z=function(){var e=this,t=e._self._c;return t("codemirror-editor")},X=[],ee=function(){var e=this,t=e._self._c;return t("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}]}},[t("el-container",[t("el-header",{staticClass:"editor__header"},[t("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.insertFormDialogVisible=!0},"show-dialog-upload-img":function(t){e.dialogUploadImgVisible=!0},startCopy:function(t){e.isCoping=!0,e.backLight=!0},endCopy:e.endCopy}})],1),t("el-main",{staticClass:"main-body"},[t("el-row",{staticClass:"main-section"},[t("el-col",{ref:"codeMirrorWrapper",staticClass:"codeMirror-wrapper",attrs:{span:12},nativeOn:{contextmenu:function(t){return t.preventDefault(),e.openMenu.apply(null,arguments)}}},[t("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)}}})]),t("el-col",{ref:"preview",staticClass:"preview-wrapper",class:{"preview-wrapper_night":e.nightMode&&e.isCoping},attrs:{span:12,id:"preview"}},[t("section",{class:{output_night:e.nightMode&&!e.backLight},attrs:{id:"output-wrapper"}},[t("div",{staticClass:"preview"},[t("section",{attrs:{id:"output"},domProps:{innerHTML:e._s(e.output)}}),e.nightMode&&e.isCoping?t("div",{staticClass:"loading-mask"},[t("div",{staticClass:"loading__img"}),t("span",[e._v("正在生成")])]):e._e()])])]),t("css-editor",{attrs:{"show-css-editor":e.showCssEditor}})],1)],1)],1),t("upload-img-dialog",{attrs:{visible:e.dialogUploadImgVisible},on:{close:function(t){e.dialogUploadImgVisible=!1},beforeUpload:e.beforeUpload,uploadImage:e.uploadImage,uploaded:e.uploaded}}),t("about-dialog",{attrs:{visible:e.aboutDialogVisible},on:{close:function(t){e.aboutDialogVisible=!1}}}),t("insert-form-dialog",{attrs:{visible:e.insertFormDialogVisible},on:{close:function(t){e.insertFormDialogVisible=!1}}}),t("right-click-menu",{attrs:{visible:e.rightClickMenuVisible,left:e.mouseLeft,top:e.mouseTop},on:{menuTick:e.onMenuEvent,closeMenu:function(t){e.rightClickMenuVisible=!1}}}),t("run-loading")],1)},te=[],oe=(o("a3a9"),function(){var e=this,t=e._self._c;return t("el-container",{staticClass:"header-container is-dark"},[t("div",{staticClass:"dropdowns"},[t("el-dropdown",[t("span",{staticClass:"el-dropdown-link"},[e._v(" 文件"),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[t("el-dropdown-item",{nativeOn:{click:function(t){return e.refClick.apply(null,arguments)}}},[t("i",{staticClass:"el-icon-upload2"}),e._v(" 导入 .md "),t("input",{ref:"fileInput",attrs:{hidden:"",type:"file",accept:".md"}})]),t("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("download")}}},[t("i",{staticClass:"el-icon-download"}),e._v(" 导出 .md ")]),t("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("export")}}},[t("i",{staticClass:"el-icon-document"}),e._v(" 导出 .html ")]),t("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.themeChanged.apply(null,arguments)}}},[t("i",{staticClass:"el-icon-check",style:{opacity:e.nightMode?1:0}}),e._v(" 暗黑模式 ")])],1)],1),t("el-dropdown",[t("span",{staticClass:"el-dropdown-link"},[e._v(" 格式"),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[e._l(e.formatItems,(function({label:o,kbd:i,emitArgs:n}){return t("el-dropdown-item",{key:i,staticClass:"format-item",nativeOn:{click:function(t){return e.$emit(...n)}}},[e._v(" "+e._s(o)+" "),t("kbd",[e._v(e._s(i))])])})),t("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.statusChanged.apply(null,arguments)}}},[t("i",{staticClass:"el-icon-check",style:{opacity:e.citeStatus?1:0}}),e._v(" 微信外链转底部引用 ")])],2)],1),t("el-dropdown",[t("span",{staticClass:"el-dropdown-link"},[e._v(" 编辑"),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[t("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-upload-img")}}},[t("i",{staticClass:"el-icon-upload"}),e._v(" 上传图片 ")]),t("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-dialog-form")}}},[t("i",{staticClass:"el-icon-s-grid"}),e._v(" 插入表格 ")])],1)],1),t("el-dropdown",[t("span",{staticClass:"el-dropdown-link"},[e._v(" 样式"),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[t("el-dropdown-item",{staticClass:"padding-left-3"},[t("style-option-menu",{attrs:{label:"字体",options:e.config.builtinFonts,current:e.selectFont,charge:e.fontChanged}})],1),t("el-dropdown-item",{staticClass:"padding-left-3"},[t("style-option-menu",{attrs:{label:"字号",options:e.config.sizeOption,current:e.selectSize,charge:e.sizeChanged}})],1),t("el-dropdown-item",{staticClass:"padding-left-3"},[t("style-option-menu",{attrs:{label:"颜色",options:e.config.colorOption,current:e.selectColor,charge:e.colorChanged}})],1),t("el-dropdown-item",{staticClass:"padding-left-3"},[t("style-option-menu",{attrs:{label:"代码主题",options:e.config.codeThemeOption,current:e.selectCodeTheme,charge:e.codeThemeChanged}})],1),t("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){return e.showPicker()}}},[e._v(" 自定义颜色 "),t("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),t("el-dropdown-item",{staticClass:"padding-left-3",nativeOn:{click:function(t){return e.customStyle.apply(null,arguments)}}},[e._v(" 自定义 CSS ")]),t("el-dropdown-item",{attrs:{divided:""},nativeOn:{click:function(t){return e.codeBlockChanged.apply(null,arguments)}}},[t("i",{staticClass:"el-icon-check",style:{opacity:e.isMacCodeBlock?1:0}}),e._v(" Mac 代码块 ")]),t("el-dropdown-item",{staticClass:"padding-left-3",attrs:{divided:""},nativeOn:{click:function(t){e.showResetConfirm=!0}}},[e._v(" 重置 ")])],1)],1),t("el-dropdown",[t("span",{staticClass:"el-dropdown-link"},[e._v(" 帮助"),t("i",{staticClass:"el-icon-arrow-down el-icon--right"})]),t("el-dropdown-menu",{attrs:{slot:"dropdown"},slot:"dropdown"},[t("el-dropdown-item",{nativeOn:{click:function(t){return e.$emit("show-about-dialog")}}},[e._v(" 关于 ")])],1)],1)],1),t("el-button",{attrs:{plain:"",size:"medium",type:e.btnType},on:{click:e.copy}},[e._v(" 复制 ")]),t("el-button",{attrs:{plain:"",size:"medium",type:e.btnType},on:{click:e.prePost}},[e._v(" 发布 ")]),t("post-info-dialog",{attrs:{form:e.form},on:{post:e.post,close:function(t){e.form.dialogVisible=!1}}}),t("reset-dialog",{attrs:{"show-reset-confirm":e.showResetConfirm},on:{confirm:e.confirmReset,close:e.cancelReset}})],1)}),ie=[],ne=(o("45da"),o("5941")),se=o.n(ne);function re(){const e=document.getElementById("output"),t=e.getElementsByTagName("img");for(let o=0;o<t.length;o++){const e=t[o],i=e.getAttribute("width"),n=e.getAttribute("height");e.removeAttribute("width"),e.removeAttribute("height"),e.style.width=i,e.style.height=n}}function ae(e){return se()(e,{inlinePseudoElements:!0,preserveImportant:!0})}var le=function(){var e=this,t=e._self._c;return t("el-dialog",{staticClass:"reset__dialog",attrs:{title:"提示",visible:e.showResetConfirm,center:""},on:{close:function(t){return e.$emit("close")}}},[t("div",{staticStyle:{"text-align":"center"}},[e._v("此操作将丢失本地自定义样式,是否继续?")]),t("template",{slot:"footer"},[t("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("close")}}},[e._v(" 取 消 ")]),t("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("confirm")}}},[e._v(" 确 定 ")])],1)],2)},ce=[],de={props:{showResetConfirm:{type:Boolean,default:!1}},computed:{btnType(){return this.nightMode?"default":"primary"},...Object(d["c"])({nightMode:e=>e.nightMode})}},ue=de,me=(o("a0b2"),Object(r["a"])(ue,le,ce,!1,null,"7fcca3b7",null)),pe=me.exports,fe=function(){var e=this,t=e._self._c;return t("el-dropdown",{staticClass:"style-option-menu",attrs:{placement:"right"}},[t("div",{staticClass:"el-dropdown-link"},[e._v(" "+e._s(e.label)+" "),t("i",{staticClass:"el-icon-arrow-right el-icon--right"})]),t("el-dropdown-menu",{staticStyle:{width:"200px"},attrs:{slot:"dropdown"},slot:"dropdown"},e._l(e.options,(function({value:o,label:i,desc:n}){return t("el-dropdown-item",{key:o,attrs:{label:i,value:o},nativeOn:{click:function(t){return e.charge(o)}}},[t("i",{staticClass:"el-icon-check",style:{opacity:e.current===o?1:0}}),e._v(" "+e._s(i)+" "),t("span",{staticClass:"select-item-right"},[e._v(e._s(n))])])})),1)],1)},he=[],ge={name:"StyleOptionMenu",props:{label:{type:String,required:!0},options:{type:Array,required:!0},current:{type:String,required:!0},charge:{type:Function,required:!0}}},be=ge,_e=(o("dcf4"),Object(r["a"])(be,fe,he,!1,null,"32cf930a",null)),Ce=_e.exports,ye=function(){var e=this,t=e._self._c;return t("el-dialog",{attrs:{title:"发布",visible:e.form.dialogVisible},on:{"update:visible":function(t){return e.$set(e.form,"dialogVisible",t)}}},[t("el-alert",{staticStyle:{"margin-bottom":"1em"},attrs:{title:"注:此功能由第三方浏览器插件支持,本平台不保证安全性。",type:"info","show-icon":""}}),t("el-form",{staticClass:"postInfo",attrs:{"label-position":"right","label-width":"50px",model:e.form}},[t("el-form-item",{attrs:{label:"封面"}},[t("el-input",{attrs:{placeholder:"自动提取第一张图"},model:{value:e.form.thumb,callback:function(t){e.$set(e.form,"thumb",t)},expression:"form.thumb"}})],1),t("el-form-item",{attrs:{label:"标题"}},[t("el-input",{attrs:{placeholder:"自动提取第一个标题"},model:{value:e.form.title,callback:function(t){e.$set(e.form,"title",t)},expression:"form.title"}})],1),t("el-form-item",{attrs:{label:"描述"}},[t("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)],1),t("template",{staticClass:"dialog-footer",slot:"footer"},[t("el-button",{on:{click:function(t){return e.$emit("close")}}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.$emit("post")}}},[e._v("确 定")])],1)],2)},Se=[],ke={name:"PostInfoDialog",props:{form:{type:Object}}},Oe=ke,we=Object(r["a"])(Oe,ye,Se,!1,null,"4ab4b77e",null),ve=we.exports,xe={name:"editor-header",data(){return{config:u,citeStatus:!1,isMacCodeBlock:!0,showResetConfirm:!1,selectFont:"",selectSize:"",selectColor:"",selectCodeTheme:u.codeThemeOption[2].value,form:{dialogVisible:!1,title:"",desc:"",thumb:"",content:""},formatItems:[{label:"加粗",kbd:"Ctrl + B",emitArgs:["addFormat","**"]},{label:"斜体",kbd:"Ctrl + I",emitArgs:["addFormat","*"]},{label:"删除线",kbd:"Alt + Shift + U",emitArgs:["addFormat","~~"]},{label:"超链接",kbd:"Alt + Shift + K",emitArgs:["addFormat","[","]()"]},{label:"格式化",kbd:"Alt + Shift + L",emitArgs:["formatContent"]}]}},components:{PostInfoDialog:ve,StyleOptionMenu:Ce,ResetDialog:pe},computed:{btnType(){return this.nightMode?"default":"primary"},...Object(d["c"])({output:e=>e.output,editor:e=>e.editor,cssEditor:e=>e.cssEditor,currentFont:e=>e.currentFont,currentSize:e=>e.currentSize,currentColor:e=>e.currentColor,codeTheme:e=>e.codeTheme,nightMode:e=>e.nightMode,currentCiteStatus:e=>e.citeStatus,currentIsMacCodeBlock:e=>e.isMacCodeBlock})},methods:{refClick(){this.$refs.fileInput.click()},showPicker(){this.$refs.colorPicker.showPicker=!0},prePost(){let e={};try{e={thumb:document.querySelector("#output img").src,title:[1,2,3,4,5,6].map(e=>document.querySelector("#output h"+e)).filter(e=>e)[0].innerText,desc:document.querySelector("#output p").innerText,content:this.output}}catch(t){console.log("error",t)}this.form={dialogVisible:!0,...e,auto:e}},post(){this.form.dialogVisible=!1,window.syncPost({title:this.form.title||this.form.auto.title,desc:this.form.desc||this.form.auto.desc,content:this.form.content||this.form.auto.content,thumb:this.form.thumb||this.form.auto.thumb})},fontChanged(e){this.setWxRendererOptions({fonts:e}),this.setCurrentFont(e),this.selectFont=e,this.$emit("refresh")},sizeChanged(e){let t=P(e.replace("px",""));t=I(t,this.currentColor),this.setWxRendererOptions({size:e,theme:t}),this.setCurrentSize(e),this.selectSize=e,this.$emit("refresh")},colorChanged(e){let t=P(this.currentSize.replace("px",""));t=I(t,e),this.setWxRendererOptions({theme:t}),this.setCurrentColor(e),this.selectColor=e,this.$emit("refresh")},codeThemeChanged(e){this.setCurrentCodeTheme(e),this.selectCodeTheme=e,this.$emit("refresh")},statusChanged(){this.citeStatus=!this.citeStatus,this.setCiteStatus(this.citeStatus),this.$emit("refresh")},codeBlockChanged(){this.isMacCodeBlock=!this.isMacCodeBlock,this.setIsMacCodeBlock(this.isMacCodeBlock),this.$emit("refresh")},copy(){this.$emit("startCopy"),setTimeout(()=>{re();const e=document.getElementById("output");e.innerHTML=ae(e.innerHTML),this.isMacCodeBlock&&(e.innerHTML=e.innerHTML.replaceAll(/(<code class="prettyprint.+?(?<=style="))/g,"$1font-family: Menlo, 'Operator Mono', Consolas, Monaco, monospace;")),e.focus(),window.getSelection().removeAllRanges();let t=document.createRange();t.setStartBefore(e.firstChild),t.setEndAfter(e.lastChild),window.getSelection().addRange(t),document.execCommand("copy"),window.getSelection().removeAllRanges(),e.innerHTML=this.output,this.$notify({showClose:!0,message:"已复制渲染后的文章到剪贴板,可直接到公众号后台粘贴",offset:80,duration:1600,type:"success"}),this.$emit("refresh"),this.$emit("endCopy")},350)},async customStyle(){this.$emit("showCssEditor"),this.$nextTick(()=>{this.cssEditor||this.cssEditor.refresh()}),setTimeout(()=>{this.cssEditor.refresh()},50);let e=localStorage.getItem("__css_content");e||this.setCssEditorValue(y)},confirmReset(){this.showResetConfirm=!1,localStorage.clear(),this.cssEditor.setValue(y),this.citeStatus=!1,this.statusChanged(!1),this.fontChanged(this.config.builtinFonts[0].value),this.colorChanged(this.config.colorOption[0].value),this.sizeChanged(this.config.sizeOption[2].value),this.codeThemeChanged(this.config.codeThemeOption[2].value),this.$emit("cssChanged"),this.selectFont=this.currentFont,this.selectSize=this.currentSize,this.selectColor=this.currentColor,this.selectCodeTheme=this.codeTheme,this.isMacCodeBlock=!1,this.codeBlockChanged()},cancelReset(){this.showResetConfirm=!1,this.editor.focus()},...Object(d["b"])(["setCurrentColor","setCiteStatus","themeChanged","setCurrentFont","setCurrentSize","setCssEditorValue","setCurrentCodeTheme","setWxRendererOptions","setIsMacCodeBlock"])},mounted(){this.selectFont=this.currentFont,this.selectSize=this.currentSize,this.selectColor=this.currentColor,this.selectCodeTheme=this.codeTheme,this.citeStatus=this.currentCiteStatus,this.isMacCodeBlock=this.currentIsMacCodeBlock;const e=this.$refs.fileInput;e.onchange=()=>{const t=e.files[0];if(null==t)return;const o=new FileReader;o.readAsText(t),o.onload=()=>{this.$emit("import-md",o.result)}}}},$e=xe,Ee=(o("7c21"),Object(r["a"])($e,oe,ie,!1,null,"4e99727f",null)),Me=Ee.exports,Te=function(){var e=this,t=e._self._c;return t("el-dialog",{staticClass:"about__dialog",attrs:{title:"关于",visible:e.visible,width:"30%",center:""},on:{close:function(t){return e.$emit("close")}}},[t("div",{staticStyle:{"text-align":"center"}},[t("h3",[e._v("一款高度简洁的微信 Markdown 编辑器")]),t("p",[e._v("扫码关注公众号 Doocs原创技术文章第一时间推送")]),t("img",{staticStyle:{width:"40%"},attrs:{src:"https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/gh/doocs/md/images/1648303220922-7e14aefa-816e-44c1-8604-ade709ca1c69.png"}})]),t("template",{slot:"footer"},[t("el-button",{attrs:{type:"primary",plain:""},on:{click:function(t){return e.onRedirect("https://github.com/doocs/md")}}},[e._v(" GitHub 仓库 ")]),t("el-button",{attrs:{type:"primary",plain:""},on:{click:function(t){return e.onRedirect("https://gitee.com/doocs/md")}}},[e._v(" Gitee 仓库 ")])],1)],2)},Ie=[],De={props:{visible:{type:Boolean,default:!1}},methods:{onRedirect(e){window.open(e)}}},Ae=De,Pe=(o("7f25"),Object(r["a"])(Ae,Te,Ie,!1,null,"314554b5",null)),Re=Pe.exports,Ke=function(){var e=this,t=e._self._c;return t("el-dialog",{staticClass:"insert__dialog",attrs:{title:"插入表格",visible:e.visible,border:""},on:{close:function(t){return e.$emit("close")}}},[t("el-row",{staticClass:"tb-options",attrs:{type:"flex",align:"middle",gutter:10}},[t("el-col",[e._v(" 行数: "),t("el-input-number",{attrs:{"controls-position":"right",min:1,max:100,size:"small"},model:{value:e.rowNum,callback:function(t){e.rowNum=t},expression:"rowNum"}})],1),t("el-col",[e._v(" 列数: "),t("el-input-number",{attrs:{"controls-position":"right",min:1,max:100,size:"small"},model:{value:e.colNum,callback:function(t){e.colNum=t},expression:"colNum"}})],1)],1),t("table",{staticClass:"input-table",staticStyle:{"border-collapse":"collapse"}},e._l(e.rowNum+1,(function(o){return t("tr",{key:o,class:{"head-style":1===o}},e._l(e.colNum,(function(i){return t("td",{key:i},[t("el-input",{attrs:{align:"center",placeholder:1===o?"表头":""},model:{value:e.tableData[`k_${o-1}_${i-1}`],callback:function(t){e.$set(e.tableData,`k_${o-1}_${i-1}`,t)},expression:"tableData[`k_${row - 1}_${col - 1}`]"}})],1)})),0)})),0),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{type:e.btnType,plain:""},on:{click:function(t){return e.$emit("close")}}},[e._v(" 取 消 ")]),t("el-button",{attrs:{type:e.btnType,plain:""},on:{click:e.insertTable}},[e._v(" 确 定 ")])],1)],1)},je=[],Be={props:{visible:{type:Boolean,default:!1}},data(){return{config:u,rowNum:3,colNum:3,tableData:{}}},computed:{btnType(){return this.nightMode?"default":"primary"},...Object(d["c"])({nightMode:e=>e.nightMode,editor:e=>e.editor})},methods:{insertTable(){this.editor.getCursor();const e=F({data:this.tableData,rows:this.rowNum,cols:this.colNum});this.tableData={},this.rowNum=3,this.colNum=3,this.editor.replaceSelection(`\n${e}\n`,"end"),this.$emit("close"),this.editorRefresh()},...Object(d["b"])(["editorRefresh"])}},Le=Be,Ue=(o("5ae1"),Object(r["a"])(Le,Ke,je,!1,null,"015ce7b9",null)),qe=Ue.exports,Fe=function(){var e=this,t=e._self._c;return t("div",{directives:[{name:"show",rawName:"v-show",value:e.visible,expression:"visible"}],staticClass:"menu",style:`left: ${e.left}px;top: ${e.top}px;`,attrs:{id:"menu"}},e._l(e.menu,(function(o,i){return t("ul",{key:i,staticClass:"menu__group"},e._l(o,(function({key:o,text:i}){return t("li",{key:o,staticClass:"menu_item",on:{mousedown:function(t){return e.onMouseDown(o)}}},[e._v(" "+e._s(i)+" ")])})),0)})),0)},ze=[],He={props:{visible:{type:Boolean,default:!1},top:{type:Number,default:0},left:{type:Number,default:0}},data(){return{menu:[[{text:"上传图片",key:"insertPic"},{text:"插入表格",key:"insertTable"},{text:"恢复默认样式",key:"resetStyle"}],[{text:"导入 .md 文档",key:"importMarkdown"},{text:"导出 .md 文档",key:"download"},{text:"导出 .html",key:"export"},{text:"格式化",key:"formatMarkdown"}]]}},methods:{onMouseDown(e){this.$emit("menuTick",e),this.$emit("closeMenu")}}},Ge=He,Ne=(o("ebc0"),Object(r["a"])(Ge,Fe,ze,!1,null,"283cf1ee",null)),We=Ne.exports,Ve=function(){var e=this,t=e._self._c;return t("el-dialog",{staticClass:"upload__dialog",attrs:{title:"本地上传",visible:e.visible},on:{close:function(t){return e.$emit("close")}}},[t("el-tabs",{attrs:{type:"activeName"},model:{value:e.activeName,callback:function(t){e.activeName=t},expression:"activeName"}},[t("el-tab-pane",{staticClass:"upload-panel",attrs:{label:"选择上传",name:"upload"}},[t("el-select",{attrs:{placeholder:"请选择",size:"small"},on:{change:e.changeImgHost},model:{value:e.imgHost,callback:function(t){e.imgHost=t},expression:"imgHost"}},e._l(e.options,(function(e){return t("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1),t("el-upload",{attrs:{drag:"",action:"",headers:{"Content-Type":"multipart/form-data"},"show-file-list":!1,multiple:!0,accept:".jpg, .jpeg, .png, .gif",name:"file","before-upload":e.beforeImageUpload,"http-request":e.uploadImage}},[t("i",{staticClass:"el-icon-upload"}),t("div",{staticClass:"el-upload__text"},[e._v(" 将图片拖到此处,或 "),t("em",[e._v("点击上传")])])])],1),t("el-tab-pane",{staticClass:"github-panel",attrs:{label:"GitHub 图床",name:"github"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.formGitHub,"label-position":"right","label-width":"140px"}},[t("el-form-item",{attrs:{label:"GitHub 仓库",required:!0}},[t("el-input",{attrs:{placeholder:"如github.com/yanglbme/resource"},model:{value:e.formGitHub.repo,callback:function(t){e.$set(e.formGitHub,"repo","string"===typeof t?t.trim():t)},expression:"formGitHub.repo"}})],1),t("el-form-item",{attrs:{label:"分支"}},[t("el-input",{attrs:{placeholder:"如release可不填默认 master"},model:{value:e.formGitHub.branch,callback:function(t){e.$set(e.formGitHub,"branch","string"===typeof t?t.trim():t)},expression:"formGitHub.branch"}})],1),t("el-form-item",{attrs:{label:"Token",required:!0}},[t("el-input",{attrs:{"show-password":"",placeholder:"如cc1d0c1426d0fd0902bd2d7184b14da61b8abc46"},model:{value:e.formGitHub.accessToken,callback:function(t){e.$set(e.formGitHub,"accessToken","string"===typeof t?t.trim():t)},expression:"formGitHub.accessToken"}}),t("el-link",{attrs:{type:"primary",href:"https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token",target:"_blank"}},[e._v("如何获取 GitHub Token ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.saveGitHubConfiguration}},[e._v("保存配置 ")])],1)],1)],1),t("el-tab-pane",{staticClass:"github-panel",attrs:{label:"阿里云 OSS",name:"aliOSS"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.formAliOSS,"label-position":"right","label-width":"140px"}},[t("el-form-item",{attrs:{label:"AccessKey ID",required:!0}},[t("el-input",{attrs:{placeholder:"如LTAI4GdoocsmdoxUf13ylbaNHk"},model:{value:e.formAliOSS.accessKeyId,callback:function(t){e.$set(e.formAliOSS,"accessKeyId","string"===typeof t?t.trim():t)},expression:"formAliOSS.accessKeyId"}})],1),t("el-form-item",{attrs:{label:"AccessKey Secret",required:!0}},[t("el-input",{attrs:{"show-password":"",placeholder:"如cc1d0c142doocs0902bd2d7md4b14da6ylbabc46"},model:{value:e.formAliOSS.accessKeySecret,callback:function(t){e.$set(e.formAliOSS,"accessKeySecret","string"===typeof t?t.trim():t)},expression:"formAliOSS.accessKeySecret"}})],1),t("el-form-item",{attrs:{label:"Bucket",required:!0}},[t("el-input",{attrs:{placeholder:"如doocs"},model:{value:e.formAliOSS.bucket,callback:function(t){e.$set(e.formAliOSS,"bucket","string"===typeof t?t.trim():t)},expression:"formAliOSS.bucket"}})],1),t("el-form-item",{attrs:{label:"Bucket 所在区域",required:!0}},[t("el-input",{attrs:{placeholder:"如oss-cn-shenzhen"},model:{value:e.formAliOSS.region,callback:function(t){e.$set(e.formAliOSS,"region","string"===typeof t?t.trim():t)},expression:"formAliOSS.region"}})],1),t("el-form-item",{attrs:{label:"自定义 CDN 域名",required:!1}},[t("el-input",{attrs:{placeholder:"如https://imagecdn.alidaodao.com可不填"},model:{value:e.formAliOSS.cdnHost,callback:function(t){e.$set(e.formAliOSS,"cdnHost","string"===typeof t?t.trim():t)},expression:"formAliOSS.cdnHost"}})],1),t("el-form-item",{attrs:{label:"存储路径"}},[t("el-input",{attrs:{placeholder:"如img可不填默认为根目录"},model:{value:e.formAliOSS.path,callback:function(t){e.$set(e.formAliOSS,"path","string"===typeof t?t.trim():t)},expression:"formAliOSS.path"}}),t("el-link",{attrs:{type:"primary",href:"https://help.aliyun.com/document_detail/31883.html",target:"_blank"}},[e._v("如何使用阿里云 OSS ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.saveAliOSSConfiguration}},[e._v(" 保存配置 ")])],1)],1)],1),t("el-tab-pane",{staticClass:"github-panel",attrs:{label:"腾讯云 COS",name:"txCOS"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.formTxCOS,"label-position":"right","label-width":"140px"}},[t("el-form-item",{attrs:{label:"SecretId",required:!0}},[t("el-input",{attrs:{placeholder:"如AKIDnQp1w3DOOCSs8F5MDp9tdoocsmdUPonW3"},model:{value:e.formTxCOS.secretId,callback:function(t){e.$set(e.formTxCOS,"secretId","string"===typeof t?t.trim():t)},expression:"formTxCOS.secretId"}})],1),t("el-form-item",{attrs:{label:"SecretKey",required:!0}},[t("el-input",{attrs:{"show-password":"",placeholder:"如ukLmdtEJ9271f3DOocsMDsCXdS3YlbW0"},model:{value:e.formTxCOS.secretKey,callback:function(t){e.$set(e.formTxCOS,"secretKey","string"===typeof t?t.trim():t)},expression:"formTxCOS.secretKey"}})],1),t("el-form-item",{attrs:{label:"Bucket",required:!0}},[t("el-input",{attrs:{placeholder:"如doocs-3212520134"},model:{value:e.formTxCOS.bucket,callback:function(t){e.$set(e.formTxCOS,"bucket","string"===typeof t?t.trim():t)},expression:"formTxCOS.bucket"}})],1),t("el-form-item",{attrs:{label:"Bucket 所在区域",required:!0}},[t("el-input",{attrs:{placeholder:"如ap-guangzhou"},model:{value:e.formTxCOS.region,callback:function(t){e.$set(e.formTxCOS,"region","string"===typeof t?t.trim():t)},expression:"formTxCOS.region"}})],1),t("el-form-item",{attrs:{label:"自定义 CDN 域名",required:!1}},[t("el-input",{attrs:{placeholder:"如https://imagecdn.alidaodao.com可不填"},model:{value:e.formTxCOS.cdnHost,callback:function(t){e.$set(e.formTxCOS,"cdnHost","string"===typeof t?t.trim():t)},expression:"formTxCOS.cdnHost"}})],1),t("el-form-item",{attrs:{label:"存储路径"}},[t("el-input",{attrs:{placeholder:"如img可不填默认根目录"},model:{value:e.formTxCOS.path,callback:function(t){e.$set(e.formTxCOS,"path","string"===typeof t?t.trim():t)},expression:"formTxCOS.path"}}),t("el-link",{attrs:{type:"primary",href:"https://cloud.tencent.com/document/product/436/38484",target:"_blank"}},[e._v("如何使用腾讯云 COS ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.saveTxCOSConfiguration}},[e._v(" 保存配置 ")])],1)],1)],1),t("el-tab-pane",{staticClass:"github-panel",attrs:{label:"七牛云 Kodo",name:"qiniu"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.formQiniu,"label-position":"right","label-width":"140px"}},[t("el-form-item",{attrs:{label:"AccessKey",required:!0}},[t("el-input",{attrs:{placeholder:"如6DD3VaLJ_SQgOdoocsyTV_YWaDmdnL2n8EGx7kG"},model:{value:e.formQiniu.accessKey,callback:function(t){e.$set(e.formQiniu,"accessKey","string"===typeof t?t.trim():t)},expression:"formQiniu.accessKey"}})],1),t("el-form-item",{attrs:{label:"SecretKey",required:!0}},[t("el-input",{attrs:{"show-password":"",placeholder:"如qgZa5qrvDOOcsmdKStD1oCjZ9nB7MDvJUs_34SIm"},model:{value:e.formQiniu.secretKey,callback:function(t){e.$set(e.formQiniu,"secretKey","string"===typeof t?t.trim():t)},expression:"formQiniu.secretKey"}})],1),t("el-form-item",{attrs:{label:"Bucket",required:!0}},[t("el-input",{attrs:{placeholder:"如md"},model:{value:e.formQiniu.bucket,callback:function(t){e.$set(e.formQiniu,"bucket","string"===typeof t?t.trim():t)},expression:"formQiniu.bucket"}})],1),t("el-form-item",{attrs:{label:"Bucket 对应域名",required:!0}},[t("el-input",{attrs:{placeholder:"如https://images.123ylb.cn"},model:{value:e.formQiniu.domain,callback:function(t){e.$set(e.formQiniu,"domain","string"===typeof t?t.trim():t)},expression:"formQiniu.domain"}})],1),t("el-form-item",{attrs:{label:"存储区域",required:!0}},[t("el-input",{attrs:{placeholder:"如z2"},model:{value:e.formQiniu.region,callback:function(t){e.$set(e.formQiniu,"region","string"===typeof t?t.trim():t)},expression:"formQiniu.region"}})],1),t("el-form-item",{attrs:{label:"存储路径",required:!1}},[t("el-input",{attrs:{placeholder:"如img可不填默认为根目录"},model:{value:e.formQiniu.path,callback:function(t){e.$set(e.formQiniu,"path","string"===typeof t?t.trim():t)},expression:"formQiniu.path"}}),t("el-link",{attrs:{type:"primary",href:"https://developer.qiniu.com/kodo",target:"_blank"}},[e._v("如何使用七牛云 Kodo ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.saveQiniuConfiguration}},[e._v(" 保存配置 ")])],1)],1)],1),t("el-tab-pane",{staticClass:"github-panel",attrs:{label:"MinIO",name:"minio"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.minioOSS,"label-position":"right","label-width":"140px"}},[t("el-form-item",{attrs:{label:"Endpoint",required:!0}},[t("el-input",{attrs:{placeholder:"如play.min.io"},model:{value:e.minioOSS.endpoint,callback:function(t){e.$set(e.minioOSS,"endpoint","string"===typeof t?t.trim():t)},expression:"minioOSS.endpoint"}})],1),t("el-form-item",{attrs:{label:"Port",required:!1}},[t("el-input",{attrs:{type:"number",placeholder:"如9000可不填http 默认为 80https 默认为 443"},model:{value:e.minioOSS.port,callback:function(t){e.$set(e.minioOSS,"port","string"===typeof t?t.trim():t)},expression:"minioOSS.port"}})],1),t("el-form-item",{attrs:{label:"UseSSL",required:!0}},[t("el-switch",{attrs:{"active-text":"是","inactive-text":"否"},model:{value:e.minioOSS.useSSL,callback:function(t){e.$set(e.minioOSS,"useSSL",t)},expression:"minioOSS.useSSL"}})],1),t("el-form-item",{attrs:{label:"Bucket",required:!0}},[t("el-input",{attrs:{placeholder:"如doocs"},model:{value:e.minioOSS.bucket,callback:function(t){e.$set(e.minioOSS,"bucket","string"===typeof t?t.trim():t)},expression:"minioOSS.bucket"}})],1),t("el-form-item",{attrs:{label:"AccessKey",required:!0}},[t("el-input",{attrs:{placeholder:"如zhangsan"},model:{value:e.minioOSS.accessKey,callback:function(t){e.$set(e.minioOSS,"accessKey","string"===typeof t?t.trim():t)},expression:"minioOSS.accessKey"}})],1),t("el-form-item",{attrs:{label:"SecretKey",required:!0}},[t("el-input",{attrs:{placeholder:"如asdasdasd"},model:{value:e.minioOSS.secretKey,callback:function(t){e.$set(e.minioOSS,"secretKey","string"===typeof t?t.trim():t)},expression:"minioOSS.secretKey"}}),t("el-link",{attrs:{type:"primary",href:"http://docs.minio.org.cn/docs/master/minio-client-complete-guide",target:"_blank"}},[e._v("如何使用 MinIO ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.saveMinioOSSConfiguration}},[e._v(" 保存配置 ")])],1)],1)],1),t("el-tab-pane",{staticClass:"github-panel formCustom",attrs:{label:"自定义代码",name:"formCustom"}},[t("el-form",{staticClass:"setting-form",attrs:{model:e.formCustom,"label-position":"right"}},[t("el-form-item",{attrs:{label:"",required:!0}},[t("el-input",{ref:"formCustomElInput",staticClass:"formCustomElInput",attrs:{type:"textarea",resize:"none",placeholder:"Your custom code here."},model:{value:e.formCustom.code,callback:function(t){e.$set(e.formCustom,"code",t)},expression:"formCustom.code"}}),t("el-link",{attrs:{type:"primary",href:"https://github.com/doocs/md#自定义上传逻辑",target:"_blank"}},[e._v("参数详情? ")])],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:e.formCustomSave}},[e._v(" 保存配置 ")])],1)],1)],1)],1)],1)},Qe=[],Je={props:{visible:{type:Boolean,default:!1}},data(){return{activeName:"upload",formGitHub:{repo:"",branch:"",accessToken:""},formAliOSS:{accessKeyId:"",accessKeySecret:"",bucket:"",region:"",path:"",cdnHost:""},minioOSS:{endpoint:"",port:"",useSSL:!0,bucket:"",accessKey:"",secretKey:""},formTxCOS:{secretId:"",secretKey:"",bucket:"",region:"",path:"",cdnHost:""},formQiniu:{accessKey:"",secretKey:"",bucket:"",domain:"",region:""},formCustom:{code:localStorage.getItem("formCustomConfig")||G(`\n const {file, util, okCb, errCb} = CUSTOM_ARG\n const param = new FormData()\n param.append('file', file)\n util.axios.post('${window.location.origin}/upload', param, {\n headers: { 'Content-Type': 'multipart/form-data' }\n }).then(res => {\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(){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(){localStorage.setItem("imgHost",this.imgHost),this.$message.success("已成功切换图床")},saveGitHubConfiguration(){if(this.formGitHub.repo&&this.formGitHub.accessToken)localStorage.setItem("githubConfig",JSON.stringify(this.formGitHub)),this.$message.success("保存成功");else{const e=this.formGitHub.repo?"token":"GitHub 仓库";this.$message.error(`参数「${e}」不能为空`)}},saveAliOSSConfiguration(){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(){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(){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(){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(){const e=this.formCustom.editor.getValue();localStorage.setItem("formCustomConfig",e),this.$message.success("保存成功")},beforeImageUpload(e){const t=H(e);if(!t.ok)return this.$message.error(t.msg),!1;let o=localStorage.getItem("imgHost");o=o||"default",localStorage.setItem("imgHost",o);const i=localStorage.getItem(o+"Config"),n="default"==o||i;return!!n||(this.$message.error(`请先配置 ${o} 图床参数`),!1)},uploadImage(e){this.$emit("uploadImage",e.file)}},watch:{activeName:{immediate:!0,handler(e){"formCustom"===e&&this.$nextTick(()=>{const e=this.$refs.formCustomElInput.$el.querySelector("textarea");this.formCustom.editor=this.formCustom.editor||_.a.fromTextArea(e,{mode:"javascript"}),this.formCustom.editor.setValue(this.formCustom.code)})}}},mounted(){}},Ye=Je,Ze=(o("65e4"),Object(r["a"])(Ye,Ve,Qe,!1,null,"5641adf4",null)),Xe=Ze.exports,et=function(){var e=this,t=e._self._c;return t("transition",{attrs:{"enter-active-class":"bounceInRight"}},[t("el-col",{directives:[{name:"show",rawName:"v-show",value:e.showCssEditor,expression:"showCssEditor"}],staticClass:"cssEditor-wrapper",attrs:{span:12}},[t("textarea",{attrs:{id:"cssEditor",type:"textarea",placeholder:"Your custom css here."}})])],1)},tt=[],ot={name:"CssEditor",props:{showCssEditor:{type:Boolean,default:!1}}},it=ot,nt=(o("6bdb"),Object(r["a"])(it,et,tt,!1,null,"912bf7ea",null)),st=nt.exports,rt=function(){var e=this,t=e._self._c;return e.loading?t("transition",{attrs:{name:"fade"}},[t("div",{staticClass:"loading",class:{loading_night:e.nightMode}},[t("strong",[e._v("致力于让 Markdown 编辑更简单")])])]):e._e()},at=[],lt={name:"RunLoading",data(){return{loading:!0}},mounted(){setTimeout(()=>{this.loading=!1},100)},computed:{...Object(d["c"])({nightMode:({nightMode:e})=>e})}},ct=lt,dt=(o("a873"),Object(r["a"])(ct,rt,at,!1,null,"19553015",null)),ut=dt.exports,mt=o("557f");o("e480");var pt={data(){return{showCssEditor:!1,aboutDialogVisible:!1,dialogUploadImgVisible:!1,insertFormDialogVisible:!1,isCoping:!1,isImgLoading:!1,backLight:!1,timeout:null,changeTimer:null,source:"",mouseLeft:0,mouseTop:0,rightClickMenuVisible:!1}},components:{CssEditor:st,RunLoading:ut,EditorHeader:Me,AboutDialog:Re,InsertFormDialog:qe,RightClickMenu:We,UploadImgDialog:Xe},computed:{...Object(d["c"])({wxRenderer:e=>e.wxRenderer,output:e=>e.output,editor:e=>e.editor,cssEditor:e=>e.cssEditor,currentSize:e=>e.currentSize,currentColor:e=>e.currentColor,nightMode:e=>e.nightMode,codeTheme:e=>e.codeTheme})},created(){this.initEditorState(),this.$nextTick(()=>{this.initEditor(),this.initCssEditor(),this.onEditorRefresh(),this.mdLocalToRemote()})},methods:{mdLocalToRemote(){const e=this,t=this.$refs.codeMirrorWrapper.$el;async function o({list:e}){return new Promise((t,o)=>{const{path:i,file:n}=e.find(e=>e.path.match(/\.md$/)),s=new FileReader;s.readAsText(n,"UTF-8"),s.onload=e=>{t({str:e.target.result,file:n,path:i})}})}async function i({md:t,list:o}){const i=[...t.str.matchAll(/!\[(.*?)\]\((.*?)\)/gm)||[]].filter(e=>e),n=t.path.match(/.+?\//)[0],s=await Promise.all(i.map(t=>new Promise((i,s)=>{let[,,r]=t;r=r.replace(/^.\//,"");const{file:a}=o.find(e=>e.path===`${n}${r}`)||{};e.uploadImage(a,e=>{i({matchStr:r,url:e})})})));s.forEach(e=>{t.str=t.str.replace(`](./${e.matchStr})`,`](${e.url})`).replace(`](${e.matchStr})`,`](${e.url})`)}),e.editor.setValue(t.str),console.log("resList",s,t.str)}async function n(e){const t=[];let o="";try{const i=[e];for(const e of i){o+=e.name+"/";for await(const[,n]of e)"file"===n.kind?t.push({path:o+n.name,file:await n.getFile()}):(t.push({path:o+n.name+"/"}),i.push(n))}}catch(i){console.error(i)}return t}t.ondragover=e=>e.preventDefault(),t.ondrop=async e=>{e.preventDefault();for(const t of e.dataTransfer.items)t.getAsFileSystemHandle().then(async e=>{if("directory"===e.kind){const t=await n(e),s=await o({list:t});i({md:s,list:t})}else{const t=await e.getFile();console.log("file",t)}})}},initEditor(){this.initEditorEntity(),this.editor.on("change",(e,t)=>{this.changeTimer&&clearTimeout(this.changeTimer),this.changeTimer=setTimeout(()=>{this.onEditorRefresh(),j(this.editor,"__editor_content")},300)}),this.editor.on("paste",(e,t)=>{if(t.clipboardData&&t.clipboardData.items&&!this.isImgLoading)for(let o=0,i=t.clipboardData.items.length;o<i;++o){let e=t.clipboardData.items[o];if("file"===e.kind){const t=e.getAsFile(),o=this.beforeUpload(t);if(!o)continue;this.uploadImage(t)}}}),this.editor.on("mousedown",()=>{this.rightClickMenuVisible=!1}),this.editor.on("blur",()=>{
//!影响到右键菜单的点击事件右键菜单的点击事件在组件内通过mousedown触发
this.rightClickMenuVisible=!1}),this.editor.on("scroll",()=>{this.rightClickMenuVisible=!1})},initCssEditor(){this.initCssEditorEntity(),this.cssEditor.on("keyup",(e,t)=>{(t.keyCode>=65&&t.keyCode<=90||189===t.keyCode)&&e.showHint(t)}),this.cssEditor.on("update",e=>{this.cssChanged(),j(this.cssEditor,"__css_content")})},cssChanged(){let e=K(this.cssEditor.getValue(0)),t=P(this.currentSize.replace("px",""));t=R(e,this.currentColor,t),this.setWxRendererOptions({theme:t}),this.onEditorRefresh()},codeThemeChanged(){let e=this.codeTheme,t=document.getElementById("hljs");if(void 0!=t)t.setAttribute("href",e);else{const t=document.createElement("link");t.setAttribute("type","text/css"),t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),t.setAttribute("id","hljs"),document.head.appendChild(t)}},beforeUpload(e){const t=H(e);if(!t.ok)return this.$message.error(t.msg),!1;let o=localStorage.getItem("imgHost");o=o||"default",localStorage.setItem("imgHost",o);const i=localStorage.getItem(o+"Config"),n="default"==o||i;return!!n||(this.$message.error(`请先配置 ${o} 图床参数`),!1)},uploadImage(e,t){this.isImgLoading=!0,z(e).then(o=>{mt["a"].fileUpload(o,e).then(e=>{console.log(e),t?t(e):this.uploaded(e)}).catch(e=>{this.$message.error(e.message)})}).catch(e=>{this.$message.error(e.message)}),this.isImgLoading=!1},uploaded(e){if(console.log("图片上传之后: ",e),!e)return void this.$message.error("上传图片未知异常");this.dialogUploadImgVisible=!1;const t=this.editor.getCursor(),o=e,i=`![](${o})`;this.editor.replaceSelection(`\n${i}\n`,t),this.$message.success("图片上传成功"),this.onEditorRefresh()},leftAndRightScroll(){const e=e=>{let i,n;clearTimeout(this.timeout),"preview"===e?(i=this.$refs.preview.$el,n=document.getElementsByClassName("CodeMirror-scroll")[0],this.editor.off("scroll",t),this.timeout=setTimeout(()=>{this.editor.on("scroll",t)},300)):"editor"===e&&(i=document.getElementsByClassName("CodeMirror-scroll")[0],n=this.$refs.preview.$el,n.removeEventListener("scroll",o,!1),this.timeout=setTimeout(()=>{n.addEventListener("scroll",o,!1)},300));let s=i.scrollTop/(i.scrollHeight-i.offsetHeight),r=s*(n.scrollHeight-n.offsetHeight);n.scrollTo(0,r)},t=()=>{e("editor")},o=()=>{e("preview")};this.$refs.preview.$el.addEventListener("scroll",o,!1),this.editor.on("scroll",t)},onEditorRefresh(){this.codeThemeChanged(this.codeTheme),this.editorRefresh(),setTimeout(()=>window.PR.prettyPrint(),0)},endCopy(){this.backLight=!1,setTimeout(()=>{this.isCoping=!1},800)},addFormat(e,t=e){const{head:o,anchor:i}=this.editor.doc.sel.ranges[0];let n,s;o.line===i.line?o.ch<i.ch?(n=o,s=i):(n=i,s=o):o.line<i.line?(n=o,s=i):(n=i,s=o);const r=[];let a="";for(const c of this.editor.getValue())"\n"===c?(r.push(a),a=""):a+=c;r.push(a);let l="";for(let c=0;c<r.length;c++){const o=r[c];for(let i=0;i<o.length;i++)c===n.line&&i===n.ch&&(l+=e),c===s.line&&i===s.ch&&(l+=t),l+=o[i];c===s.line&&o.length===s.ch&&(l+=t),l+="\n"}this.editor.setValue(l)},importMD(e){this.editor.setValue(e),this.onEditorRefresh()},downloadEditorContent(){U(this.editor.getValue(0))},exportEditorContent(){this.$nextTick(()=>{q(),document.getElementById("output").innerHTML=this.output})},importMarkdownContent(){let e=document.getElementById("menu"),t=document.createElement("input");t.type="file",t.name="filename",t.accept=".txt,.md",e.appendChild(t),t.onchange=()=>{if(!t.files)return;const e=t.files[0];if(!/\.(txt|TXT|MD|md)$/.test(e.name))return void this.$message.error("不支持的文档格式");const o=new FileReader;o.readAsText(e),o.onload=e=>{let t=e.target.result;t=B(t),t&&(localStorage.setItem("__editor_content",t),this.editor.setValue(t),this.$message.success("文档导入成功"))}},t.click(),e.removeChild(t)},formatContent(){const e=B(this.editor.getValue(0));localStorage.setItem("__editor_content",e),this.editor.setValue(e)},openMenu(e){const t=105,o=this.$el.getBoundingClientRect().left,i=this.$el.offsetWidth,n=i-t,s=e.clientX-o;this.mouseLeft=Math.min(n,s),this.mouseTop=e.clientY+10,this.rightClickMenuVisible=!0},onMenuEvent(e){switch(e){case"resetStyle":this.$refs.header.showResetConfirm=!0;break;case"insertPic":this.dialogUploadImgVisible=!0;break;case"download":this.downloadEditorContent();break;case"export":this.exportEditorContent();break;case"insertTable":this.insertFormDialogVisible=!0;break;case"importMarkdown":this.importMarkdownContent();break;case"formatMarkdown":this.formatContent();break;default:break}},...Object(d["b"])(["initEditorState","initEditorEntity","setWxRendererOptions","editorRefresh","initCssEditorEntity"])},mounted(){setTimeout(()=>{this.leftAndRightScroll(),window.PR.prettyPrint()},300)}},ft=pt,ht=(o("3ddd"),o("daeb"),o("9c0d"),Object(r["a"])(ft,ee,te,!1,null,"b4e935ba",null)),gt=ht.exports,bt={name:"App",components:{CodemirrorEditor:gt}},_t=bt,Ct=Object(r["a"])(_t,Z,X,!1,null,"821a8f8c",null),yt=Ct.exports;i["default"].use(Y["a"]);const St=[{path:"/",name:"index",component:yt}],kt=new Y["a"]({mode:"history",base:"/md/",routes:St});var Ot=kt;i["default"].use(J.a),i["default"].config.productionTip=!1,c.mpType="app";const wt=new i["default"]({router:Ot,store:V,...c});wt.$mount("#app")},"37a4":function(e,t,o){},"3ddd":function(e,t,o){"use strict";o("b888")},4:function(e,t){},"4f8e":function(e,t,o){"use strict";o.d(t,"b",(function(){return i})),o.d(t,"a",(function(){return n}));const i={username:"filess",repoList:Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],e=>"img"+e),branch:"main",accessTokenList:["7715d7ca67b5d3837cfdoocsmde8c38421815aa423510af","c411415bf95dbe39625doocsmd5047ba9b7a2a6c9642abe","2821cd8819fa345c053doocsmdca86ac653f8bc20db1f1b","445f0dae46ef1f2a4d6doocsmdc797301e94797b4750a4c","cc1d0c1426d0fd0902bdoocsmdd2d7184b14da61b86ec46","b67e9d15cb6f910492fdoocsmdac6b44d379c953bb19eff","618c4dc2244ccbbc088doocsmd125d17fd31b7d06a50cf3","a4b581732e1c1507458doocsmdc5b223b27dae5e2e16a55","77904db41aee57ad79bdoocsmd760f848201dac9c96fd5e","02f251cb14ac62ab100doocsmdddbfc8527d773f1f04ce1","eb321079a95ba7028d9doocsmde2e84c502dac70de7cf08","22f74fcfb071a961fa2doocsmde28dabc746f0503a15e5d","85124c2bfe7abba0938doocsmd0af7f67918b99d085a5fd","0a561b4d4bbecb2de7edoocsmdd9ba3833d11dbc5e430f5","e8a01491188d8d5a097doocsmd03ede0aad1fe9e3af24e9","36e1f420d7e5bdebd67doocsmd65463562f5f25b20b8377"]},n={username:"filesss",repoList:Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],e=>"img"+e),branch:"main",accessTokenList:["ed5fc9866bd6c2fdoocsmddd433f806fd2f399c","5448ffebbbf1151doocsmdc4e337cf814fc8a62","25b05efd2557ca2doocsmd75b5c0835e3395911","11628c7a5aef015doocsmd2eeff9fb9566f0458","cb2f5145ed938dedoocsmdbd063b4ed244eecf8","d8c0b57500672c1doocsmd55f48b866b5ebcd98","78c56eadb88e453doocsmd43ddd95753351771a","03e1a688003948fdoocsmda16fcf41e6f03f1f0","c49121cf4d191fbdoocsmdd6a7877ed537e474a","adfeb2fadcdc4aadoocsmdfe1ee869ac9c968ff","116c94549ca4a0ddoocsmd192653af5c0694616","ecf30ed7f2eb184doocsmd51ea4ec8300371d9e","5837cf2bd5afd93doocsmd73904bed31934949e","b5b7e1c7d57e01fdoocsmd5266f552574297d78","684d55564ffbd0bdoocsmd7d747e5cc23aed6d6","3fc04a9d272ab71doocsmd010c56cb57d88d2ba"]}},5:function(e,t){},"557f":function(module,__webpack_exports__,__webpack_require__){"use strict";var _fetch__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("1cd3"),_config__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("4f8e"),crypto_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("02fe"),crypto_js__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(crypto_js__WEBPACK_IMPORTED_MODULE_2__),ali_oss__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("fd9d"),ali_oss__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(ali_oss__WEBPACK_IMPORTED_MODULE_3__),minio__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("8890"),minio__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(minio__WEBPACK_IMPORTED_MODULE_4__),cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__("bd88"),cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5__),buffer_from__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__("8113"),buffer_from__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(buffer_from__WEBPACK_IMPORTED_MODULE_6__),uuid__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__("78ac"),qiniu_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__("b114"),_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__("8f11");function getConfig(e,t){if(e){const e="github"===t?_config__WEBPACK_IMPORTED_MODULE_1__["b"]:_config__WEBPACK_IMPORTED_MODULE_1__["a"],{username:o,repoList:i,branch:n,accessTokenList:s}=e,r=Math.floor(Math.random()*s.length),a=s[r].replace("doocsmd",""),l=Math.floor(Math.random()*i.length),c=i[l];return{username:o,repo:c,branch:n,accessToken:a}}const o=JSON.parse(localStorage.getItem(t+"Config")),i=o.repo.replace(`https://${t}.com/`,"").replace(`http://${t}.com/`,"").replace(t+".com/","").split("/");return{username:i[0],repo:i[1],branch:o.branch||"master",accessToken:o.accessToken}}function getDir(){const e=new Date,t=e.getFullYear(),o=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getDate().toString().padStart(2,"0");return`${t}/${o}/${i}`}function getDateFilename(e){const t=(new Date).getTime(),o=e.split(".")[1];return`${t}-${Object(uuid__WEBPACK_IMPORTED_MODULE_7__["a"])()}.${o}`}async function ghFileUpload(e,t){var o;const i="default"===localStorage.getItem("imgHost"),{username:n,repo:s,branch:r,accessToken:a}=getConfig(i,"github"),l=getDir(),c=`https://api.github.com/repos/${n}/${s}/contents/${l}/`,d=getDateFilename(t),u=await Object(_fetch__WEBPACK_IMPORTED_MODULE_0__["a"])({url:c+d,method:"put",headers:{Authorization:"token "+a},data:{content:e,branch:r,message:"Upload by "+window.location.href}}),m=`raw.githubusercontent.com/${n}/${s}/${r}/`,p=`fastly.jsdelivr.net/gh/${n}/${s}@${r}/`;return u.content=(null===(o=u.data)||void 0===o?void 0:o.content)||u.content,i?u.content.download_url.replace(m,p):u.content.download_url}async function giteeUpload(e,t){var o;const i="default"===localStorage.getItem("imgHost"),{username:n,repo:s,branch:r,accessToken:a}=getConfig(i,"gitee"),l=getDir(),c=getDateFilename(t),d=`https://gitee.com/api/v5/repos/${n}/${s}/contents/${l}/${c}`,u=await Object(_fetch__WEBPACK_IMPORTED_MODULE_0__["a"])({url:d,method:"POST",data:{content:e,branch:r,access_token:a,message:"Upload by "+window.location.href}});return u.content=(null===(o=u.data)||void 0===o?void 0:o.content)||u.content,encodeURI(u.content.download_url)}function getQiniuToken(e,t,o){const i=JSON.stringify(o),n=Object(_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__["base64encode"])(Object(_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__["utf16to8"])(i)),s=crypto_js__WEBPACK_IMPORTED_MODULE_2___default.a.HmacSHA1(n,t),r=s.toString(crypto_js__WEBPACK_IMPORTED_MODULE_2___default.a.enc.Base64);return`${e}:${Object(_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__["safe64"])(r)}:${n}`}async function qiniuUpload(e){const{accessKey:t,secretKey:o,bucket:i,region:n,path:s,domain:r}=JSON.parse(localStorage.getItem("qiniuConfig")),a=getQiniuToken(t,o,{scope:i,deadline:Math.trunc((new Date).getTime()/1e3)+3600}),l=s?s+"/":"",c=l+getDateFilename(e.name),d=qiniu_js__WEBPACK_IMPORTED_MODULE_8__["upload"](e,c,a,{},{region:n});return new Promise((e,t)=>{d.subscribe({next:e=>{console.log(e)},error:e=>{t(e.message)},complete:t=>{e(`${r}/${t.key}`)}})})}async function aliOSSFileUpload(e,t){const o=getDateFilename(t),{region:i,bucket:n,accessKeyId:s,accessKeySecret:r,cdnHost:a,path:l}=JSON.parse(localStorage.getItem("aliOSSConfig")),c=buffer_from__WEBPACK_IMPORTED_MODULE_6___default()(e,"base64"),d=`${l}/${o}`,u=new ali_oss__WEBPACK_IMPORTED_MODULE_3___default.a({region:i,bucket:n,accessKeyId:s,accessKeySecret:r});try{const e=await u.put(d,c);return""===a?e.url:`${a}/${""===l?o:d}`}catch(m){return Promise.reject(m)}}async function txCOSFileUpload(e){const t=getDateFilename(e.name),{secretId:o,secretKey:i,bucket:n,region:s,path:r,cdnHost:a}=JSON.parse(localStorage.getItem("txCOSConfig")),l=new cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5___default.a({SecretId:o,SecretKey:i});return new Promise((o,i)=>{l.putObject({Bucket:n,Region:s,Key:`${r}/${t}`,Body:e},(function(e,n){e?i(e):o(a?""==r?`${a}/${t}`:`${a}/${r}/${t}`:"https://"+n.Location)}))})}async function minioFileUpload(e,t){const o=getDateFilename(t),{endpoint:i,port:n,useSSL:s,bucket:r,accessKey:a,secretKey:l}=JSON.parse(localStorage.getItem("minioConfig")),c=buffer_from__WEBPACK_IMPORTED_MODULE_6___default()(e,"base64"),d={endPoint:i,useSSL:s,accessKey:a,secretKey:l},u=Number(n||0),m=u>0&&80!==u&&443!==u;return m&&(d.port=u),new Promise((e,t)=>{const a=new minio__WEBPACK_IMPORTED_MODULE_4__["Client"](d);try{a.putObject(r,o,c,(function(a){a&&t(a);const l=`${s?"https://":"http://"}${i}${m?":"+n:""}`,c=`${l}/${r}/${o}`;e(c)}))}catch(l){t(l)}})}async function formCustomUpload(content,file){const str=`\n async (CUSTOM_ARG) => {\n ${localStorage.getItem("formCustomConfig")}\n }\n `;return new Promise((resolve,reject)=>{const exportObj={content:content,file:file,util:{axios:_fetch__WEBPACK_IMPORTED_MODULE_0__["a"],CryptoJS:crypto_js__WEBPACK_IMPORTED_MODULE_2___default(),OSS:ali_oss__WEBPACK_IMPORTED_MODULE_3___default(),COS:cos_js_sdk_v5__WEBPACK_IMPORTED_MODULE_5___default(),Buffer:buffer_from__WEBPACK_IMPORTED_MODULE_6___default(),uuidv4:uuid__WEBPACK_IMPORTED_MODULE_7__["a"],qiniu:qiniu_js__WEBPACK_IMPORTED_MODULE_8__,tokenTools:_assets_scripts_tokenTools__WEBPACK_IMPORTED_MODULE_9__,getDir:getDir,getDateFilename:getDateFilename},okCb:resolve,errCb:reject};eval(str)(exportObj).catch(e=>{console.error(e),reject(e)})})}function fileUpload(e,t){const 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}},"5ae1":function(e,t,o){"use strict";o("890c")},6:function(e,t){},"65e4":function(e,t,o){"use strict";o("f691")},"6bdb":function(e,t,o){"use strict";o("c2d6")},7:function(e,t){},"7c21":function(e,t,o){"use strict";o("adf2")},"7f25":function(e,t,o){"use strict";o("8af6")},8:function(e,t){},"890c":function(e,t,o){},"898f":function(e,t,o){},"8af6":function(e,t,o){},"8f11":function(e,t,o){"use strict";function i(e){var t,o,i,n;for(t="",i=e.length,o=0;o<i;o++)n=e.charCodeAt(o),n>=1&&n<=127?t+=e.charAt(o):n>2047?(t+=String.fromCharCode(224|n>>12&15),t+=String.fromCharCode(128|n>>6&63),t+=String.fromCharCode(128|n>>0&63)):(t+=String.fromCharCode(192|n>>6&31),t+=String.fromCharCode(128|n>>0&63));return t}function n(e){var t,o,i,n,s,r;t="",i=e.length,o=0;while(o<i)switch(n=e.charCodeAt(o++),n>>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:s=e.charCodeAt(o++),t+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e.charCodeAt(o++),r=e.charCodeAt(o++),t+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&r)<<0);break}return t}o.r(t),o.d(t,"utf16to8",(function(){return i})),o.d(t,"utf8to16",(function(){return n})),o.d(t,"base64encode",(function(){return a})),o.d(t,"base64decode",(function(){return l})),o.d(t,"safe64",(function(){return c}));const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",r=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 a(e){var t,o,i,n,r,a;i=e.length,o=0,t="";while(o<i){if(n=255&e.charCodeAt(o++),o==i){t+=s.charAt(n>>2),t+=s.charAt((3&n)<<4),t+="==";break}if(r=e.charCodeAt(o++),o==i){t+=s.charAt(n>>2),t+=s.charAt((3&n)<<4|(240&r)>>4),t+=s.charAt((15&r)<<2),t+="=";break}a=e.charCodeAt(o++),t+=s.charAt(n>>2),t+=s.charAt((3&n)<<4|(240&r)>>4),t+=s.charAt((15&r)<<2|(192&a)>>6),t+=s.charAt(63&a)}return t}function l(e){var t,o,i,n,s,a,l;a=e.length,s=0,l="";while(s<a){do{t=r[255&e.charCodeAt(s++)]}while(s<a&&-1==t);if(-1==t)break;do{o=r[255&e.charCodeAt(s++)]}while(s<a&&-1==o);if(-1==o)break;l+=String.fromCharCode(t<<2|(48&o)>>4);do{if(i=255&e.charCodeAt(s++),61==i)return l;i=r[i]}while(s<a&&-1==i);if(-1==i)break;l+=String.fromCharCode((15&o)<<4|(60&i)>>2);do{if(n=255&e.charCodeAt(s++),61==n)return l;n=r[n]}while(s<a&&-1==n);if(-1==n)break;l+=String.fromCharCode((3&i)<<6|n)}return l}function c(e){return e=e.replace(/\+/g,"-"),e=e.replace(/\//g,"_"),e}},9:function(e,t){},"9c0d":function(e,t,o){"use strict";o("37a4")},a0b2:function(e,t,o){"use strict";o("2dab")},a873:function(e,t,o){"use strict";o("202b")},adf2:function(e,t,o){},b888:function(e,t,o){},c2d6:function(e,t,o){},daeb:function(e,t,o){"use strict";o("107b")},dcf4:function(e,t,o){"use strict";o("ff68")},e90d:function(e,t,o){},ebc0:function(e,t,o){"use strict";o("e90d")},f691:function(e,t,o){},f961:function(e,t,o){"use strict";o("898f")},ff68:function(e,t,o){}});