const{createApp}=Vue const{createVuetify,useGoTo,useDisplay}=Vuetify var data={alert:{show:false,color:'success',text:'',timeout:0,},theme:{dark:false,},nav:{showDrawer:false,showTOC:true,tocPanel:0,tab:'account',post:{discussionId:501,currentPage:1,targetPage:1,total:11,anchor:0,goToOptions:{container:null,duration:0,easing:'easeInOutCubic',offset:-100,},worker:null,task:[],active:[],apiLock:[],originLike:new Map([]),},related:{block:1,}},search:{width:80,text:null,loading:false,},tags:[{id:53,url:'/t/2b2771216a045c7263771533431d',name:'SpartanHost',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:6875,num:0,uid:3153,content:'\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/011.webp\"\u003E 不知道收不收的到 随缘收 有的PM\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 12:27:48',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6876,num:1,uid:1467,content:'\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/016.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 12:28:08',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6877,num:2,uid:2003,content:'\u003Cp\u003E这玩意这么值钱?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 12:28:39',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6878,num:3,uid:3154,content:'\u003Cp\u003E绑定同收\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 12:30:54',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6879,num:4,uid:3155,content:'\u003Cp\u003E斯巴达传家宝\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 12:39:40',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6880,num:5,uid:1739,content:'\u003Cp\u003E这才叫传家宝\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 13:11:43',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6881,num:6,uid:1604,content:'\u003Cp\u003E值钱在哪?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 13:26:43',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6882,num:7,uid:1543,content:'\u003Cp\u003E还不如600收24刀\u003Cbr\u003E400块可以续费三年呢\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 13:51:31',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6883,num:8,uid:3153,content:'\u003Cp\u003E愿意溢价600买24刀,那我为什么不溢价1000收12刀呢。\u003C/p\u003E\u003Cp\u003E不管是600还是1000,在传家宝没有被废之前都值那么多。但12刀续费就是便宜了一半。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 13:58:29',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6884,num:9,uid:2010,content:'\u003Cp\u003E4837还这么值钱?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 14:14:33',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:6885,num:10,uid:1651,content:'\u003Cp\u003E12刀续费便宜一半,但是它溢价也贵一倍,都是对等的\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 17:40:27',updatedAt:'2025-03-11 17:22:04',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1467,{uid:1467,url:'/u/331b42186a045c76646c516f4723077e',avatar:'/a/331b42186a045c76646c516f4723077e',username:'江郎才尽🤖',}],[2010,{uid:2010,url:'/u/09317b206a045c75606b566f040a2023',avatar:'/a/09317b206a045c75606b566f040a2023',username:'giyuniba🤖',}],[1739,{uid:1739,url:'/u/6e2b51386a045c7667695f6f231f2a74',avatar:'/a/6e2b51386a045c7667695f6f231f2a74',username:'今晚打老鼠🤖',}],[3153,{uid:3153,url:'/u/0e0c53076a045c74616f556f25216a14',avatar:'/a/0e0c53076a045c74616f556f25216a14',username:'立华奏🤖',}],[1651,{uid:1651,url:'/u/2e79631b6a045c76666f576f060d1b08',avatar:'/a/2e79631b6a045c76666f576f060d1b08',username:'JaneSmith🤖',}],[3154,{uid:3154,url:'/u/2c2b7a066a045c74616f526f04502a31',avatar:'/a/2c2b7a066a045c74616f526f04502a31',username:'ois🤖',}],[1604,{uid:1604,url:'/u/370876276a045c76666a526f1e26002f',avatar:'/a/370876276a045c76666a526f1e26002f',username:'Joeyhj🤖',}],[3155,{uid:3155,url:'/u/1338405b6a045c74616f536f2603667e',avatar:'/a/1338405b6a045c74616f536f2603667e',username:'城西Louis🤖',}],[1543,{uid:1543,url:'/u/1c2d5b1f6a045c76656e556f223f1626',avatar:'/a/1c2d5b1f6a045c76656e556f223f1626',username:'hostloc-Jacky🤖',}],[2003,{uid:2003,url:'/u/33017d086a045c75606a556f4350120d',avatar:'/a/33017d086a045c75606a556f4350120d',username:'kevinlaw🤖',}],]),related:[{title:'刚收了台 claw 服务器,该不该把网站从斯巴达迁过去?',url:'/d/312c051e6a045c77606a567a4559636a2f34031e',},{title:'求教大佬正常建站的话腾讯云海外站锐驰和斯巴达选哪一个 ?',url:'/d/14107f206a045c77606a567a475d646a2e711e18',},{title:'请问付了一年前斯巴达的服务工单还能正常用吗,和搬瓦工 Plan 比该留哪一个',url:'/d/372a0a356a045c77606a56744551666a28162401',},{title:'斯巴达3刀西雅图 网络质量评测留档',url:'/d/0a3e74356a045c77606a5677465c6a6a07003139',},{title:'纯做站用那个好?',url:'/d/693d605d6a045c77606a56764e5d646a3d06643b',},{title:'收个斯巴达西雅图AMD黑五126刀,吃灰大佬请m',url:'/d/000a5d016a045c77606a56704459636a02091a06',},],} const App={setup(){const goTo=useGoTo() const{mdAndUp}=useDisplay() return{goTo,mdAndUp}},data(){return data;},mounted(){const themeDark=localStorage.getItem("themeDark") if(themeDark!==null){this.theme.dark=JSON.parse(themeDark)} if(this.nav.post.total>(this.nav.post.currentPage-1)*100+20){let moreLen=100 if(this.nav.post.total({id:null,num:(this.nav.post.currentPage-1)*100+v,uid:null,content:null,ipRegion:null,updatedByUid:null,createdAt:null,updatedAt:null,mentionNum:null,mentionedBy:null,mentionUsers:null,likeUsers:null,})) this.posts.push(...morePosts.slice(20))} this.workerStart() const hash=window.location.hash const match=hash.match(/#(\d+)/) if(match){const n=parseInt(match[1],10) if(n>=(this.nav.post.currentPage-1)*100&&n{this.jumpTo(n)})}} this.$nextTick(()=>{this.addHeadingIds() tocbot.init({tocSelector:'.toc',contentSelector:'#post-content-0',headingSelector:'h2, h3, h4',headingsOffset:100,scrollSmoothOffset:-100,scrollSmooth:true,collapseDepth:6,onClick:function(e){setTimeout(()=>{history.replaceState(null,'',window.location.pathname+window.location.search)},0)},}) tocbot.refresh()});},beforeUnmount(){this.workerStop() if(this.quill){this.quill.destroy() this.quill=null}},computed:{dposts(){return this.posts.slice(20);},},created(){},methods:{successAlert(msg){this.alert={show:true,color:'success',text:msg,timeout:1500,}},failureAlert(msg){this.alert={show:true,color:'error',text:msg,timeout:5000,}},flipThemeDark(){this.theme.dark=!this.theme.dark localStorage.setItem("themeDark",JSON.stringify(this.theme.dark))},toSearch(){if(!this.search.text){this.failureAlert('搜索词不能为空') return} let keywords=this.search.text.trim() if(keywords.length<1){this.failureAlert('搜索词不能为空') return} if(keywords.length>100){this.failureAlert('搜索词过长') return} this.doSearch(keywords)},toReg(){window.location.href="/reg"},toLogin(){window.location.href="/login"},toPage(){let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,this.nav.post.targetPage>1?`/${this.nav.post.targetPage}`:'') window.location.href=url},toLoadRelated({done}){if(this.my&&this.my.uid){this.apiLoadRelated({done})}else{done('ok')}},workerStart(){this.nav.post.worker=setInterval(()=>{this.workerLoad()},500);},workerStop(){if(this.nav.post.worker){clearInterval(this.nav.post.worker);this.nav.post.worker=null;}},async jumpTo(num){const page=Math.floor(num/100)+1 const i=num-(page-1)*100 if(page===this.nav.post.currentPage){this.goTo("#post-"+num,this.nav.post.goToOptions) if(!this.posts[i].id){const block=Math.floor(num/20)+1 this.nav.post.apiLock[block]=true await this.apiLoadPosts(block) this.$nextTick(()=>{this.goTo("#post-"+num,this.nav.post.goToOptions)})}}else{let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,page>1?`/${page}`:'') url=url+"#"+num window.location.href=url}},postIntersect(num){return(isIntersecting,entries,observer)=>{if(isIntersecting){this.nav.post.task.push(num) this.nav.post.active.push(num) this.nav.post.active=this.nav.post.active.filter(item=>Math.abs(item-num)<=5) this.nav.post.active.sort((a,b)=>a-b)}else{this.nav.post.active=this.nav.post.active.filter(item=>item!==num)} if(this.nav.post.active[0]){this.nav.post.anchor=this.nav.post.active[0]}else{this.nav.post.anchor=0}}},async apiLoadPosts(block){try{const response=await axios.post('/fapi/v1/post/block/'+block,{discussionId:this.nav.post.discussionId,}) if(response.data.code===0){response.data.data.posts.forEach(post=>{const i=post.num%100 Object.assign(this.posts[i],post)}) response.data.data.users.forEach(user=>{this.usersMap.set(user.uid,user)})}else{this.failureAlert('回帖数据加载失败: '+response.data.msg)}}catch(error){this.failureAlert('回帖数据加载失败: '+error)} this.nav.post.apiLock[block]=false},workerLoad(){while(this.nav.post.task.length){const num=this.nav.post.task.pop() const i=num-(this.nav.post.currentPage-1)*100 if(!this.posts[i].id){const block=Math.floor(num/20)+1 if(!this.nav.post.apiLock[block]){this.nav.post.apiLock[block]=true this.apiLoadPosts(block)}}}},getTimeInfo(t){if(!t){return ""} const now=new Date();const then=new Date(t);const diff=now-then;const minute=60*1000;const hour=minute*60;const day=hour*24;const month=day*30;const year=month*12;if(diffpost.num===num) if(!post){return "#"+num} const uid=post.uid const username=this.usersMap.get(uid)?.username if(!username){return "#"+num} return username},getUsernameByPostId(id){const post=this.posts.find(post=>post.id===id) if(!post){return "#"+this.getPostNumByPostId(id)} const uid=post.uid const username=this.usersMap.get(uid).username if(!username){return "#"+this.getPostNumByPostId(id)} return username},getPostNumByPostId(id){const post=this.posts.find(post=>post.id===id) return post.num},getPostById(id){const post=this.posts.find(post=>post.id===id) return post},getPostByNum(num){const post=this.posts.find(post=>post.num===num) return post},getAvatarByUid(uid){const avatar=this.usersMap.get(uid)?.avatar if(!avatar){return this.getRandomAvatar()} return avatar},getAvatarByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post){return this.getRandomAvatar()} const uid=post.uid return this.getAvatarByUid(uid)},getRandomAvatar(){const num=Math.floor(Math.random()*100) return "https://randomuser.me/api/portraits/men/"+num+".jpg"},getUrlByUid(uid){const url=this.usersMap.get(uid)?.url if(!url){return ""} return url},getTextByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post||!post.content){return '点击跳转到#'+num+'查看'} const parser=new DOMParser() const doc=parser.parseFromString(post.content,'text/html') const text=doc.body.textContent||'' return text.slice(0,100)},addHeadingIds(){const content=document.getElementById('post-content-0') if(!content){this.nav.showTOC=false return} const headings=content.querySelectorAll('h2, h3, h4') headings.forEach((heading,index)=>{if(!heading.id){heading.id=`toc-nav-${index}`}}) if(headings.length==0){this.nav.showTOC=false}},async doSearch(keywords){this.search.loading=true try{const response=await axios.post('/fapi/v1/search',{keywords:keywords,}) if(response.data.code===0){if(response.data.data.hash&&response.data.data.hash.length===32){window.location.href="/s/"+response.data.data.hash}else{this.failureAlert('搜索失败: 搜索服务异常')}}else{this.failureAlert('搜索失败: '+response.data.msg)}}catch(error){this.failureAlert('搜索失败: '+error)} this.search.loading=false},debounce(fn,delay){let timer=null return function(...args){if(timer)clearTimeout(timer) timer=setTimeout(()=>{fn.apply(this,args)},delay);};},},watch:{'nav.post.targetPage':{handler:async function(newV,oldV){this.toPage()},immediate:false},},} const vuetify=createVuetify({defaults:{global:{ripple:true,},},}) const app=createApp(App) app.use(vuetify).mount("#app")