[WIP] Add playground configuration rules and backend adjustments #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
好的,这个改动可以分成三块:配置设计、后端逻辑调整、文档说明。
下面直接给出新的规则和需要修改的点。
一、配置规则(新的行为)
新增/统一成类似配置(示例):
行为逻辑:
enabled = false(默认)/playground页面不可访问(前端路由跳转到提示页或 404)。/v2/playground/**)直接拒绝(例如 403/404)。enabled = true且有passwordenabled = true且没有配置密码(空字符串 / null)二、后端逻辑需要调整的点
1. 去掉“默认有密码”的逻辑
之前的思路是:
public为 true 才开放。现在改为:
enabled控制是否开启;password是否为空控制是否需要输入密码。伪代码调整:
访问检查
所有 playground 相关接口(以及
/playground页面)在进入时做:登录接口逻辑
POST /v2/playground/login:状态接口(给前端用)
GET /v2/playground/status返回类似结构:{ "enabled": true, "needPassword": true, "authed": false }实现逻辑:
三、前端 Playground 行为调整
前端
Playground.vue逻辑调整为:/v2/playground/status:enabled = false:提示“Playground 未开启”并不加载编辑器。enabled = true & needPassword = true & !authed:显示密码输入框。initPlayground()加载 TS 编译器、编辑器等。伪代码:
模板:
!enabled:显示“Playground 未开启,由管理员在配置中启用后方可使用”;enabled && needPassword && !authed:显示密码输入框;enabled && (!needPassword || authed):显示原有 playground 内容(带加载动画)。四、文档改动建议
在你现在已有的 TS 演练场文档(
TYPESCRIPT_PLAYGROUND_GUIDE.md或单独的配置文档)中增加一节「访问控制 / 安全」。示例文案要点(简化版):
访问控制与安全
配置示例:
行为说明:
enabled = false(默认)/playground页面和相关 API 不可访问。enabled = true且password非空/playground时需要输入密码。enabled = true且password为空**...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.