Skip to content

Commit

Permalink
fix(web): remove unused /api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Mar 19, 2024
1 parent 66b31ce commit 500ffb5
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 93 deletions.
1 change: 0 additions & 1 deletion apps/web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default defineNuxtConfig({
imports: {
dirs: [
'stores',
'server/utils',
join(root, 'packages/core/src'),
],
},
Expand Down
43 changes: 0 additions & 43 deletions apps/web/server/api/img.ts

This file was deleted.

46 changes: 0 additions & 46 deletions apps/web/server/api/weibo/[...slot].ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/core/src/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { storage } from './index'
* 将图片的远程 url 替换为本地图片
* 格式:域名-文件名
*/
export function replaceImg(img: string) {
export function replaceImg(img: string, forceCdn = false) {
if (!img)
return imgViewSrc

Expand All @@ -15,7 +15,7 @@ export function replaceImg(img: string) {
const imgHost = storage<string>('imgHost', '/')

// 使用 ipfs cdn
if (imgHost === imgCdn) {
if (imgHost === imgCdn || forceCdn) {
if (img.includes('sinaimg.cn')) {
const { pathname } = new URL(img)
return `${imgCdn}${pathname}`
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/UserProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ withDefaults(defineProps<{
color="#9ca3af"
text="3 center"
:size="56"
:src="`/api/img?url=${encodeURIComponent(user.avatar)}`"
:src="replaceImg(user.avatar, true)"
:img-props="{
alt: `${user.name}'s avatar`,
}"
Expand Down

0 comments on commit 500ffb5

Please sign in to comment.