Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

edit-page-b3c7902a.js 6.5 KiB

9 månader sedan
123
  1. import{j as B,k as o,C as D,z as N,s as R,J as z,r as A,c as m,a as e,b as M,w as q,m as h,v as w,x as Q,i as T,t as C,y as W,F as J,u as O,d as K,e as X,o as f,D as Y}from"./index-5dca7a6a.js";import{g as Z,a as ee,p as V,Q as te,r as ae}from"./apiFrom-e81977dd.js";/* empty css */import{c as se,p as oe,b as ne}from"./api-2fe5baa7.js";const le={class:"page-wrapper",id:"app","data-layout":"horizontal","data-navbarbg":"skin6","data-sidebartype":"full","data-sidebar-position":"fixed","data-header-position":"fixed"},ie=K('<header class="app-header"><nav class="navbar navbar-expand-lg navbar-light container-fluid px-0"><ul class="navbar-nav"><li class="nav-item d-block d-lg-none"><a class="nav-link sidebartoggler ms-n3" id="sidebarCollapse" href="javascript:void(0)"><i class="ti ti-menu-2"></i></a></li><li class="nav-item d-none d-lg-block"><a href="index.html" class="text-nowrap nav-link"><img src="'+X+'" class="light-logo" width="180" alt=""></a></li></ul></nav></header>',1),ce={class:"body-wrapper overflow-hidden"},de={class:"position-relative overflow-hidden min-vh-100 d-flex align-items-center justify-content-center drawise-auth-bg"},re={class:"d-flex align-items-center justify-content-center w-100"},ue={class:"row justify-content-center w-100"},pe={class:"col-md-8 col-lg-8 col-xxl-8"},ve=e("i",{class:"ti ti-chevron-left fs-4 me-2"},null,-1),_e={class:"container mt-4"},ge={class:"row"},me={class:"form-floating mb-3"},he=e("label",null,"Page name",-1),fe=e("hr",null,null,-1),be=e("p",{class:"fs-8 fw-bold"},"Body text",-1),ye={class:"container"},xe={class:"row"},ke={class:"col-12 col-md-8 mb-5"},we={class:"col-12 col-md-4 profnajafi"},Te={class:"card"},Ce={class:"card-body"},Ie=e("h1",{class:"fs-6 fw-bolder"},"Explain the Text:",-1),Le=["disabled"],Fe=e("i",{class:"ti ti-sparkles fs-4 me-2"},null,-1),Me=e("hr",null,null,-1),Ve=e("p",{class:"fs-4"},"Generate Image",-1),Ge=["disabled"],je={key:0},Se=e("p",{class:"fs-4 mt-5"},"Select Image",-1),Ue={class:"radio-tile-group"},$e={class:"checkbox-group"},Ee={class:"checkbox-wrapper"},He=["onUpdate:modelValue"],Pe={class:"checkbox-tile"},Be=["src"],De=["onClick"],Ne=e("i",{class:"ti ti-trash fs-4"},null,-1),Re=[Ne],ze={class:"col-12 mb-5"},Ae=["disabled"],qe=e("i",{class:"ti ti-device-floppy fs-4 me-2"},null,-1),Xe=B({__name:"edit-page",setup(Qe){const v=o(!1),_=o("Save"),i=o(!1),c=o(!1),b=o(""),d=D(),I=o(""),g=o(""),n=o(null),L=N(),y=L.params.id,r=o(),x=o(),k=o();R(()=>{se(),G()});async function G(){try{(await Z)(`/create_site/pages/${y}/`).then(t=>{console.log(t.data),t.data&&(r.value=t.data.site,n.value.setHTML(t.data.content),g.value=t.data.page_name,console.log(r.value),k.value=t.data.image)})}catch(t){console.error(t)}}async function j(){console.log(n.value.getHTML());try{v.value=!0,_.value="Saving...",(await ee)(`/create_site/pages/${y}/`,{site:r.value,page_name:g.value,content:n.value.getHTML(),images:H.value}).then(t=>{console.log(t.data),v.value=!1,_.value="Save",d.push(`../../../dash/${r.value}/pages`)})}catch(t){v.value=!1,_.value="Failed, Try Again",console.error(t)}}const S=o(!1),u=o("Generate"),U=()=>{c.value=!0,u.value="Generating...",V("/create_site/picogen/",{prompt:x.value}).then(t=>{console.log(t.data[0]),u.value="Generate",oe("/create_site/picogen/",{url:t.data[0],page_id:L.params.id}).then(a=>{console.log(a.data),c.value=!1,d.go(0)}).catch(()=>{c.value=!1,u.value="Failed, Try Again"})}).catch(()=>{c.value=!1,u.value="Failed, Try Again"})},F=o(null),$=async()=>{var s;const a=(s=F.value.files)==null?void 0:s[0];if(!a)return;const p=new FormData;p.append("image",a),p.append("page",y.toString()),console.log(a);try{(await V)("/create_site/images/",p).then(l=>{console.log("Image uploaded successfully:",l.data),d.go(0)})}catch(l){console.error("Error uploading image:",l)}},E=async()=>{n.value.setHTML("<p>Generating ... </p>"),i.value=!0;try{await ne.post("https://avindev.com/bot/public/drawise",{text:b.value+" in HTML Format only <body>"}).then(t=>{console.log(t.data.text),n.value.setHTML(t.data.text),i.value=!1}).catch(()=>{n.value.setHTML("<p>Failed</p>"),i.value=!1})}catch(t){console.error("Error:",t)}},H=z(()=>k.value.filter(t=>t.selected).map(t=>t.id)),P=async t=>{(await ae)(`/create_site/images/${t}`).then(a=>{console.log(a.data),d.go(0)}).catch(()=>{d.go(0)})};return(t,a)=>{const p=A("RouterLink");return f(),m("div",le,[ie,e("div",ce,[e("div",de,[e("div",re,[e("div",ue,[e("div",pe,[M(p,{to:`../../../dash/${r.value}/pages`,class:"btn btn-outline-warning py-8 mb-4 rounded-2"},{default:q(()=>[ve,T(" Back To Pages")]),_:1},8,["to"]),e("div",_e,[e("div",ge,[e("div",me,[h(e("input",{type:"text",class:"form-control",placeholder:"Username","onUpdate:modelValue":a[0]||(a[0]=s=>g.value=s)},null,512),[[w,g.value]]),he]),fe,be,e("div",ye,[e("div",xe,[e("div",ke,[M(Q(te),{ref_key:"quill",ref:n,content:I.value,"onUpdate:content":a[1]||(a[1]=s=>I.value=s),theme:"snow"},null,8,["content"])]),e("div",we,[e("div",Te,[e("div",Ce,[Ie,h(e("textarea",{"onUpdate:modelValue":a[2]||(a[2]=s=>b.value=s),class:"form-control mb-4",rows:"10",placeholder:`Ex: Write SEO optimized marketing copy for blogs,\r
  2. Facebook ads, Google Ads and more to increase clicks,\r
  3. conversions and sales.`},null,512),[[w,b.value]]),e("button",{onClick:E,type:"button",disabled:i.value,class:"justify-content-center w-100 btn mb-1 btn-rounded btn-danger d-flex align-items-center"},[Fe,T(" "+C(i.value?"Generating ...":"Generate"),1)],8,Le)])])]),Me,Ve,h(e("input",{"onUpdate:modelValue":a[3]||(a[3]=s=>x.value=s),type:"text",class:"form-control",id:"nametext","aria-describedby":"name",placeholder:"Type your imagination"},null,512),[[w,x.value]]),e("button",{disabled:c.value,onClick:U,class:"btn btn-primary mt-3"},C(u.value),9,Ge),S.value?(f(),m("p",je,"Wait for image generation ...")):W("",!0),Se,e("input",{class:"form-control mb-4",type:"file",id:"formFile",ref_key:"imageInput",ref:F,onChange:$,accept:"image/*"},null,544),e("div",Ue,[e("fieldset",$e,[(f(!0),m(J,null,O(k.value,s=>(f(),m("div",{key:s,class:"checkbox"},[e("label",Ee,[h(e("input",{type:"checkbox",class:"checkbox-input","onUpdate:modelValue":l=>s.selected=l},null,8,He),[[Y,s.selected]]),e("span",Pe,[e("img",{src:`https://api.drawise.net${s.image}`,alt:"",style:{"max-width":"150px"}},null,8,Be),e("button",{onClick:l=>P(s.id),class:"btn btn-outline-danger btn-sm p-1 m-1"},Re,8,De)])])]))),128))])]),e("div",ze,[e("button",{onClick:j,type:"button",disabled:v.value,class:"justify-content-center btn mb-1 btn-rounded btn-success"},[qe,T(" "+C(_.value),1)],8,Ae)])])])])])])])])])])])}}});export{Xe as default};