{"id":19999152,"url":"https://github.com/mr-addict/punch-next","last_synced_at":"2025-05-04T14:31:30.440Z","repository":{"id":157155355,"uuid":"633304439","full_name":"MR-Addict/punch-next","owner":"MR-Addict","description":"值班笔记 Next.js 重构","archived":false,"fork":false,"pushed_at":"2024-10-23T15:18:20.000Z","size":3835,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-24T22:45:50.775Z","etag":null,"topics":["mongodb","nextjs","tailwindcss","typescript"],"latest_commit_sha":null,"homepage":"https://punch.doiry.cn","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MR-Addict.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-27T08:04:06.000Z","updated_at":"2024-10-23T15:18:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e357d1d-60cb-4f60-8e5e-aec3605d2dd5","html_url":"https://github.com/MR-Addict/punch-next","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MR-Addict%2Fpunch-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MR-Addict%2Fpunch-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MR-Addict%2Fpunch-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MR-Addict%2Fpunch-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MR-Addict","download_url":"https://codeload.github.com/MR-Addict/punch-next/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224393899,"owners_count":17303725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mongodb","nextjs","tailwindcss","typescript"],"created_at":"2024-11-13T05:10:50.247Z","updated_at":"2025-05-04T14:31:30.434Z","avatar_url":"https://github.com/MR-Addict.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 值班笔记\n\n值班笔记 Next.js 重构。\n\n|           首页           |         提交页面         |\n| :----------------------: | :----------------------: |\n| ![home](images/home.jpg) | ![form](images/form.jpg) |\n\n本项目主要是个南京工业大学校大学生科协技术开发部使用的值班笔记，用来让大家记录值班期间所作的活动，同时做个值班备份，让后人可以来查看。\n\n## 一、项目说明\n\n### 1. 数据库\n\n本项目使用`mongodb`作为数据库，只需要提供数据库的 URI 即可，新提交的值班笔记会存到`stas/notes`路径下。\n\n### 2. 笔记归档\n\n每学期结束后会把本学期的笔记添加到归档页面当中，归档页面不再使用数据库存储，而是使用本地的 JSON 文件，并编译成静态页面以提高访问速度。JSON 文件的路径是`archive` ，每条笔记的 schema 如下：\n\n```json\n{\n  \"_id\": \"string\",\n  \"date\": \"string\",\n  \"week\": \"number\",\n  \"name\": \"string\",\n  \"useMarkdown\": \"boolean\",\n  \"content\": \"string\"\n}\n```\n\n使用下面的命令可以将当前数据库的笔记导出到 `archive` 目录下，导出前请确保以上环境变量已正确设置：\n\n```bash\nnpm run archive\n```\n\n\u003e 注：\n\u003e\n\u003e 如果归档中文件名和当前学期名称重复，那么会优先使用归档的文件，而不是数据库中的笔记，因此请确保归档后将数据库中的笔记删除，以免重复。\n\u003e\n\u003e 你可以用下面的命令备份数据库：\n\u003e\n\u003e ```js\n\u003e use stas\n\u003e db.notes.renameCollection(\"notes-backup\", { dropTarget: true })\n\u003e ```\n\u003e\n\u003e 因为默认索引的collection是notes，所以将其重命名为notes-backup，这样就相当于删除了数据库。\n\n### 3. 值班时间\n\n值班笔记可以设置值班时间，不在值班时间不能提交值班笔记，只能查看笔记。需要设置的时间有**第一周时间**，**开始时间**，**结束时间**和**当前学期**，第一周时间必须是每学期的第一天，否则页面有关学期周数的地方都会不准确，开始时间和第一周时间不一定要一样。\n\n例如：\n\n```conf\nFIRST_WEEK=\"2024-09-02 00:01\"\nSTART_DATE=\"2024-09-02 00:01\"\nEND_DATE=\"2025-01-19 23:59\"\nCURRENT_TERM=\"2024-2025年第一学期\"\n```\n\n### 4. ~~ISR~~（已弃用）\n\nISR，也就是 Next.js 的按需编译，查看笔记的页面正常情况下都是静态页面，只有在新的提交笔记后才会重新编译，这样可以显著提高访问流畅度。\n\n~~但是测试发现目前 13.3.2 版本本地使用存在问题，可是部署在 Vercel 之后又可以正常使用。这应该是 Bug，后面将持续关注随时更新 Next.js 的版本。另外目前 ISR 还没有嵌入到 app 目录当中，仍然在使用 pages 中的 api。~~（更新：13.4.0 之后的稳定版本推出后，现在使用 **revalidatePath** 就可以很简单地在服务端重新编译想要的静态页面，不需要另开 API 了。）\n\n\u003e 注：\n\u003e\n\u003e 自 2024年10月31日起，本项目已弃用 Next.js 的 ISR 功能\n\n## 二、Docker 部署\n\n本项目已经提前编译好了 Docker 镜像，部署只需要修改一些环境变量即可，如值班时间和当前学期名称，数据库URI不用改：\n\n```yaml\nservices:\n  punch:\n    image: mraddict063/punch\n    restart: unless-stopped\n    ports:\n      - 3000:3000\n    environment:\n      - FIRST_WEEK=2024-09-02 00:01\n      - START_DATE=2024-09-02 00:01\n      - END_DATE=2025-01-19 23:59\n      - CURRENT_TERM=2024-2025年第一学期\n      - MONGODB_URI=mongodb://punch:punch@mongodb:27017\n    depends_on:\n      - mongodb\n\n  mongodb:\n    image: mongo\n    restart: unless-stopped\n    environment:\n      - MONGO_INITDB_ROOT_USERNAME=punch\n      - MONGO_INITDB_ROOT_PASSWORD=punch\n    volumes:\n      - ./data:/data/db\n```\n\n## 三、原项目地址\n\n原项目已不再维护，但是仍然可以使用：\n\n- [https://github.com/MR-Addict/punch](https://github.com/MR-Addict/punch)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-addict%2Fpunch-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-addict%2Fpunch-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-addict%2Fpunch-next/lists"}