42 lines
6.6 KiB
JavaScript
42 lines
6.6 KiB
JavaScript
import{x as j,_ as F}from"./index-r_E2mS1x.js";import{B as O,a as H,b as u,o as J,_ as W,D as f,G as a,U as i,u as r,H as d,P as p,Z as k,Y as I,O as $,W as G,I as _,X as P,a0 as R,C as c,V as b,ah as h}from"./vue-DweYBrEc.js";import{d as X,s as Y}from"./embed-DhRtM3gu.js";const Z={class:"default-main domain-status-page"},q={class:"setting-grid"},K={class:"panel setting-panel"},Q={class:"panel-title"},ee={class:"panel-body setting-form"},oe={class:"form-row"},te={class:"form-row textarea-row"},ae={class:"form-row template-row"},le={class:"color-grid"},ne={class:"panel embed-panel"},se={class:"panel-title"},ie={class:"panel-body"},re={class:"panel domain-panel"},de={class:"panel-title"},me={class:"domain-list"},w=`{
|
|
"hideDomain": [
|
|
"domain1.com",
|
|
"domain2.com"
|
|
]
|
|
}`,ce=O({name:"embed/domainStatus",__name:"domainStatus",setup(ue){const{t:n}=j.useI18n(),x=R(),e=H({headerImage:"",customConfig:"",baseColor:"#1c2130",borderColor:"#2a3147",onlineColor:"#48bb78",offlineColor:"#f56565",titleColor:"#006dff",textColor:"#ffffff",labelColor:"#718096"}),V=[{key:"baseColor",label:"embed.domainStatus.baseColor"},{key:"titleColor",label:"embed.domainStatus.titleColor"},{key:"borderColor",label:"embed.domainStatus.borderColor"},{key:"textColor",label:"embed.domainStatus.textColor"},{key:"onlineColor",label:"embed.domainStatus.onlineColor"},{key:"labelColor",label:"embed.domainStatus.labelColor"},{key:"offlineColor",label:"embed.domainStatus.offlineColor"}],g=u(`<div style="position: relative;max-width: 1000px;margin: 0 auto;overflow: hidden;border: none;">
|
|
<iframe id="domainstatusIframe" src="https://1xaud.em7bd7.co/embed/domain-status/domain-status.asp" style="width: 100%;overflow: hidden;border: none;"></iframe>
|
|
<script>
|
|
(() => {
|
|
const merchantId = (typeof _ !== "undefined" && typeof _.getVar === "function") ? (_.getVar("merchantId") ?? "") : "";
|
|
if (!merchantId) {
|
|
console.log("merchantId not found");
|
|
return;
|
|
}
|
|
function init(iframe) {
|
|
iframe.addEventListener('load', function() {
|
|
iframe.contentWindow.postMessage({ type: 'setIframeData', clientMerchant: merchantId }, '*');
|
|
});
|
|
window.addEventListener("message", function(event) {
|
|
if (event.data && event.data.type === "setDomainStatusIframeHeight") {
|
|
iframe.style.height = event.data.height + "px";
|
|
}
|
|
}, false);
|
|
}
|
|
var el = document.getElementById('domainstatusIframe');
|
|
if (el) { init(el); return; }
|
|
var attempts = 0;
|
|
var timer = setInterval(function() {
|
|
attempts++;
|
|
var el = document.getElementById('domainstatusIframe');
|
|
if (el) {
|
|
clearInterval(timer);
|
|
init(el);
|
|
} else if (attempts >= 5) {
|
|
clearInterval(timer);
|
|
alert("iframe not found");
|
|
}
|
|
}, 1000);
|
|
})();
|
|
<\/script>
|
|
</div>`),C=u(!1),D=async()=>{let o={};try{if(e.customConfig.trim()){const t=JSON.parse(e.customConfig);if(!t||Array.isArray(t)||typeof t!="object")throw new Error;o=t}}catch{h.error(n("embed.domainStatus.invalidConfig"));return}C.value=!0;try{await Y({header_image_url:e.headerImage,custom_config:o,base_color:e.baseColor,border_color:e.borderColor,online_color:e.onlineColor,offline_color:e.offlineColor,title_color:e.titleColor,text_color:e.textColor,tag_color:e.labelColor}),await S()}finally{C.value=!1}},E=async()=>{try{await navigator.clipboard.writeText(g.value),h.success(n("embed.domainStatus.copied"))}catch{h.error(n("embed.domainStatus.copyFailed"))}},y=u([]),v=u(!1),B=o=>o?typeof o=="string"?o:JSON.stringify(o,null,2):"",L=o=>(Array.isArray(o)?o:typeof o=="string"?o.split(/[\n,;]+/):[]).map(s=>String(typeof s=="object"&&s?s.domain??s.name??"":s)).map(s=>s.trim()).filter(Boolean).map((s,m)=>({id:m+1,name:s})),N=o=>{o&&(e.headerImage=o.header_image_url??"",e.customConfig=B(o.custom_config),e.baseColor=o.base_color??"",e.borderColor=o.border_color??"",e.onlineColor=o.online_color??"",e.offlineColor=o.offline_color??"",e.titleColor=o.title_color??"",e.textColor=o.text_color??"",e.labelColor=o.tag_color??"")},S=async()=>{v.value=!0;try{const o=await X(),t=o.data??o;N(t==null?void 0:t.domain),y.value=L(t==null?void 0:t.domain_list)}finally{v.value=!1}},U=()=>{x.push({name:"routine/config"})};return J(S),(o,t)=>{const s=_("el-input"),m=_("el-button"),z=_("el-color-picker"),T=_("el-empty"),A=P("loading");return W((c(),f("div",Z,[a("section",q,[a("div",K,[a("div",Q,i(r(n)("embed.domainStatus.settingTitle")),1),a("div",ee,[a("div",oe,[a("label",null,i(r(n)("embed.domainStatus.headerImage"))+":",1),d(s,{modelValue:e.headerImage,"onUpdate:modelValue":t[0]||(t[0]=l=>e.headerImage=l),placeholder:"e.g. https://image.png"},null,8,["modelValue"])]),a("div",te,[a("label",null,i(r(n)("embed.domainStatus.customConfig"))+":",1),d(s,{modelValue:e.customConfig,"onUpdate:modelValue":t[1]||(t[1]=l=>e.customConfig=l),type:"textarea",rows:7,placeholder:w,resize:"vertical"},null,8,["modelValue"])]),a("div",ae,[t[4]||(t[4]=a("label",null,null,-1)),d(m,{size:"small",onClick:t[2]||(t[2]=l=>e.customConfig=w)},{default:p(()=>[b(i(r(n)("embed.domainStatus.loadTemplate")),1)]),_:1})]),a("div",le,[(c(),f(k,null,I(V,l=>a("div",{key:l.key,class:"color-item"},[a("label",null,i(r(n)(l.label))+":",1),d(z,{modelValue:e[l.key],"onUpdate:modelValue":M=>e[l.key]=M},null,8,["modelValue","onUpdate:modelValue"]),a("span",null,i(e[l.key]),1)])),64))]),d(m,{type:"success",class:"save-button",loading:C.value,onClick:D},{default:p(()=>[b(i(r(n)("embed.domainStatus.save")),1)]),_:1},8,["loading"])])]),a("div",ne,[a("div",se,i(r(n)("embed.domainStatus.embedCode")),1),a("div",ie,[d(s,{modelValue:g.value,"onUpdate:modelValue":t[3]||(t[3]=l=>g.value=l),type:"textarea",rows:17,readonly:"",resize:"none"},null,8,["modelValue"]),d(m,{class:"copy-button",onClick:E},{default:p(()=>[b(i(r(n)("embed.domainStatus.copyCode")),1)]),_:1})])])]),a("section",re,[a("div",de,i(r(n)("embed.domainStatus.domainList")),1),a("div",me,[(c(!0),f(k,null,I(y.value,l=>(c(),f("div",{key:l.id,class:"domain-row"},[t[5]||(t[5]=a("span",{class:"domain-icon","aria-hidden":"true"},null,-1)),a("span",null,i(l.name),1)]))),128)),y.value.length===0?(c(),$(T,{key:0,description:r(n)("embed.domainStatus.empty"),"image-size":60},null,8,["description"])):G("",!0)])]),d(m,{link:"",type:"primary",class:"edit-link",onClick:U},{default:p(()=>[b(i(r(n)("embed.domainStatus.editDomainList")),1)]),_:1})])),[[A,v.value]])}}}),be=F(ce,[["__scopeId","data-v-6c94bd73"]]);export{be as default};
|