Compare commits

..

67 Commits

Author SHA1 Message Date
Tim
d7e58a5741 feat: add base item group component 2025-10-15 21:04:29 +08:00
tim
a68c925c68 fix: 集成一下父亲容器 2025-10-15 19:52:30 +08:00
tim
4f248e8a71 fix: 布局微调 2025-10-15 18:08:16 +08:00
Tim
277883f9d9 Merge pull request #1064 from nagisa77/codex/refactor-reactionsgroup-to-remove-slot-mechanism
Refactor ReactionsGroup layout responsibilities
2025-10-15 17:55:55 +08:00
Tim
e9e996f291 refactor: simplify reactions group usage 2025-10-15 17:47:45 +08:00
Tim
a8667ce5e9 Merge pull request #1062 from smallclover/main
修复markdown手机模式下换行问题
2025-10-14 20:37:52 +08:00
夢夢の幻想郷
0d316af22a Merge branch 'nagisa77:main' into main 2025-10-14 20:25:46 +09:00
smallclover
f8e13af672 修复,markdown在手机模式下换行,导致行号和代码无法一致 2025-10-14 20:24:11 +09:00
Tim
92d90c997c Merge pull request #1061 from smallclover/main
追加
2025-10-13 20:56:40 +08:00
smallclover
303ec9b6c1 追加
首页贴吧表情显示
2025-10-13 19:35:18 +09:00
Tim
90eafe27fd Merge pull request #1060 from smallclover/main
icon对齐
2025-10-13 13:30:10 +08:00
smallclover
98e2ea7ef8 icon对齐
https://github.com/nagisa77/OpenIsle/issues/854
2025-10-13 09:47:58 +09:00
Tim
e3290f3431 Merge pull request #1059 from smallclover/main
header菜单栏调整
2025-10-12 16:32:34 +08:00
smallclover
160570574c 1.header菜单栏格式统一
2.修复未登录的情况下邀请链接状态错误
2025-10-11 10:13:03 +09:00
Tim
cf7b667f30 Merge pull request #1058 from sivdead/fix/issue-857-signup-ui-optimization
fix: 优化申请注册页面UI (#857)
2025-10-10 16:12:53 +08:00
sivdead
60fa6051b7 fix: 优化申请注册页面UI (#857)
- 将字符计数移至输入框内部右下角
- 错误提示距离输入框8px
- 优化布局结构,使用input-wrapper包裹输入区域
2025-10-10 15:20:39 +08:00
Tim
1c0e90d32d Merge pull request #1056 from smallclover/main
主页对齐方式修复
2025-10-10 09:56:28 +08:00
smallclover
a15065575d 修复问题
https://github.com/nagisa77/OpenIsle/issues/1057
问题原因:行号的css限制宽度,导致行数超过99错位
2025-10-09 21:40:28 +09:00
夢夢の幻想郷
cb958e162e Merge branch 'nagisa77:main' into main 2025-10-08 21:32:11 +09:00
smallclover
660d8ffe51 https://github.com/nagisa77/OpenIsle/issues/843
对齐方式修复
2025-10-08 21:31:36 +09:00
tim
5509a1eead Merge branch 'main' of github.com:nagisa77/OpenIsle 2025-10-08 19:18:10 +08:00
tim
1acd776d3b fix: 启动排队机制 2025-10-08 19:17:45 +08:00
Tim
53be8d943a Merge pull request #1055 from immortal521/fix/theme-toggle-flicker
fix: theme-toggle-flicker
2025-10-08 15:48:23 +08:00
immortal521
9957042746 fix: theme-toggle-flicker
- remove unnecessary await nextTick in view transition

- Simplify transition callback

- Add fill: 'both' to transition style
2025-10-08 01:19:38 +08:00
tim
302f98f44e Revert "feat: 先把每日定时构件给注释掉"
This reverts commit 0119605649.
2025-10-07 18:02:06 +08:00
Tim
790c4db8ea Merge pull request #1054 from nagisa77/codex/update-dropdown.vue-for-empty-state-rendering
Add empty dropdown state message when search yields no results
2025-10-07 18:00:59 +08:00
tim
bbb0a11d49 fix: searchdropdown新增空state、 2025-10-07 18:00:37 +08:00
tim
35340319c6 fix: 限定profile 2025-10-07 16:38:04 +08:00
Tim
343c4d3793 Add empty state to dropdown when no search results 2025-10-07 16:29:53 +08:00
Tim
87b214cbc0 Merge pull request #1052 from smallclover/main
修改主页各section间距
2025-10-07 16:20:48 +08:00
tim
e7f06787d2 fix: 仅支配websocket打头域名 2025-10-07 15:59:23 +08:00
tim
d7d2fd5dcb fix: 仅支配websocket打头域名 2025-10-07 15:58:18 +08:00
smallclover
76b65a1400 修改主页各section间距 2025-10-05 21:08:05 +09:00
tim
fa8ee113a2 fix: 设置telegram测试环境 2025-10-05 18:05:45 +08:00
tim
181237adee fix: 更新GitHub预发环境登录 2025-10-05 17:45:40 +08:00
tim
1b8135acfb Merge branch 'main' of github.com:nagisa77/OpenIsle 2025-10-05 17:44:25 +08:00
tim
67bbe832a0 fix: 更新GitHub预发环境登录 2025-10-05 17:43:45 +08:00
Tim
9d67f7d8d6 Merge pull request #1051 from nagisa77/codex/fix-comment-pinning-order-in-article
Ensure pinned comments stay at top of post timeline
2025-10-05 17:22:16 +08:00
Tim
da0d26c8b5 Ensure pinned comments stay at top of post timeline 2025-10-05 17:21:45 +08:00
Tim
81d64bfc7b Merge pull request #1048 from smallclover/main
修复手机网页iframe的视频标签超出容器的问题
2025-10-04 17:44:23 +08:00
smallclover
3e255c1288 修复手机网页iframe的视频标签超出容器的问题 2025-10-04 17:13:00 +09:00
tim
224e1a1018 Merge branch 'main' of github.com:nagisa77/OpenIsle 2025-10-04 14:52:53 +08:00
tim
4456997573 fix: 解决GitHub登录问题 2025-10-04 14:52:42 +08:00
Tim
ef0f0d013b Merge pull request #1046 from smallclover/main
修复文章变动图标问题
2025-10-04 14:46:45 +08:00
Tim
a83ddc40fe Update CONTRIBUTING.md 2025-10-04 12:46:19 +08:00
tim
f36ed28185 Revert "fix: 修改为资源图片"
This reverts commit 536979501e.

# Conflicts:
#	CONTRIBUTING.md
2025-10-04 12:26:38 +08:00
smallclover
1d31284dba 1.修复置顶图标不显示
2.修复取消置顶图标不显示
2025-10-04 09:13:34 +09:00
Tim
995d68b50b Merge pull request #1045 from nagisa77/codex/update-contributing.md-instructions
docs: update docker compose dev instructions
2025-10-04 02:02:53 +08:00
Tim
55b680ef83 Update CONTRIBUTING.md 2025-10-04 02:02:43 +08:00
Tim
024e52b763 docs: update docker compose dev instructions 2025-10-04 02:01:32 +08:00
tim
536979501e fix: 修改为资源图片 2025-10-04 01:53:19 +08:00
tim
85a67a6215 fix: 本站自部署方法 2025-10-04 01:44:56 +08:00
tim
57a9a98da6 fix: 修改deploy地址 2025-10-03 16:52:00 +08:00
tim
e8976a98d4 fix: 新增nginx配置,修改deploy地址 2025-10-03 16:43:38 +08:00
tim
57e6bcaa0c Revert "feat: add admin point grants and history UI"
This reverts commit adfc05b9b2.
2025-10-03 00:58:24 +08:00
tim
c95b2ebdc2 fix: 修改staging部署 2025-10-03 00:48:00 +08:00
tim
83cf7439c9 fix: 删除dashboard 2025-10-02 22:35:19 +08:00
tim
994f4028fc fix: 取消opensearch 2025-10-02 22:29:35 +08:00
tim
2362458024 fix: volumes 修改 2025-10-02 22:25:15 +08:00
tim
03c92d4861 Merge branch 'main' of github.com:nagisa77/OpenIsle 2025-10-02 22:00:20 +08:00
tim
8df566a9c9 fix: 修改为main 2025-10-02 22:00:08 +08:00
Tim
870d1e2940 Merge pull request #1042 from nagisa77/codex/add-iframe-support-for-markdown-rendering
Allow iframe embeds in markdown sanitizer
2025-10-02 21:43:04 +08:00
Tim
0033374481 Allow iframe embeds in markdown sanitizer 2025-10-02 21:42:52 +08:00
tim
8f36422609 fix: 解决传参 2025-10-02 15:28:25 +08:00
tim
b98871bed9 fix: mysql 时区 2025-10-01 16:40:23 +08:00
tim
2cb8c12f65 fix: 修改main 2025-10-01 16:33:14 +08:00
Tim
87a256ba0c Merge pull request #1037 from nagisa77/feature/docker
所有业务适配Docker
2025-10-01 16:19:10 +08:00
35 changed files with 1134 additions and 667 deletions

View File

@@ -80,26 +80,39 @@ WEBPUSH_PRIVATE_KEY=
LOG_LEVEL=INFO
# === Frontend (Nuxt) ===
# 本地开发
NUXT_PUBLIC_API_BASE_URL=http://localhost:8080
# 线上环境
# NUXT_PUBLIC_API_BASE_URL=https://www.open-isle.com
# 测试环境
# NUXT_PUBLIC_API_BASE_URL=https://www.staging.open-isle.com
# 本地开发
NUXT_PUBLIC_WEBSOCKET_URL=http://localhost:8082
# NUXT_PUBLIC_WEBSOCKET_URL=https://www.open-isle.com
# NUXT_PUBLIC_WEBSOCKET_URL=https://www.staging.open-isle.com
# 线上环境
# NUXT_PUBLIC_WEBSOCKET_URL=https://www.open-isle.com/websocket
# 测试环境
# NUXT_PUBLIC_WEBSOCKET_URL=https://www.staging.open-isle.com/websocket
# 本地开发
NUXT_PUBLIC_WEBSITE_BASE_URL=http://localhost:3000
# 线上 & 本地均可使用
# 线上 & 测试 (www.staging.open-isle.com) & 本地均可使用
NUXT_PUBLIC_GOOGLE_CLIENT_ID=777830451304-nt8afkkap18gui4f9entcha99unal744.apps.googleusercontent.com
# 线上
NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liOlrZnPKRF7s7NN
NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liVkO1NPAX5JyWxJ
# 测试环境 (www.staging.open-isle.com)
# NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23li6GHPxx4MwipWnM
# 本地
# NUXT_PUBLIC_GITHUB_CLIENT_ID=Ov23liOlrZnPKRF7s7NN
# 线上 & 本地均可使用
NUXT_PUBLIC_DISCORD_CLIENT_ID=1394985417044000779
# 线上 & 本地均可使用
NUXT_PUBLIC_TWITTER_CLIENT_ID=ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ
# 线上
NUXT_PUBLIC_TELEGRAM_BOT_ID=8450237135
# 测试环境 (www.staging.open-isle.com)
# NUXT_PUBLIC_TELEGRAM_BOT_ID=7832207011

View File

@@ -11,12 +11,17 @@ on:
permissions:
contents: write
# 文档发布自己的排队锁,不影响服务器部署
concurrency:
group: openisle-docs
cancel-in-progress: false
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

View File

@@ -2,28 +2,33 @@ name: Staging CI & CD
on:
push:
branches: [main]
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: write
# 与生产部署共用同一把锁,确保服务器上始终串行(跨工作流也互斥)
concurrency:
group: openisle-server
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: Deploy
if: ${{ !github.event.repository.fork }} # 只有非 fork 才执行
if: ${{ !github.event.repository.fork }}
steps:
- uses: actions/checkout@v4
- name: Deploy to Server
- name: Deploy to Server (staging)
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: root
key: ${{ secrets.SSH_KEY }}
script: bash /opt/openisle/deploy-staging.sh
script: bash /opt/openisle/OpenIsle/deploy/deploy_staging.sh
deploy-docs:
needs: build-and-deploy

View File

@@ -2,8 +2,13 @@ name: CI & CD
on:
workflow_dispatch:
# schedule:
# - cron: "0 19 * * *" # 每天 UTC 19:00相当于北京时间凌晨3点
schedule:
- cron: "0 19 * * *" # 每天 UTC 19:00(北京 03:00
# 与 Staging 共用同一把锁,避免两边同时在 8G 服务器上跑
concurrency:
group: openisle-server
cancel-in-progress: false
jobs:
build-and-deploy:
@@ -13,10 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Deploy to Server
- name: Deploy to Server (prod)
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: root
key: ${{ secrets.SSH_KEY }}
script: bash /opt/openisle/deploy.sh
script: bash /opt/openisle/OpenIsle/deploy/deploy.sh

View File

@@ -1,25 +1,19 @@
- [前置工作](#前置工作)
- [前端极速调试Docker 全量环境)](#前端极速调试docker-全量环境)
- [启动后端服务](#启动后端服务)
- [本地 IDEA](#本地-idea)
- [配置环境变量](#配置环境变量)
- [配置 IDEA 参数](#配置-idea-参数)
- [配置 MySQL](#配置-mysql)
- [配置 Redis](#配置-redis)
- [配置 RabbitMQ](#配置-rabbitmq)
- [Docker 环境](#docker-环境)
- [配置环境变量](#配置环境变量-1)
- [构建并启动镜像](#构建并启动镜像)
- [启动前端服务](#启动前端服务)
- [配置环境变量](#配置环境变量-2)
- [安装依赖和运行](#安装依赖和运行)
- [连接预发或正式环境](#连接预发或正式环境)
- [其他配置](#其他配置)
- [配置第三方登录以GitHub为例](#配置第三方登录以GitHub为例)
- [配置Resend邮箱服务](#配置Resend邮箱服务)
- [配置第三方登录以GitHub为例](#配置第三方登录以github为例)
- [配置Resend邮箱服务](#配置resend邮箱服务)
- [API文档](#api文档)
- [OpenAPI文档](#openapi文档)
- [部署时间线以及文档时效性](#部署时间线以及文档时效性)
- [OpenAPI文档使用](#OpenAPI文档使用)
- [OpenAPI文档应用场景](#OpenAPI文档应用场景)
- [OpenAPI文档使用](#openapi文档使用)
- [OpenAPI文档应用场景](#openapi文档应用场景)
## 前置工作
@@ -35,6 +29,52 @@ cd OpenIsle
- 前端开发环境
- Node.JS 20+
## 前端极速调试Docker 全量环境)
想要最快速地同时体验前端和后端,可直接使用仓库提供的 Docker Compose。该方案会一次性拉起数据库、消息队列、搜索、后端、WebSocket 以及前端 Dev Server适合需要全链路联调的场景。
1. 准备环境变量文件:
```shell
cp .env.example .env
```
`.env.example` 是模板,可在 `.env` 中按需覆盖如端口、密钥等配置。确保 `NUXT_PUBLIC_API_BASE_URL`、`NUXT_PUBLIC_WEBSOCKET_URL` 等仍指向 `localhost`,方便前端直接访问容器映射端口。
2. 启动 Dev Profile
```shell
docker compose \
-f docker/docker-compose.yaml \
--env-file .env \
--profile dev build
```
```shell
docker compose \
-f docker/docker-compose.yaml \
--env-file .env \
--profile dev up -d
```
该命令会创建名为 `frontend_dev` 的容器并运行 `npm run dev`,浏览器访问 http://127.0.0.1:3000 即可查看页面。
修改代码后,可以强制重新创建所有容器,执行:
```shell
docker compose \
-f docker/docker-compose.yaml \
--env-file .env \
--profile dev up -d --force-recreate
```
3. 查看服务状态:
```shell
docker compose -f docker/docker-compose.yaml --env-file .env ps
docker compose -f docker/docker-compose.yaml --env-file .env logs -f frontend_dev
```
4. 停止所有容器:
```shell
docker compose -f docker/docker-compose.yaml --env-file .env --profile dev down
```
如需自定义 Node 依赖缓存、数据库持久化等,可参考 `docker/docker-compose.yaml` 中各卷的定义进行调整。
## 启动后端服务
启动后端服务有多种方式,选择一种即可。
@@ -52,37 +92,26 @@ IDEA 打开 `backend/` 文件夹。
#### 配置环境变量
1. 生成环境变量文件
1. 生成环境变量文件
```shell
cp open-isle.env.example open-isle.env
```
`open-isle.env` 才是实际被读取的文件。可在其中补充数据库、第三方服务等配置,`open-isle.env` 已被 Git 忽略,放心修改。
2. 在 IDEA 中配置「Environment file」将 `Run/Debug Configuration` 的 `Environment variables` 指向刚刚复制的 `open-isle.env`,即可让 IDE 读取该文件。
3. 需要调整端口或功能开关时,优先修改 `open-isle.env`,例如:
```ini
SERVER_PORT=8081
LOG_LEVEL=DEBUG
```
`open-isle.env.example` 是环境变量模板,`open-isle.env` 才是真正读取的内容
2. 修改环境变量,留下需要的,比如你要开发 Google 登录业务,就需要谷歌相关的变量,数据库是一定要的
![环境变量](assets/contributing/backend_img_7.png)
3. 应用环境文件,选择刚刚的 `open-isle.env`
可以在 `open-isle.env` 按需填写个性化的配置,该文件不会被 Git 追踪。比如你想把服务跑在 `8082`(默认为 `8080`),那么直接改 `open-isle.env` 即可:
```ini
SERVER_PORT=8082
```
另一种方式是修改 `.properities` 文件(但不建议),位于 `src/main/application.properties`,该配置同样来源于 `open-isle.env`,但修改 `.properties` 文件会被 Git 追踪。
也可以修改 `src/main/resources/application.properties`,但该文件会被 Git 追踪,通常不推荐。
![配置数据库](assets/contributing/backend_img_5.png)
#### 配置 IDEA 参数
- 设置 JDK 版本为 java 17
- 设置 VM Option最好运行在其他端口非 `8080`,这里设置 `8081`
若上面在环境变量中设置了端口,那这里就不需要再额外设置
- 设置 JDK 版本为 Java 17
- 设置 VM Option最好运行在其他端口例如 `8081`)。若已经在 `open-isle.env` 中调整端口,可省略此步骤。
```shell
-Dserver.port=8081
```
@@ -91,191 +120,22 @@ SERVER_PORT=8082
![配置2](assets/contributing/backend_img_2.png)
#### 配置 MySQL
> [!TIP]
> 如果不知道怎么配置数据库可以参考 [Docker 环境](#docker-环境) 章节
1. 本机配置 MySQL 服务(网上很多教程,忽略)
- 可以用 Laragon自带 MySQL 包括 Nodejs版本建议 `6.x``7` 以后需要 Lisence
- [下载地址](https://github.com/leokhoa/laragon/releases)
2. 填写环境变量
![环境变量](assets/contributing/backend_img_6.png)
```ini
MYSQL_URL=jdbc:mysql://<数据库地址>:<端口>/<数据库名>?useUnicode=yes&characterEncoding=UTF-8&useInformationSchema=true&useSSL=false&serverTimezone=UTC
MYSQL_USER=<数据库用户名>
MYSQL_PASSWORD=<数据库密码>
```
3. 执行 [`db/init/init_script.sql`](backend/src/main/resources/db/init/init_script.sql) 脚本,导入基本的数据
管理员:**admin/123456**
普通用户1**user1/123456**
普通用户2**user2/123456**
![初始化脚本](assets/contributing/resources_img.png)
#### 配置 Redis
后端的登录态缓存、访问频控等都依赖 Redis请确保本地有可用的 Redis 实例。
1. **启动 Redis 服务**(已有服务可跳过)
```bash
docker run --name openisle-redis -p 6379:6379 -d redis:7-alpine
```
该命令会在本机暴露 `6379` 端口。若你已有其他端口的 Redis可以根据实际情况调整映射关系。
2. **在 `backend/open-isle.env` 中填写连接信息**
```ini
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
# 可选:若需要切换逻辑库,可新增此变量,默认使用 0 号库
REDIS_DATABASE=0
```
`application.properties` 中的默认值为 `localhost:6379`、数据库 `0`,如果你的环境恰好一致,也可以不额外填写;显式声明可以避免 IDE/运行时读取到意外配置。
3. **验证连接**
```bash
redis-cli -h 127.0.0.1 -p 6379 ping
```
启动后端后,日志中会出现 `Redis connection established ...`(来自 `RedisConnectionLogger`),说明已成功连通。
#### 配置 RabbitMQ
消息通知和 WebSocket 推送链路依赖 RabbitMQ。后端会自动声明交换机与队列确保本地 RabbitMQ 可用即可。
1. **启动 RabbitMQ 服务**(推荐包含管理界面)
```bash
docker run --name openisle-rabbitmq \
-e RABBITMQ_DEFAULT_USER=openisle \
-e RABBITMQ_DEFAULT_PASS=openisle \
-p 5672:5672 -p 15672:15672 \
-d rabbitmq:3.13-management
```
管理界面位于 http://127.0.0.1:15672 ,可用于查看队列、交换机等资源。
2. **同步填写后端与 WebSocket 服务的环境变量**
```ini
# backend/open-isle.env
RABBITMQ_HOST=127.0.0.1
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=openisle
RABBITMQ_PASSWORD=openisle
# 如果需要启动 websocket_service也需要在 websocket_service.env 中保持一致
```
如果沿用 RabbitMQ 默认的 `guest/guest`可以不显式设置Spring Boot 会回退到 `application.properties` 中的默认值 (`localhost:5672`、`guest/guest`、虚拟主机 `/`)。
3. **确认自动声明的资源**
- 交换机:`openisle-exchange`
- 旧版兼容队列:`notifications-queue`
- 分片队列:`notifications-queue-0` ~ `notifications-queue-f`(共 16 个,对应路由键 `notifications.shard.0` ~ `notifications.shard.f`
- 队列持久化默认开启,来自 `rabbitmq.queue.durable=true`,如需仅在本地短暂测试,可在 `application.properties` 中调整该配置。
启动后端时可在日志中看到 `=== 开始主动声明 RabbitMQ 组件 ===` 与后续的声明结果,也可以在管理界面中查看是否创建成功。
完成 Redis 与 RabbitMQ 配置后,即可继续启动后端服务。
完成环境变量和运行参数设置后,即可启动 Spring Boot 应用。
![运行画面](assets/contributing/backend_img_4.png)
### Docker 环境
## 前端连接预发或正式环境
#### 配置环境变量
前端默认读取 `.env` 中的接口地址,可通过修改以下变量快速切换到预发或正式环境:
```shell
cd docker/
```
1. 按需覆盖关键变量:
主要配置两个 `.env` 文件
```ini
NUXT_PUBLIC_API_BASE_URL=https://www.staging.open-isle.com
NUXT_PUBLIC_WEBSOCKET_URL=https://www.staging.open-isle.com
```
将 `staging` 替换为 `www` 即可连接正式环境。其他变量(如 OAuth Client ID、站点地址等可根据需求调整。
- `backend/open-isle.env`:后端环境变量,配置同上,见 [配置环境变量](#配置环境变量)。
- `docker/.env`Docker Compose 环境变量,主要配置 MySQL 相关
```shell
cp .env.example .env
```
> [!TIP]
> 使用单独的 `.env` 文件是为了兼容线上环境或已启用 MySQL 服务的情况,如果只是想快速体验或者启动统一的环境,则推荐使用本方式。
在指定 `docker/.env` 后,`backend/open-isle.env` 中以下配置会被覆盖,这样就确保使用了同一份配置。
```ini
MYSQL_URL=
MYSQL_USER=
MYSQL_PASSWORD=
```
#### 构建并启动镜像
```shell
docker compose up -d
```
如果想了解启动过程发生了什么可以查看日志
```shell
docker compose logs
```
## 启动前端服务
> [!IMPORTANT]
> **⚠️ 环境要求Node.js 版本最低 20.0.0(因为 Nuxt 框架要求)**
```shell
cd frontend_nuxt/
```
### 配置环境变量
前端可以依赖本机部署的后端,也可以直接调用线上的后端接口。
- 利用预发环境:**(⚠️ 强烈推荐只开发前端的朋友使用该环境)**
```shell
cp .env.staging.example .env
```
- 利用生产环境
```shell
cp .env.production.example .env
```
- 利用本地环境
```shell
cp .env.dev.example .env
```
若依赖本机部署的后端,需要修改 `.env` 中的 `NUXT_PUBLIC_API_BASE_URL` 值与后端服务端口一致
### 安装依赖和运行
前端安装依赖并启动服务。
```shell
# 安装依赖
npm install --verbose
# 运行前端服务
npm run dev
```
如此一来,浏览器访问 http://127.0.0.1:3000 即可访问前端页面。
## 其他配置
@@ -334,7 +194,7 @@ https://docs.open-isle.com
### OpenAPI文档使用
- 预发环境/正式环境切换,以通过如下位置切换API环境
- 预发环境/正式环境切换以通过如下位置切换API环境
![CleanShot 2025-09-10 at 12.08.00@2x.png](https://openisle-1307107697.cos.accelerate.myqcloud.com/dynamic_assert/f9fb7a0f020d4a0e94159d7820783224.png)

View File

@@ -1,35 +0,0 @@
package com.openisle.controller;
import com.openisle.dto.AdminGrantPointRequest;
import com.openisle.service.PointService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/admin/points")
@RequiredArgsConstructor
public class AdminPointController {
private final PointService pointService;
@PostMapping("/grant")
@SecurityRequirement(name = "JWT")
@Operation(summary = "Grant points", description = "Grant points to a user as administrator")
@ApiResponse(responseCode = "200", description = "Points granted")
public Map<String, Object> grant(
@RequestBody AdminGrantPointRequest request,
Authentication auth
) {
String username = request.getUsername();
int balance = pointService.grantPointByAdmin(auth.getName(), username, request.getAmount());
return Map.of("username", username.trim(), "point", balance);
}
}

View File

@@ -15,6 +15,7 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@@ -131,6 +132,7 @@ public class CommentController {
c.getId(),
"comment",
c.getCreatedAt(),
c.getPinnedAt(),
c // payload 是 CommentDto
)
)
@@ -145,17 +147,39 @@ public class CommentController {
l.getId(),
"log",
l.getTime(), // 注意字段名不一样
null,
l // payload 是 PostChangeLogDto
)
)
.toList()
);
// 排序
Comparator<TimelineItemDto<?>> comparator = Comparator.comparing(TimelineItemDto::getCreatedAt);
Comparator<TimelineItemDto<?>> pinnedOrderComparator = (a, b) -> {
LocalDateTime aPinned = a.getPinnedAt();
LocalDateTime bPinned = b.getPinnedAt();
if (aPinned == null && bPinned == null) {
return 0;
}
if (aPinned == null) {
return 1;
}
if (bPinned == null) {
return -1;
}
return bPinned.compareTo(aPinned);
};
Comparator<TimelineItemDto<?>> comparator = Comparator.<TimelineItemDto<?>, Boolean>comparing(
item -> item.getPinnedAt() == null
).thenComparing(pinnedOrderComparator);
Comparator<TimelineItemDto<?>> createdAtComparator = Comparator.comparing(
TimelineItemDto::getCreatedAt
);
if (CommentSort.NEWEST.equals(sort)) {
comparator = comparator.reversed();
createdAtComparator = createdAtComparator.reversed();
}
itemDtoList.sort(comparator);
itemDtoList.sort(comparator.thenComparing(createdAtComparator));
log.debug("listComments returning {} comments", itemDtoList.size());
return itemDtoList;
}

View File

@@ -1,12 +0,0 @@
package com.openisle.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class AdminGrantPointRequest {
private String username;
private int amount;
}

View File

@@ -15,5 +15,6 @@ public class TimelineItemDto<T> {
private Long id;
private String kind; // "comment" | "log"
private LocalDateTime createdAt;
private LocalDateTime pinnedAt;
private T payload; // 泛型,具体类型由外部决定
}

View File

@@ -13,5 +13,4 @@ public enum PointHistoryType {
REDEEM,
LOTTERY_JOIN,
LOTTERY_REWARD,
ADMIN_GRANT,
}

View File

@@ -43,22 +43,6 @@ public class PointService {
return addPoint(user, 500, PointHistoryType.FEATURE, post, null, null);
}
public int grantPointByAdmin(String adminName, String targetUsername, int amount) {
if (amount <= 0) {
throw new FieldException("amount", "积分必须为正数");
}
if (targetUsername == null || targetUsername.isBlank()) {
throw new FieldException("username", "用户名不能为空");
}
String normalizedUsername = targetUsername.trim();
User admin = userRepository.findByUsername(adminName).orElseThrow();
User target = userRepository
.findByUsername(normalizedUsername)
.orElseThrow(() -> new FieldException("username", "用户不存在"));
addPoint(target, amount, PointHistoryType.ADMIN_GRANT, null, null, admin);
return target.getPoint();
}
public void processLotteryJoin(User participant, LotteryPost post) {
int cost = post.getPointCost();
if (cost > 0) {

View File

@@ -4,7 +4,7 @@ server.port=${SERVER_PORT:8080}
# for mysql
logging.level.root=${LOG_LEVEL:INFO}
logging.level.com.openisle.service.CosImageUploader=DEBUG
spring.datasource.url=jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}
spring.datasource.url=jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}?useUnicode=yes&characterEncoding=UTF-8&useInformationSchema=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
spring.datasource.username=${MYSQL_USER:root}
spring.datasource.password=${MYSQL_PASSWORD:password}
spring.jpa.hibernate.ddl-auto=update

View File

@@ -4,7 +4,7 @@ set -euo pipefail
# 可用法:
# ./deploy.sh
# ./deploy.sh feature/docker
deploy_branch="${1:-feature/docker}"
deploy_branch="${1:-main}"
repo_dir="/opt/openisle/OpenIsle"
compose_file="${repo_dir}/docker/docker-compose.yaml"
@@ -40,12 +40,12 @@ echo "👉 Build images ..."
docker compose -f "$compose_file" --env-file "$env_file" \
build --pull \
--build-arg NUXT_ENV=production \
frontend_service opensearch
frontend_service
echo "👉 Recreate & start all target services (no dev profile)..."
docker compose -f "$compose_file" --env-file "$env_file" \
up -d --force-recreate --remove-orphans \
mysql redis rabbitmq opensearch dashboards websocket-service springboot frontend_service
up -d --force-recreate --remove-orphans --no-deps \
mysql redis rabbitmq websocket-service springboot frontend_service
echo "👉 Current status:"
docker compose -f "$compose_file" --env-file "$env_file" ps

View File

@@ -4,11 +4,10 @@ set -euo pipefail
# 可用法:
# ./deploy-staging.sh
# ./deploy-staging.sh feature/docker
deploy_branch="${1:-feature/docker}"
deploy_branch="${1:-main}"
repo_dir="/opt/openisle/OpenIsle-staging"
compose_file="${repo_dir}/docker/docker-compose.yaml"
# 使用仓库根目录的 .envCI 预先写好),也可以改成绝对路径
env_file="${repo_dir}/.env"
project="openisle_staging"
@@ -41,12 +40,12 @@ echo "👉 Build images (staging)..."
docker compose -f "$compose_file" --env-file "$env_file" \
build --pull \
--build-arg NUXT_ENV=staging \
frontend_service opensearch
frontend_service
echo "👉 Recreate & start all target services (no dev profile)..."
docker compose -f "$compose_file" --env-file "$env_file" \
up -d --force-recreate --remove-orphans \
mysql redis rabbitmq opensearch dashboards websocket-service springboot frontend_service
up -d --force-recreate --remove-orphans --no-deps \
mysql redis rabbitmq websocket-service springboot frontend_service
echo "👉 Current status:"
docker compose -f "$compose_file" --env-file "$env_file" ps

View File

@@ -45,8 +45,8 @@ services:
memlock: { soft: -1, hard: -1 }
nofile: { soft: 65536, hard: 65536 }
volumes:
- ${OPENSEARCH_DATA_DIR:-./data}:/usr/share/opensearch/data
- ${OPENSEARCH_SNAPSHOT_DIR:-./snapshots}:/snapshots
- opensearch-data:/usr/share/opensearch/data
- opensearch-snapshots:/snapshots
ports:
- "${OPENSEARCH_PORT:-9200}:9200"
- "${OPENSEARCH_METRICS_PORT:-9600}:9600"
@@ -226,6 +226,8 @@ services:
websocket-service:
condition: service_healthy
restart: unless-stopped
profiles: ["staging", "prod"]
loopback_8080:
image: alpine/socat
@@ -293,3 +295,7 @@ volumes:
name: "${COMPOSE_PROJECT_NAME}_frontend-service-node-modules"
frontend-static:
name: "${COMPOSE_PROJECT_NAME}_frontend-static"
opensearch-data:
name: "${COMPOSE_PROJECT_NAME}_opensearch-data"
opensearch-snapshots:
name: "${COMPOSE_PROJECT_NAME}_opensearch-snapshots"

View File

@@ -179,7 +179,9 @@ body {
.info-content-text pre .line-numbers {
counter-reset: line-number 0;
width: 2em;
white-space: nowrap; /* 禁止数字换行 */
font-variant-numeric: tabular-nums; /* 数字等宽 */
/* width: 2em; */
font-size: 13px;
position: sticky;
flex-shrink: 0;
@@ -203,6 +205,7 @@ body {
border-radius: 4px;
background-color: var(--code-highlight-background-color);
color: var(--text-color);
white-space: pre; /* 禁止自动换行 */
}
.copy-code-btn {
@@ -341,6 +344,16 @@ body {
.info-content-text pre {
line-height: 1.5;
}
/*处理iframe视频标签*/
.info-content-text iframe {
width: 100%;
max-width: 100%;
height: auto;
aspect-ratio: 16 / 9; /* 保持 16:9 比例 */
border: none;
display: block;
}
.d2h-file-name {
font-size: 14px !important;

View File

@@ -0,0 +1,157 @@
<template>
<div
class="base-item-group"
:style="{
width: `${containerWidth}px`,
height: `${itemSize}px`,
'--base-item-group-duration': `${animationDuration}ms`,
}"
@mouseenter="onMouseEnter"
@mouseleave="onMouseLeave"
>
<div
v-for="(item, index) in items"
:key="itemKey(item, index)"
class="base-item-group__item"
:style="{
width: `${itemSize}px`,
height: `${itemSize}px`,
transform: `translateX(${index * activeGap}px)`,
zIndex: items.length - index,
}"
>
<slot :item="item" :index="index">
<BaseImage
v-if="item && (item.src || typeof item === 'string')"
class="base-item-group__image"
:src="typeof item === 'string' ? item : item.src"
:alt="itemAlt(item, index)"
/>
<div v-else class="base-item-group__placeholder">{{ placeholderText(item) }}</div>
</slot>
</div>
</div>
</template>
<script setup>
import { computed, ref, watchEffect } from 'vue'
import BaseImage from './BaseImage.vue'
const props = defineProps({
items: {
type: Array,
default: () => [],
},
itemSize: {
type: Number,
default: 40,
},
collapsedGap: {
type: Number,
default: 12,
},
expandedGap: {
type: Number,
default: null,
},
animationDuration: {
type: Number,
default: 200,
},
itemKeyField: {
type: String,
default: 'id',
},
})
const isHovered = ref(false)
const onMouseEnter = () => {
isHovered.value = true
}
const onMouseLeave = () => {
isHovered.value = false
}
const effectiveExpandedGap = computed(() =>
props.expandedGap == null ? props.itemSize : props.expandedGap,
)
const activeGap = computed(() =>
isHovered.value ? effectiveExpandedGap.value : props.collapsedGap,
)
const containerWidth = computed(() =>
props.items.length ? props.itemSize + (props.items.length - 1) * activeGap.value : props.itemSize,
)
watchEffect(() => {
if (effectiveExpandedGap.value < props.collapsedGap) {
console.warn('[BaseItemGroup] `expandedGap` should be greater than or equal to `collapsedGap`.')
}
})
const itemKey = (item, index) => {
if (item && typeof item === 'object' && props.itemKeyField in item) {
return item[props.itemKeyField]
}
return index
}
const itemAlt = (item, index) => {
if (item && typeof item === 'object') {
return item.alt || `item-${index}`
}
if (typeof item === 'string') {
return `item-${index}`
}
return 'item'
}
const placeholderText = (item) => {
if (item == null) return ''
if (typeof item === 'object' && 'text' in item) return item.text
return String(item)
}
</script>
<style scoped>
.base-item-group {
display: flex;
position: relative;
transition: width var(--base-item-group-duration) ease;
}
.base-item-group__item {
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
border-radius: 9999px;
overflow: hidden;
background-color: var(--color-neutral-100, #f0f2f5);
transition: transform var(--base-item-group-duration) ease;
box-shadow: 0 0 0 2px var(--color-surface, #fff);
}
.base-item-group__image {
width: 100%;
height: 100%;
object-fit: cover;
}
.base-item-group__placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 500;
color: var(--color-neutral-500, #666);
background-color: var(--color-neutral-200, #e5e7eb);
}
</style>

View File

@@ -53,14 +53,29 @@
@click="handleContentClick"
></div>
<div class="article-footer-container">
<ReactionsGroup v-model="comment.reactions" content-type="comment" :content-id="comment.id">
<div class="make-reaction-item comment-reaction" @click="toggleEditor">
<ReactionsGroup
ref="commentReactionsGroupRef"
v-model="comment.reactions"
content-type="comment"
:content-id="comment.id"
/>
<div class="comment-reaction-actions">
<div
class="reaction-action like-action"
:class="{ selected: commentLikedByMe }"
@click="toggleCommentLike"
>
<like v-if="!commentLikedByMe" />
<like v-else theme="filled" />
<span v-if="commentLikeCount" class="reaction-count">{{ commentLikeCount }}</span>
</div>
<div class="reaction-action comment-reaction" @click="toggleEditor">
<comment-icon />
</div>
<div class="make-reaction-item copy-link" @click="copyCommentLink">
<div class="reaction-action copy-link" @click="copyCommentLink">
<link-icon />
</div>
</ReactionsGroup>
</div>
</div>
<div class="comment-editor-wrapper" ref="editorWrapper">
<CommentEditor
@@ -156,6 +171,18 @@ const lightboxVisible = ref(false)
const lightboxIndex = ref(0)
const lightboxImgs = ref([])
const loggedIn = computed(() => authState.loggedIn)
const commentReactionsGroupRef = ref(null)
const commentLikeCount = computed(
() => (props.comment.reactions || []).filter((reaction) => reaction.type === 'LIKE').length,
)
const commentLikedByMe = computed(() =>
(props.comment.reactions || []).some(
(reaction) => reaction.type === 'LIKE' && reaction.user === authState.username,
),
)
const toggleCommentLike = () => {
commentReactionsGroupRef.value?.toggleReaction('LIKE')
}
const countReplies = (list) => list.reduce((sum, r) => sum + 1 + countReplies(r.reply || []), 0)
const replyCount = computed(() => countReplies(props.comment.reply || []))
const isCommentFromPostAuthor = computed(() => {
@@ -365,6 +392,47 @@ const handleContentClick = (e) => {
</script>
<style scoped>
.comment-reaction-actions {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
}
.reaction-action {
cursor: pointer;
padding: 4px 10px;
border-radius: 10px;
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
opacity: 0.6;
font-size: 18px;
transition:
background-color 0.2s ease,
opacity 0.2s ease;
}
.reaction-action:hover {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-action.like-action {
color: #ff0000;
}
.reaction-action.selected {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-count {
font-size: 14px;
font-weight: bold;
}
.reply-toggle {
cursor: pointer;
color: var(--primary-color);
@@ -378,10 +446,6 @@ const handleContentClick = (e) => {
color: var(--primary-color);
}
.comment-reaction:hover {
background-color: lightgray;
}
.comment-highlight {
animation: highlight 2s;
}

View File

@@ -49,7 +49,11 @@
</slot>
</div>
<div
v-if="open && !isMobile && (loading || filteredOptions.length > 0 || showSearch)"
v-if="
open &&
!isMobile &&
(loading || filteredOptions.length > 0 || showSearch || (remote && search))
"
:class="['dropdown-menu', menuClass]"
v-click-outside="close"
ref="menuRef"
@@ -62,26 +66,29 @@
<l-hatch size="20" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div>
<template v-else>
<div
v-for="o in filteredOptions"
:key="o.id"
@click="select(o.id)"
:class="['dropdown-option', optionClass, { selected: isSelected(o.id) }]"
>
<slot name="option" :option="o" :isSelected="isSelected(o.id)">
<template v-if="o.icon">
<BaseImage
v-if="isImageIcon(o.icon)"
:src="o.icon"
class="option-icon"
:alt="o.name"
/>
<component v-else :is="o.icon" class="option-icon" :size="16" />
</template>
<span>{{ o.name }}</span>
</slot>
</div>
<slot name="footer" :close="close" :loading="loading" />
<div v-if="filteredOptions.length === 0" class="dropdown-empty">没有搜索结果</div>
<template v-else>
<div
v-for="o in filteredOptions"
:key="o.id"
@click="select(o.id)"
:class="['dropdown-option', optionClass, { selected: isSelected(o.id) }]"
>
<slot name="option" :option="o" :isSelected="isSelected(o.id)">
<template v-if="o.icon">
<BaseImage
v-if="isImageIcon(o.icon)"
:src="o.icon"
class="option-icon"
:alt="o.name"
/>
<component v-else :is="o.icon" class="option-icon" :size="16" />
</template>
<span>{{ o.name }}</span>
</slot>
</div>
<slot name="footer" :close="close" :loading="loading" />
</template>
</template>
</div>
<Teleport to="body">
@@ -99,26 +106,29 @@
<l-hatch size="20" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div>
<template v-else>
<div
v-for="o in filteredOptions"
:key="o.id"
@click="select(o.id)"
:class="['dropdown-option', optionClass, { selected: isSelected(o.id) }]"
>
<slot name="option" :option="o" :isSelected="isSelected(o.id)">
<template v-if="o.icon">
<BaseImage
v-if="isImageIcon(o.icon)"
:src="o.icon"
class="option-icon"
:alt="o.name"
/>
<component v-else :is="o.icon" class="option-icon" :size="16" />
</template>
<span>{{ o.name }}</span>
</slot>
</div>
<slot name="footer" :close="close" :loading="loading" />
<div v-if="filteredOptions.length === 0" class="dropdown-empty">没有搜索结果</div>
<template v-else>
<div
v-for="o in filteredOptions"
:key="o.id"
@click="select(o.id)"
:class="['dropdown-option', optionClass, { selected: isSelected(o.id) }]"
>
<slot name="option" :option="o" :isSelected="isSelected(o.id)">
<template v-if="o.icon">
<BaseImage
v-if="isImageIcon(o.icon)"
:src="o.icon"
class="option-icon"
:alt="o.name"
/>
<component v-else :is="o.icon" class="option-icon" :size="16" />
</template>
<span>{{ o.name }}</span>
</slot>
</div>
<slot name="footer" :close="close" :loading="loading" />
</template>
</template>
</div>
</div>
@@ -283,6 +293,7 @@ export default {
isImageIcon,
setSearch,
isMobile,
remote: props.remote,
}
},
}
@@ -384,6 +395,13 @@ export default {
padding: 10px 0;
}
.dropdown-empty {
padding: 20px;
text-align: center;
color: var(--muted-text-color, #8c8c8c);
font-size: 14px;
}
.dropdown-mobile-page {
position: fixed;
top: 0;

View File

@@ -26,43 +26,59 @@
<ClientOnly>
<div class="header-content-right">
<div v-if="isMobile" class="search-icon" @click="search">
<search-icon />
</div>
<div v-if="isMobile" class="theme-icon" @click="cycleTheme">
<component :is="iconClass" />
</div>
<div v-if="!isMobile" class="invite_text" @click="copyInviteLink">
<copy />
邀请
<loading v-if="isCopying" />
</div>
<!-- 搜索 -->
<ToolTip v-if="isMobile" content="搜索" placement="bottom">
<div class="header-icon-item" @click="search">
<search-icon class="header-icon" />
<span class="header-label">搜索</span>
</div>
</ToolTip>
<!-- 主题切换 -->
<ToolTip v-if="isMobile" content="切换主题" placement="bottom">
<div class="header-icon-item" @click="cycleTheme">
<component :is="iconClass" class="header-icon" />
<span class="header-label">主题</span>
</div>
</ToolTip>
<!-- 邀请 -->
<ToolTip v-if="!isMobile" content="邀请好友" placement="bottom">
<div class="header-icon-item" @click="copyInviteLink">
<template v-if="!isCopying">
<copy-link class="header-icon" />
<span class="header-label">邀请</span>
</template>
<loading v-else />
</div>
</ToolTip>
<!-- 在线人数 -->
<ToolTip v-if="!isMobile" content="当前在线人数" placement="bottom">
<div class="online-count">
<peoples-two />
<span>{{ onlineCount }}</span>
<div class="header-icon-item">
<peoples-two class="header-icon" />
<span class="header-label">在线</span>
<span class="header-badge">{{ onlineCount }}</span>
</div>
</ToolTip>
<!-- RSS -->
<ToolTip content="复制RSS链接" placement="bottom">
<div class="rss-icon" @click="copyRssLink">
<rss />
<div class="header-icon-item" @click="copyRssLink">
<rss class="header-icon" />
<span class="header-label">RSS</span>
</div>
</ToolTip>
<!-- 发帖 -->
<ToolTip v-if="!isMobile && isLogin" content="发帖" placement="bottom">
<div class="new-post-icon" @click="goToNewPost">
<edit />
<div class="header-icon-item" @click="goToNewPost">
<edit class="header-icon" />
<span class="header-label">发帖</span>
</div>
</ToolTip>
<!-- 消息 -->
<ToolTip v-if="isLogin" content="站内信和频道" placement="bottom">
<div class="messages-icon" @click="goToMessages">
<message-emoji />
<span v-if="unreadMessageCount > 0" class="unread-badge">{{
unreadMessageCount
}}</span>
<div class="header-icon-item" @click="goToMessages">
<message-emoji class="header-icon" />
<span class="header-label">消息</span>
<span v-if="unreadMessageCount > 0" class="unread-badge">{{ unreadMessageCount }}</span>
<span v-else-if="hasChannelUnread" class="unread-dot"></span>
</div>
</ToolTip>
@@ -192,6 +208,7 @@ const copyInviteLink = async () => {
const token = getToken()
if (!token) {
toast.error('请先登录')
isCopying.value = false // 🔥 修复:未登录时立即复原状态
return
}
try {
@@ -333,7 +350,7 @@ onMounted(async () => {
height: var(--header-height);
background-color: var(--background-color-blur);
backdrop-filter: var(--blur-10);
color: var(--header-text-color);
color: var(--primary-color);
border-bottom: 1px solid var(--header-border-color);
}
@@ -376,6 +393,7 @@ onMounted(async () => {
flex-direction: row;
align-items: center;
gap: 20px;
padding-right: 15px;
}
.micon {
@@ -464,16 +482,14 @@ onMounted(async () => {
cursor: pointer;
}
.invite_text {
font-size: 12px;
cursor: pointer;
color: var(--primary-color);
}
.invite_text:hover {
opacity: 0.8;
text-decoration: underline;
}
.invite_text,
.online-count,
.rss-icon,
.new-post-icon,
.messages-icon {
@@ -484,8 +500,8 @@ onMounted(async () => {
.unread-badge {
position: absolute;
top: -5px;
right: -10px;
top: -4px;
right: -6px;
background-color: #ff4d4f;
color: white;
border-radius: 50%;
@@ -500,8 +516,8 @@ onMounted(async () => {
.unread-dot {
position: absolute;
top: -2px;
right: -4px;
top: 0;
right: -1px;
width: 8px;
height: 8px;
border-radius: 50%;
@@ -513,14 +529,58 @@ onMounted(async () => {
}
.online-count {
font-size: 14px;
display: flex;
align-items: center;
gap: 5px;
color: var(--primary-color);
cursor: default;
}
/* === 统一图标按钮风格 === */
.header-icon-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
font-size: 14px;
color: var(--primary-color);
cursor: pointer;
position: relative;
transition: color 0.25s ease, transform 0.15s ease, opacity 0.2s ease;
}
.header-icon-item:hover {
opacity: 0.8;
transform: translateY(-1px);
}
/* 点击时瞬间高亮 + 轻微缩放 */
.header-icon-item:active {
color: var(--primary-color-hover);
transform: scale(0.92);
}
.header-icon {
font-size: 20px;
line-height: 1;
}
.header-label {
font-size: 12px;
line-height: 1;
}
/* 在线人数的数字文字样式(无背景) */
.header-badge {
position: absolute;
top: -4px;
right: -6px;
color: var(--primary-color); /* 🔹 使用主题主色 */
background: none; /* 🔹 去掉背景 */
font-size: 11px; /* 字体稍微大一点以便清晰 */
font-weight: 600; /* 加一点权重让数字更醒目 */
line-height: 1;
padding: 0; /* 去掉内边距 */
}
@keyframes rss-glow {
0% {
text-shadow: 0 0 0px var(--primary-color);
@@ -556,5 +616,12 @@ onMounted(async () => {
.header-content-right {
gap: 15px;
}
/* 手机不显示文字 */
.header-label {
display: none;
}
.header-badge {
display: none;
}
}
</style>

View File

@@ -35,21 +35,11 @@
</template>
</div>
</div>
<div class="make-reaction-container">
<div
v-if="props.contentType !== 'message'"
class="make-reaction-item like-reaction"
@click="toggleReaction('LIKE')"
>
<like v-if="!userReacted('LIKE')" />
<like v-else theme="filled" />
<span class="reactions-count" v-if="likeCount">{{ likeCount }}</span>
</div>
<slot></slot>
</div>
<div
v-if="panelVisible"
class="reactions-panel"
ref="reactionsPanelRef"
:style="panelInlineStyle"
@mouseenter="cancelHide"
@mouseleave="scheduleHide"
>
@@ -69,7 +59,7 @@
</template>
<script setup>
import { computed, onMounted, ref, watch } from 'vue'
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { toast } from '~/main'
import { authState, getToken } from '~/utils/auth'
import { reactionEmojiMap } from '~/utils/reactions'
@@ -102,8 +92,6 @@ const counts = computed(() => {
})
const totalCount = computed(() => Object.values(counts.value).reduce((a, b) => a + b, 0))
const likeCount = computed(() => counts.value['LIKE'] || 0)
const userReacted = (type) =>
reactions.value.some((r) => r.type === type && r.user === authState.username)
@@ -152,9 +140,11 @@ const displayedReactions = computed(() => {
.map((type) => ({ type }))
})
const panelTypes = computed(() => sortedReactionTypes.value.filter((t) => t !== 'LIKE'))
const panelTypes = computed(() => sortedReactionTypes.value)
const panelVisible = ref(false)
const reactionsPanelRef = ref(null)
const panelInlineStyle = ref({})
let hideTimer = null
const openPanel = () => {
clearTimeout(hideTimer)
@@ -170,6 +160,33 @@ const cancelHide = () => {
clearTimeout(hideTimer)
}
const updatePanelInlineStyle = () => {
if (!panelVisible.value) return
const panelEl = reactionsPanelRef.value
if (!panelEl) return
const parentEl = panelEl.closest('.reactions-container')?.parentElement
if (!parentEl) return
const parentWidth = parentEl.clientWidth - 20
panelInlineStyle.value = {
width: 'max-content',
maxWidth: `${parentWidth}px`,
}
}
watch(panelVisible, async (visible) => {
if (visible) {
await nextTick()
updatePanelInlineStyle()
}
})
watch(panelTypes, async () => {
if (panelVisible.value) {
await nextTick()
updatePanelInlineStyle()
}
})
const toggleReaction = async (type) => {
const token = getToken()
if (!token) {
@@ -245,6 +262,15 @@ const toggleReaction = async (type) => {
onMounted(async () => {
await initialize()
window.addEventListener('resize', updatePanelInlineStyle)
})
defineExpose({
toggleReaction,
})
onBeforeUnmount(() => {
window.removeEventListener('resize', updatePanelInlineStyle)
})
</script>
@@ -253,11 +279,7 @@ onMounted(async () => {
position: relative;
display: flex;
flex-direction: row;
gap: 10px;
align-items: center;
width: 100%;
justify-content: space-between;
flex-wrap: wrap;
}
.reactions-viewer {
@@ -295,32 +317,6 @@ onMounted(async () => {
padding-left: 5px;
}
.make-reaction-container {
display: flex;
flex-direction: row;
gap: 10px;
}
.make-reaction-item {
cursor: pointer;
padding: 4px;
opacity: 0.5;
border-radius: 8px;
font-size: 20px;
}
.like-reaction {
color: #ff0000;
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
}
.make-reaction-item:hover {
background-color: #ffe2e2;
}
.reactions-count {
font-size: 16px;
font-weight: bold;
@@ -328,7 +324,7 @@ onMounted(async () => {
.reactions-panel {
position: absolute;
bottom: 50px;
bottom: 40px;
background-color: var(--background-color);
border: 1px solid var(--normal-border-color);
border-radius: 20px;

View File

@@ -202,6 +202,7 @@ defineExpose({
}
.result-body {
line-height: 1;
display: flex;
flex-direction: column;
}

View File

@@ -71,16 +71,6 @@ export default {
label: '隐私政策',
file: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/about/privacy.md',
},
{
key: 'points',
label: '积分说明',
content: `# 积分说明
- 积分可用于兑换商品、参与抽奖等社区玩法。
- 管理员可以通过后台新增的积分模块为用户发放奖励积分。
- 每次发放都会记录在积分历史中,方便你查看积分来源。
`,
},
{
key: 'api',
label: 'API与调试',
@@ -98,21 +88,11 @@ export default {
return `${token.value.slice(0, 20)}...${token.value.slice(-10)}`
})
const loadContent = async (tab) => {
if (!tab || tab.key === 'api') return
if (tab.content) {
isFetching.value = false
content.value = tab.content
return
}
if (!tab.file) {
isFetching.value = false
content.value = ''
return
}
const loadContent = async (file) => {
if (!file) return
try {
isFetching.value = true
const res = await fetch(tab.file)
const res = await fetch(file)
if (res.ok) {
content.value = await res.text()
} else {
@@ -130,15 +110,15 @@ export default {
if (initTab && tabs.find((t) => t.key === initTab)) {
selectedTab.value = initTab
const tab = tabs.find((t) => t.key === initTab)
if (tab) loadContent(tab)
if (tab && tab.file) loadContent(tab.file)
} else {
loadContent(tabs[0])
loadContent(tabs[0].file)
}
})
watch(selectedTab, (name) => {
const tab = tabs.find((t) => t.key === name)
if (tab) loadContent(tab)
if (tab && tab.file) loadContent(tab.file)
router.replace({ query: { ...route.query, tab: name } })
})
@@ -147,8 +127,6 @@ export default {
(name) => {
if (name && name !== selectedTab.value && tabs.find((t) => t.key === name)) {
selectedTab.value = name
const tab = tabs.find((t) => t.key === name)
if (tab) loadContent(tab)
}
},
)

View File

@@ -75,8 +75,8 @@
<star v-if="!article.rssExcluded" class="featured-icon" />
{{ article.title }}
</NuxtLink>
<NuxtLink class="article-item-description main-item">
{{ sanitizeDescription(article.description) }}
<NuxtLink class="article-item-description main-item" :to="`/posts/${article.id}`">
<div v-html="sanitizeDescription(article.description)"></div>
</NuxtLink>
<div class="article-info-container main-item">
<ArticleCategory :category="article.category" />
@@ -378,8 +378,27 @@ onBeforeUnmount(() => {
/** 供 InfiniteLoadMore 重建用的 key筛选/Tab 改变即重建内部状态 */
const ioKey = computed(() => asyncKey.value.join('::'))
/** 其他工具函数 **/
const sanitizeDescription = (text) => stripMarkdown(text)
// 在首页摘要加载贴吧表情包
const sanitizeDescription = (text) => {
if (!text) return ''
// 1⃣ 先把 Markdown 转成纯文本
const plain = stripMarkdown(text)
// 2⃣ 替换 :tieba123: 为 <img>
const withEmoji = plain.replace(/:tieba(\d+):/g, (match, num) => {
const key = `tieba${num}`
const file = tiebaEmoji[key]
return file
? `<img loading="lazy" class="emoji" src="${file}" alt="${key}">`
: match // 没有匹配到图片则保留原样
})
// 3 可选截断纯文本长度防止撑太长
const truncated = withEmoji.length > 500 ? withEmoji.slice(0, 500) + '…' : withEmoji
return truncated
}
// 页面选项同步到全局状态
watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
@@ -537,16 +556,22 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
.article-comments,
.header-item.comments {
width: 5%;
justify-content: flex-end;
text-align: right;
}
.article-views,
.header-item.views {
width: 5%;
justify-content: flex-end;
text-align: right;
}
.article-time,
.header-item.activity {
width: 10%;
justify-content: flex-end;
text-align: left;
}
.article-item-title {

View File

@@ -61,14 +61,31 @@
@click="handleContentClick"
></div>
</div>
<ReactionsGroup
:model-value="item.reactions"
content-type="message"
:content-id="item.id"
@update:modelValue="(v) => (item.reactions = v)"
>
<div @click="setReply(item)" class="reply-btn"><next /> 写个回复...</div>
</ReactionsGroup>
<div class="message-reaction-row">
<ReactionsGroup
:ref="(el) => setMessageReactionRef(item.id, el)"
:model-value="item.reactions"
content-type="message"
:content-id="item.id"
@update:modelValue="(v) => (item.reactions = v)"
/>
<div class="message-reaction-actions">
<div
class="reaction-action like-action"
:class="{ selected: isMessageLiked(item) }"
@click="toggleMessageLike(item)"
>
<like v-if="!isMessageLiked(item)" />
<like v-else theme="filled" />
<span v-if="getMessageLikeCount(item)" class="reaction-count">{{
getMessageLikeCount(item)
}}</span>
</div>
<div @click="setReply(item)" class="reaction-action reply-btn">
<next /> 写个回复...
</div>
</div>
</div>
</template>
</BaseTimeline>
<div class="empty-container">
@@ -180,6 +197,32 @@ function setReply(message) {
replyTo.value = message
}
const messageReactionRefs = new Map()
function setMessageReactionRef(id, el) {
if (el) {
messageReactionRefs.set(id, el)
} else {
messageReactionRefs.delete(id)
}
}
function getMessageLikeCount(message) {
return (message.reactions || []).filter((reaction) => reaction.type === 'LIKE').length
}
function isMessageLiked(message) {
const username = currentUser.value?.username
if (!username) return false
return (message.reactions || []).some(
(reaction) => reaction.type === 'LIKE' && reaction.user === username,
)
}
function toggleMessageLike(message) {
const group = messageReactionRefs.get(message.id)
group?.toggleReaction('LIKE')
}
/** 改造:滚动函数 —— smooth & instant */
function scrollToBottomSmooth() {
const el = messagesListEl.value
@@ -710,6 +753,55 @@ function goBack() {
background-color: var(--normal-light-background-color);
}
.message-reaction-row {
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 10px;
flex-wrap: wrap;
margin-top: 6px;
}
.message-reaction-actions {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
}
.reaction-action {
cursor: pointer;
padding: 4px 10px;
border-radius: 10px;
display: flex;
align-items: center;
gap: 5px;
opacity: 0.6;
font-size: 16px;
transition:
background-color 0.2s ease,
opacity 0.2s ease;
}
.reaction-action:hover {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-action.like-action {
color: #ff0000;
}
.reaction-action.selected {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-count {
font-size: 14px;
font-weight: bold;
}
.reply-header {
display: flex;
flex-direction: row;
@@ -723,14 +815,8 @@ function goBack() {
}
.reply-btn {
cursor: pointer;
padding: 4px;
opacity: 0.6;
font-size: 12px;
}
.reply-btn:hover {
opacity: 1;
color: var(--primary-color);
}
.active-reply {

View File

@@ -184,16 +184,6 @@
}}</NuxtLink>
参与获得 {{ item.amount }} 积分
</template>
<template v-else-if="item.type === 'ADMIN_GRANT' && item.fromUserId">
管理员
<NuxtLink :to="`/users/${item.fromUserId}`" class="timeline-link">{{
item.fromUserName
}}</NuxtLink>
赠送了 {{ item.amount }} 积分
</template>
<template v-else-if="item.type === 'ADMIN_GRANT'">
管理员赠送了 {{ item.amount }} 积分
</template>
<template v-else-if="item.type === 'SYSTEM_ONLINE'"> 积分历史系统上线 </template>
<paper-money-two /> 你目前的积分是 {{ item.balance }}
</div>
@@ -239,7 +229,6 @@ const pointRules = [
'评论被点赞:每次 10 积分',
'邀请好友加入可获得 500 积分/次,注意需要使用邀请链接注册',
'文章被收录至精选:每次 500 积分',
'管理员赠送:特殊活动可由管理员手动赠送积分',
]
const goods = ref([])
@@ -261,7 +250,6 @@ const iconMap = {
LOTTERY_REWARD: 'fireworks',
POST_LIKE_CANCELLED: 'clear-icon',
COMMENT_LIKE_CANCELLED: 'clear-icon',
ADMIN_GRANT: 'paper-money-two',
}
const loadTrend = async () => {

View File

@@ -92,11 +92,26 @@
></div>
<div class="article-footer-container">
<ReactionsGroup v-model="postReactions" content-type="post" :content-id="postId">
<div class="make-reaction-item copy-link" @click="copyPostLink">
<ReactionsGroup
ref="postReactionsGroupRef"
v-model="postReactions"
content-type="post"
:content-id="postId"
/>
<div class="article-footer-actions">
<div
class="reaction-action like-action"
:class="{ selected: postLikedByMe }"
@click="togglePostLike"
>
<like v-if="!postLikedByMe" />
<like v-else theme="filled" />
<span v-if="postLikeCount" class="reaction-count">{{ postLikeCount }}</span>
</div>
<div class="reaction-action copy-link" @click="copyPostLink">
<link-icon />
</div>
</ReactionsGroup>
</div>
</div>
</div>
</div>
@@ -223,6 +238,18 @@ const postContent = ref('')
const category = ref('')
const tags = ref([])
const postReactions = ref([])
const postReactionsGroupRef = ref(null)
const postLikeCount = computed(
() => postReactions.value.filter((reaction) => reaction.type === 'LIKE').length,
)
const postLikedByMe = computed(() =>
postReactions.value.some(
(reaction) => reaction.type === 'LIKE' && reaction.user === authState.username,
),
)
const togglePostLike = () => {
postReactionsGroupRef.value?.toggleReaction('LIKE')
}
const comments = ref([])
const changeLogs = ref([])
const status = ref('PUBLISHED')
@@ -366,7 +393,11 @@ const changeLogIcon = (l) => {
return 'unlock'
}
} else if (l.type === 'PINNED') {
return 'pin-icon'
if (l.newPinnedAt) {
return 'pin'
} else {
return 'clear-icon'
}
} else if (l.type === 'FEATURED') {
if (l.newFeatured) {
return 'star'
@@ -1241,35 +1272,53 @@ onMounted(async () => {
.article-footer-container {
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 10px;
margin-top: 0px;
flex-wrap: wrap;
}
.reactions-viewer {
display: flex;
flex-direction: row;
gap: 20px;
align-items: center;
}
.reactions-viewer-item-container {
display: flex;
flex-direction: row;
gap: 2px;
align-items: center;
}
.reactions-viewer-item {
font-size: 16px;
}
.make-reaction-container {
.article-footer-actions {
display: flex;
flex-direction: row;
gap: 10px;
align-items: center;
}
.copy-link:hover {
.reaction-action {
cursor: pointer;
padding: 4px 10px;
opacity: 0.6;
border-radius: 10px;
font-size: 20px;
display: flex;
align-items: center;
gap: 5px;
transition:
background-color 0.2s ease,
opacity 0.2s ease;
}
.reaction-action:hover {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-action.like-action {
color: #ff0000;
}
.reaction-action.selected {
opacity: 1;
background-color: var(--normal-light-background-color);
}
.reaction-count {
font-size: 16px;
font-weight: bold;
}
.reaction-action.copy-link:hover {
background-color: #e2e2e2;
}

View File

@@ -65,35 +65,6 @@
<div class="setting-title">注册模式</div>
<Dropdown v-model="registerMode" :fetch-options="fetchRegisterModes" />
</div>
<div class="form-row grant-row">
<div class="setting-title">发放积分</div>
<div class="grant-form">
<BaseInput
v-model="grantUsername"
placeholder="请输入用户名"
class="grant-input"
@input="grantError = ''"
/>
<BaseInput
v-model="grantAmount"
type="number"
placeholder="积分数量"
class="grant-input amount"
@input="grantError = ''"
/>
<button
type="button"
class="grant-button"
:class="{ disabled: isGrantingPoints }"
:disabled="isGrantingPoints"
@click="grantPoint"
>
{{ isGrantingPoints ? '发放中...' : '发放' }}
</button>
</div>
<div v-if="grantError" class="grant-error-message">{{ grantError }}</div>
<div class="setting-description">积分会立即发放给目标用户并记录在积分历史中</div>
</div>
</div>
<div class="buttons">
<div v-if="isSaving" class="save-button disabled">保存中...</div>
@@ -131,10 +102,6 @@ const registerMode = ref('DIRECT')
const isLoadingPage = ref(false)
const isSaving = ref(false)
const frosted = ref(true)
const grantUsername = ref('')
const grantAmount = ref('')
const grantError = ref('')
const isGrantingPoints = ref(false)
onMounted(async () => {
isLoadingPage.value = true
@@ -217,55 +184,6 @@ const loadAdminConfig = async () => {
// ignore
}
}
const grantPoint = async () => {
if (isGrantingPoints.value) return
const username = grantUsername.value.trim()
if (!username) {
grantError.value = '用户名不能为空'
toast.error(grantError.value)
return
}
const amount = Number(grantAmount.value)
if (!Number.isInteger(amount) || amount <= 0) {
grantError.value = '积分数量必须为正整数'
toast.error(grantError.value)
return
}
isGrantingPoints.value = true
try {
const token = getToken()
const res = await fetch(`${API_BASE_URL}/api/admin/points/grant`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ username, amount }),
})
let data = null
try {
data = await res.json()
} catch (e) {
// ignore body parse errors
}
if (res.ok) {
toast.success(`已为 ${username} 发放 ${amount} 积分`)
grantUsername.value = ''
grantAmount.value = ''
grantError.value = ''
} else {
const message = data?.error || '发放失败'
grantError.value = message
toast.error(message)
}
} catch (e) {
grantError.value = '发放失败,请稍后再试'
toast.error(grantError.value)
} finally {
isGrantingPoints.value = false
}
}
const save = async () => {
isSaving.value = true
@@ -405,51 +323,6 @@ const save = async () => {
max-width: 200px;
}
.grant-row {
max-width: 100%;
}
.grant-form {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
.grant-input {
flex: 1 1 180px;
}
.grant-input.amount {
max-width: 140px;
}
.grant-button {
background-color: var(--primary-color);
color: #fff;
border: none;
border-radius: 8px;
padding: 8px 16px;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
}
.grant-button.disabled,
.grant-button:disabled {
cursor: not-allowed;
background-color: var(--primary-color-disabled);
}
.grant-button:not(.disabled):hover {
background-color: var(--primary-color-hover);
}
.grant-error-message {
color: red;
font-size: 14px;
margin-top: 8px;
}
.switch-row {
flex-direction: row;
align-items: center;

View File

@@ -5,11 +5,18 @@
<div class="reason-description">
为了我们社区的良性发展请填写注册理由我们将根据你的理由审核你的注册, 谢谢!
</div>
<div class="reason-input-container">
<BaseInput textarea rows="4" v-model="reason" placeholder="20个字以上"></BaseInput>
<div class="char-count">{{ reason.length }}/20</div>
<div class="input-wrapper">
<div class="reason-input-container">
<BaseInput
textarea
rows="4"
v-model="reason"
placeholder="请输入至少20个字符"
></BaseInput>
<div class="char-count">{{ reason.length }}/20</div>
</div>
<div v-if="error" class="error-message">{{ error }}</div>
</div>
<div v-if="error" class="error-message">{{ error }}</div>
<div v-if="!isWaitingForRegister" class="signup-page-button-primary" @click="submit">
提交
</div>
@@ -38,8 +45,9 @@ onMounted(async () => {
})
const submit = async () => {
if (!reason.value || reason.value.trim().length < 20) {
error.value = '请至少输入20个字'
const trimmedReason = reason.value.trim()
if (!trimmedReason || trimmedReason.length < 20) {
error.value = '请至少输入20个字符'
return
}
@@ -98,16 +106,29 @@ const submit = async () => {
width: 400px;
}
.input-wrapper {
display: flex;
flex-direction: column;
}
.reason-input-container {
position: relative;
}
.char-count {
position: absolute;
bottom: 8px;
right: 12px;
font-size: 12px;
color: #888;
width: 100%;
text-align: right;
background-color: transparent;
pointer-events: none;
}
.error-message {
color: red;
font-size: 14px;
margin-top: 8px;
}
.signup-page-button-primary {

View File

@@ -849,7 +849,8 @@ watch(selectedTab, async (val) => {
display: flex;
flex-direction: column;
padding: 20px;
gap: 20px;
row-gap: 40px; /* 行间距 */
column-gap: 20px; /* 列间距 */
}
.summary-title {
@@ -888,10 +889,10 @@ watch(selectedTab, async (val) => {
}
.summary-divider {
margin-top: 20px;
display: flex;
flex-direction: row;
gap: 20px;
row-gap: 40px; /* 行间距 */
column-gap: 20px; /* 列间距 */
width: 100%;
flex-wrap: wrap;
}

View File

@@ -29,6 +29,7 @@ import {
ApplicationMenu,
Search,
Copy,
CopyLink,
Loading,
Rss,
MessageEmoji,
@@ -111,6 +112,7 @@ export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component('ApplicationMenu', ApplicationMenu)
nuxtApp.vueApp.component('SearchIcon', Search)
nuxtApp.vueApp.component('Copy', Copy)
nuxtApp.vueApp.component('CopyLink', CopyLink)
nuxtApp.vueApp.component('Loading', Loading)
nuxtApp.vueApp.component('Rss', Rss)
nuxtApp.vueApp.component('MessageEmoji', MessageEmoji)

View File

@@ -157,6 +157,7 @@ const SANITIZE_CFG = {
'th',
'video',
'source',
'iframe',
],
// 允许的属性
allowedAttributes: {
@@ -180,6 +181,16 @@ const SANITIZE_CFG = {
'crossorigin',
],
source: ['src', 'type'],
iframe: [
'src',
'title',
'width',
'height',
'allow',
'allowfullscreen',
'frameborder',
'referrerpolicy',
],
},
// 允许的类名(保留你的样式钩子)
allowedClasses: {

View File

@@ -93,9 +93,8 @@ function getCircle(event) {
function withViewTransition(event, applyFn, direction = true) {
if (typeof document !== 'undefined' && document.startViewTransition) {
const transition = document.startViewTransition(async () => {
const transition = document.startViewTransition(() => {
applyFn()
await nextTick()
})
transition.ready
@@ -111,6 +110,7 @@ function withViewTransition(event, applyFn, direction = true) {
{
duration: 400,
easing: 'ease-in-out',
fill: 'both',
pseudoElement: direction
? '::view-transition-new(root)'
: '::view-transition-old(root)',

130
nginx/openisle Normal file
View File

@@ -0,0 +1,130 @@
server {
listen 443 ssl;
server_name open-isle.com www.open-isle.com;
ssl_certificate /etc/letsencrypt/live/open-isle.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/open-isle.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
add_header Cache-Control "no-store" always;
add_header X-Upstream $upstream_addr always;
}
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0" always;
proxy_no_cache 1;
proxy_cache_bypass 1;
}
# 通过 https://open-isle.com/rabbitmq/ 访问管理界面
location ^~ /rabbitmq/ {
# 关键点proxy_pass 以 "/" 结尾,保留后缀子路径映射
proxy_pass http://127.0.0.1:15672/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
# 把上游返回的绝对重定向 /... 改写为 /rabbitmq/...
proxy_redirect ~^(/.*)$ /rabbitmq$1;
# 为了做 HTML/CSS/JS 内绝对路径替换,需要关闭压缩
proxy_set_header Accept-Encoding "";
# 将页面中以 "/" 开头的 src/href 替换为 "/rabbitmq/..."
sub_filter_types text/html text/css application/javascript;
sub_filter 'href="/' 'href="/rabbitmq/';
sub_filter 'src="/' 'src="/rabbitmq/';
sub_filter_once off;
# 建议对管理台再加一道保护(可选)
# auth_basic "RabbitMQ Console";
# auth_basic_user_file /etc/nginx/.htpasswd;
}
# 通过 https://open-isle.com/docker/ 访问 Portainer上游是自签名 HTTPS
location ^~ /docker/ {
proxy_pass https://127.0.0.1:19000/; # 末尾 / 保留子路径
proxy_http_version 1.1;
# 上游是自签证书,关闭校验(仅内网/自签场景)
proxy_ssl_verify off;
# 透传头
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
# WebSocket/事件流Portainer 某些功能会用到)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
# 把上游返回的绝对重定向 /... 改写为 /docker/...
proxy_redirect ~^(/.*)$ /docker$1;
# 为了替换 HTML/CSS/JS 中的绝对路径,需要关闭压缩
proxy_set_header Accept-Encoding "";
# 将页面中以 "/" 开头的 src/href 替换为 "/docker/..."
sub_filter_types text/html text/css application/javascript;
sub_filter 'href="/' 'href="/docker/';
sub_filter 'src="/' 'src="/docker/';
sub_filter_once off;
# 可选:再加一道基本认证
# auth_basic "Portainer";
# auth_basic_user_file /etc/nginx/.htpasswd;
}
# ---------- WEBSOCKET GATEWAY TO :8082 ----------
location ^~ /websocket/ {
proxy_pass http://127.0.0.1:8084/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
add_header Cache-Control "no-store" always;
}
}
server {
listen 80;
server_name open-isle.com www.open-isle.com;
return 301 https://$host$request_uri;
}

133
nginx/openisle-staging Normal file
View File

@@ -0,0 +1,133 @@
# 放在 http { } 里一次定义
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
server_name staging.open-isle.com www.staging.open-isle.com;
ssl_certificate /etc/letsencrypt/live/staging.open-isle.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/staging.open-isle.com/privkey.pem;
# ssl_certificate /etc/letsencrypt/live/open-isle.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/open-isle.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# ---------- SSR ----------
location / {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
# 正确的升级头(仅在有 Upgrade 时)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# 透传真实主机/协议/源 IP
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
# 合理超时,避免 SSR 首屏慢查询导致 502/504
proxy_read_timeout 120s;
proxy_send_timeout 120s;
add_header Cache-Control "no-store" always;
add_header X-Upstream $upstream_addr always;
}
# 1) 原生 WebSocket
location ^~ /api/ws {
proxy_pass http://127.0.0.1:8081; # 不要尾随 /,保留原样 URI
proxy_http_version 1.1;
# 升级所需
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# 统一透传这些头(你在 /api/ 有,/api/ws 也要有)
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
}
# 2) SockJS包含 /info、/iframe.html、/.../websocket 等)
location ^~ /api/sockjs {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
# 如要同源 iframe 回退,下面两行二选一(或者交给 Spring Security 的 sameOrigin
# proxy_hide_header X-Frame-Options;
# add_header X-Frame-Options "SAMEORIGIN" always;
}
# ---------- API ----------
location /api/ {
proxy_pass http://127.0.0.1:8081/api/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 120s;
proxy_send_timeout 120s;
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0" always;
proxy_no_cache 1;
proxy_cache_bypass 1;
}
# ---------- WEBSOCKET GATEWAY TO :8083 ----------
location ^~ /websocket/ {
proxy_pass http://127.0.0.1:8083/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
add_header Cache-Control "no-store" always;
}
}