diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 737761f..b98a846 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -236,7 +236,8 @@ export const i18nData = { "Collection created successfully": "合集创建成功", "Collection deleted successfully": "合集删除成功", "Remove Resource": "移除资源", - "Are you sure you want to remove this resource?": "您确定要移除此资源吗?", + "Are you sure you want to remove this resource?": + "您确定要移除此资源吗?", "Resource deleted successfully": "资源移除成功", "Edit Collection": "编辑合集", "Edit successful": "编辑成功", @@ -250,7 +251,9 @@ export const i18nData = { "Update File Info": "更新文件信息", "File info updated successfully": "文件信息更新成功", "File URL": "文件URL", - "You do not have permission to upload files, please contact the administrator.": "您没有上传文件的权限,请联系管理员。", + "You do not have permission to upload files, please contact the administrator.": + "您没有上传文件的权限,请联系管理员。", + "Private": "私有", }, }, "zh-TW": { @@ -490,7 +493,8 @@ export const i18nData = { "Collection created successfully": "合集創建成功", "Collection deleted successfully": "合集刪除成功", "Remove Resource": "移除資源", - "Are you sure you want to remove this resource?": "您確定要移除此資源嗎?", + "Are you sure you want to remove this resource?": + "您確定要移除此資源嗎?", "Resource deleted successfully": "資源移除成功", "Edit Collection": "編輯合集", "Edit successful": "編輯成功", @@ -504,7 +508,9 @@ export const i18nData = { "Update File Info": "更新檔案信息", "File info updated successfully": "檔案信息更新成功", "File URL": "檔案URL", - "You do not have permission to upload files, please contact the administrator.": "您沒有上傳檔案的權限,請聯繫管理員。", + "You do not have permission to upload files, please contact the administrator.": + "您沒有上傳檔案的權限,請聯繫管理員。", + "Private": "私有", }, }, }; diff --git a/frontend/src/network/models.ts b/frontend/src/network/models.ts index 78a6d1f..f6582c8 100644 --- a/frontend/src/network/models.ts +++ b/frontend/src/network/models.ts @@ -199,4 +199,5 @@ export interface Collection { user: User; resources_count: number; images: Image[]; + isPublic: boolean; } diff --git a/frontend/src/network/network.ts b/frontend/src/network/network.ts index 1502948..0671620 100644 --- a/frontend/src/network/network.ts +++ b/frontend/src/network/network.ts @@ -693,11 +693,13 @@ class Network { async createCollection( title: string, article: string, + isPublic: boolean, ): Promise> { return this._callApi(() => axios.postForm(`${this.apiBaseUrl}/collection/create`, { title, article, + public: isPublic, }), ); } @@ -706,12 +708,14 @@ class Network { id: number, title: string, article: string, + isPublic: boolean, ): Promise> { return this._callApi(() => axios.postForm(`${this.apiBaseUrl}/collection/update`, { id, title, article, + public: isPublic, }), ); } diff --git a/frontend/src/pages/collection_page.tsx b/frontend/src/pages/collection_page.tsx index 25d9182..e8c3c32 100644 --- a/frontend/src/pages/collection_page.tsx +++ b/frontend/src/pages/collection_page.tsx @@ -6,10 +6,11 @@ import { Collection } from "../network/models"; import Markdown from "react-markdown"; import ResourcesView from "../components/resources_view"; import Loading from "../components/loading"; -import { MdOutlineDelete, MdOutlineEdit } from "react-icons/md"; +import { MdOutlineAdd, MdOutlineDelete, MdOutlineEdit } from "react-icons/md"; import { app } from "../app"; import { useTranslation } from "../utils/i18n"; import Button from "../components/button"; +import Badge from "../components/badge"; export default function CollectionPage() { const { id } = useParams<{ id: string }>(); @@ -54,7 +55,7 @@ export default function CollectionPage() { useEffect(() => { if (!collection) return; document.title = collection.title; - }, [collection]) + }, [collection]); const toBeDeletedRID = useRef(null); @@ -160,6 +161,12 @@ export default function CollectionPage() { )} + + {!collection.isPublic && ( + + {t("Private")} + + )}