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:2185,currentPage:1,targetPage:1,total:11,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:50,url:'/t/32715a296a045c7260770f713010',name:'图床',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:26631,num:0,uid:2007,content:'\u003Ccode\u003Edocker compose #-------------------------------------------# Docker Compose# @RobLandry# Repo : https://github.com/LycheeOrg/Lychee-Docker#-------------------------------------------services: lychee_cache: image: redis:alpine container_name: lychee_redis hostname: lychee_redis security_opt: - no-new-privileges:true healthcheck: test: [\u0026#34;CMD-SHELL\u0026#34;, \u0026#34;redis-cli ping || exit 1\u0026#34;] ports: - ${REDIS_PORT:-6379}:${REDIS_PORT:-6379} user: 1026:100 env_file: - path: ./.env required: false environment: - TZ\u003D${TIMEZONE:-UTC} networks: - lychee volumes: - cache:/data:rw restart: on-failure:5 lychee_db: container_name: lychee_db image: mariadb:10 security_opt: - no-new-privileges:true env_file: - path: ./.env required: false environment: - MYSQL_ROOT_PASSWORD\u003D${DB_ROOT_PASSWORD:-rootpassword} - MYSQL_DATABASE\u003D${DB_DATABASE:-lychee} - MYSQL_USER\u003D${DB_USERNAME:-lychee} - MYSQL_PASSWORD\u003D${DB_PASSWORD} expose: - 3306 volumes: - mysql:/var/lib/mysql networks: - lychee restart: unless-stopped lychee: image: lycheeorg/lychee container_name: lychee security_opt: - no-new-privileges:true ports: - 90:80 volumes: - ./lychee/conf:/conf - ./lychee/uploads:/uploads - ./lychee/sym:/sym - ./lychee/logs:/logs - ./lychee/tmp:/lychee-tmp env_file: - path: ./.env required: false networks: - lychee environment: - PUID\u003D${PUID:-1000} - PGID\u003D${PGID:-1000} # PHP timezone e.g. PHP_TZ\u003DAmerica/New_York - PHP_TZ\u003D${TIMEZONE:-UTC} - TIMEZONE\u003D${TIMEZONE:-UTC} #- APP_NAME\u003DLar**el #- APP_ENV\u003Dlocal #- APP_DEBUG\u003Dtrue #- APP_FORCE_HTTPS\u003Dfalse - APP_URL\u003D${APP_URL:-http://localhost} #- APP_DIR\u003D #- DEBUGBAR_ENABLEd\u003Dfalse #- VUEJS_ENABLED\u003Dtrue #- LEGACY_API_ENABLED\u003Dfalse #- LEGACY_V4_REDIRECT\u003Dfalse #- DB_OLD_LYCHEE_PREFIX\u003D\u0026#39;\u0026#39; - DB_CONNECTION\u003Dmysql - DB_HOST\u003Dlychee_db - DB_PORT\u003D${DB_PORT:-3306} - DB_DATABASE\u003D${DB_DATABASE:-lychee} - DB_USERNAME\u003D${DB_USERNAME:-lychee} - DB_PASSWORD\u003D${DB_PASSWORD} #- DB_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt; #- DB_LOG_SQL\u003Dfalse #- DB_LOG_SQL_EXPLAIN\u003Dfalse #- ENABLE_TOKEN_AUTH\u003Dtrue #- CACHE_DRIVER\u003Dfile #- SESSION_DRIVER\u003Dfile #- SESSION_LIFETIME\u003D120 #- QUEUE_CONNECTION\u003Dsync #- SECURITY_HEADER_HSTS_ENABLE\u003Dfalse #- SECURITY_HEADER_CSP_CONNECT_SRC\u003D #- SECURITY_HEADER_SCRIPT_SRC_ALLOW\u003D #- SESSION_SECURE_COOKIE\u003Dfalse #- MAIL_DRIVER\u003D**tp #- MAIL_HOST\u003D**tp.mailtrap.io #- MAIL_PORT\u003D2525 #- MAIL_USERNAME\u003Dnull #- MAIL_PASSWORD\u003Dnull #- MAIL_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt; #- MAIL_ENCRYPTION\u003Dnull #- MAIL_FROM_NAME\u003D #- MAIL_FROM_ADDRESS\u003D #- TRUSTED_PROXIES\u003D - SKIP_PERMISSIONS_CHECKS\u003D${SKIP_PERMISSIONS_CHECKS:-false} - STARTUP_DELAY\u003D30 #- ADMIN_USER\u003Dadmin #- ADMIN_PASSWORD\u003D\u0026lt;ADMIN_PASSWORD\u0026gt; #- ADMIN_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt; - CACHE_DRIVER\u003D${CACHE_DRIVER:-redis} - REDIS_URL\u003Dredis://${REDIS_USERNAME:-default}:${REDIS_PASSWORD:-}@${REDIS_HOST:-lychee_redis}:${REDIS_PORT:-6379} - REDIS_HOST\u003D${REDIS_HOST:-lychee_redis} - REDIS_PORT\u003D${REDIS_PORT:-6379} - REDIS_PASSWORD\u003D${REDIS_PASSWORD:-} - LOG_VIEWER_CACHE_DRIVER\u003D${LOG_VIEWER_CACHE_DRIVER:-file} restart: unless-stopped depends_on: - lychee_dbnetworks: lychee:volumes: mysql: name: lychee_prod_mysql driver: local cache: name: lychee_prod_redis driver: local\u003C/code\u003E\u003Cp\u003E项目地址:https://github.com/LycheeOrg/Lychee\u003C/p\u003E\u003Ccode\u003E带个图\u003C/code\u003E\u003Cp\u003E\u003Cimg src\u003D\"https://img.lowb.dedyn.io/gallery/unsorted/m0lUeks-G5aJICc2YWQSewDC\" alt\u003D\"\"\u003E\u003Cbr\u003E\u003Cimg src\u003D\"https://img.lowb.dedyn.io/uploads/medium/a6/84/00698141ddd7cd131ee30d5789e6.jpg\" alt\u003D\"\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 12:57:23',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26632,num:1,uid:1844,content:'\u003Cp\u003E我不 就爱用别人的\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 12:58:09',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26633,num:2,uid:2007,content:'\u003Cp\u003E诶我艹,还是不会发图\u003Cbr\u003E我图呢 ?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 12:58:16',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26634,num:3,uid:1582,content:'\u003Cp\u003E文中多次出现😒\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 12:58:28',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26635,num:4,uid:2217,content:'\u003Cblockquote\u003E\u003Cp\u003Edriver: local\u003C/p\u003E\u003Cp\u003E带个图\u003C/p\u003E\u003Cp\u003E\u003Cimg src\u003D\"https://img.lowb.dedyn.io/gallery/unsorted\" alt\u003D\"image\"\u003E\u003C/p\u003E\u003C/blockquote\u003E\u003Cp\u003E#-------------------------------------------\u003C/p\u003E\u003Ccode\u003Eservices:lychee_cache:image: redis:alpinecontainer_name: lychee_redishostname: lychee_redissecurity_opt:- no-new-privileges:truehealthcheck:test: [\u0026#34;CMD-SHELL\u0026#34;, \u0026#34;redis-cli ping || exit 1\u0026#34;]ports:- ${REDIS_PORT:-6379}😒{REDIS_PORT:-6379}user: 1026:100env_file:- path: ./.envrequired: falseenvironment:- TZ\u003D${TIMEZONE:-UTC}networks:- lycheevolumes:- cache:/data:rwrestart: on-failure:5lychee_db:container_name: lychee_dbimage: mariadb:10security_opt:- no-new-privileges:trueenv_file:- path: ./.envrequired: falseenvironment:- MYSQL_ROOT_PASSWORD\u003D${DB_ROOT_PASSWORD:-rootpassword}- MYSQL_DATABASE\u003D${DB_DATABASE:-lychee}- MYSQL_USER\u003D${DB_USERNAME:-lychee}- MYSQL_PASSWORD\u003D${DB_PASSWORD}expose:- 3306volumes:- mysql:/var/lib/mysqlnetworks:- lycheerestart: unless-stoppedlychee:image: lycheeorg/lycheecontainer_name: lycheesecurity_opt:- no-new-privileges:trueports:- 90:80volumes:- ./lychee/conf:/conf- ./lychee/uploads:/uploads- ./lychee/sym:/sym- ./lychee/logs:/logs- ./lychee/tmp:/lychee-tmpenv_file:- path: ./.envrequired: falsenetworks:- lycheeenvironment:- PUID\u003D${PUID:-1000}- PGID\u003D${PGID:-1000}# PHP timezone e.g. PHP_TZ\u003DAmerica/New_York- PHP_TZ\u003D${TIMEZONE:-UTC}- TIMEZONE\u003D${TIMEZONE:-UTC}#- APP_NAME\u003DLar**el#- APP_ENV\u003Dlocal#- APP_DEBUG\u003Dtrue#- APP_FORCE_HTTPS\u003Dfalse- APP_URL\u003D${APP_URL:-http://localhost}#- APP_DIR\u003D#- DEBUGBAR_ENABLEd\u003Dfalse#- VUEJS_ENABLED\u003Dtrue#- LEGACY_API_ENABLED\u003Dfalse#- LEGACY_V4_REDIRECT\u003Dfalse#- DB_OLD_LYCHEE_PREFIX\u003D\u0026#39;\u0026#39;- DB_CONNECTION\u003Dmysql- DB_HOST\u003Dlychee_db- DB_PORT\u003D${DB_PORT:-3306}- DB_DATABASE\u003D${DB_DATABASE:-lychee}- DB_USERNAME\u003D${DB_USERNAME:-lychee}- DB_PASSWORD\u003D${DB_PASSWORD}#- DB_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt;#- DB_LOG_SQL\u003Dfalse#- DB_LOG_SQL_EXPLAIN\u003Dfalse#- ENABLE_TOKEN_AUTH\u003Dtrue#- CACHE_DRIVER\u003Dfile#- SESSION_DRIVER\u003Dfile#- SESSION_LIFETIME\u003D120#- QUEUE_CONNECTION\u003Dsync#- SECURITY_HEADER_HSTS_ENABLE\u003Dfalse#- SECURITY_HEADER_CSP_CONNECT_SRC\u003D#- SECURITY_HEADER_SCRIPT_SRC_ALLOW\u003D#- SESSION_SECURE_COOKIE\u003Dfalse#- MAIL_DRIVER\u003D**tp#- MAIL_HOST\u003D**tp.mailtrap.io#- MAIL_PORT\u003D2525#- MAIL_USERNAME\u003Dnull#- MAIL_PASSWORD\u003Dnull#- MAIL_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt;#- MAIL_ENCRYPTION\u003Dnull#- MAIL_FROM_NAME\u003D#- MAIL_FROM_ADDRESS\u003D#- TRUSTED_PROXIES\u003D- SKIP_PERMISSIONS_CHECKS\u003D${SKIP_PERMISSIONS_CHECKS:-false}- STARTUP_DELAY\u003D30#- ADMIN_USER\u003Dadmin#- ADMIN_PASSWORD\u003D\u0026lt;ADMIN_PASSWORD\u0026gt;#- ADMIN_PASSWORD_FILE\u003D\u0026lt;filename\u0026gt;- CACHE_DRIVER\u003D${CACHE_DRIVER:-redis}- REDIS_URL\u003Dredis://${REDIS_USERNAME:-default}😒{REDIS_PASSWORD:-}@${REDIS_HOST:-lychee_redis}😒{REDIS_PORT:-6379}- REDIS_HOST\u003D${REDIS_HOST:-lychee_redis}- REDIS_PORT\u003D${REDIS_PORT:-6379}- REDIS_PASSWORD\u003D${REDIS_PASSWORD:-}- LOG_VIEWER_CACHE_DRIVER\u003D${LOG_VIEWER_CACHE_DRIVER:-file}restart: unless-stoppeddepends_on:- lychee_dbnetworks:lychee:volumes:mysql:name: lychee_prod_mysqldriver: localcache:name: lychee_prod_redisdriver: local\u003C/code\u003E\u003Cp\u003E加个代码块这么难吗 \u003Cimg src\u003D\"/z/img/ac/01.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 12:59:55',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26636,num:5,uid:2007,content:'\u003Cp\u003E我不会啊,菜鸡一个\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:00:33',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[6,],mentionUsers:[],likeUsers:[],},{id:26637,num:6,uid:2217,content:'\u003Cblockquote\u003E\u003Cp\u003E我不会啊,菜鸡一个\u003C/p\u003E\u003C/blockquote\u003E\u003Cp\u003EMarkdown编辑一搜就有吧 学了就会了 \u003Cimg src\u003D\"/z/img/xhj/007.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:02:03',updatedAt:'2025-03-15 13:44:03',mentionNum:5,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26638,num:7,uid:5470,content:'\u003Cp\u003E说了这么多你图呢 \u003Cimg src\u003D\"/z/img/ac/01.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:07:49',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26639,num:8,uid:7648,content:'\u003Cp\u003E图没了 \u003Cimg src\u003D\"/z/img/xhj/001.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:08:11',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26640,num:9,uid:1802,content:'\u003Cp\u003E\u003Cimg src\u003D\"/z/img/xhj/024.webp\"\u003E 说了这么多,图还是挂的,这。。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:12:57',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:26641,num:10,uid:2007,content:'\u003Cp\u003E我图不知道怎么加到帖子 我没用过这玩意\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 13:14:21',updatedAt:'2025-03-15 13:44:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1844,{uid:1844,url:'/u/6b1f45586a045c76686e526f0e050573',avatar:'/a/6b1f45586a045c76686e526f0e050573',username:'zhoubiao🤖',}],[1582,{uid:1582,url:'/u/6f0d6a3a6a045c766562546f36282013',avatar:'/a/6f0d6a3a6a045c766562546f36282013',username:'z318969887🤖',}],[2007,{uid:2007,url:'/u/6b0002076a045c75606a516f44336205',avatar:'/a/6b0002076a045c75606a516f44336205',username:'aseenm🤖',}],[1802,{uid:1802,url:'/u/362d542a6a045c76686a546f1f056524',avatar:'/a/362d542a6a045c76686a546f1f056524',username:'yyndsk🤖',}],[7648,{uid:7648,url:'/u/330d573c6a045c70666e5e6f110f2237',avatar:'/a/330d573c6a045c70666e5e6f110f2237',username:'yhkz🤖',}],[5470,{uid:5470,url:'/u/0e1955076a045c72646d566f3a0a231e',avatar:'/a/0e1955076a045c72646d566f3a0a231e',username:'宁清🤖',}],[2217,{uid:2217,url:'/u/293343276a045c75626b516f3a5c2334',avatar:'/a/293343276a045c75626b516f3a5c2334',username:'velezkirsten🤖',}],]),related:[{title:'兰空图床马上要涨价了!',url:'/d/2f78602b6a045c77606a567a445d6b6a1d2a3b0a',},{title:'过客图床测试',url:'/d/33105d076a045c77606a5675405a6b6a1a73623e',},{title:'有大佬会minio接入CloudFlare-ImgBed',url:'/d/091e5f206a045c77606a5675405b606a2e39113c',},{title:'大伙为什么做公益图床',url:'/d/092340196a045c77606a56744650626a580a6338',},{title:'love图床 欢迎使用',url:'/d/160274006a045c77606a56774f51626a2e1b071d',},{title:'测一下图床速度',url:'/d/117f772f6a045c77606a56774f5b6b6a3a140460',},{title:'有服务器、网盘、nas、公网IP怎么搞一套最好的图床',url:'/d/340a7e026a045c77606a5677435d666a01316315',},{title:'上次看到有人分享avif的图床,是哪个的?',url:'/d/3d2107556a045c77606a56774658626a140e6420',},{title:'兰空开源版,有办法上传avif吗?',url:'/d/0d0b00176a045c77606a5676465a606a2b7b2907',},{title:'不懂就问 蓝空图床的注册点了之后没反应是怎么回事?',url:'/d/157c0a276a045c77606a56714e58626a3d071d04',},{title:'论坛只能用自建图床发图片吗?',url:'/d/303f642c6a045c77606a56714159626a08022562',},{title:'屌大的来个免费稳定的图床!',url:'/d/1f2277036a045c77606a567145586a6a0f2d6b28',},{title:'自建图床测试NSFW',url:'/d/6e2864386a045c77606a5671475f616a22326a26',},{title:'请教大佬们图床问题',url:'/d/6d70631e6a045c77606a5671475a6a6a3e753131',},{title:'废物利用自建php图床+插件',url:'/d/12185e1e6a045c77606a56704e5e666a2b0e2b38',},{title:'bing出问题了吗?简单图床登录界面抓取bing图片失败',url:'/d/6e394b256a045c77606a5670405a676a010d1507',},{title:'图床半挂?',url:'/d/192e7b226a045c77606a5670445b656a1c090935',},{title:'Lsky 公益图床',url:'/d/3e22785c6a045c77606a5673465e666a25313067',},{title:'各位用公共图床会不会有不安全感',url:'/d/30227f076a045c77606a5673465d666a26082721',},{title:'收个二手蓝空图床正版认证',url:'/d/693941346a045c77606a56724e5e676a5f331825',},],} 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")