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:8093,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:36,url:'/t/332c78596a045c7466775227135f',name:'Claw',color:'#78909C',icon:'mdi-server-network-outline',},],posts:[{id:103937,num:0,uid:8540,content:'\u003Cp\u003E可换季付8刀hk\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 13:58:09',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103938,num:1,uid:17148,content:'\u003Cp\u003E47就好了,都说8不稳\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:01:02',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103939,num:2,uid:17680,content:'\u003Cp\u003E翻倍的就好了\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:04:29',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103940,num:3,uid:8540,content:'\u003Cp\u003E 都是玄学,感觉没差\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:07:31',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103941,num:4,uid:8563,content:'\u003Cp\u003E有大陆优化吗?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:08:33',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103942,num:5,uid:10275,content:'\u003Cp\u003E明盘\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:10:19',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103943,num:6,uid:8540,content:'\u003Cp\u003E 对,大陆优化\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:21:52',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103944,num:7,uid:8540,content:'\u003Cp\u003E 报价就行,差不多都可以出\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:22:07',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103945,num:8,uid:14991,content:'\u003Cp\u003E翻倍的就好了\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 14:46:34',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103946,num:9,uid:8540,content:'\u003Cp\u003E 没有喔,翻倍的应该抢手些\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 15:15:18',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:103947,num:10,uid:8563,content:'\u003Cp\u003E不知道什么行情,我出30吧。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 15:20:21',updatedAt:'2025-04-14 15:30:28',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[10275,{uid:10275,url:'/u/1f23732c6a045d77626d536f442b111d',avatar:'/a/1f23732c6a045d77626d536f442b111d',username:'赛博帕鲁🤖',}],[17148,{uid:17148,url:'/u/3b7f7a2b6a045d70616e5e6f042b3d09',avatar:'/a/3b7f7a2b6a045d70616e5e6f042b3d09',username:'Yeoh🤖',}],[14991,{uid:14991,url:'/u/2a2d04066a045d736963576f01386029',avatar:'/a/2a2d04066a045d736963576f01386029',username:'MoeBoy🤖',}],[8540,{uid:8540,url:'/u/3b2f400c6a045c7f656e566f1f0d2b0a',avatar:'/a/3b2f400c6a045c7f656e566f1f0d2b0a',username:'萌客🤖',}],[8563,{uid:8563,url:'/u/1e3e67276a045c7f656c556f210b6a20',avatar:'/a/1e3e67276a045c7f656c556f210b6a20',username:'Magnus-79🤖',}],[17680,{uid:17680,url:'/u/623a47346a045d706662566f16071023',avatar:'/a/623a47346a045d706662566f16071023',username:'springuan🤖',}],]),related:[{title:'刚收了台 claw 服务器,该不该把网站从斯巴达迁过去?',url:'/d/312c051e6a045c77606a567a4559636a2f34031e',},{title:'ClawCloud 的7刀年付sg 移动突然直了',url:'/d/103f44096a045c77606a567a475e616a0b213725',},{title:'用claw免费容器搭建v0哪吒探针,0.05$一天',url:'/d/1820551d6a045c77606a567a475e636a14100962',},{title:'收claw年付12.6刀内存翻倍jp',url:'/d/6b717b3f6a045c77606a56754e50636a1c066135',},{title:'【已出】出Claw 老4刀 HK',url:'/d/371074226a045c77606a56754e51656a07331863',},{title:'秒出:CLAW的2C4G的新加坡主机25.2刀年付',url:'/d/2c2504286a045c77606a56754e5e646a2211661c',},{title:'280收claw hk老4刀翻倍,100原邮出老4刀',url:'/d/2b3c79256a045c77606a56754f58606a59081104',},{title:'【已收】临期Claw SG 5.25/季 or 10.5/半年付',url:'/d/113c76386a045c77606a56754f59616a18052534',},{title:'阿里ecs,阿里轻量,isif,wawo pis claw Yxvm-hyper skystroll 网络横评',url:'/d/020862066a045c77606a5675405f616a0b2c121e',},{title:'claw翻倍 Yxvm hyper skystroll 三家网络对比',url:'/d/203956396a045c77606a5675405d6a6a25146022',},{title:'我决定保留我的Claw $4',url:'/d/3d1168196a045c77606a5675405a626a3b0f3164',},{title:'claw和yxvm哪个体验更好? 三网来看',url:'/d/2e257c226a045c77606a567540586a6a151b3020',},{title:'Claw代理一直在',url:'/d/3f7941296a045c77606a56754558616a1e732b34',},{title:'出Claw 老4刀,没被限过,每月使用较少,五一到期,120口令包push',url:'/d/3d0e070f6a045c77606a56754651656a27301518',},{title:'claw 这个机子谁知道?',url:'/d/0025761d6a045c77606a5675465c616a3f133e35',},{title:'收claw hk8.4季付的',url:'/d/693b74026a045c77606a56754658676a0e11100b',},{title:'[已出] Claw 4$ 香港 VDS 2C2G-1T 中国优化款',url:'/d/1e0200356a045c77606a56754750626a0b02181a',},{title:'120 claw 4U -250428 push',url:'/d/69017e2f6a045c77606a5674405c666a00171d2a',},{title:'Claw这个25.6的和论坛里经常看到的老4刀是一样的吗',url:'/d/367f56246a045c77606a5674405d6b6a55282b20',},{title:'260收一台Claw HK $4翻倍款',url:'/d/6831763f6a045c77606a5674405b646a0e710a64',},],} 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")