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:6354,currentPage:1,targetPage:1,total:80,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',},{id:30,url:'/t/6c1e511e6a045c7460771613430f',name:'Python',color:'#FFA726',icon:'mdi-language-python',},{id:25,url:'/t/0d0f7d3d6a045c75657751293a0c',name:'C#',color:'#FFA726',icon:'mdi-language-csharp',},],posts:[{id:75921,num:0,uid:6605,content:'\u003Cp\u003E\u003Ccode\u003Enode_modules\u003C/code\u003E 每个项目都有几个 GB ,这站里大部分都是前端,应该都懂,不用多说了\u003C/p\u003E\u003Cp\u003E最近发现 Python 的 venv 也超大,并且比 Node.js 还离谱,每个项目的 venv 里都还会复制一遍 python 解析器\u003C/p\u003E\u003Cp\u003E为什么就不能像.NET 的 NuGet 一样,把依赖都按版本放在一起?放在项目目录里,还要配置版本管理排除\u003C/p\u003E\u003Cp\u003ENuGet 的包缓存目录里有版本号,不同依赖版本不会冲突\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 02:43:20',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75922,num:1,uid:14048,content:'pnpm:你在想我?\u003Cbr\u003E\u003Cbr\u003Env:你在想我?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 03:00:49',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75923,num:2,uid:14048,content:'哦,python 的那个叫 uv',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 03:01:12',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75924,num:3,uid:9929,content:'历史遗留 不好改了。。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 03:07:54',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75925,num:4,uid:10751,content:'因为存储不值钱',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 04:44:03',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75926,num:5,uid:14049,content:'\u003Cbr\u003E用下面这个两个, 代替默认的 Python, Node 包管理\u003Cbr\u003Ehttps://docs.astral.sh/uv/\u003Cbr\u003Ehttps://pnpm.io/',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 05:38:03',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75927,num:6,uid:12016,content:'yarn2: 你在说我?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 06:01:38',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75928,num:7,uid:6525,content:'我一个以前很讨厌 python 的人,用了 rye + uv 之后,开始喜欢写 python 工具了,特别是嵌入式工具的脚本',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 07:38:21',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75929,num:8,uid:708,content:'Python venv 不应该会复制解析器,直接链接的啊... 但是 venv 和 node_modules 的情况类似,你都需要每个项目复制一遍依赖包,当然情况多少比 node_modules 好一点点',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 07:42:06',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75930,num:9,uid:2923,content:'npm: 不同 package 自己在 package.json 里指定了自己的依赖版本,怪我咯?\u003Cbr\u003Ehttps://stackoverflow.com/questions/65487385/should-i-duplicate-peerdependencies-in-dependencies-field-of-package-json',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 08:06:47',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75931,num:10,uid:796,content:'其他语言什么装包速度也配跟 nodejs 比。我看一了一下新项目的 node_modules 大小只有 500MB 。一般能 node_modules 上 G 的,肯定是什么公司里的屎山代码,这种公司啊,不值得待应该跑路。\u003Cbr\u003Enode_modules 要是容量大了,那还不是编译了 node-sqlite 、node-sass 之类外来二进制包的锅',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 08:41:01',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[37,],mentionUsers:[],likeUsers:[],},{id:75932,num:11,uid:4687,content:'pnpm 和 uv 都是靠链接,我个人还是更喜欢全局**仓库的概念,让软件自己去**仓库找。\u003Cbr\u003E\u003Cbr\u003E依赖版本号冲突的时候,在那里反复安装删除就受不了,用 pip 的肯定都体验过。**仓库直接什么版本都有,反正调用的时候去取吧。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 08:41:03',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75933,num:12,uid:9823,content:'现在才$0.1/gb\u003Cbr\u003E没必要吧\u003Cbr\u003E不要为了节省空间而浪费大家的时间',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 08:56:59',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75934,num:13,uid:8084,content:'uv 这种靠链接, 有时候需要打包一个可执行环境给别人, 还是用 conda 方便些',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 08:59:46',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75935,num:14,uid:1242,content:'独立的 venv 也有独立的好处,不同环境不会互相污染,清理的时候文件夹一删就完事',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:00:27',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75936,num:15,uid:4923,content:'那生成 requirements.txt 有什么好方式吗,每次都是切到 venv 环境下一顿处理,才能弄到只有必须的包,要不总会包含很多别的不用的包?才开始使用 python ,希望不吝赐教啊',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:04:51',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75937,num:16,uid:14050,content:'pipreqs',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:16:10',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75938,num:17,uid:8003,content:'没见过公司项目少于 g 的 node_mofules 。。。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:20:52',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75939,num:18,uid:7119,content:'Sounds like a skill issue',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:35:18',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:75940,num:19,uid:4923,content:'尝试过,不知道哪弄得不对,会出异常。就没有继续研究。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 09:42:46',updatedAt:'2025-03-26 00:37:58',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[14050,{uid:14050,url:'/u/0f277d2f6a045d73606f566f3c3f3114',avatar:'/a/0f277d2f6a045d73606f566f3c3f3114',username:'cdwyd🤖',}],[708,{uid:708,url:'/u/6f7c451c6a045c77676a5e6f46506017',avatar:'/a/6f7c451c6a045c77676a5e6f46506017',username:'crackidz🤖',}],[14049,{uid:14049,url:'/u/343e43096a045d73606e5f6f3d103277',avatar:'/a/343e43096a045d73606e5f6f3d103277',username:'dcoder🤖',}],[8084,{uid:8084,url:'/u/3013785e6a045c7f6062526f0d5d1e1e',avatar:'/a/3013785e6a045c7f6062526f0d5d1e1e',username:'chengyiqun🤖',}],[8003,{uid:8003,url:'/u/620f51216a045c7f606a556f4413193f',avatar:'/a/620f51216a045c7f606a556f4413193f',username:'Bingchunmoli🤖',}],[4687,{uid:4687,url:'/u/202b41016a045c736662516f45030929',avatar:'/a/202b41016a045c736662516f45030929',username:'samnya🤖',}],[9929,{uid:9929,url:'/u/3d1e001d6a045c7e69685f6f39281c23',avatar:'/a/3d1e001d6a045c7e69685f6f39281c23',username:'abcdxe2v🤖',}],[1242,{uid:1242,url:'/u/0e31503c6a045c76626e546f230a2006',avatar:'/a/0e31503c6a045c76626e546f230a2006',username:'yolee599🤖',}],[9823,{uid:9823,url:'/u/1e7a7c216a045c7e6868556f40203973',avatar:'/a/1e7a7c216a045c7e6868556f40203973',username:'guiyumin🤖',}],[347,{uid:347,url:'/u/1f1b680b6a045c77636e516f11386710',avatar:'/a/1f1b680b6a045c77636e516f11386710',username:'Donaldo🤖',}],[2923,{uid:2923,url:'/u/227d5e276a045c756968556f423d3116',avatar:'/a/227d5e276a045c756968556f423d3116',username:'charlie21🤖',}],[6525,{uid:6525,url:'/u/1f3a602f6a045c716568536f3451040f',avatar:'/a/1f3a602f6a045c716568536f3451040f',username:'c0t🤖',}],[4923,{uid:4923,url:'/u/227b0a076a045c736968556f2d241600',avatar:'/a/227b0a076a045c736968556f2d241600',username:'darktutu🤖',}],[14048,{uid:14048,url:'/u/0a0451186a045d73606e5e6f42253a03',avatar:'/a/0a0451186a045d73606e5e6f42253a03',username:'seki🤖',}],[7119,{uid:7119,url:'/u/6270001e6a045c70616b5f6f390e3c2c',avatar:'/a/6270001e6a045c70616b5f6f390e3c2c',username:'NessajCN🤖',}],[796,{uid:796,url:'/u/0f0c05056a045c776763506f0e282712',avatar:'/a/0f0c05056a045c776763506f0e282712',username:'wangtian2020🤖',}],[12016,{uid:12016,url:'/u/1d3a040c6a045d75606b506f435e0932',avatar:'/a/1d3a040c6a045d75606b506f435e0932',username:'yuankui🤖',}],[6605,{uid:6605,url:'/u/3b0047256a045c71666a536f2f1b310e',avatar:'/a/3b0047256a045c71666a536f2f1b310e',username:'drymonfidelia🤖',}],[10751,{uid:10751,url:'/u/382563386a045d77676f576f32211616',avatar:'/a/382563386a045d77676f576f32211616',username:'rogerer🤖',}],]),related:[{title:'推荐一款自己写的提升效率的浏览器插件: HarmonyAutoCopy,让文本复制更轻松!',url:'/d/6f06033d6a045c77606a567a475c646a1f371708',},{title:'程序猿创业失败,转行做独立开发',url:'/d/393e7d3e6a045c77606a56754350616a59191c16',},{title:'Python 开发工程师(全栈)',url:'/d/6d0454026a045c77606a5675435b636a3d293821',},{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:'技术栈选择: Java 还是 Python',url:'/d/2878683b6a045c77606a5675475d616a083a1603',},{title:'请问下 github 上有没有哪个 Python 项目使用了 langchain 对接目前市面上所有的大模型的',url:'/d/1c3e743c6a045c77606a56744e5e626a3e050927',},{title:'用 PyQt 搞了个日历笔记本',url:'/d/0d11435b6a045c77606a56744f50626a0e081434',},{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:'求助!双显卡连接 6 个屏幕,展示不同的 URL 页面。Electron 的 displayId 每次重启都会变',url:'/d/1f3158176a045c77606a56744551676a24111b3b',},],} 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")