Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/components/HitokotoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default {
refreshInterval: 60,
kvConfig: {
sources: ['zhaoyu'],
sensitiveWords: []
sensitiveWords: [],
hitokotoCategories: []
},
sentence: '',
author: '',
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() : '')
Comment on lines +160 to +165
const res = await axios.get(url)
data = res.data
content = data.hitokoto
author = data.from_who
Expand Down
39 changes: 37 additions & 2 deletions src/components/HitokotoSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@
</div>
</v-list-item>

<v-list-item v-if="kvConfig.sources.includes('hitokoto')">
<v-list-item-title class="mb-2">一言句子类型</v-list-item-title>
<div class="text-caption text-grey mb-2">不选则返回所有类型;可多选。</div>
<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"
Comment on lines +55 to +59
hide-details
density="compact"
class="mr-4"
:disabled="loading"
@update:model-value="saveKvSettings"
/>
Comment on lines +53 to +65
</div>
</v-list-item>

<v-list-item v-if="kvConfig.sources.includes('jinrishici')">
<v-text-field
v-model="kvConfig.jinrishiciToken"
Expand Down Expand Up @@ -278,8 +297,23 @@ export default {
kvConfig: {
sources: ['zhaoyu'],
sensitiveWords: '',
jinrishiciToken: null
jinrishiciToken: null,
hitokotoCategories: []
},
hitokotoCategories: [
{ value: 'a', label: '动画' },
{ value: 'b', label: '漫画' },
{ value: 'c', label: '游戏' },
{ value: 'd', label: '文学' },
{ value: 'e', label: '原创' },
{ value: 'f', label: '来自网络' },
{ value: 'g', label: '其他' },
{ value: 'h', label: '影视' },
{ value: 'i', label: '诗词' },
{ value: 'j', label: '网易云' },
{ value: 'k', label: '哲学' },
{ value: 'l', label: '抖机灵' }
],
loading: false,
testLoading: false,
testMessage: '',
Expand All @@ -306,7 +340,8 @@ export default {
this.kvConfig = {
sources: Array.isArray(data.sources) ? data.sources : ['zhaoyu'],
sensitiveWords: data.sensitiveWords || '',
jinrishiciToken: data.jinrishiciToken
jinrishiciToken: data.jinrishiciToken,
hitokotoCategories: Array.isArray(data.hitokotoCategories) ? data.hitokotoCategories : []
}
}
} catch (e) {
Expand Down
Loading