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:4631,currentPage:1,targetPage:1,total:8,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:15,url:'/t/0f074b236a045c7665770f3a1528',name:'软路由',color:'#66BB6A',icon:'mdi-router-wireless-settings',},{id:21,url:'/t/182c700e6a045c756177250e2d18',name:'Nginx',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:52678,num:0,uid:4446,content:'\u003Cp\u003E官方有提供意见脚本,直接按照提示安装,简单配置就行了\u003Cbr\u003EURL https://github.com/AdguardTeam/AdGuardHome\u003Cbr\u003E稳定版,Beta版和Edge版,安装在/root目录下;不设置的话,默认好像在/opt的文件夹下\u003Cbr\u003E常用的Linux版本都支持,alpine也可以\u003Cbr\u003Ecurl -s -S -L \u0026#39;https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh\u0026#39; | sh -s -- -o \u0026#39;/root\u0026#39; -v\u003Cbr\u003Ecurl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -c beta -o \u0026#39;/root\u0026#39; -v\u003Cbr\u003Ecurl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -c edge -o \u0026#39;/root\u0026#39; -v\u003C/p\u003E\u003Cp\u003EAdGuardHome.yaml配置文件里,在tls的下面,将allow_unencrypted_doh设置成true\u003Cbr\u003Eallow_unencrypted_doh: true\u003Cbr\u003E这样就可以使用http://127.0.0.1/dns-query\u003C/p\u003E\u003Cp\u003E分享几个nginx的配置,最好是放在https里\u003Cbr\u003E将Agh的登陆也设置成首页\u003C/p\u003E\u003Ccode\u003Elocation / { proxy_pass http://127.0.0.1:3000/; proxy_redirect / /; proxy_cookie_path / /;}\u003C/code\u003E\u003Cp\u003E将Agh的首页设置/agh/路径,可以跟其他共存\u003C/p\u003E\u003Ccode\u003Elocation /agh/ { proxy_pass http://127.0.0.1:3000/; proxy_redirect / /agh/; proxy_cookie_path / /agh/;}\u003C/code\u003E\u003Cp\u003E将doh的路径设置成/query-dns或者任何的其他东东(理论上可以设置无限个)~\u003C/p\u003E\u003Ccode\u003Elocation /query-dns { proxy_set_header Host $http_host; proxy_buffering off; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000/dns-query;}\u003C/code\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 12:49:16',updatedAt:'2025-03-19 11:59:31',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52679,num:1,uid:1964,content:'\u003Cp\u003E这种配置,ad开启edns有效不,\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 12:51:23',updatedAt:'2025-03-19 11:59:31',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52680,num:2,uid:3152,content:'\u003Cp\u003E有木有caddy的\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 12:53:33',updatedAt:'2025-03-19 11:59:31',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52681,num:3,uid:4446,content:'\u003Cp\u003E没具体测,理论上应该跟agh带的dns-query一样的效果~\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 12:57:59',updatedAt:'2025-03-19 11:59:31',mentionNum:0,mentionedBy:[4,],mentionUsers:[],likeUsers:[],},{id:52682,num:4,uid:1964,content:'\u003Cblockquote\u003E\u003Cp\u003E没具体测,理论上应该跟agh带的dns-query一样的效果~\u003C/p\u003E\u003C/blockquote\u003E\u003Cp\u003E一年多前我试过,套了nginxedns不起作用。同一个域名在不套nginx时解析对比就能得出\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 16:35:43',updatedAt:'2025-03-19 11:59:31',mentionNum:3,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52683,num:5,uid:1781,content:'\u003Cp\u003E套nginx也可以支持 EDNS\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 16:47:59',updatedAt:'2025-03-19 11:59:31',mentionNum:0,mentionedBy:[7,],mentionUsers:[],likeUsers:[],},{id:52684,num:6,uid:3573,content:'\u003Cp\u003E 用的dnsproxy, 也是AdGuard家的,套nginx不影响edns\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 16:52:46',updatedAt:'2025-03-19 11:59:32',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:52685,num:7,uid:1964,content:'\u003Cblockquote\u003E\u003Cp\u003E套nginx也可以支持 EDNS\u003C/p\u003E\u003C/blockquote\u003E\u003Cp\u003E现在不想试了,以前研究时使用hk谷歌dns解析国内,去年12月左右开始谷歌dns解析国内就是一坨,已经不想整了。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 16:52:52',updatedAt:'2025-03-19 11:59:32',mentionNum:5,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1781,{uid:1781,url:'/u/6b3968396a045c766762576f47336233',avatar:'/a/6b3968396a045c766762576f47336233',username:'qiying🤖',}],[1964,{uid:1964,url:'/u/122f5d3a6a045c76696c526f2d1d1233',avatar:'/a/122f5d3a6a045c76696c526f2d1d1233',username:'leic-山水🤖',}],[3573,{uid:3573,url:'/u/113b5a0e6a045c74656d556f03391b06',avatar:'/a/113b5a0e6a045c74656d556f03391b06',username:'OAA🤖',}],[4446,{uid:4446,url:'/u/2026540b6a045c73646e506f38380229',avatar:'/a/2026540b6a045c73646e506f38380229',username:'xServ🤖',}],[3152,{uid:3152,url:'/u/290043196a045c74616f546f1a2a0534',avatar:'/a/290043196a045c74616f546f1a2a0534',username:'jsllxx🤖',}],]),related:[{title:'tailscale 和 zerotier 哪个好用,功能多?',url:'/d/360b75096a045c77606a567a445d6a6a2b280405',},{title:'Openwrt 上如何设置递归静态路由',url:'/d/2f2c575e6a045c77606a567a465f676a5b2f3139',},{title:'小米 wifi7 路由器千兆都跑不满',url:'/d/313003376a045c77606a567a475c606a1c101014',},{title:'家庭路由器组网求助',url:'/d/3711025f6a045c77606a56754f5e636a3b0c3505',},{title:'请问 Nginx 怎么添加 CORS 白名单?',url:'/d/093d6b5b6a045c77606a5675445c606a3a0f0767',},{title:'Caddy \u0026amp;nginx 一键部署反代脚本 支持Debian/Ubuntu系统',url:'/d/3d08420f6a045c77606a5675465a636a1e392033',},{title:'EasyTier 组网是真不错',url:'/d/6a035e586a045c77606a56744051666a5d332b01',},{title:'目前好像感受到了 openwrt 作为主路由的无力感',url:'/d/373048036a045c77606a56744051616a2517642b',},{title:'路由器选择就推荐,小米还是中兴呢?或者华硕呢',url:'/d/6a3e555a6a045c77606a5674405f676a282f0920',},{title:'畅网 N100 软路由死机频繁, PVE + 爱快 + IstoreOS 配置,换硬盘后仍未解决,求助!',url:'/d/037d540e6a045c77606a56744251656a38131d3e',},{title:'城中村租房 OpenWrt 抢共享带宽问题求助',url:'/d/6b3b512b6a045c77606a5674425d626a2e731038',},{title:'两个路由器之间的电力猫应该如何配置?',url:'/d/0f784b076a045c77606a56744258656a2b711f64',},{title:'大佬们能帮我看看拓扑图吗?现在旁路无法上网,折腾两天了,头都大了。',url:'/d/3f2c713a6a045c77606a56744358656a15356b34',},{title:'求推荐带两路 SFP+口的路由器',url:'/d/620859076a045c77606a5674455f656a1b131f15',},{title:'使用 nginx 监听已被监听的端口, reload 不会失败, 但会导致其他配置不生效.',url:'/d/627843026a045c77606a5674455c666a012f6731',},{title:'你们的AdGuard home能去youtube客户端广告吗',url:'/d/1c7c482c6a045c77606a5674465f6a6a5b2f0319',},{title:'有什么好用的软路由系统推荐吗',url:'/d/3d3b7e1d6a045c77606a5674465b636a2902231f',},{title:'openwrt 去广告的方案',url:'/d/1f3c621a6a045c77606a56774550656a0d326304',},{title:'r2s 的内存卡(带op系统 ) 插r4s 上能否直接使用。',url:'/d/2f38780f6a045c77606a5677455b6b6a0a7a1a2a',},{title:'AdGuard现在哪里还有活动吗?',url:'/d/1d1077186a045c77606a56764e5b616a162f6736',},],} 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")