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:4785,currentPage:1,targetPage:1,total:99,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:54663,num:0,uid:2977,content:'\u003Cp\u003E其他语言使用不也使用框架,而且封装的更方便, 还有很多语言的标准库就直接有类似 spring 的功能了\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:02:17',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54664,num:1,uid:4265,content:'如果是用 J**a 开发 WEB 应用的话,不用 Spring 也要用个别的,完全自己写的话,怕是要 3 天的工作量直接飙升到 3 个月以上了。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:06:25',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54665,num:2,uid:4179,content:'哪里喷的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:07:53',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54666,num:3,uid:11232,content:'我没喷',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:12:55',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54667,num:4,uid:2977,content:'![img]( \u003Cimg src\u003D\"https://i.imgur.com/M4ar1by.png\"\u003E)',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:15:34',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[70,],mentionUsers:[],likeUsers:[],},{id:54668,num:5,uid:2977,content:'但是其他语言也不用自己写啊这些,也都是框架',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:16:17',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54669,num:6,uid:2593,content:'可能是注解这玩意儿比较抽象吧,不过其实跟调函数也差不多,都是闷着眼干。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:17:20',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54670,num:7,uid:761,content:'人说的不是写脚本吗?别的语言写脚本确实不会用这种框架',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:19:09',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54671,num:8,uid:73,content:'不用吵,已经进化到了没有 AI 不会写代码的地步',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:22:17',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54672,num:9,uid:2376,content:'有些功能不庞大的,用上 Springboot 的话,就变成高射炮打蚊子了。\u003Cbr\u003E\u003Cbr\u003E至于为什么是 Spring ,应该说有什么东西能完全替代 Spring ,做到对象管理、web 接口平面对接等功能?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:27:24',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54673,num:10,uid:2977,content:'感觉是语言的缺陷, py 自带的装饰器就能替代 spring 框架的一些功能',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:30:44',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54674,num:11,uid:11233,content:'j**a 目前开发问题就是太啰哩啰唆了,你想写个简单的项目都得搭一堆 spring 脚手架,写单体微服务这玩意简直是一种心智负担,更不用说安卓开发用 j**a 了,无论写啥安卓项目,最经典的 demo 都得浪费很多时间配那些** gardle 配置,看看隔壁 flutter 写起来就是简洁,基本不需要考虑太多乱七八糟的配置',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:36:05',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54675,num:12,uid:920,content:'Android 的新手村 demo 其实还好,现在 Studio 里面新建项目,直接就能跑,比服务端项目还是简单多了。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 21:54:53',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54676,num:13,uid:2376,content:'一部分吧。我认为:\u003Cbr\u003E\u003Cbr\u003EJ**a 的全对象化和原始值适配不够彻底,对应的原始值包装类自动装拆箱出现得太晚了,同时也存在编译器的能力问题,无法做到原始值在编译层面的包装类对应,导致了泛型不彻底。\u003Cbr\u003E\u003Cbr\u003E还有提得最多的操作符重载,可能只有数学计算可以变得更直觉外,其他业务基本不一定用上,甚至会导致操作符滥用带来的代码清晰性问题。另外偶然找到一种替代机制——Manifold ( https://github.com/manifold-systems/manifold ),可以实现类似的操作符重载能力,机制是基于类似 lombok 的编译器行为拦截,原理就是同为 JVM 语言的 Kotlin 的操作符重载。\u003Cbr\u003E\u003Cbr\u003EJ**a 的问题是过于工程规范化,并且语言特性更新得太保守太慢了。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 22:09:27',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54677,num:14,uid:2790,content:'那要看开发者面对着到底是什么需求,简单的 api 服务器换个框架也能用,但是需求复杂度上去,什么限流鉴权缓存分布式通信大数据搜索引擎一箩筐东西开发效率毫无疑问 springboot 效率最高',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 22:21:09',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54678,num:15,uid:1090,content:'你从哪里得出这个结论的。很多 J**a 开发又不是只会一种编程语言。干什么活什么语言,灵活选择,单一语言的很少好吧。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 22:26:26',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54679,num:16,uid:7364,content:'因为 J**a 中确实有不少都是面向 Spring 编程,我遇到不少写习惯了 Spring 那一套后甚至都不会建立普通 J**a 项目,忘了上次有个什么事情,同事让我帮忙看下,我说建个非 web 项目然后把这个导入进去跑一下看看,结果反过来问我应该怎么做,但是不妨碍 Spring 确实玩的溜。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 22:37:27',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54680,num:17,uid:993,content:'说的 go 离了框架能写啥似的。。\u003Cbr\u003E说的 python 离了 django,flask 能写啥似的。。\u003Cbr\u003E说的 php 离了框架能写啥似的。。\u003Cbr\u003E说的 perl 离了框架能写啥似的。。。对了 perl 好像不怎么用在 web 上。。\u003Cbr\u003E说的 js 离了框架能写啥的,离了 jquery 都未必能写几行。。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 22:55:28',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[49,56,72,],mentionUsers:[],likeUsers:[],},{id:54681,num:18,uid:3827,content:'相当多程序员干的就是依葫芦画瓢的活',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 23:29:31',updatedAt:'2025-03-19 14:16:30',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:54682,num:19,uid:58,content:'J**a 第二大框架,quarkus/vert.x ,好多人都没听过吧,在 techpower 的 benchmark 看到这两货的时候都以为是 benchmark 专用的非常小众的玩意儿。实际上也有好多公司好多项目在用,这也不是野生项目,是 redhat 推动的。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 23:30:03',updatedAt:'2025-03-19 14:16:31',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[993,{uid:993,url:'/u/6c7f7f1f6a045c776963556f133b1774',avatar:'/a/6c7f7f1f6a045c776963556f133b1774',username:'hefish🤖',}],[11233,{uid:11233,url:'/u/080d48046a045d766269556f323f3117',avatar:'/a/080d48046a045d766269556f323f3117',username:'jackOff🤖',}],[7364,{uid:7364,url:'/u/3f035f3b6a045c70636c526f2d1c1c2d',avatar:'/a/3f035f3b6a045c70636c526f2d1c1c2d',username:'meiyiliya🤖',}],[761,{uid:761,url:'/u/3c2e4b0c6a045c77676c576f30263a06',avatar:'/a/3c2e4b0c6a045c77676c576f30263a06',username:'renmu🤖',}],[4265,{uid:4265,url:'/u/6e2b7f3b6a045c73626c536f101b3700',avatar:'/a/6e2b7f3b6a045c73626c536f101b3700',username:'xuanbg🤖',}],[3827,{uid:3827,url:'/u/102050266a045c746868516f1a13627e',avatar:'/a/102050266a045c746868516f1a13627e',username:'duron600🤖',}],[2376,{uid:2376,url:'/u/2b3e672a6a045c75636d506f45110a3f',avatar:'/a/2b3e672a6a045c75636d506f45110a3f',username:'cwek🤖',}],[73,{uid:73,url:'/u/1d2c76266a045c77606d556f41501f15',avatar:'/a/1d2c76266a045c77606d556f41501f15',username:'Perry🤖',}],[58,{uid:58,url:'/u/6c314b256a045c77606f5e6f032a181e',avatar:'/a/6c314b256a045c77606f5e6f032a181e',username:'sagaxu🤖',}],[1090,{uid:1090,url:'/u/691844036a045c766063566f245c1722',avatar:'/a/691844036a045c766063566f245c1722',username:'Gilfoyle26🤖',}],[2593,{uid:2593,url:'/u/223a641e6a045c756563556f25231529',avatar:'/a/223a641e6a045c756563556f25231529',username:'crysislinux🤖',}],[4179,{uid:4179,url:'/u/220359216a045c73616d5f6f4f2b310f',avatar:'/a/220359216a045c73616d5f6f4f2b310f',username:'superchijinpeng🤖',}],[11232,{uid:11232,url:'/u/327a0a026a045d766269546f2f2d2725',avatar:'/a/327a0a026a045d766269546f2f2d2725',username:'yuzii🤖',}],[2977,{uid:2977,url:'/u/69216a586a045c75696d516f3659062b',avatar:'/a/69216a586a045c75696d516f3659062b',username:'Suger828🤖',}],[6085,{uid:6085,url:'/u/177d7a0f6a045c716062536f30196071',avatar:'/a/177d7a0f6a045c716062536f30196071',username:'XDiLa🤖',}],[920,{uid:920,url:'/u/2d0e5b2c6a045c776968566f14581e20',avatar:'/a/2d0e5b2c6a045c776968566f14581e20',username:'ysy950803🤖',}],[11240,{uid:11240,url:'/u/3c39061c6a045d76626e566f04312312',avatar:'/a/3c39061c6a045d76626e566f04312312',username:'Leon6868🤖',}],[2374,{uid:2374,url:'/u/6e7a41286a045c75636d526f30513f12',avatar:'/a/6e7a41286a045c75636d526f30513f12',username:'jqtmviyu🤖',}],[6082,{uid:6082,url:'/u/2301783c6a045c716062546f27383b17',avatar:'/a/2301783c6a045c716062546f27383b17',username:'kakakakaka8889🤖',}],[2790,{uid:2790,url:'/u/6c2203006a045c756763566f42100a3f',avatar:'/a/6c2203006a045c756763566f42100a3f',username:'cvbnt🤖',}],]),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 找工作有感,行业经验大于一切',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',},{title:'主力开发工具不是 VS 的比如 Java ,如何使用大模型辅助开发呢?转到 VS 或者 IDEA 有什么可以使用大模型 API 的插件?',url:'/d/332c065d6a045c77606a56734759676a2a021e61',},],} 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")