From df3c8e5a1285b895debedd60018f13066cb5847c Mon Sep 17 00:00:00 2001 From: SunWuyuan Date: Sat, 1 Nov 2025 19:31:41 +0800 Subject: [PATCH] feat: Add ReadOnlyTokenWarning component and implement student name management dialog - Introduced ReadOnlyTokenWarning.vue to alert users when using a read-only token. - Added StudentNameManager.vue for managing student names with a dialog interface. - Implemented AlternativeCodeDialog.vue for entering alternative codes (functionality pending). - Created DeviceAuthDialog.vue for device authentication using namespace and password. - Developed FirstTimeGuide.vue to guide users through the initial setup of Classworks KV. - Added TokenInputDialog.vue for manual input of KV authorization tokens. - Updated settings.vue to include a button for opening Classworks KV. - Enhanced error handling and user feedback across components. --- src/components/InitServiceChooser.vue | 441 ++++++++---- src/components/MigrationTool.vue | 2 +- src/components/ReadOnlyTokenWarning.vue | 125 ++++ src/components/StudentNameManager.vue | 261 +++++++ src/components/auth/AlternativeCodeDialog.vue | 68 ++ src/components/auth/DeviceAuthDialog.vue | 198 ++++++ src/components/auth/FirstTimeGuide.vue | 671 ++++++++++++++++++ src/components/auth/README.md | 133 ++++ src/components/auth/TokenInputDialog.vue | 103 +++ .../settings/cards/CloudNamespaceInfoCard.vue | 40 +- src/pages/index.vue | 111 +++ src/pages/settings.vue | 4 + 12 files changed, 2003 insertions(+), 154 deletions(-) create mode 100644 src/components/ReadOnlyTokenWarning.vue create mode 100644 src/components/StudentNameManager.vue create mode 100644 src/components/auth/AlternativeCodeDialog.vue create mode 100644 src/components/auth/DeviceAuthDialog.vue create mode 100644 src/components/auth/FirstTimeGuide.vue create mode 100644 src/components/auth/README.md create mode 100644 src/components/auth/TokenInputDialog.vue diff --git a/src/components/InitServiceChooser.vue b/src/components/InitServiceChooser.vue index b8ab94d..078cabd 100644 --- a/src/components/InitServiceChooser.vue +++ b/src/components/InitServiceChooser.vue @@ -6,149 +6,201 @@
- 选择要使用的服务 + 欢迎使用 Classworks
- 左侧为 Classworks 管理端,右侧为 Classworks KV 控制台 + 请选择你的使用方式
-
- + +
+ -
-
-
- Classworks +
+
+ + mdi-new-box + +
+
+
+ 初次使用
-
- 适用于班级大屏的作业板工具 +
+ 了解 Classworks KV 并开始使用
- -
- - 开始使用 - - - 输入 Token - - - 使用本地模式 - -
- - -
- - - {{ verifyError }} - -
- - - 保存 Token - -
-
-
-
- + -
-
-
+
+
+ + mdi-account-check + +
+
+
+ 已注册 +
+
+ 使用设备 Namespace 登录 +
+
+
+ + + + + + +
+
+ + mdi-database-cog + +
+
+
Classworks KV
-
- 云原生键值数据库 +
+ 打开云端控制台管理数据
- -
- - 打开 Classworks KV - -
-
+
+ + 使用本地模式 + + + 授权码式授权(弃用) + + + 输入 Token + + + 输入替代代码 + +
+
+ + + + + + + + + + + + + + + + +
diff --git a/src/components/MigrationTool.vue b/src/components/MigrationTool.vue index ed5993d..00acab9 100644 --- a/src/components/MigrationTool.vue +++ b/src/components/MigrationTool.vue @@ -225,7 +225,7 @@ + + diff --git a/src/components/StudentNameManager.vue b/src/components/StudentNameManager.vue new file mode 100644 index 0000000..e4330c0 --- /dev/null +++ b/src/components/StudentNameManager.vue @@ -0,0 +1,261 @@ + + + + + diff --git a/src/components/auth/AlternativeCodeDialog.vue b/src/components/auth/AlternativeCodeDialog.vue new file mode 100644 index 0000000..07a5e08 --- /dev/null +++ b/src/components/auth/AlternativeCodeDialog.vue @@ -0,0 +1,68 @@ + + + diff --git a/src/components/auth/DeviceAuthDialog.vue b/src/components/auth/DeviceAuthDialog.vue new file mode 100644 index 0000000..0259dac --- /dev/null +++ b/src/components/auth/DeviceAuthDialog.vue @@ -0,0 +1,198 @@ + + + + + diff --git a/src/components/auth/FirstTimeGuide.vue b/src/components/auth/FirstTimeGuide.vue new file mode 100644 index 0000000..1b8e787 --- /dev/null +++ b/src/components/auth/FirstTimeGuide.vue @@ -0,0 +1,671 @@ + + + + + diff --git a/src/components/auth/README.md b/src/components/auth/README.md new file mode 100644 index 0000000..b0b337f --- /dev/null +++ b/src/components/auth/README.md @@ -0,0 +1,133 @@ +# 认证组件 + +这个目录包含可复用的认证相关组件,可以在应用的任何地方使用。 + +## 组件列表 + +### DeviceAuthDialog.vue +设备认证对话框,用于通过 namespace 和密码进行设备认证。 + +**Props:** +- `showCancel` (Boolean): 是否显示取消按钮,默认为 `false` + +**Events:** +- `@success`: 认证成功时触发,传递认证数据 +- `@cancel`: 点击取消按钮时触发 + +**暴露的方法:** +- `reset()`: 清空表单和错误信息 + +**使用示例:** +```vue + + + +``` + +--- + +### TokenInputDialog.vue +Token 输入对话框,用于手动输入 KV 授权 Token。 + +**Props:** +- `showCancel` (Boolean): 是否显示取消按钮,默认为 `false` + +**Events:** +- `@success`: Token 验证成功时触发 +- `@cancel`: 点击取消按钮时触发 + +**暴露的方法:** +- `reset()`: 清空表单和错误信息 + +**使用示例:** +```vue + + + +``` + +--- + +### AlternativeCodeDialog.vue +替代代码输入对话框(功能暂未实现)。 + +**Props:** +- `showCancel` (Boolean): 是否显示取消按钮,默认为 `false` + +**Events:** +- `@submit`: 提交代码时触发,传递代码内容 +- `@cancel`: 点击取消按钮时触发 + +**暴露的方法:** +- `reset()`: 清空表单 + +**使用示例:** +```vue + + + +``` + +--- + +### FirstTimeGuide.vue +初次使用指南,介绍 Classworks KV 的功能和使用方式。 + +**Events:** +- `@close`: 关闭指南时触发 + +**使用示例:** +```vue + + + +``` + +## 设计原则 + +1. **可复用性**: 所有组件都被设计为独立可复用的,可以在应用的任何地方使用 +2. **独立性**: 每个组件都包含自己的逻辑和样式,不依赖外部状态 +3. **统一接口**: 所有对话框组件都遵循相同的 props 和 events 模式 +4. **响应式设计**: 组件适配各种屏幕尺寸 + +## 注意事项 + +- 这些组件需要配合 Vuetify 使用 +- 组件内部使用了 `@/utils/settings` 和 `@/axios/axios`,确保这些依赖可用 +- 建议将这些组件包裹在 `v-dialog` 中使用,以获得最佳的用户体验 diff --git a/src/components/auth/TokenInputDialog.vue b/src/components/auth/TokenInputDialog.vue new file mode 100644 index 0000000..1ef7ed2 --- /dev/null +++ b/src/components/auth/TokenInputDialog.vue @@ -0,0 +1,103 @@ + + + diff --git a/src/components/settings/cards/CloudNamespaceInfoCard.vue b/src/components/settings/cards/CloudNamespaceInfoCard.vue index 974fecf..2089ac5 100644 --- a/src/components/settings/cards/CloudNamespaceInfoCard.vue +++ b/src/components/settings/cards/CloudNamespaceInfoCard.vue @@ -102,15 +102,35 @@ 刷新设备信息 - + 重新初始化云端存储 + + + + + 确认重新初始化 + + + 警告 + 此操作将清除当前的云端存储配置(包括 Token),您需要重新进行授权。 + +

您确定要重新初始化云端存储吗?

+
+ + + 取消 + 确认 + +
+