You can not 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
4.9 KiB

import{C as e,D as t,G as n,O as r,W as i,Z as a,_t as o,at as s,b as c,in as l,k as u,m as d,q as f,st as p,w as m,x as h}from"./vue.runtime.esm-bundler-OsdSFvn7.js";import{d as g,m as _,n as v}from"./api-rQwE0AaH.js";import{l as y,u as b}from"./index-DFPdDGyr.js";import{t as x}from"./_plugin-vue_export-helper-CXTkFu_Z.js";/* empty css *//* empty css */import{a as S,i as C,r as w,t as ee}from"./competitionBranding-DKFkcrfF.js";var T={class:`participant-layout`},E={key:0,class:`admin-impersonation-banner text-center small py-2 px-3`,role:`status`},D={class:`navbar navbar-expand-lg layout-header`},O={class:`container-fluid px-3 px-lg-4`},k={class:`navbar-brand mb-0 prototype-title`},A={class:`dropdown`},j={class:`header-user dropdown-toggle`,type:`button`,"data-bs-toggle":`dropdown`,"aria-expanded":`false`},M={class:`header-user-name`},N={class:`dropdown-menu dropdown-menu-end header-user-menu`},P={class:`container-fluid px-3 px-lg-4 py-3 layout-main`},F={class:`row layout-main-row g-3`},I={class:`col-12 col-md-2 col-lg-2 layout-sider`},L={class:`card h-100`},R={class:`card-body`},z={class:`nav flex-column gap-2`},B={class:`col-12 col-md-10 col-lg-10 participant-main-col`},V={id:`layoutFooter`,class:`border-top bg-white text-center py-2 small text-secondary prototype-subtitle`},H=`#052d62`,U=x(u({__name:`MainLayout`,setup(u){let x=b(),U=y(),W=c(()=>String(U.params.slug??``).trim()),G=o(w()),K=o(``),q=c(()=>S(G.value,K.value)),J=c(()=>{if(C(G.value.login.footerCopyright))return G.value.login.footerCopyright;let e=K.value.trim();return e?`版权所有:${e}`:`版权所有`});async function Y(){let e=W.value;if(!e){G.value=w(),K.value=``;return}try{let t=await fetch(`${_()}/api/v1/public/competitions/by-slug/${encodeURIComponent(e)}`,{headers:{Accept:`application/json`}});if(!t.ok){G.value=w(),K.value=``;return}let n=await t.json(),r=n.data!=null&&typeof n.data==`object`&&!Array.isArray(n.data)?n.data:n;K.value=String(r.name??``),G.value=ee(r.branding_json??null)}catch{G.value=w(),K.value=``}}s(W,()=>{Y()},{immediate:!0});function X(e){let t=e.trim().replace(`#`,``);return/^[0-9a-f]{6}$/i.test(t)?`${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}`:null}function Z(){if(typeof document>`u`)return;let e=G.value.login.themePrimary?.trim()??``,t=C(e)?/^(?:#|rgb|hsl)/i.test(e)?e:`#${e.replace(/^#/,``)}`:H;if(document.body.style.setProperty(`--primary`,t),document.body.style.setProperty(`--bs-primary`,t),t.startsWith(`#`)){document.body.style.setProperty(`--primary-soft`,`${t}14`);let e=X(t);e&&document.body.style.setProperty(`--bs-primary-rgb`,e)}else document.body.style.removeProperty(`--primary-soft`),document.body.style.removeProperty(`--bs-primary-rgb`)}s(G,()=>Z(),{deep:!0,immediate:!0});let Q=o(``),$=o(sessionStorage.getItem(v)===`1`),te=c(()=>{if($.value){let e=Q.value.trim();return e?`管理员代登 · ${e}`:`管理员代登中`}return Q.value||`用户`});async function ne(){let e=localStorage.getItem(g),t=_();if(e)try{let n=await fetch(`${t}/api/me`,{headers:{Authorization:`Bearer ${e}`,Accept:`application/json`}});if(!n.ok)return;let r=await n.json();Q.value=r.name||r.mobile||``}catch{}}function re(){localStorage.removeItem(g),localStorage.removeItem(`cxxfds_user`),sessionStorage.removeItem(v),$.value=!1;let e=W.value;e?x.push({name:`participant-login`,params:{slug:e}}):x.push(`/c`)}return i(()=>{document.body.classList.add(`prototype-page`,`user-mobile-no-menu`),$.value=sessionStorage.getItem(v)===`1`,ne()}),n(()=>{document.body.classList.remove(`prototype-page`,`user-mobile-no-menu`),document.body.style.removeProperty(`--primary`),document.body.style.removeProperty(`--primary-soft`),document.body.style.removeProperty(`--bs-primary`),document.body.style.removeProperty(`--bs-primary-rgb`)}),(n,i)=>{let o=a(`router-link`),s=a(`router-view`);return f(),m(`div`,T,[$.value?(f(),m(`div`,E,` 当前为管理员代登选手端,操作将以该选手身份生效。请用完后点击右上角「退出登录」。 `)):e(``,!0),h(`header`,D,[h(`div`,O,[h(`span`,k,l(q.value),1),h(`div`,A,[h(`button`,j,[i[0]||=h(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`},[h(`circle`,{cx:`12`,cy:`12`,r:`9.5`,stroke:`currentColor`,"stroke-width":`2`}),h(`circle`,{cx:`12`,cy:`9`,r:`3.2`,fill:`currentColor`}),h(`path`,{d:`M6.8 18.2c1.1-2.4 3-3.6 5.2-3.6s4.1 1.2 5.2 3.6`,fill:`currentColor`})],-1),h(`span`,M,l(te.value),1)]),h(`ul`,N,[h(`li`,null,[h(`a`,{class:`dropdown-item text-danger`,href:`javascript:void(0)`,onClick:d(re,[`prevent`])},[...i[1]||=[h(`span`,{class:`menu-icon`},`↪`,-1),t(`退出登录 `,-1)]])])])])])]),h(`div`,P,[h(`div`,F,[h(`aside`,I,[h(`div`,L,[h(`div`,R,[h(`nav`,z,[r(o,{class:`nav-link text-start`,"active-class":`active`,to:{name:`participant-apply`,params:{slug:W.value}}},{default:p(()=>[...i[2]||=[t(` 赛事报名 `,-1)]]),_:1},8,[`to`])])])])]),h(`main`,B,[r(s)])])]),h(`footer`,V,l(J.value),1)])}}}),[[`__scopeId`,`data-v-ff65c5a6`]]);export{U as default};