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:1004,currentPage:1,targetPage:1,total:13,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:28,url:'/t/3d104b0f6a045c7568772c310313',name:'Java',color:'#FFA726',icon:'mdi-language-java',},],posts:[{id:12377,num:0,uid:4636,content:'',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 15:58:03',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12378,num:1,uid:4637,content:'生成代码用 VS ,IDEA 负责手写。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 16:00:51',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12379,num:2,uid:1363,content:'双开',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 16:26:57',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12380,num:3,uid:4638,content:'IDEA 里面不是有 Continue,通义灵码插件吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 16:40:48',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12381,num:4,uid:4639,content:'jb 家族的 IDE 里面的插件问答可以,再稍微向 agent 方向的那种就莫得好用的了,确实比较坑',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 16:50:17',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12382,num:5,uid:4640,content:'vsc 我也没钱买 cursor 会员啊',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 17:36:39',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12383,num:6,uid:4641,content:'日常写代码用 IDEA, 要让 AI 生成的时候开 vscode 。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 20:07:58',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12384,num:7,uid:2918,content:'IDEA + Claude Project',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 20:10:03',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12385,num:8,uid:4636,content:'idea 插件的话我希望可以自己配置 api',ipRegion:'',updatedByUid:0,createdAt:'2025-03-10 21:47:53',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[9,],mentionUsers:[],likeUsers:[],},{id:12386,num:9,uid:4638,content:'#8 Continue 插件就是自己配置 api 的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-11 10:24:56',updatedAt:'2025-03-12 13:23:12',mentionNum:8,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12387,num:10,uid:4642,content:'为了方便直接用 cursor 的路过,其实也没有那么难适应 \u003Cimg src\u003D\"https://i.imgur.com/N9E3iZ2.png\"\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-11 12:21:58',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12388,num:11,uid:4643,content:'github copilot',ipRegion:'',updatedByUid:0,createdAt:'2025-03-11 17:13:21',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:12389,num:12,uid:4644,content:'阿里的通义在 VScode 下不错,可以免费用 deepseek R1',ipRegion:'',updatedByUid:0,createdAt:'2025-03-11 20:44:10',updatedAt:'2025-03-12 13:23:12',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1363,{uid:1363,url:'/u/132d64176a045c76636c556f4e303b2e',avatar:'/a/132d64176a045c76636c556f4e303b2e',username:'FrankFang128🤖',}],[4639,{uid:4639,url:'/u/222760346a045c7366695f6f3f5c0b2a',avatar:'/a/222760346a045c7366695f6f3f5c0b2a',username:'iflint🤖',}],[4640,{uid:4640,url:'/u/3e1c5e396a045c73666e566f4404382c',avatar:'/a/3e1c5e396a045c73666e566f4404382c',username:'angryfish🤖',}],[4638,{uid:4638,url:'/u/2b30575f6a045c7366695e6f2d2b3123',avatar:'/a/2b30575f6a045c7366695e6f2d2b3123',username:'loocao🤖',}],[4636,{uid:4636,url:'/u/141b67596a045c736669506f242c2a30',avatar:'/a/141b67596a045c736669506f242c2a30',username:'SlanWyf🤖',}],[4644,{uid:4644,url:'/u/121f71296a045c73666e526f4e240531',avatar:'/a/121f71296a045c73666e526f4e240531',username:'xysemies🤖',}],[2918,{uid:2918,url:'/u/6901682b6a045c75696b5e6f1058240f',avatar:'/a/6901682b6a045c75696b5e6f1058240f',username:'wulongqiu🤖',}],[4641,{uid:4641,url:'/u/101e5a086a045c73666e576f401e062a',avatar:'/a/101e5a086a045c73666e576f401e062a',username:'nightwitch🤖',}],[4637,{uid:4637,url:'/u/0006051c6a045c736669516f3b061b30',avatar:'/a/0006051c6a045c736669516f3b061b30',username:'hunterzhang86🤖',}],[4643,{uid:4643,url:'/u/037a7e2e6a045c73666e556f1219100f',avatar:'/a/037a7e2e6a045c73666e556f1219100f',username:'soulflysimple123🤖',}],[4642,{uid:4642,url:'/u/312206376a045c73666e546f155c3500',avatar:'/a/312206376a045c73666e546f155c3500',username:'ShawBen🤖',}],]),related:[{title:'有在 vscode 上写 Java 的么?一个非常简单的扩展:可以一键复制 arthas 的 watch 命令。',url:'/d/0b26510b6a045c77606a567a455e606a5f011624',},{title:'「郑州」招聘高级 Java 15K 上下,看个人水平',url:'/d/6a2d46346a045c77606a56754e58616a0e216467',},{title:'技术栈选择: Java 还是 Python',url:'/d/2878683b6a045c77606a5675475d616a083a1603',},{title:'Java 开发,接下来的路咋走啊?',url:'/d/1f78462e6a045c77606a5675475b656a1c37230a',},{title:'windsurf 和 cursor 用来写 kotlin 后端还是不太行',url:'/d/2b780b5e6a045c77606a5674425a656a2d103a64',},{title:'Java 后端开发 , macbookAir m4 16+256G 入门款值得入手不,pdd6199 元,(之前那个 MacBookpro 2018 32G+512G 电脑坏了修起来要 4k 以上,没什么维修价值了)另外问一下够用不',url:'/d/200d00356a045c77606a5674435b6b6a0d276310',},{title:'C++ 开发不想 996,如何跳槽转到 Java ?',url:'/d/09207c086a045c77606a56744358646a1f292613',},{title:'Java 和 go 都会,以后找工作偏向哪个方面好呢',url:'/d/000b7b1b6a045c77606a5674445e656a1977262a',},{title:'作为一个传统开发者,如何使用 ai 或者机器学习实现一些简单事情',url:'/d/34015f186a045c77606a5674445e626a25016611',},{title:'Java 生态下想搞大流量下的 ws,是不是暂时只能 netty?',url:'/d/6c7f0b1a6a045c77606a56774251626a5b761219',},{title:'为什么很多人喷 Java 开发者离了 spring 框架就不会写代码了',url:'/d/2c795a5c6a045c77606a56764051666a58303c13',},{title:'Java 找工作有感,行业经验大于一切',url:'/d/3d06072a6a045c77606a5676405c616a050b2611',},{title:'小白发问,都说 C++开发效率比 Java 低,但 C++的 hello world 也没多几行代码啊',url:'/d/6f7157036a045c77606a5676425b616a342a1235',},{title:'作为 Java 狗的我,学习 rust 的时候为啥总念着 go 的好呢?',url:'/d/6f2a02176a045c77606a5671435d636a2f121465',},{title:'原 Java 刚学习 go, 自己在写项目, 针对 go 日志方面的疑惑',url:'/d/6b2c02596a045c77606a56714359626a0f361626',},{title:'Java ReentrantLock 冗余设计?',url:'/d/301a573d6a045c77606a56734759666a5c170733',},],} 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")