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:8395,currentPage:1,targetPage:1,total:101,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:[],posts:[{id:110216,num:0,uid:8679,content:'',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:17:20',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110217,num:1,uid:18015,content:'R2S',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:19:53',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110218,num:2,uid:8679,content:'手头有个 R2S 准备出掉,小问题太多了,折腾了主路由、旁路由,都不太稳定。放弃了',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:26:03',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110219,num:3,uid:342,content:'OpenWrt 本身就不太稳定,如果只是科学需求不如整个 surge 当网关,分流需求用 ros 或者 ikuai',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:35:28',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[78,],mentionUsers:[],likeUsers:[],},{id:110220,num:4,uid:3825,content:'N1 盒子',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:42:46',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110221,num:5,uid:441,content:'京东云太乙 ER1 ?',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:44:55',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110222,num:6,uid:2407,content:'我用 r5c 刷 debian 挺稳的',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 08:47:36',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110223,num:7,uid:490,content:'R2S 有硬件缺陷,USB 通道那个网口经常掉驱动重连,但是改旁路由只插原生的网口就没问题了',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:21:45',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110224,num:8,uid:8679,content:'是的,我昨天插的原生的 WAN 口,在 OP 改了网口设置后一切正常,几个小时候没走旁路由的手机没有网了,拔掉旁路的 R2S 恢复正常,所以有了换掉它的想法。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:29:24',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110225,num:9,uid:18485,content:'不知树莓派 4B + OpenWrt 如何,用了几年了',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:29:31',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110226,num:10,uid:7608,content:'R2S 要选对固件',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:31:33',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110227,num:11,uid:18486,content:'hinlink H28K 刷 iStoreOS 。\u003Cbr\u003E或者你试试 R2S 刷 iStoreOS 呢?我 H68K 刷 iStore 用了 3 年了,除了自己重启没有任何关停过。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:33:14',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110228,num:12,uid:5864,content:'出个 king3399 / j4105 小主机,黄鱼 Amieeis',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:34:54',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110229,num:13,uid:8679,content:'我是在 https://openwrt.ai/这个网站上编译的,大哥有稳定的固件推荐吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:35:21',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110230,num:14,uid:4076,content:'GL-MT3000 硬路由不好吗。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:43:00',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[17,],mentionUsers:[],likeUsers:[],},{id:110231,num:15,uid:4076,content:'买 R3S 也别买 R2S 吧,2025 年了。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:44:11',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110232,num:16,uid:25,content:'我去年买过一个美版的,小玩意挺厉害,挺稳定的。据说官方 openwrt 系统比较老,但是我用着没差异。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:46:24',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110233,num:17,uid:8679,content:'#14 之前是主路由,现在想换成旁路,折腾的时候对象的手机不断网',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:51:53',updatedAt:'2025-04-19 23:44:08',mentionNum:14,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110234,num:18,uid:7608,content:'ImmortalWrt',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:52:58',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:110235,num:19,uid:15489,content:'官方 openwrt 或者 immortalwrt',ipRegion:'',updatedByUid:0,createdAt:'2025-04-14 09:53:59',updatedAt:'2025-04-19 23:44:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[8679,{uid:8679,url:'/u/200258216a045c7f666d5f6f40230b1d',avatar:'/a/200258216a045c7f666d5f6f40230b1d',username:'Debug1998🤖',}],[7608,{uid:7608,url:'/u/007b73236a045c70666a5e6f420f3872',avatar:'/a/007b73236a045c70666a5e6f420f3872',username:'ejoe123🤖',}],[18486,{uid:18486,url:'/u/6b1d561c6a045d7f6462506f473b0a0b',avatar:'/a/6b1d561c6a045d7f6462506f473b0a0b',username:'JxQg597🤖',}],[15489,{uid:15489,url:'/u/6f040b0f6a045d7264625f6f1420382f',avatar:'/a/6f040b0f6a045d7264625f6f1420382f',username:'bigshawn🤖',}],[25,{uid:25,url:'/u/1c3958196a045c776068536f21182a0d',avatar:'/a/1c3958196a045c776068536f21182a0d',username:'williamjing🤖',}],[2407,{uid:2407,url:'/u/141070246a045c75646a516f20393c31',avatar:'/a/141070246a045c75646a516f20393c31',username:'titanium98118🤖',}],[490,{uid:490,url:'/u/090b5e0e6a045c776463566f1623390b',avatar:'/a/090b5e0e6a045c776463566f1623390b',username:'Leon777🤖',}],[965,{uid:965,url:'/u/373164236a045c77696c536f3c211817',avatar:'/a/373164236a045c77696c536f3c211817',username:'WhatTheBridgeSay🤖',}],[18485,{uid:18485,url:'/u/1220465a6a045d7f6462536f051f3a3f',avatar:'/a/1220465a6a045d7f6462536f051f3a3f',username:'oisadfo🤖',}],[5864,{uid:5864,url:'/u/3e180a356a045c72686c526f031c1a28',avatar:'/a/3e180a356a045c72686c526f031c1a28',username:'Donahue🤖',}],[441,{uid:441,url:'/u/2d7e733b6a045c77646e576f0f0c3429',avatar:'/a/2d7e733b6a045c77646e576f0f0c3429',username:'itianjing🤖',}],[3825,{uid:3825,url:'/u/102806056a045c746868536f27390936',avatar:'/a/102806056a045c746868536f27390936',username:'blessyou🤖',}],[342,{uid:342,url:'/u/683e550f6a045c77636e546f2e312128',avatar:'/a/683e550f6a045c77636e546f2e312128',username:'SakuraYuki🤖',}],[18015,{uid:18015,url:'/u/127860276a045d7f606b536f145a022f',avatar:'/a/127860276a045d7f606b536f145a022f',username:'willygeek007🤖',}],[4076,{uid:4076,url:'/u/6c0a5a036a045c73606d506f3b5c3074',avatar:'/a/6c0a5a036a045c73606d506f3b5c3074',username:'ZeekChatCom🤖',}],]),related:[],} 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")