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:4643,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:7,url:'/t/301068246a045c77677734351a2d',name:'VirMach',color:'#3949AB',icon:'mdi-server-network-outline',},],posts:[{id:52782,num:0,uid:2234,content:'\u003Cp\u003ENode:RYZE.TYO-C038.VMS 又趴窝了吗\u003C/p\u003E\u003Cp\u003E关机好几天了,妈的启动不了了,还剩一个月到期扔了\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:07:12',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52783,num:1,uid:5237,content:'\u003Cp\u003Evir 就这样了, 只能等恢复 \u003Cimg src\u003D\"/z/img/xhj/023.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:09:27',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52784,num:2,uid:1766,content:'\u003Cp\u003E随缘\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:15:32',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52785,num:3,uid:3223,content:'\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/010.webp\"\u003E 续费多少,扔我玩玩\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:17:40',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52786,num:4,uid:4346,content:'\u003Cp\u003E**不佳 丢了吧 \u003Cimg src\u003D\"/z/img/xhj/014.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:32:42',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52787,num:5,uid:3276,content:'\u003Cp\u003E还有一年到期。。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:37:19',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52788,num:6,uid:2029,content:'\u003Cp\u003E啥情况?商家不修的么?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 14:17:03',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52789,num:7,uid:3606,content:'\u003Cp\u003E 这是VIR,你要求有点过分了昂 \u003Cimg src\u003D\"/z/img/xhj/029.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 14:33:57',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[8,],mentionUsers:[],likeUsers:[],},{id:52790,num:8,uid:2029,content:'\u003Cblockquote\u003E\u003Cp\u003E 这是VIR,你要求有点过分了昂 \u003Cimg src\u003D\"/z/img/xhj/029.webp\"\u003E\u003C/p\u003E\u003C/blockquote\u003E\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/024.webp\"\u003E \u003Cimg src\u003D\"/z/img/xhj/024.webp\"\u003E \u003Cimg src\u003D\"/z/img/xhj/024.webp\"\u003E \u003Cimg src\u003D\"/z/img/xhj/023.webp\"\u003E \u003Cimg src\u003D\"/z/img/xhj/023.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 14:41:17',updatedAt:'2025-03-19 11:59:45',mentionNum:7,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52791,num:9,uid:10982,content:'\u003Cp\u003E39节点稳定几年了,偶尔重启一次。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 14:49:26',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52792,num:10,uid:2118,content:'\u003Cp\u003E18.58刀2年付\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 14:50:44',updatedAt:'2025-03-19 11:59:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[10982,{uid:10982,url:'/u/232e5b176a045d776962546f05230330',avatar:'/a/232e5b176a045d776962546f05230330',username:'炒土豆丝🤖',}],[4346,{uid:4346,url:'/u/6a2765226a045c73636e506f1c251903',avatar:'/a/6a2765226a045c73636e506f1c251903',username:'coffeeccc🤖',}],[3606,{uid:3606,url:'/u/1e01510c6a045c74666a506f3b31642c',avatar:'/a/1e01510c6a045c74666a506f3b31642c',username:'naohjohn🤖',}],[2118,{uid:2118,url:'/u/297c683c6a045c75616b5e6f102a107f',avatar:'/a/297c683c6a045c75616b5e6f102a107f',username:'川建国让中国再次伟大🤖',}],[3223,{uid:3223,url:'/u/152057286a045c746268556f312d0515',avatar:'/a/152057286a045c746268556f312d0515',username:'pipi1021🤖',}],[1766,{uid:1766,url:'/u/3b3c5d2a6a045c76676c506f270e1e1d',avatar:'/a/3b3c5d2a6a045c76676c506f270e1e1d',username:'iMranRan🤖',}],[2234,{uid:2234,url:'/u/1633431d6a045c756269526f2e2c1a02',avatar:'/a/1633431d6a045c756269526f2e2c1a02',username:'Rb🤖',}],[2029,{uid:2029,url:'/u/3d78031f6a045c7560685f6f1b1b1d12',avatar:'/a/3d78031f6a045c7560685f6f1b1b1d12',username:'jahguleth🤖',}],[5237,{uid:5237,url:'/u/020665216a045c726269516f19250025',avatar:'/a/020665216a045c726269516f19250025',username:'happybird🤖',}],[3276,{uid:3276,url:'/u/150476176a045c74626d506f07000021',avatar:'/a/150476176a045c74626d506f07000021',username:'吹风秀**🤖',}],]),related:[{title:'【收鸡收鸡】每日一发,收virmach年付8.88刀/两年付18.58刀,sakura1.6刀hk,yvgs12.99o的8c8g版',url:'/d/322f711e6a045c77606a5674415c616a24776310',},{title:'【收鸡收鸡】收virmach年付8/12刀、deluxhost年付6欧',url:'/d/62257c146a045c77606a5677455f636a3f110334',},{title:'virmach jp有多少节点?',url:'/d/1920665f6a045c77606a567640596a6a1616243c',},{title:'【收】收一台virmach年付8/12刀',url:'/d/0a7c063c6a045c77606a5676415e666a152c6605',},{title:'【已出】25R出virmach 日本年付12.17刀 月流量2T土著机',url:'/d/3d0451096a045c77606a5676415b616a29370518',},{title:'已出 virmach 圣何塞 8刀',url:'/d/357c5c206a045c77606a56714f5b646a1b376315',},{title:'virmach 18刀两年',url:'/d/1c3178546a045c77606a56704158626a21390906',},{title:'我的virmach 线路终于回到 IIJ 感觉又可以愉快玩了。',url:'/d/6b38051a6a045c77606a56734f5f646a16363b07',},{title:'再出点小鸡回点血',url:'/d/333c51236a045c77606a5672415b656a0e07113c',},{title:'剩余价值93R带原始邮箱出一台 virmach 美国年付17.64刀3c2.5g 80Gssd 月流量15T的机器',url:'/d/3f2c531f6a045c77606a56724350646a0f0b256a',},],} 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")