From 6f697d0fd0a5d9f93f3b61d26db9ac79708be68d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Apr 2026 13:38:31 +0000 Subject: [PATCH 2/3] Add Hitokoto API category customization support Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6de2bd3a-dd64-4f26-a5a5-0f7fed081fdc Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com> --- src/components/HitokotoCard.vue | 14 ++++++++--- src/components/HitokotoSettings.vue | 39 +++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/components/HitokotoCard.vue b/src/components/HitokotoCard.vue index 6cbf3fd..a0bf03b 100644 --- a/src/components/HitokotoCard.vue +++ b/src/components/HitokotoCard.vue @@ -61,7 +61,8 @@ export default { refreshInterval: 60, kvConfig: { sources: ['zhaoyu'], - sensitiveWords: [] + sensitiveWords: [], + hitokotoCategories: [] }, sentence: '', author: '', @@ -125,7 +126,8 @@ export default { this.kvConfig = { sources: Array.isArray(data.sources) && data.sources.length > 0 ? data.sources : ['zhaoyu'], sensitiveWords: data.sensitiveWords ? data.sensitiveWords.split(/[,,]/).map(w => w.trim()).filter(w => w) : [], - jinrishiciToken: data.jinrishiciToken + jinrishiciToken: data.jinrishiciToken, + hitokotoCategories: Array.isArray(data.hitokotoCategories) ? data.hitokotoCategories : [] } } } catch (e) { @@ -155,7 +157,13 @@ export default { let origin = '' if (source === 'hitokoto') { - const res = await axios.get('https://v1.hitokoto.cn/') + 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() : '') + const res = await axios.get(url) data = res.data content = data.hitokoto author = data.from_who diff --git a/src/components/HitokotoSettings.vue b/src/components/HitokotoSettings.vue index 26555e7..75efd00 100644 --- a/src/components/HitokotoSettings.vue +++ b/src/components/HitokotoSettings.vue @@ -47,6 +47,25 @@ + + 一言句子类型 +
不选则返回所有类型;可多选。
+
+ +
+
+ Date: Sat, 11 Apr 2026 13:38:58 +0000 Subject: [PATCH 3/3] Remove trailing comma in hitokotoCategories array Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6de2bd3a-dd64-4f26-a5a5-0f7fed081fdc Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com> --- src/components/HitokotoSettings.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HitokotoSettings.vue b/src/components/HitokotoSettings.vue index 75efd00..2bce7af 100644 --- a/src/components/HitokotoSettings.vue +++ b/src/components/HitokotoSettings.vue @@ -312,7 +312,7 @@ export default { { value: 'i', label: '诗词' }, { value: 'j', label: '网易云' }, { value: 'k', label: '哲学' }, - { value: 'l', label: '抖机灵' }, + { value: 'l', label: '抖机灵' } ], loading: false, testLoading: false,