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:2316,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:38,url:'/t/3e0b66186a045c7468772a362e2f',name:'阿里云',color:'#66BB6A',icon:'mdi-tag-heart',},{id:39,url:'/t/63287c046a045c7469771524140c',name:'腾讯云',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:27790,num:0,uid:1626,content:'\u003Cp\u003Ert,4c8g起步的那种,套路云和良心云续费太贵了,但又要国内能直连\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:05:20',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27791,num:1,uid:4340,content:'\u003Cp\u003Enetcup\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:06:50',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27792,num:2,uid:7772,content:'\u003Cp\u003E这个规格没便宜的,除非收华为云初创计划,35000代金券开出来。不过华为初创过户要企业认证\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:07:54',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27793,num:3,uid:4376,content:'\u003Cp\u003E200出破碎工坊云4c8g80g 60m三网优化建站鸡,续费159元/年\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:08:47',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27794,num:4,uid:1803,content:'\u003Cp\u003E国内服务器就这两个吧,海外还是有其他选择的\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:10:05',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27795,num:5,uid:3283,content:'\u003Cp\u003E申请公网IP,家里建\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:15:13',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27796,num:6,uid:3155,content:'\u003Cp\u003E斯巴达\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:24:34',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27797,num:7,uid:5151,content:'\u003Cp\u003E建站最好还是稳定第一,月付200+买一个省心\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 17:48:19',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27798,num:8,uid:3376,content:'\u003Cp\u003E稳定跟钞票挂钩\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 21:35:02',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27799,num:9,uid:1859,content:'\u003Cp\u003E推荐Netcup \u003Cimg src\u003D\"/z/img/xhj/010.webp\"\u003E 不介意的话可以走我AFF \u003Cimg src\u003D\"/z/img/xhj/010.webp\"\u003E\u003Cbr\u003Evps系列VPS4000 附一个月折扣码 4103nc17414940950\u003Cbr\u003E追求CPU高性能可以选择\u003Cbr\u003ERS系列-AMD9634 RS4000 附一个月折扣码 4099nc17414940830\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 21:41:23',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:27800,num:10,uid:2040,content:'\u003Cp\u003E建站稳定最重要,不要在乎那点小钱\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 08:05:12',updatedAt:'2025-03-15 13:48:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[2040,{uid:2040,url:'/u/2a2f74586a045c75606e566f30071213',avatar:'/a/2a2f74586a045c75606e566f30071213',username:'1450-qq噢🤖',}],[5151,{uid:5151,url:'/u/1c7061386a045c72616f576f2e241b09',avatar:'/a/1c7061386a045c72616f576f2e241b09',username:'Moken765🤖',}],[7772,{uid:7772,url:'/u/170147186a045c70676d546f1d230110',avatar:'/a/170147186a045c70676d546f1d230110',username:'小白本白🤖',}],[4376,{uid:4376,url:'/u/2c18660f6a045c73636d506f055a067e',avatar:'/a/2c18660f6a045c73636d506f055a067e',username:'yeshooo🤖',}],[3376,{uid:3376,url:'/u/237c50096a045c74636d506f11221670',avatar:'/a/237c50096a045c74636d506f11221670',username:'terra🤖',}],[3283,{uid:3283,url:'/u/181f7d1a6a045c746262556f3d3b122a',avatar:'/a/181f7d1a6a045c746262556f3d3b122a',username:'Outsider🤖',}],[4340,{uid:4340,url:'/u/032b623b6a045c73636e566f135f3e75',avatar:'/a/032b623b6a045c73636e566f135f3e75',username:'1331244x🤖',}],[1859,{uid:1859,url:'/u/0b3b515d6a045c76686f5f6f2702607e',avatar:'/a/0b3b515d6a045c76686f5f6f2702607e',username:'BlackDDDK🤖',}],[1626,{uid:1626,url:'/u/107f62206a045c766668506f12036324',avatar:'/a/107f62206a045c766668506f12036324',username:'Mmo🤖',}],[3155,{uid:3155,url:'/u/1338405b6a045c74616f536f2603667e',avatar:'/a/1338405b6a045c74616f536f2603667e',username:'城西Louis🤖',}],[1803,{uid:1803,url:'/u/3d20025d6a045c76686a556f1f313e1d',avatar:'/a/3d20025d6a045c76686a556f1f313e1d',username:'GckJoy🤖',}],]),related:[{title:'求教大佬正常建站的话腾讯云海外站锐驰和斯巴达选哪一个 ?',url:'/d/14107f206a045c77606a567a475d646a2e711e18',},{title:'看起来腾讯云是按机子限速的,换ip没啥用',url:'/d/340b60546a045c77606a56754e51616a55020b3d',},{title:'阿里云香港轻量和 ECS 网络一样吗?',url:'/d/680d761b6a045c77606a56754e5f6a6a0e2d2a3b',},{title:'出阿里云🇭🇰e1,2029.10.29过期 2000Mbps',url:'/d/3c1d4b096a045c77606a56754f58616a1e026662',},{title:'腾讯云CDN现在不送每月流量了吗?',url:'/d/6f78655a6a045c77606a56754f59656a36193136',},{title:'套腾讯CDN需要备案么',url:'/d/0a274b096a045c77606a5675405e6b6a20742108',},{title:'阿里ecs,阿里轻量,isif,wawo pis claw Yxvm-hyper skystroll 网络横评',url:'/d/020862066a045c77606a5675405f616a0b2c121e',},{title:'【收】腾讯云锐驰200M 3年5年香港。或者2折3折卷!',url:'/d/157f7d236a045c77606a56754650626a34090a1f',},{title:'请问阿里云轻量200MB可以push吗,想收个阿里云广州和上海,和香港',url:'/d/371d0a046a045c77606a56754750666a397a0061',},{title:'老哥们现在阿里国内200m的限速怎么样了',url:'/d/350d712a6a045c77606a5674405d606a04251239',},{title:'【已出】IX前置车 阿里云国内六地可选',url:'/d/0270783d6a045c77606a56744651616a3b1a2b03',},{title:'腾讯云直播嘎嘎猛',url:'/d/6a13460e6a045c77606a5677435e666a23216311',},{title:'腾讯云发公告了净网行动',url:'/d/193e563c6a045c77606a56774451676a3f226001',},{title:'阿里云轻量新增公网线路类型BGP_NCO',url:'/d/1b2742066a045c77606a5677445e6b6a2f1b1623',},{title:'明盘80push出阿里云日本ecs一年半',url:'/d/12796b096a045c77606a5677455d6b6a54312606',},{title:'现在还有没有腾讯200m轻量机器的优惠券收啊',url:'/d/0e0e74256a045c77606a56774558646a00271410',},{title:'出阿里云2h512m20G杭州CDT 2029.6.18到期',url:'/d/192c7b3d6a045c77606a5676405d626a5f36236a',},{title:'个人买云服务器最便宜的是哪家',url:'/d/2a0653246a045c77606a5676425d6a6a18306b2b',},{title:'阿里云HK轻量、DD的系统。咋还自动给我禁用ssh-rsa密钥【改用ed25519】',url:'/d/1d2d4b1f6a045c77606a5676435a636a2608161c',},{title:'阿里云吃灰中...删我机器,剩余费用给退了',url:'/d/2c7b7a596a045c77606a5676455b606a5d37013c',},],} 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")