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:8066,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:3,url:'/t/2b05770f6a045c7763772a264105',name:'Bandwagon',color:'#FF8F00',icon:'mdi-server-plus',},],posts:[{id:103747,num:0,uid:3144,content:'\u003Cp\u003E瓦工 SG CN2 46刀,市场价去到多少?听说线路很好。\u003Cbr\u003E就是不知道市场价,论坛帖子也不多。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:24:27',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103748,num:1,uid:3116,content:'\u003Cp\u003E天价\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:25:20',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103749,num:2,uid:1496,content:'\u003Cp\u003E 溢价3.400能收到,毕竟流量太少了,就167G,天价的是V2 SG \u003Cimg src\u003D\"/z/img/xhj/008.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:26:49',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103750,num:3,uid:5288,content:'\u003Cp\u003E原油溢价大几百\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:27:16',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103751,num:4,uid:3116,content:'\u003Cp\u003E \u003Cimg src\u003D\"/z/img/xhj/001.webp\"\u003E 升级 the plan 和 v2 的流量bug是不是也修复到1/3?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:28:45',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103752,num:5,uid:17659,content:'\u003Cp\u003E联通我用爪子云,感觉很丝滑。不比CN2差\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:30:51',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103753,num:6,uid:1496,content:'\u003Cp\u003E 667G 2.5G口,带原油溢价中四 \u003Cimg src\u003D\"/z/img/xhj/008.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:31:02',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103754,num:7,uid:3144,content:'\u003Cp\u003E还有一个V2 ,谢谢教学了\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:34:54',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103755,num:8,uid:3144,content:'\u003Cp\u003E这个就是V2款?\u003Cbr\u003E中四是?1400?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:35:31',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103756,num:9,uid:1496,content:'\u003Cp\u003E 想啥呢,4000起步 \u003Cimg src\u003D\"/z/img/xhj/008.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:36:51',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103757,num:10,uid:3144,content:'\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/011.webp\"\u003E \u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:37:49',updatedAt:'2025-04-14 15:29:51',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[3116,{uid:3116,url:'/u/3e1948236a045c74616b506f3f3d072e',avatar:'/a/3e1948236a045c74616b506f3f3d072e',username:'ssd🤖',}],[1496,{uid:1496,url:'/u/30304a3e6a045c766463506f235f3d34',avatar:'/a/30304a3e6a045c766463506f235f3d34',username:'先生在发呆🤖',}],[5288,{uid:5288,url:'/u/3c2259346a045c7262625e6f073b002d',avatar:'/a/3c2259346a045c7262625e6f073b002d',username:'jazzus🤖',}],[3144,{uid:3144,url:'/u/0f2c5d3f6a045c74616e526f4f3f310c',avatar:'/a/0f2c5d3f6a045c74616e526f4f3f310c',username:'Quan🤖',}],[17659,{uid:17659,url:'/u/6205461f6a045d70666f5f6f3d5a2429',avatar:'/a/6205461f6a045d70666f5f6f3d5a2429',username:'Hululu🤖',}],]),related:[{title:'求推荐个三网优化的鸡 要买',url:'/d/3d275f096a045c77606a567540516b6a227b1130',},{title:'请教各位,Bwg 跟Dmit 哪个能打一点?',url:'/d/1c1a06596a045c77606a5675405e656a002b6330',},{title:'请问付了一年前斯巴达的服务工单还能正常用吗,和搬瓦工 Plan 比该留哪一个',url:'/d/372a0a356a045c77606a56744551666a28162401',},{title:'瓦工的v6将来会做优化吗?',url:'/d/3f2c581f6a045c77606a5674465a656a3d253964',},{title:'测试一下刚刚收到的临期瓦工The DC9 Plan VPS 曾经的梦中情机',url:'/d/6d3f7f256a045c77606a56774f51636a1d772516',},{title:'你们对瓦工的megabox满意吗',url:'/d/6f207b016a045c77606a56774f5f646a240c2234',},{title:'去年的瓦工DC9 ,有人要么?$35.42 USD( 已出)',url:'/d/0e0f68246a045c77606a56774f5c616a262f0662',},{title:'搬瓦工 dc9 不到一个月,2025-04-15到期,放生了,改过邮 20出',url:'/d/382f74076a045c77606a56774f5a616a1b70061d',},{title:'我这个bwg的powerbox还能卖多少?',url:'/d/030660086a045c77606a5677405d616a5f700125',},{title:'biggerbox升级megabox pro记录贴',url:'/d/1e1874086a045c77606a5677405b646a3d373725',},{title:'瓦工日本还会重新推出吗',url:'/d/0d11035d6a045c77606a567742506b6a3f223d6b',},{title:'搬瓦工逆天 Bug',url:'/d/2e195c1c6a045c77606a567742516a6a357b360a',},{title:'150折价出瓦工BIGGERBOX',url:'/d/2c0660276a045c77606a5677435f666a152f0210',},{title:'MINIBOX也是CN2GIA了吗?',url:'/d/193068356a045c77606a5677435c656a29101015',},{title:'[出] 搬瓦工DC99机房POWERBOX-30-1536',url:'/d/020f7c2e6a045c77606a5677435c666a08053a22',},{title:'(出)原邮瓦工biggerbox未付订单,已承诺线路保障,也可升级到最新DC1机房',url:'/d/323e64156a045c77606a5677435b606a5e2d611c',},{title:'搬瓦工Box系列补货,可升级Pro更高级套餐,最后末班车速速上车,赶快升级MegaBox',url:'/d/032a5f226a045c77606a567743586b6a1c053c39',},{title:'【收到了】溢价收个瓦工minibox',url:'/d/027b75146a045c77606a56774358666a2a251227',},{title:'继续用dc99还是升级dc1好',url:'/d/1c7945236a045c77606a5677455e636a35151034',},{title:'DC99 box可以升级到DC1 box pro了。',url:'/d/0e187b546a045c77606a5677455d656a1d2c3e10',},],} 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")