Add Hitokoto API category filter support#50
Merged
Conversation
Closed
Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6de2bd3a-dd64-4f26-a5a5-0f7fed081fdc Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
Deploying classworks with
|
| Latest commit: |
91169b0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a305e701.classworks.pages.dev |
| Branch Preview URL: | https://copilot-add-custom-parameter.classworks.pages.dev |
Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6de2bd3a-dd64-4f26-a5a5-0f7fed081fdc Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add custom parameters for Hitokoto API
Add Hitokoto API category filter support
Apr 11, 2026
There was a problem hiding this comment.
Pull request overview
Adds category filtering support for the Hitokoto (一言) sentence source by persisting selected API categories to the shared sentence-info cloud KV config and applying them when building the Hitokoto request URL.
Changes:
- Added a “一言句子类型” multi-select UI (a–l) in
HitokotoSettings.vue, persisted ashitokotoCategories: string[]in KV. - Extended both settings/card KV load defaults to include
hitokotoCategories. - Updated
HitokotoCard.vueto append repeatedcquery params (?c=a&c=c...) when categories are selected.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/components/HitokotoSettings.vue | Adds category checkbox UI and KV persistence/loading for hitokotoCategories. |
| src/components/HitokotoCard.vue | Builds Hitokoto API URL with optional category query params sourced from KV. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+59
| v-for="cat in hitokotoCategories" | ||
| :key="cat.value" | ||
| v-model="kvConfig.hitokotoCategories" | ||
| :label="cat.label" | ||
| :value="cat.value" |
Comment on lines
+53
to
+65
| <div class="d-flex flex-wrap gap-2"> | ||
| <v-checkbox | ||
| v-for="cat in hitokotoCategories" | ||
| :key="cat.value" | ||
| v-model="kvConfig.hitokotoCategories" | ||
| :label="cat.label" | ||
| :value="cat.value" | ||
| hide-details | ||
| density="compact" | ||
| class="mr-4" | ||
| :disabled="loading" | ||
| @update:model-value="saveKvSettings" | ||
| /> |
Comment on lines
+160
to
+165
| const params = new URLSearchParams() | ||
| const categories = this.kvConfig.hitokotoCategories | ||
| if (Array.isArray(categories) && categories.length > 0) { | ||
| categories.forEach(cat => params.append('c', cat)) | ||
| } | ||
| const url = 'https://v1.hitokoto.cn/' + (params.toString() ? '?' + params.toString() : '') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Hitokoto (一言) source had no way to filter by sentence type — every request returned a random sentence from all categories. This adds per-category selection, stored in cloud KV config so it applies across all devices in a classroom.
Changes
HitokotoSettings.vuehitokotoCategories: string[]in the existingsentence-infoKV configHitokotoCard.vue?c=a&c=c&...params from storedhitokotoCategorieswhen categories are selected