diff --git a/pages/index.tsx b/pages/index.tsx
index c801c624..d1a30d29 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -8,7 +8,7 @@ import {
Heading,
Divider
} from "@chakra-ui/react"
-import Card from "components/card"
+import Card, { CardBody, CardHeader } from "components/card"
import Stories from "components/story/stories"
import SimplePostCard from "components/story/simple-story-card"
import SEO from "components/seo"
@@ -96,18 +96,20 @@ export const HomeSidebar = () => {
return (
-
+
热榜
-
-
-
+
+
+
-
+
-
-
-
+
+
+
+
+
)
diff --git a/pages/tags/index.tsx b/pages/tags/index.tsx
index 0a2b6525..b0f7f00b 100644
--- a/pages/tags/index.tsx
+++ b/pages/tags/index.tsx
@@ -4,19 +4,24 @@ import {
MenuList,
MenuItem,
IconButton,
- Divider
+ Divider,
+ Box,
+ Image
} from "@chakra-ui/react"
import SEO from "components/seo"
import siteConfig from "configs/site-config"
import PageContainer1 from "layouts/page-container1"
import React, { useEffect, useState } from "react"
import { HomeSidebar } from 'pages/index'
-import Card from "components/card"
+import Card, { CardBody, CardHeader } from "components/card"
import { config } from "configs/config"
import { getSvgIcon } from "components/svg-icon"
import { Tag } from "src/types/tag"
import { requestApi } from "utils/axios/request"
import TagCard from 'src/components/tags/tag-card'
+import useSession from "hooks/use-session"
+import Link from "next/link"
+import { IDType } from "src/types/id"
const tagsFilter = [{
name: 'Popular',
@@ -39,14 +44,33 @@ const tagsFilter = [{
const TagsPage = () => {
const [filter, setFilter] = useState(tagsFilter[0])
const [tags, setTags]: [Tag[], any] = useState([])
+ const [userTags,setUserTags]:[Tag[],any] = useState([])
+
+ const session = useSession()
const getTags = () => {
requestApi.get(`/tag/all`).then((res) => setTags(res.data)).catch(_ => setTags([]))
}
+ const getUserTags = async () => {
+ const res = await requestApi.get(`/interaction/following/${session.user.id}?type=${IDType.Tag}`)
+ const ids = []
+ for (const f of res.data) {
+ ids.push(f.id)
+ }
+
+ const res1 = await requestApi.post(`/tag/ids`, ids)
+ setUserTags(res1.data)
+ }
+
useEffect(() => {
getTags()
}, [filter])
+ useEffect(() => {
+ if (session) {
+ getUserTags()
+ }
+ },[session])
return (
<>
{
description={siteConfig.seo.description}
/>
-
+
@@ -95,7 +119,24 @@ const TagsPage = () => {
-
+ {userTags.length > 0 &&
+
+ 我关注的Tags
+
+
+
+
+ {
+ userTags.map(tag =>
+
+ {tag.icon && }
+ #{tag.name}
+
+ )
+ }
+
+
+ }
>
diff --git a/server/internal/server.go b/server/internal/server.go
index 9c34333a..d475da35 100644
--- a/server/internal/server.go
+++ b/server/internal/server.go
@@ -69,10 +69,10 @@ func (s *Server) Start() error {
r.POST("/tag", IsLogin(), api.SubmitTag)
r.DELETE("/tag/:id", IsLogin(), api.DeleteTag)
r.GET("/tag/all", api.GetTags)
- r.POST("tag/ids", api.GetTagsByIDs)
+ r.POST("tag/ids", api.GetTagsByIDs) // 根据对象ID列表获取关联的标签
r.GET("/tag/posts/:id", api.GetTagPosts)
r.GET("/tag/info/:name", api.GetTag)
- r.GET("/tag/user/:userID", api.GetUserTags)
+ r.GET("/tag/user/:userID", api.GetUserTags) // 获取用户博客用到的标签列表
// user apis
r.GET("/user/all", api.GetUsers)
r.POST("/user/ids", api.GetUsersByIDs)
diff --git a/src/components/card.tsx b/src/components/card.tsx
index d510dc4e..f6e55bf5 100644
--- a/src/components/card.tsx
+++ b/src/components/card.tsx
@@ -1,5 +1,5 @@
import React from "react"
-import { Box, BoxProps, useColorModeValue } from "@chakra-ui/react"
+import { Box, BoxProps, Flex, useColorModeValue } from "@chakra-ui/react"
interface Props {
shadowed?: boolean
@@ -21,3 +21,12 @@ export const Card = ({shadowed, ...rest}: BoxProps&Props) => {
}
export default Card
+
+
+export const CardHeader = (props) => {
+ return ()
+}
+
+export const CardBody = (props) => {
+ return
+}
\ No newline at end of file
diff --git a/src/components/tags/tag-card.tsx b/src/components/tags/tag-card.tsx
index e70b4558..04cba6a7 100644
--- a/src/components/tags/tag-card.tsx
+++ b/src/components/tags/tag-card.tsx
@@ -23,7 +23,7 @@ export const TagCard= (props:Props) =>{
{tag.title}
- {tag.md}
+ {tag.md}
diff --git a/theme/layer-styles.js b/theme/layer-styles.js
index ad3ead44..a1b56f74 100644
--- a/theme/layer-styles.js
+++ b/theme/layer-styles.js
@@ -11,5 +11,11 @@ export default function layerStyles(theme) {
},
_focus: null
},
+ cardHeader: {
+ px: "4",
+ py: "3",
+ justifyContent:"space-between",
+ alignItems:"center"
+ }
}
}
\ No newline at end of file