newfront/dist/js/634.7c04f4de.js

2 lines
21 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";(self["webpackChunknewfront"]=self["webpackChunknewfront"]||[]).push([[634],{1634:function(e,t,s){s.r(t),s.d(t,{default:function(){return Xe}});var a=s(6768);const n={class:"user-center"},o={key:0,class:"loading-container"},i={key:1,class:"container"},r={class:"upper-section"},l={class:"user-info-container"},c={class:"coin-container"},d={class:"lower-section"},u={key:2,class:"login-required-container"};function h(e,t,s,h,g,m){const k=(0,a.g2)("Navbar"),v=(0,a.g2)("UserInfo"),f=(0,a.g2)("Coin"),p=(0,a.g2)("SubmissionList");return(0,a.uX)(),(0,a.CE)("div",n,[(0,a.bF)(k),g.isLoading?((0,a.uX)(),(0,a.CE)("div",o,t[0]||(t[0]=[(0,a.Lk)("div",{class:"loading-spinner"},"加载中...",-1)]))):g.isAuthenticated?((0,a.uX)(),(0,a.CE)("div",i,[(0,a.Lk)("div",r,[(0,a.Lk)("div",l,[(0,a.bF)(v,{ref:"userInfo"},null,512)]),(0,a.Lk)("div",c,[(0,a.bF)(f,{ref:"coin"},null,512)])]),(0,a.Lk)("div",d,[(0,a.bF)(p,{onManageWorks:m.handleManageWorks},null,8,["onManageWorks"])])])):((0,a.uX)(),(0,a.CE)("div",u,t[1]||(t[1]=[(0,a.Lk)("div",{class:"login-required-message"},[(0,a.Lk)("h2",null,"请先登录!"),(0,a.Lk)("p",null,"您需要登录后才能访问个人中心")],-1)])))])}var g=s(3070),m=s(4232);const k={class:"user-info-card"},v={class:"card-container"},f={class:"detail-header"},p={class:"avatar-wrapper"},b=["src"],w={class:"detail-right"},L={class:"detail-name-container"},C={class:"detail-name"},y={class:"user-badges"},M=["title"],T=["title"],I={key:2,class:"badge medal"},A={class:"user-sign-container"},_={class:"user-sign"},x={class:"sign-text"},S={class:"user-email"},E={class:"email-text"},P={class:"user-stats"},$={class:"stat-item"},j={class:"stat-value"},D={class:"stat-item"},N={class:"stat-value"},X={class:"stat-item"},z={class:"stat-value"},B={key:0,class:"message-box"};function F(e,t,s,n,o,i){return(0,a.uX)(),(0,a.CE)("div",k,[(0,a.Lk)("div",v,[(0,a.Lk)("div",f,[t[6]||(t[6]=(0,a.Lk)("div",{class:"header-bg"},null,-1)),(0,a.Lk)("div",p,[(0,a.Lk)("img",{src:o.userInfo.avatar_path,alt:"用户头像",class:"detail-avatar"},null,8,b),(0,a.Lk)("div",{class:"avatar-edit-overlay",onClick:t[0]||(t[0]=(...e)=>i.triggerFileInput&&i.triggerFileInput(...e))},t[4]||(t[4]=[(0,a.Lk)("i",{class:"edit-icon"},"📷",-1)])),(0,a.Lk)("input",{type:"file",ref:"fileInput",style:{display:"none"},accept:"image/jpeg, image/png, image/gif",onChange:t[1]||(t[1]=(...e)=>i.uploadAvatar&&i.uploadAvatar(...e))},null,544)]),(0,a.Lk)("div",w,[(0,a.Lk)("div",L,[(0,a.Lk)("div",C,(0,m.v_)(o.userInfo.nickname),1),(0,a.Lk)("button",{class:"edit-btn",onClick:t[2]||(t[2]=(...e)=>i.editNickname&&i.editNickname(...e)),title:"修改昵称"},t[5]||(t[5]=[(0,a.Lk)("i",{class:"edit-icon"},"✏️",-1)]))]),(0,a.Lk)("div",y,[o.userInfo.verified?((0,a.uX)(),(0,a.CE)("span",{key:0,class:"badge verified",title:o.userInfo.verified},"认证",8,M)):(0,a.Q3)("",!0),o.userInfo.invited?((0,a.uX)(),(0,a.CE)("span",{key:1,class:"badge invited",title:o.userInfo.invited},"特邀",8,T)):(0,a.Q3)("",!0),o.userInfo.medal?((0,a.uX)(),(0,a.CE)("span",I,"小站奖章")):(0,a.Q3)("",!0)])])]),(0,a.Lk)("div",A,[(0,a.Lk)("div",_,[t[8]||(t[8]=(0,a.Lk)("div",{class:"sign-icon"},"✍️",-1)),(0,a.Lk)("div",x,(0,m.v_)(o.userInfo.sign||"这个人很懒,还没有写个性签名~"),1),(0,a.Lk)("button",{class:"edit-btn",onClick:t[3]||(t[3]=(...e)=>i.editSign&&i.editSign(...e)),title:"修改签名"},t[7]||(t[7]=[(0,a.Lk)("i",{class:"edit-icon"},"✏️",-1)]))])]),(0,a.Lk)("div",S,[t[9]||(t[9]=(0,a.Lk)("div",{class:"email-icon"},"📧",-1)),(0,a.Lk)("div",E,(0,m.v_)(o.userInfo.email),1)]),(0,a.Lk)("div",P,[(0,a.Lk)("div",$,[(0,a.Lk)("div",j,(0,m.v_)(o.userInfo.follower||0),1),t[10]||(t[10]=(0,a.Lk)("div",{class:"stat-label"},"粉丝",-1))]),t[13]||(t[13]=(0,a.Lk)("div",{class:"stat-separator"},null,-1)),(0,a.Lk)("div",D,[(0,a.Lk)("div",N,(0,m.v_)(o.userInfo.following||0),1),t[11]||(t[11]=(0,a.Lk)("div",{class:"stat-label"},"关注",-1))]),t[14]||(t[14]=(0,a.Lk)("div",{class:"stat-separator"},null,-1)),(0,a.Lk)("div",X,[(0,a.Lk)("div",z,(0,m.v_)(o.userInfo.coin||"未激活"),1),t[12]||(t[12]=(0,a.Lk)("div",{class:"stat-label"},"东币",-1))])]),o.message.show?((0,a.uX)(),(0,a.CE)("div",B,[(0,a.Lk)("div",{class:(0,m.C4)(["message-content",o.message.type])},(0,m.v_)(o.message.text),3)])):(0,a.Q3)("",!0)])])}var U=s(8704),q=s(6253),O={name:"UserInfo",data(){return{userInfo:{id:"",nickname:"加载中...",verified:null,invited:null,medal:!1,avatar_path:"",email:"",sign:"",follower:0,following:0,coin:0},message:{show:!1,text:"",type:"success",timer:null}}},created(){this.fetchUserInfo()},methods:{async fetchUserInfo(){try{const e=U.A.get("token");if(!e)return void this.showMessage("未登录或登录已过期","error");const t=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/info",{method:"GET",headers:{Authorization:e}});if(!t.ok)throw new Error("获取用户信息失败");const s=await t.json();this.userInfo=s}catch(e){console.error("获取用户信息出错:",e),this.showMessage("获取用户信息失败","error")}},triggerFileInput(){this.$refs.fileInput.click()},async uploadAvatar(e){const t=e.target.files[0];if(!t)return void this.showMessage("请选择一个文件","error");if(t.size>1048576)return void this.showMessage("头像必须小于1MB","error");const s=U.A.get("token");if(s)try{const e=new FormData;e.append("avatar",t);const a=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/avatar/upload",{method:"POST",headers:{Authorization:s},body:e});if(a.ok){const e=await a.json();this.userInfo.avatar_path=e.avatarUrl,this.showMessage("头像上传成功","success")}else 401===a.status||403===a.status?this.showMessage("权限错误,请重新登录后再试","error"):this.showMessage("上传失败,请稍后再试","error")}catch(a){console.error("头像上传错误:",a),this.showMessage("上传过程中发生错误","error")}else this.showMessage("请先登录,再上传头像","error")},async editNickname(){const e=U.A.get("token");e?(0,q.A)({title:"修改昵称",message:"请输入新的昵称:",showInput:!0,inputPlaceholder:"请输入新昵称",inputValue:this.userInfo.nickname,confirmText:"确认",cancelText:"取消",cancel:!0}).then((async({value:t})=>{if(null!==t&&""!==t.trim())try{const s=await fetch("https://userlogin.xn--xhq44jb2fzpc.com/avatar/edit-nickname",{method:"POST",headers:{"Content-Type":"application/json",Authorization:e},body:JSON.stringify({nickname:t.trim()})});if(s.ok){await s.json();this.userInfo.nickname=t.trim(),this.showMessage("昵称修改成功","success")}else{const e=await s.json();this.showMessage(`修改昵称失败:${e.message}`,"error")}}catch(s){console.error("修改昵称错误:",s),this.showMessage("发生错误,请稍后再试","error")}else this.showMessage("昵称不能为空","error")})).catch((()=>{})):this.showMessage("您尚未登录,请登录后再尝试修改昵称","error")},async editSign(){const e=U.A.get("token");if(!e)return void this.showMessage("您尚未登录,请登录后再尝试修改签名","error");const t=this.userInfo.sign||"";(0,q.A)({title:"修改个性签名",message:"请输入新的个性签名 (最多20个汉字留空表示删除个性签名):",showInput:!0,inputValue:t,inputPlaceholder:"请输入个性签名",confirmText:"确认",cancelText:"取消",cancel:!0}).then((async({value:t})=>{if(null!==t)try{const s=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/sign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:e},body:JSON.stringify({sign:t.trim()})});if(s.ok)this.userInfo.sign=t.trim(),this.showMessage("个性签名修改成功","success");else{const e=await s.json();this.showMessage(`修改签名失败:${e.message}`,"error")}}catch(s){console.error("修改签名错误:",s),this.showMessage("发生错误,请稍后再试","error")}})).catch((()=>{}))},showMessage(e,t="success"){this.message.timer&&clearTimeout(this.message.timer),this.message.show=!0,this.message.text=e,this.message.type=t,this.message.timer=setTimeout((()=>{this.message.show=!1}),3e3)}}},V=s(1241);const J=(0,V.A)(O,[["render",F],["__scopeId","data-v-7c40ae87"]]);var Q=J,W=s(5130);const G={class:"coin-container"},H={key:0,class:"not-activated"},K={class:"alert alert-info"},Y={key:1,class:"activated"},R={class:"coin-info"},Z={class:"coin-amount"},ee={class:"transactions"},te={key:0,class:"no-records"},se={key:1,class:"transaction-table"},ae={key:2,class:"pagination"},ne=["disabled"],oe={class:"page-info"},ie=["disabled"],re={class:"modal-header"},le={class:"modal-body"},ce={class:"form-group"},de={class:"input-group"},ue=["disabled"],he={class:"form-group"},ge={key:0,class:"modal-message"},me=["disabled"];function ke(e,t,s,n,o,i){return(0,a.uX)(),(0,a.CE)("div",G,[o.isActivated?((0,a.uX)(),(0,a.CE)("div",Y,[(0,a.Lk)("div",R,[(0,a.Lk)("h3",null,[t[11]||(t[11]=(0,a.eW)("您当前拥有 ")),(0,a.Lk)("span",Z,(0,m.v_)(o.coinAmount),1),t[12]||(t[12]=(0,a.eW)(" 枚东币"))])]),(0,a.Lk)("div",ee,[0===o.transactions.length?((0,a.uX)(),(0,a.CE)("div",te," 暂无交易记录 ")):((0,a.uX)(),(0,a.CE)("table",se,[t[13]||(t[13]=(0,a.Lk)("thead",null,[(0,a.Lk)("tr",null,[(0,a.Lk)("th",null,"时间"),(0,a.Lk)("th",null,"金额"),(0,a.Lk)("th",null,"备注")])],-1)),(0,a.Lk)("tbody",null,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(o.transactions,(e=>((0,a.uX)(),(0,a.CE)("tr",{key:e.id},[(0,a.Lk)("td",null,(0,m.v_)(i.formatDate(e.created_at)),1),(0,a.Lk)("td",{class:(0,m.C4)({credit:"credit"===e.type,debit:"debit"===e.type})},(0,m.v_)("credit"===e.type?"+":"-")+(0,m.v_)(e.amount),3),(0,a.Lk)("td",null,(0,m.v_)(e.note),1)])))),128))])])),o.totalPages>1?((0,a.uX)(),(0,a.CE)("div",ae,[(0,a.Lk)("button",{disabled:1===o.currentPage,onClick:t[1]||(t[1]=e=>i.loadTransactions(o.currentPage-1)),class:"btn btn-sm btn-outline-primary"}," 上一页 ",8,ne),(0,a.Lk)("span",oe,(0,m.v_)(o.currentPage)+" / "+(0,m.v_)(o.totalPages),1),(0,a.Lk)("button",{disabled:o.currentPage===o.totalPages,onClick:t[2]||(t[2]=e=>i.loadTransactions(o.currentPage+1)),class:"btn btn-sm btn-outline-primary"}," 下一页 ",8,ie)])):(0,a.Q3)("",!0)])])):((0,a.uX)(),(0,a.CE)("div",H,[(0,a.Lk)("div",K,[t[10]||(t[10]=(0,a.Lk)("p",null,"您未激活东币系统。点击按钮验证手机号后即可激活。",-1)),(0,a.Lk)("button",{class:"btn btn-primary",onClick:t[0]||(t[0]=(...e)=>i.showVerificationModal&&i.showVerificationModal(...e))},"立即激活")])])),(0,a.bo)((0,a.Lk)("div",{class:"modal",onClick:t[9]||(t[9]=(0,W.D$)(((...e)=>i.closeModal&&i.closeModal(...e)),["self"]))},[(0,a.Lk)("div",{class:"modal-content",onClick:t[8]||(t[8]=(0,W.D$)((()=>{}),["stop"]))},[(0,a.Lk)("div",re,[t[14]||(t[14]=(0,a.Lk)("h3",null,"手机验证",-1)),(0,a.Lk)("span",{class:"close",onClick:t[3]||(t[3]=(...e)=>i.closeModal&&i.closeModal(...e))},"×")]),(0,a.Lk)("div",le,[(0,a.Lk)("div",ce,[t[15]||(t[15]=(0,a.Lk)("label",{for:"phone-number"},"手机号码",-1)),(0,a.Lk)("div",de,[(0,a.bo)((0,a.Lk)("input",{type:"text",id:"phone-number","onUpdate:modelValue":t[4]||(t[4]=e=>o.phoneNumber=e),class:"form-control",placeholder:"请输入11位手机号",maxlength:"11"},null,512),[[W.Jo,o.phoneNumber]]),(0,a.Lk)("button",{class:"btn btn-primary",onClick:t[5]||(t[5]=(...e)=>i.sendVerificationCode&&i.sendVerificationCode(...e)),disabled:o.sendCodeDisabled},(0,m.v_)(o.sendCodeBtnText),9,ue)])]),(0,a.Lk)("div",he,[t[16]||(t[16]=(0,a.Lk)("label",{for:"verification-code"},"验证码",-1)),(0,a.bo)((0,a.Lk)("input",{type:"text",id:"verification-code","onUpdate:modelValue":t[6]||(t[6]=e=>o.verificationCode=e),class:"form-control",placeholder:"请输入验证码",maxlength:"6"},null,512),[[W.Jo,o.verificationCode]])]),o.modalMessage?((0,a.uX)(),(0,a.CE)("div",ge,(0,m.v_)(o.modalMessage),1)):(0,a.Q3)("",!0),(0,a.Lk)("button",{class:"btn btn-success verify-btn",onClick:t[7]||(t[7]=(...e)=>i.verifyCode&&i.verifyCode(...e)),disabled:o.verifyBtnDisabled}," 验证 ",8,me)])])],512),[[W.aG,o.showModal]])])}var ve={name:"CoinComponent",data(){return{isActivated:!1,coinAmount:0,transactions:[],currentPage:1,totalPages:1,showModal:!1,phoneNumber:"",verificationCode:"",modalMessage:"",sendCodeDisabled:!1,verifyBtnDisabled:!1,sendCodeBtnText:"发送验证码",countdownTimer:null}},created(){this.fetchUserInfo()},methods:{async fetchUserInfo(){try{const e=U.A.get("token");if(!e)return void console.error("未找到登录token");const t=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/info",{method:"GET",headers:{Authorization:e}});if(!t.ok)throw new Error("获取用户信息失败");const s=await t.json();null!==s.coin&&(this.isActivated=!0,this.coinAmount=s.coin,this.loadTransactions(1))}catch(e){console.error("获取用户信息出错:",e)}},async loadTransactions(e){try{const t=U.A.get("token");if(!t)return void console.error("未找到登录token");const s=await fetch("https://newfront.xn--xhq44jb2fzpc.com/coin/transactions",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({page_num:e})});if(!s.ok)throw new Error("获取交易记录失败");const a=await s.json();this.transactions=a.transactions,this.currentPage=a.current_page,this.totalPages=a.total_pages}catch(t){console.error("获取交易记录出错:",t)}},showVerificationModal(){this.showModal=!0,this.phoneNumber="",this.verificationCode="",this.modalMessage="",this.sendCodeDisabled=!1,this.verifyBtnDisabled=!1,this.sendCodeBtnText="发送验证码"},closeModal(){this.showModal=!1,this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null)},async sendVerificationCode(){if(/^\d{11}$/.test(this.phoneNumber)&&"1"===this.phoneNumber.charAt(0))try{this.sendCodeDisabled=!0,this.startCountdown();const e=await fetch("https://sms.xn--xhq44jb2fzpc.com/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:this.phoneNumber})}),t=await e.json();e.ok?(this.modalMessage="验证码已发送。若未收到2分钟后可重新发送。",localStorage.setItem("phoneNumber",this.phoneNumber)):409===e.status?(this.modalMessage="此手机号已被验证过!",this.sendCodeDisabled=!1,this.sendCodeBtnText="发送验证码",this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null)):t.error&&t.error.includes("试用签名的发送量已达到限制阈值")?(this.modalMessage="由于运营商限制,非企业用户的验证码数量今日已达到阈值,请从网站底部联系管理员验证手机号。",this.sendCodeDisabled=!1,this.sendCodeBtnText="发送验证码",this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null)):(this.modalMessage="发送失败!请稍后再试。",this.sendCodeDisabled=!1,this.sendCodeBtnText="发送验证码",this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null))}catch(e){console.error("发送验证码时出错:",e),this.modalMessage="发送验证码时出错,请稍后重试。",this.sendCodeDisabled=!1,this.sendCodeBtnText="发送验证码",this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null)}else this.modalMessage="请输入有效的11位手机号码"},startCountdown(){let e=120;this.sendCodeBtnText=`重新发送(${e})`,this.countdownTimer=setInterval((()=>{e--,this.sendCodeBtnText=`重新发送(${e})`,e<=0&&(clearInterval(this.countdownTimer),this.countdownTimer=null,this.sendCodeDisabled=!1,this.sendCodeBtnText="发送验证码")}),1e3)},async verifyCode(){const e=localStorage.getItem("phoneNumber")||this.phoneNumber,t=this.verificationCode.trim();if(this.modalMessage="",t&&e)try{const s=U.A.get("token"),a=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/info",{method:"GET",headers:{Authorization:s}});if(!a.ok)throw new Error("获取用户信息失败");const n=await a.json(),o=n.email,i=await fetch("https://sms.xn--xhq44jb2fzpc.com/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:e,verificationCode:t,email:o})}),r=await i.json();i.ok&&r.verified?(this.modalMessage="验证通过,请稍后……",this.verifyBtnDisabled=!0,setTimeout((()=>{this.closeModal(),window.location.reload()}),2e3)):this.modalMessage="验证码错误,请重新输入。"}catch(s){console.error("验证时出错:",s),this.modalMessage="验证时出错,请稍后重试。"}else this.modalMessage="请输入手机号和验证码。"},formatDate(e){const t=new Date(e);return`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()} ${t.getHours()}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`}}};const fe=(0,V.A)(ve,[["render",ke],["__scopeId","data-v-ceb38a98"]]);var pe=fe;const be={class:"submission-container"},we={class:"header"},Le={class:"submission-table-wrapper"},Ce={key:0,class:"submission-table"},ye=["onClick"],Me={class:"title-cell"},Te={key:1,class:"empty-state"},Ie={key:2,class:"pagination"},Ae=["disabled"],_e={class:"page-info"},xe=["disabled"];function Se(e,t,s,n,o,i){return(0,a.uX)(),(0,a.CE)("div",be,[(0,a.Lk)("div",we,[t[3]||(t[3]=(0,a.Lk)("h3",{class:"title"},"我的投稿记录",-1)),(0,a.Lk)("button",{class:"manage-btn",onClick:t[0]||(t[0]=(...e)=>i.handleManage&&i.handleManage(...e))},"作品管理")]),(0,a.Lk)("div",Le,[o.submissions.length>0?((0,a.uX)(),(0,a.CE)("table",Ce,[t[4]||(t[4]=(0,a.Lk)("thead",null,[(0,a.Lk)("tr",null,[(0,a.Lk)("th",null,"标题"),(0,a.Lk)("th",null,"板块"),(0,a.Lk)("th",null,"审核状态"),(0,a.Lk)("th",null,"审核备注"),(0,a.Lk)("th",null,"投稿时间"),(0,a.Lk)("th",null,"状态更新时间")])],-1)),(0,a.Lk)("tbody",null,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(o.submissions,(e=>((0,a.uX)(),(0,a.CE)("tr",{key:e.id,class:(0,m.C4)({clickable:e.article_id}),onClick:t=>e.article_id&&i.navigateToArticle(e.article_id)},[(0,a.Lk)("td",Me,(0,m.v_)(e.title),1),(0,a.Lk)("td",null,(0,m.v_)(e.section),1),(0,a.Lk)("td",null,[(0,a.Lk)("span",{class:(0,m.C4)(i.getStatusClass(e.status))},(0,m.v_)(e.status),3)]),(0,a.Lk)("td",null,(0,m.v_)(e.note||"无"),1),(0,a.Lk)("td",null,(0,m.v_)(i.formatDate(e.created_at)),1),(0,a.Lk)("td",null,(0,m.v_)(i.formatDate(e.updated_at)),1)],10,ye)))),128))])])):((0,a.uX)(),(0,a.CE)("div",Te,t[5]||(t[5]=[(0,a.Lk)("p",null,"暂无投稿记录",-1)]))),o.totalPages>1?((0,a.uX)(),(0,a.CE)("div",Ie,[(0,a.Lk)("button",{disabled:1===o.currentPage,onClick:t[1]||(t[1]=e=>i.loadSubmissions(o.currentPage-1)),class:"page-btn"}," 上一页 ",8,Ae),(0,a.Lk)("span",_e,(0,m.v_)(o.currentPage)+" / "+(0,m.v_)(o.totalPages),1),(0,a.Lk)("button",{disabled:o.currentPage===o.totalPages,onClick:t[2]||(t[2]=e=>i.loadSubmissions(o.currentPage+1)),class:"page-btn"}," 下一页 ",8,xe)])):(0,a.Q3)("",!0)])])}s(4114);var Ee={name:"SubmissionList",data(){return{submissions:[],currentPage:1,totalPages:1,totalSubmissions:0,loading:!1}},created(){this.loadSubmissions(1)},methods:{async loadSubmissions(e){this.loading=!0;try{const t=U.A.get("token");if(!t)return void console.error("未找到登录token");const s=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/submission",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({page_num:e})});if(!s.ok)throw new Error("获取投稿记录失败");const a=await s.json();this.submissions=a.submissions,this.currentPage=a.current_page,this.totalPages=a.total_pages,this.totalSubmissions=a.total_submissions}catch(t){console.error("获取投稿记录出错:",t)}finally{this.loading=!1}},handleManage(){console.log("点击了作品管理按钮"),this.$emit("manage-works")},navigateToArticle(e){this.$router.push(`/article/${e}`)},formatDate(e){if(!e)return"未知";const t=new Date(e);return`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()} ${t.getHours()}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`},getStatusClass(e){switch(e){case"已通过":return"status-approved";case"审核中":return"status-pending";case"未通过":return"status-rejected";default:return""}}}};const Pe=(0,V.A)(Ee,[["render",Se],["__scopeId","data-v-2aba7af9"]]);var $e=Pe,je=s(6965),De={name:"UserCenter",components:{Navbar:g.A,UserInfo:Q,Coin:pe,SubmissionList:$e},data(){return{isAuthenticated:!1,isLoading:!0}},created(){document.title="个人中心 - NEU小站"},mounted(){this.checkAuthAndFetchUserInfo()},methods:{async checkAuthAndFetchUserInfo(){const e=U.A.get("token");if(!e)return this.isLoading=!1,"/user-center"===this.$route.path?void this.$router.replace("/login"):void("/login"===this.$route.path&&this.showLoginDialog());try{const t=await fetch("https://newfront.xn--xhq44jb2fzpc.com/user/info",{method:"GET",headers:{Authorization:e}});if(!t.ok)throw new Error("获取用户信息失败");await t.json();this.isAuthenticated=!0,this.isLoading=!1,"/login"===this.$route.path&&this.$router.replace("/user-center")}catch(t){if(console.error("获取用户信息出错:",t),this.isLoading=!1,U.A.remove("token"),"/user-center"===this.$route.path)return void this.$router.replace("/login");"/login"===this.$route.path&&this.showLoginDialog()}},showLoginDialog(){(0,je.A)().then((e=>{console.log("登录成功:",e),this.isAuthenticated=!0,this.$router.replace("/user-center")})).catch((e=>{console.log("登录取消:",e)}))},handleManageWorks(){q.A.alert("暂未开放,如需投稿请联系网站管理员~","提示").then((()=>{})).catch((()=>{}))}}};const Ne=(0,V.A)(De,[["render",h],["__scopeId","data-v-70bc2314"]]);var Xe=Ne}}]);
//# sourceMappingURL=634.7c04f4de.js.map