editor.f95ac3c9.js 9.2 KB

1
  1. import{n as q,_ as te,f1 as ae,u as le,a as se,r,a7 as ie,o as re,a9 as ue,a6 as ne,E as ce,K as de,L as pe,f2 as ve,e as _,f as w,h as s,g as l,i as y,w as u,l as x,y as N,F as me,x as fe,j as $,du as _e,p as ye,q as ge,H as he,I as be,B as Te,C as we}from"./index.f884e450.js";/* empty css */import{T as xe,E as qe}from"./index.esm.cc592525.js";import{C as ke,a as Ee,u as Ce}from"./usePost.f4c734d0.js";import{a as Ie,i as Ve}from"./article.c01b4a44.js";import{a as Fe,i as Se}from"./news.b621e126.js";import{b as Ne,i as $e}from"./video.c430579b.js";import{a as Ue,i as Be}from"./forum.c125424a.js";import{E as Re}from"./index.7a6f4560.js";/* empty css */import"./topic.bdc58923.js";/* empty css */import"./index.0f7f0657.js";import"./throttle.88168f2d.js";const M=(b,a)=>{const n=Ie,t=Fe,v=Ne,T=Ue;let i=null;switch(console.log(b,"bbb"),b){case"article":i=n;break;case"news":i=t;break;case"video":i=v;break;case"forum":i=T;break}return new Promise((d,U)=>{try{if(console.log(i),i)i(a).then(E=>{d(E)}).catch(()=>{q.error("token\u8FC7\u671F\u8BF7\u91CD\u65B0\u767B\u5F55"),localStorage.clear()});else throw new Error("\u7C7B\u578B\u9519\u8BEF")}catch(E){console.log(i),U(E)}})};const k=b=>(Te("data-v-d9d4459c"),b=b(),we(),b),Pe={class:"editor-container"},ze={class:"editor-header p800"},Me={class:"mainbox"},je={key:0,class:"editor-main videobox"},Oe={class:"footerbox"},Ae=k(()=>s("div",{class:"footerbox-title"},"\u53D1\u5E03\u89C6\u9891",-1)),Le=k(()=>s("div",{class:"editor-main__border editor-main__border--video"},null,-1)),De={class:"editor-main"},Ge={key:1,class:"editor-main__border"},He=k(()=>s("div",{class:"editor-main__border"},null,-1)),Ke={class:"footerbox"},Je=k(()=>s("div",{class:"footerbox-title"},"\u53D1\u5E03\u8BBE\u7F6E",-1)),Ze=["src"],Qe=["src"],We=k(()=>s("span",{class:"xtip"},"\u6DFB\u52A0\u6587\u7AE0\u5C01\u9762",-1)),Xe=k(()=>s("p",{class:"upload-tip"},"\u56FE\u7247\u4E0A\u4F20\u683C\u5F0F\u652F\u6301JPEG\u3001PNG",-1)),Ye={class:"fixed-main flex-row flex-aic flex-jc-sb"},eo={class:"fixed__left"},oo={class:"fixed__right"},j="default",to={__name:"editor",setup(b){const a=ae(),n=le(),t=se(),v=r(0),T=r(null),i=ie(),d=r("<p></p>"),U=async()=>{try{const{data:e}=await Ve({id:t.query.id});d.value=e.content,g.value=e.title,h.value=e.image,v.value=e.topic_id,T.value=e.topic.title,console.log("currentTopid",v.value)}catch{}},E=async()=>{try{const{data:e}=await Se({id:t.query.id});d.value=e.content,g.value=e.title,h.value=e.image,v.value=e.topic_id,T.value=e.topic.title}catch{}},O=async()=>{try{const{data:e}=await $e({id:t.query.id});d.value=e.content,g.value=e.title,h.value=e.image,v.value=e.topic_id,console.log("currentTopid",v.value),C.value=e.video_title,I.value=e.video_url,T.value=e.topic.title}catch{}},A=async()=>{try{const{data:e}=await Be({id:t.query.id});d.value=e.content,g.value=e.title,m.value=e.images,v.value=e.topic_id,T.value=e.topic.title}catch{}};re(()=>{t.query.type=="article"&&t.query.id?(U(),a.setEditorType("article")):t.query.type=="info"&&t.query.id?(E(),a.setEditorType("news"),console.log(a.editorType)):t.query.type=="video"&&!t.query.id?a.setEditorType("video"):t.query.type=="post"&&t.query.id?(A(),a.setEditorType("forum"),console.log("forum",a.editorType)):t.query.type=="video"&&t.query.id&&(O(),a.setEditorType("video"))});const L={toolbarKeys:["undo","redo","|","bold","italic","|","justifyLeft","justifyCenter","|","divider","uploadImage"],MENU_CONF:{uploadImage:{server:`${{}.VITE_AP_BASE_API}/upload/image`,maxFileSize:1*1024*1024,maxNumberOfFiles:1,allowedFileTypes:["image/*"],fieldName:"file",headers:{"Content-Type":"multipart/form-data"},timeout:5*1e3,onSuccess(e,o){console.log(`${e.name} \u4E0A\u4F20\u6210\u529F`,o)},customInsert(e,o){console.log("%c custom insert >>>","background: blue; color: #fff",e),o(url,alt,href)}}}};r("");const D={placeholder:"\u8BF7\u8F93\u5165\u6B63\u6587",MENU_CONF:{uploadImage:{server:"https://www.yixiangvr.com/api/upload/image",fieldName:"image",onSuccess(e,o){console.log(e)},customInsert(e,o){console.log("%c custom insert >>>","background: blue; color: #fff",e),o(e.data.url)}}}};ue(()=>{const e=i.value;e?.destroy()});const G=e=>{i.value=e,console.log("%c ??? >>>","background: blue; color: #fff",e.getConfig().MENU_CONF)};ne(d,()=>{const e=i.value.getText();R.value=e.length}),r("");const g=r(""),h=r(""),R=r(0),H=()=>{},K=()=>{},m=r([]),F=r(),J=e=>{F.value.clearFiles(),F.value.handleStart(e[0]),F.value.submit()},Z=async e=>{console.log("%c --- handle custom upload image >>>","background: blue; color: #fff",e);try{m.value=[];const{file:o}=e,p=new FormData;p.append("image",o);const{imageFile:c}=await Ee(p);console.log("imageCove.value",m.value),c.value&&t.query.type=="forum"||t.query.type=="post"?(m.value=[c.value],console.log("imageFile",m.value)):c.value&&(h.value=c.value),e.onSuccess()}catch(o){e.onError(),console.log("%c ??? >>>","background: blue; color: #fff",o),q.error("\u4E0A\u4F20\u5C01\u9762\u56FE\u51FA\u9519")}},C=r(""),I=r(""),Q=async()=>{let e={title:g.value,content:d.value,topic_id:V.value?V.value.id:v.value,status:"normal",image:h.value,id:t.query.id,images:m.value};a.editorType==="video"&&(e.video_title=C.value,e.video_url=I.value);try{const o=await M(a.editorType,e);q.success("\u7F16\u8F91\u6210\u529F"),a.editorType=="video"?n.push({path:"/video"}):t.query.type=="article"?n.push({path:"/articles"}):t.query.type=="forum"||t.query.type=="post"?n.push({path:"/forum"}):t.query.type=="info"&&n.push({path:"/zixun"})}catch{q.error(`${str}\u5931\u8D25`)}},P=e=>{let o=e==="draft"?"\u5B58\u8349\u7A3F":"\u53D1\u5E03";_e.confirm(`\u786E\u8BA4\u8981${o}\u5417`).then(async()=>{let p={title:g.value,content:d.value,topic_id:V.value?V.value.id:"0",status:e,image:h.value,id:t.query.id,images:m.value};a.editorType==="video"&&(p.video_title=C.value,p.video_url=I.value);try{if(t.query.verdict==1){const c=await M(a.editorType,p)}else{console.log(a.editorType);const c=await Ce(a.editorType,p)}q.success(`${o}\u6210\u529F`),console.log("str",o),a.editorType=="video"&&o!="\u5B58\u8349\u7A3F"?n.push({path:"/video"}):t.query.type=="article"&&o!="\u5B58\u8349\u7A3F"?n.push({path:"/articles"}):t.query.type=="forum"||t.query.type=="post"&&o!="\u5B58\u8349\u7A3F"?n.push({path:"/forum"}):t.query.type=="news"&&o!="\u5B58\u8349\u7A3F"?n.push({path:"/zixun"}):o=="\u5B58\u8349\u7A3F"&&n.push({path:"/draft"})}catch{q.error(`${o}\u5931\u8D25`)}})};console.log("type",t);const V=r(null),W=e=>{console.log("%c current topic >>>","background: blue; color: #fff",e),V.value=e},X=()=>{n.go(-1)};t.query.verdict;const B=t.query.dict;return(e,o)=>{const p=ce,c=de,z=pe,Y=ye,ee=Re,S=ge,oe=ve;return _(),w("div",Pe,[s("div",ze,[s("div",Me,[l(y(xe),{editor:i.value,defaultConfig:L,mode:j},null,8,["editor"])])]),y(a).editorType=="video"?(_(),w("div",je,[s("div",Oe,[Ae,Le,l(z,{"label-position":"left",class:"video-custom"},{default:u(()=>[l(c,{label:"\u8BF7\u6DFB\u52A0\u5173\u8054\u89C6\u9891\u6807\u9898"},{default:u(()=>[l(p,{modelValue:C.value,"onUpdate:modelValue":o[0]||(o[0]=f=>C.value=f),size:"large",placeholder:"\u8BF7\u8F93\u5165\u6807\u9898"},null,8,["modelValue"])]),_:1}),l(c,{label:"\u8BF7\u6DFB\u52A0\u5173\u8054\u89C6\u9891\u94FE\u63A5"},{default:u(()=>[l(p,{size:"large",modelValue:I.value,"onUpdate:modelValue":o[1]||(o[1]=f=>I.value=f),placeholder:"\u89C6\u9891\u94FE\u63A5\uFF0C\u4F8B\uFF1Ahttps://www.bilibili.com/video/BV188411V7Z7/?spm_id_from"},null,8,["modelValue"])]),_:1})]),_:1})])])):x("",!0),s("div",De,[y(a).editorType!="forum"?(_(),N(p,{key:0,class:"inputtitle",modelValue:g.value,"onUpdate:modelValue":o[2]||(o[2]=f=>g.value=f),size:"large",placeholder:"\u8BF7\u8F93\u5165\u6807\u9898"},null,8,["modelValue"])):x("",!0),y(a).editorType!="forum"?(_(),w("div",Ge)):x("",!0),l(y(qe),{style:{height:"500px","overflow-y":"hidden"},modelValue:d.value,"onUpdate:modelValue":o[3]||(o[3]=f=>d.value=f),defaultConfig:D,mode:j,onOnCreated:G},null,8,["modelValue"]),He,s("div",Ke,[Je,l(z,{"label-width":"100","label-position":"left"},{default:u(()=>[l(c,{label:"\u6DFB\u52A0\u5C01\u9762",class:"flex-customs"},{default:u(()=>[l(ee,{ref_key:"uploadRef",ref:F,limit:1,accept:y(he)("image"),"auto-upload":!0,action:"#","list-type":"picture-card","on-preview":H,"on-exceed":J,"http-request":Z,"on-remove":K},{default:u(()=>[h.value?(_(),w("img",{key:0,src:h.value,class:"image-cover"},null,8,Ze)):m.value&&m.value.length>0?(_(),w("img",{key:1,src:m.value,class:"image-cover"},null,8,Qe)):(_(),w(me,{key:2},[l(Y,{size:18,color:"#999"},{default:u(()=>[l(y(be))]),_:1}),We],64))]),_:1},8,["accept"]),Xe]),_:1}),l(c,{label:"\u8BDD\u9898\u9009\u62E9"},{default:u(()=>[l(ke,{onReciveTopic:W,Topid:v.value,Title:T.value},null,8,["Topid","Title"])]),_:1})]),_:1})])]),l(oe,{class:"fixed-footer"},{default:u(()=>[s("div",Ye,[s("div",eo,"\u5B57\u6570\uFF1A"+fe(R.value),1),s("div",oo,[l(S,{onClick:X},{default:u(()=>[$("\u53D6\u6D88\u53D1\u5E03")]),_:1}),y(B)!=2?(_(),N(S,{key:0,onClick:o[4]||(o[4]=f=>P("draft"))},{default:u(()=>[$("\u5B58\u8349\u7A3F")]),_:1})):x("",!0),y(B)!=2?(_(),N(S,{key:1,type:"primary",onClick:o[5]||(o[5]=f=>P("normal"))},{default:u(()=>[$("\u53D1\u5E03")]),_:1})):x("",!0),y(B)==2?(_(),N(S,{key:2,type:"primary",onClick:o[6]||(o[6]=f=>Q())},{default:u(()=>[$("\u53D1\u5E03")]),_:1})):x("",!0)])])]),_:1})])}}};var go=te(to,[["__scopeId","data-v-d9d4459c"]]);export{go as default};