mirror of https://github.com/go-sonic/sonic.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
7.9 KiB
JavaScript
1 line
7.9 KiB
JavaScript
(self["webpackChunkhalo_admin"]=self["webpackChunkhalo_admin"]||[]).push([[265],{86763:function(e,t,n){var r="Expected a function",a=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,c=/^0o[0-7]+$/i,h=parseInt,l="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,f="object"==typeof self&&self&&self.Object===Object&&self,d=l||f||Function("return this")(),g=Object.prototype,v=g.toString,p=Math.max,S=Math.min,m=function(){return d.Date.now()};function w(e,t,n){var a,o,i,s,u,c,h=0,l=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError(r);function g(t){var n=a,r=o;return a=o=void 0,h=t,s=e.apply(r,n),s}function v(e){return h=e,u=setTimeout(y,t),l?g(e):s}function w(e){var n=e-c,r=e-h,a=t-n;return f?S(a,i-r):a}function T(e){var n=e-c,r=e-h;return void 0===c||n>=t||n<0||f&&r>=i}function y(){var e=m();if(T(e))return x(e);u=setTimeout(y,w(e))}function x(e){return u=void 0,d&&a?g(e):(a=o=void 0,s)}function C(){void 0!==u&&clearTimeout(u),h=0,a=c=o=u=void 0}function R(){return void 0===u?s:x(m())}function $(){var e=m(),n=T(e);if(a=arguments,o=this,c=e,n){if(void 0===u)return v(c);if(f)return u=setTimeout(y,t),g(c)}return void 0===u&&(u=setTimeout(y,t)),s}return t=k(t)||0,b(n)&&(l=!!n.leading,f="maxWait"in n,i=f?p(k(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d),$.cancel=C,$.flush=R,$}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function T(e){return!!e&&"object"==typeof e}function y(e){return"symbol"==typeof e||T(e)&&v.call(e)==o}function k(e){if("number"==typeof e)return e;if(y(e))return a;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=u.test(e);return n||c.test(e)?h(e.slice(2),n?2:8):s.test(e)?a:+e}e.exports=w},25265:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("page-view",{attrs:{"sub-title":e.sheetToStage.inProgress?"当前内容已保存,但还未发布。":"",title:e.sheetToStage.title?e.sheetToStage.title:"新页面",affix:""}},[n("template",{slot:"extra"},[n("a-space",[n("a-button",{attrs:{loading:e.previewSaving},on:{click:e.handlePreviewClick}},[e._v("预览")]),n("a-button",{attrs:{type:"primary"},on:{click:function(t){e.sheetSettingVisible=!0}}},[e._v("发布")])],1)],1),n("a-row",{attrs:{gutter:12}},[n("a-col",{attrs:{span:24}},[n("div",{staticClass:"mb-4"},[n("a-input",{attrs:{placeholder:"请输入页面标题",size:"large"},model:{value:e.sheetToStage.title,callback:function(t){e.$set(e.sheetToStage,"title",t)},expression:"sheetToStage.title"}})],1),n("div",{style:{height:e.editorHeight},attrs:{id:"editor"}},[n("MarkdownEditor",{attrs:{originalContent:e.sheetToStage.originalContent},on:{"update:originalContent":function(t){return e.$set(e.sheetToStage,"originalContent",t)},"update:original-content":function(t){return e.$set(e.sheetToStage,"originalContent",t)},change:e.onContentChange,save:function(t){return e.handleSaveDraft()}}})],1)])],1),n("SheetSettingModal",{attrs:{sheet:e.sheetToStage,savedCallback:e.onSheetSavedCallback,visible:e.sheetSettingVisible},on:{"update:visible":function(t){e.sheetSettingVisible=t},onUpdate:e.onUpdateFromSetting}})],2)},a=[],o=n(54288),i=(n(70315),n(12566),n(30535),n(85018),n(96667)),s=n(65899),u=n(58799),c=n(94370),h=n(25572),l=n(36591),f=n(86763),d=n.n(f),g={components:{PageView:i.B4,SheetSettingModal:s.Z,MarkdownEditor:u.Z},mixins:[c.jB,c.KT,c.g3],data:function(){return{sheetSettingVisible:!1,sheetToStage:{},contentChanges:0,previewSaving:!1}},beforeRouteEnter:function(e,t,n){var r=e.query.sheetId;n(function(){var e=(0,o.Z)(regeneratorRuntime.mark((function e(t){var n,a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!r){e.next=6;break}return e.next=3,l.Z.sheet.get(Number(r));case 3:n=e.sent,a=n.data,t.sheetToStage=a;case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())},destroyed:function(){window.onbeforeunload&&(window.onbeforeunload=null)},beforeRouteLeave:function(e,t,n){var r=this.$createElement;this.contentChanges<=1?n():this.$confirm({title:"当前页面数据未保存,确定要离开吗?",content:function(){return r("div",{style:"color:red;"},["如果离开当面页面,你的数据很可能会丢失!"])},onOk:function(){n()},onCancel:function(){n(!1)}})},mounted:function(){window.onbeforeunload=function(e){return e=e||window.event,e&&(e.returnValue="当前页面数据未保存,确定要离开吗?"),"当前页面数据未保存,确定要离开吗?"}},beforeMount:function(){document.addEventListener("keydown",this.onRegisterSaveShortcut)},beforeDestroy:function(){document.removeEventListener("keydown",this.onRegisterSaveShortcut)},methods:{onRegisterSaveShortcut:function(e){!e.ctrlKey&&!e.metaKey||e.altKey||e.shiftKey||83!==e.keyCode||(e.preventDefault(),e.stopPropagation(),this.handleSaveDraft())},handleSaveDraft:d()((0,o.Z)(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!this.sheetToStage.id){e.next=16;break}return e.prev=1,e.next=4,l.Z.sheet.updateDraftById(this.sheetToStage.id,this.sheetToStage.originalContent,this.sheetToStage.content,!0);case 4:t=e.sent,n=t.data,this.sheetToStage.inProgress=n.inProgress,this.handleRestoreSavedStatus(),this.$message.success({content:"内容已保存",duration:.5}),e.next=14;break;case 11:e.prev=11,e.t0=e["catch"](1),this.$log.error("Failed to update sheet content",e.t0);case 14:e.next=18;break;case 16:return e.next=18,this.handleCreateSheet();case 18:case"end":return e.stop()}}),e,this,[[1,11]])}))),300),handleCreateSheet:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.sheetToStage.title||(e.sheetToStage.title=(0,h._)(new Date,"YYYY-MM-DD-HH-mm-ss")),t.prev=1,e.sheetToStage.keepRaw=!0,t.next=5,l.Z.sheet.create(e.sheetToStage);case 5:n=t.sent,r=n.data,e.sheetToStage=r,e.handleRestoreSavedStatus(),a=e.$router.history.current.path,e.$router.replace({path:a,query:{sheetId:e.sheetToStage.id}}).catch((function(e){return e})),e.$message.success({content:"页面已创建",duration:.5}),t.next=17;break;case 14:t.prev=14,t.t0=t["catch"](1),e.$log.error("Failed to create sheet",t.t0);case 17:case"end":return t.stop()}}),t,null,[[1,14]])})))()},handlePreviewClick:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.previewSaving=!0,!e.sheetToStage.id){t.next=9;break}return t.next=4,l.Z.sheet.updateDraftById(e.sheetToStage.id,e.sheetToStage.originalContent,e.sheetToStage.content,!0);case 4:n=t.sent,r=n.data,e.sheetToStage.inProgress=r.inProgress,t.next=11;break;case 9:return t.next=11,e.handleCreateSheet();case 11:return t.next=13,e.handleOpenPreview();case 13:case"end":return t.stop()}}),t)})))()},handleOpenPreview:function(){var e=this;return(0,o.Z)(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,l.Z.sheet.getPreviewLinkById(e.sheetToStage.id);case 3:n=t.sent,window.open(n,"_blank"),e.handleRestoreSavedStatus(),t.next=11;break;case 8:t.prev=8,t.t0=t["catch"](0),e.$log.error("Failed to get preview link",t.t0);case 11:return t.prev=11,setTimeout((function(){e.previewSaving=!1}),400),t.finish(11);case 14:case"end":return t.stop()}}),t,null,[[0,8,11,14]])})))()},handleRestoreSavedStatus:function(){this.contentChanges=0},onContentChange:function(e){var t=e.originalContent,n=e.renderContent;this.contentChanges++,this.sheetToStage.originalContent=t,this.sheetToStage.content=n},onSheetSavedCallback:function(){this.contentChanges=0,this.$router.push({name:"SheetList",query:{activeKey:"custom"}})},onUpdateFromSetting:function(e){this.sheetToStage=e}}},v=g,p=n(70739),S=(0,p.Z)(v,r,a,!1,null,null,null),m=S.exports}}]); |