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:5992,currentPage:1,targetPage:1,total:30,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:20,url:'/t/2c0b5e546a045c756077023a1a1e',name:'Js|Ts|H5',color:'#FFA726',icon:'mdi-language-javascript',},],posts:[{id:69457,num:0,uid:12962,content:'\u003Cp\u003E关于跨端开发一直是争议比较多的地方,因为方案还是挺多的,移动端比较有代表性的就是 react native 和 flutter 。感觉在国内,flutter 是不是比 react native 热度更高,但是在外网,比如推特上,我感觉 react native 热度挺高的,前段时间看了一个帖子说,事实上国际大厂用 react native 的远远比 flutter 多,举例了微软,meta,amazon 以及 shopify 这样全部迁移到 react native 上的,更是有 expo 这样的商业公司提供了商业支持。\u003C/p\u003E\u003Cp\u003E大家觉得列。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:37:29',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69458,num:1,uid:10646,content:'如果你是技术决策者,如果要 KPI 。\u003Cbr\u003E\u003Cbr\u003E现有技术栈用 RN ,你就迁移到 flutter 。现有技术栈用 flutter ,你就迁移到 RN 。\u003Cbr\u003E\u003Cbr\u003E现阶段还争论哪个技术栈好?幼稚。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:51:42',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69459,num:2,uid:12962,content:'只是提出一个议题大家讨论下,这就幼稚了?就你清醒?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:53:02',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69460,num:3,uid:12899,content:'看看 bug 数量,维护更新频率你就知道选谁了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:53:47',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69461,num:4,uid:12298,content:'其实我感觉都差不多,技术小白。\u003Cbr\u003E兼容性问题的话,我觉得 Flutter 比 RN 好。\u003Cbr\u003E学习成本的话,RN 起码用 JS ,Flutter 用 dart 。\u003Cbr\u003E从 Weex 时代过来的, 我觉得多端调试太累了,有的时候两端那种调完 iOS 端,Android 端不一样,调完 Android ,iOS 又不一样的无力感我不想再来了,代码里充斥着判断终端类型的 if ,让我觉得有种还不如写原生的错觉。\u003Cbr\u003E简单的项目我觉得 Flutter 一把梭,基本不用看。\u003Cbr\u003E如果特别精细化要求的,我只觉得用原生,其次又思考为什么两种终端两个人的活要一个人干😂',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:57:02',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69462,num:5,uid:827,content:'我选 Lynx \u003Cimg src\u003D\"https://i.imgur.com/agAJ0Rd.png\"\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 09:58:25',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69463,num:6,uid:12962,content:'好像这个是前端恋综大佬 黄玄搞的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 10:00:15',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[8,],mentionUsers:[],likeUsers:[],},{id:69464,num:7,uid:1077,content:'大厂的一些决策可能没法类比,他们只需要一个 UI 壳子。并且肯定是有很多原生定制的。\u003Cbr\u003E\u003Cbr\u003E人少经验少,RN 吧,生态和热度都挺好的,共享大部分前端生态,招人也简单。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 10:12:09',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69465,num:8,uid:6373,content:'#6 感觉像 kpi 项目',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 10:17:47',updatedAt:'2025-03-23 11:50:33',mentionNum:6,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69466,num:9,uid:6967,content:'后期可以试下 KMP (现在还不稳定)',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 10:22:54',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69467,num:10,uid:2662,content:'比起什么大厂, 我更想知道新项目用什么的更多, 这才代表未来,',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 10:52:35',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69468,num:11,uid:4179,content:'2025 年了,你去看看社区活跃度不就知道了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 11:03:04',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69469,num:12,uid:3743,content:'以前开发 flutter 的时候,最难受的就是列表总是一卡一卡的,不知道现在解决了没有……',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 11:33:13',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[13,18,],mentionUsers:[],likeUsers:[],},{id:69470,num:13,uid:3743,content:'#12 可能总结一下,就是操作手感有点肉',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 11:33:35',updatedAt:'2025-03-23 11:50:33',mentionNum:12,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69471,num:14,uid:7027,content:'后端开发者,想转独立开发,推荐哪个?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 13:00:49',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69472,num:15,uid:52,content:'独立开发就写 ios 原生就可以了,支持多端其实主打的是远端的 service ,并不靠客户端功能赚钱,而独立开发其实很难靠远端的服务赚钱',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 13:07:39',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69473,num:16,uid:81,content:'大公司用 rn ,小公司用 flutter',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 13:32:39',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69474,num:17,uid:3848,content:'跨端国内就 uniapp ,要么就自己 webview ,h5 的快捷和复用性会磨平 flutter 和 react native 的一切优势\u003Cbr\u003E\u003Cbr\u003E天天各种吹,落地了全在套壳 h5',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 14:07:12',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69475,num:18,uid:470,content:'#12 老版本 Debug 模式吧,现在稍微有改善',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 16:06:59',updatedAt:'2025-03-23 11:50:33',mentionNum:12,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:69476,num:19,uid:13036,content:'看搜索 trend 的话 flutter 是大于 react native 的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 16:09:49',updatedAt:'2025-03-23 11:50:33',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[6967,{uid:6967,url:'/u/2e084b2f6a045c71696c516f071d0931',avatar:'/a/2e084b2f6a045c71696c516f071d0931',username:'location123🤖',}],[3848,{uid:3848,url:'/u/293066256a045c74686e5e6f340c3470',avatar:'/a/293066256a045c74686e5e6f340c3470',username:'murmur🤖',}],[470,{uid:470,url:'/u/142f7c376a045c77646d566f21313615',avatar:'/a/142f7c376a045c77646d566f21313615',username:'liu731🤖',}],[827,{uid:827,url:'/u/3e0e7a396a045c776868516f45191028',avatar:'/a/3e0e7a396a045c776868516f45191028',username:'bojackhorseman🤖',}],[52,{uid:52,url:'/u/2d0605376a045c77606f546f42301174',avatar:'/a/2d0605376a045c77606f546f42301174',username:'foolishcrab🤖',}],[3743,{uid:3743,url:'/u/6d3a59016a045c74676e556f07273728',avatar:'/a/6d3a59016a045c74676e556f07273728',username:'tonytonychopper🤖',}],[10646,{uid:10646,url:'/u/0e06781b6a045d77666e506f15200721',avatar:'/a/0e06781b6a045d77666e506f15200721',username:'weixind🤖',}],[1077,{uid:1077,url:'/u/113f57036a045c76606d516f261e0415',avatar:'/a/113f57036a045c76606d516f261e0415',username:'Tyaqing🤖',}],[12962,{uid:12962,url:'/u/6a200b2c6a045d75696c546f4551233e',avatar:'/a/6a200b2c6a045d75696c546f4551233e',username:'momowei🤖',}],[12298,{uid:12298,url:'/u/322a7d176a045d7562635e6f0f250b7e',avatar:'/a/322a7d176a045d7562635e6f0f250b7e',username:'SilentlyYc🤖',}],[81,{uid:81,url:'/u/1d044b0b6a045c776062576f363e3d3d',avatar:'/a/1d044b0b6a045c776062576f363e3d3d',username:'passon🤖',}],[7027,{uid:7027,url:'/u/1c07663a6a045c706068516f441e1c02',avatar:'/a/1c07663a6a045c706068516f441e1c02',username:'Jhon11🤖',}],[13036,{uid:13036,url:'/u/3d39415a6a045d746069506f181f1714',avatar:'/a/3d39415a6a045d746069506f181f1714',username:'hedwi🤖',}],[2662,{uid:2662,url:'/u/030c7a5f6a045c75666c546f350a6223',avatar:'/a/030c7a5f6a045c75666c546f350a6223',username:'AoEiuV020JP🤖',}],[4179,{uid:4179,url:'/u/220359216a045c73616d5f6f4f2b310f',avatar:'/a/220359216a045c73616d5f6f4f2b310f',username:'superchijinpeng🤖',}],[6373,{uid:6373,url:'/u/2a3c770b6a045c71636d556f3d1a3a24',avatar:'/a/2a3c770b6a045c71636d556f3d1a3a24',username:'ZGame🤖',}],[12899,{uid:12899,url:'/u/1f0374546a045d7568635f6f3c3e3f0a',avatar:'/a/1f0374546a045d7568635f6f3c3e3f0a',username:'spinlock🤖',}],]),related:[{title:'推荐一款自己写的提升效率的浏览器插件: HarmonyAutoCopy,让文本复制更轻松!',url:'/d/6f06033d6a045c77606a567a475c646a1f371708',},{title:'程序猿创业失败,转行做独立开发',url:'/d/393e7d3e6a045c77606a56754350616a59191c16',},{title:'发现一个有意思的项目,把一个字符串隐藏到另一个字符串中',url:'/d/3c117a346a045c77606a56754359676a5b323b0b',},{title:'编程小白,终于成功上线了自己的第一个导航站😭 激动',url:'/d/333944256a045c77606a56754451666a3e0e3e67',},{title:'vue 指令更新问题',url:'/d/2f3c4a3e6a045c77606a5675445e636a250e3f24',},{title:'小红书 | 图文,视频,评论 浏览与导出工具',url:'/d/1b1806556a045c77606a56754458676a04343b26',},{title:'[BadouCMS] Vue3+TypeScript+ThinkPHP8 构建 CMS 系统(开源)',url:'/d/303350036a045c77606a56754458626a20390564',},{title:'开发了一个开箱即用的本地终端 Ztty',url:'/d/0c045a2e6a045c77606a5675455e6b6a3e200734',},{title:'第一个完全用 AI 工具生成的工具站',url:'/d/6a18771a6a045c77606a5675475e616a01126104',},{title:'为什么 vue 的 nuxt.js 不跟进 nextjs 的 app route 目录结构',url:'/d/02116a1e6a045c77606a56744f516a6a1b02141e',},{title:'Vite 开发服务器路径遍历漏洞(CVE-2025-30208)',url:'/d/2f2f0a2b6a045c77606a56744f5a646a231a021b',},{title:'做定时任务,一定要用这个神库!',url:'/d/2a1a550b6a045c77606a56744f5b626a5c151613',},{title:'XUGOU - 轻量级系统监控平台,基于 CloudFlare 零成本部署!',url:'/d/0a21430f6a045c77606a56744f58656a0f741e25',},{title:'NextJS 超瓜皮漏洞,赶紧升级!',url:'/d/03226a096a045c77606a56744258646a59126264',},{title:'Typescript 如此成功,为何没有发展出所谓 “Typthon”?',url:'/d/35315c016a045c77606a5674445f626a0e730224',},{title:'为什么 Python 、Node.js 就不能学习一下 C#这种优雅的依赖管理方式?',url:'/d/0f1f5f3d6a045c77606a5674445c676a04311f60',},{title:'求助!双显卡连接 6 个屏幕,展示不同的 URL 页面。Electron 的 displayId 每次重启都会变',url:'/d/1f3158176a045c77606a56744551676a24111b3b',},{title:'[野生程序员花三天时间用 Cursor 复刻经典游戏「俄罗丝方块」,求各位提点建议]',url:'/d/6b047a5e6a045c77606a56774e5c626a2b361d65',},{title:'分享一个用 JS、canvas 写的星空穿越效果',url:'/d/191c61346a045c77606a5677425e6a6a2f28273c',},{title:'郑州招 Python , Node.js 开发岗',url:'/d/082c61146a045c77606a5677425e616a3d706116',},],} 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")