Merge pull request #304 from Hellodwadawd12312312/feature

添加搜索类型的翻译
This commit is contained in:
Alger
2025-06-09 10:41:25 +08:00
committed by GitHub
6 changed files with 32 additions and 39 deletions
+7
View File
@@ -16,5 +16,12 @@ export default {
noMore: 'No more results', noMore: 'No more results',
error: { error: {
searchFailed: 'Search failed' searchFailed: 'Search failed'
},
search: {
single: 'Single',
album: 'Album',
playlist: 'Playlist',
mv: 'MV',
bilibili: 'Bilibili'
} }
}; };
+7
View File
@@ -16,5 +16,12 @@ export default {
noMore: '没有更多了', noMore: '没有更多了',
error: { error: {
searchFailed: '搜索失败' searchFailed: '搜索失败'
},
search: {
single: '单曲',
album: '专辑',
playlist: '歌单',
mv: 'MV',
bilibili: 'B站'
} }
}; };
+1 -1
View File
@@ -70,6 +70,6 @@ declare global {
// for type re-export // for type re-export
declare global { declare global {
// @ts-ignore // @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
import('vue') import('vue')
} }
-5
View File
@@ -13,17 +13,13 @@ declare module 'vue' {
NBadge: typeof import('naive-ui')['NBadge'] NBadge: typeof import('naive-ui')['NBadge']
NButton: typeof import('naive-ui')['NButton'] NButton: typeof import('naive-ui')['NButton']
NButtonGroup: typeof import('naive-ui')['NButtonGroup'] NButtonGroup: typeof import('naive-ui')['NButtonGroup']
NCard: typeof import('naive-ui')['NCard']
NCarousel: typeof import('naive-ui')['NCarousel'] NCarousel: typeof import('naive-ui')['NCarousel']
NCarouselItem: typeof import('naive-ui')['NCarouselItem'] NCarouselItem: typeof import('naive-ui')['NCarouselItem']
NCheckbox: typeof import('naive-ui')['NCheckbox'] NCheckbox: typeof import('naive-ui')['NCheckbox']
NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup'] NCheckboxGroup: typeof import('naive-ui')['NCheckboxGroup']
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDivider: typeof import('naive-ui')['NDivider']
NDrawer: typeof import('naive-ui')['NDrawer'] NDrawer: typeof import('naive-ui')['NDrawer']
NDrawerContent: typeof import('naive-ui')['NDrawerContent'] NDrawerContent: typeof import('naive-ui')['NDrawerContent']
NDropdown: typeof import('naive-ui')['NDropdown'] NDropdown: typeof import('naive-ui')['NDropdown']
@@ -41,7 +37,6 @@ declare module 'vue' {
NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal'] NModal: typeof import('naive-ui')['NModal']
NPopover: typeof import('naive-ui')['NPopover'] NPopover: typeof import('naive-ui')['NPopover']
NProgress: typeof import('naive-ui')['NProgress']
NRadio: typeof import('naive-ui')['NRadio'] NRadio: typeof import('naive-ui')['NRadio']
NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NRadioGroup: typeof import('naive-ui')['NRadioGroup']
NScrollbar: typeof import('naive-ui')['NScrollbar'] NScrollbar: typeof import('naive-ui')['NScrollbar']
+6 -29
View File
@@ -23,51 +23,28 @@ export const USER_SET_OPTIONS = [
export const SEARCH_TYPES = [ export const SEARCH_TYPES = [
{ {
label: '单曲', label: 'search.search.single', // 单曲
key: 1 key: 1
}, },
{ {
label: '专辑', label: 'search.search.album', // 专辑
key: 10 key: 10
}, },
// {
// label: '歌手',
// key: 100,
// },
{ {
label: '歌单', label: 'search.search.playlist', // 歌单
key: 1000 key: 1000
}, },
// {
// label: '用户',
// key: 1002,
// },
{ {
label: 'MV', label: 'search.search.mv', // MV
key: 1004 key: 1004
}, },
{ {
label: 'B站', label: 'search.search.bilibili', // B站
key: 2000 key: 2000
} }
// {
// label: '歌词',
// key: 1006,
// },
// {
// label: '电台',
// key: 1009,
// },
// {
// label: '视频',
// key: 1014,
// },
// {
// label: '综合',
// key: 1018,
// },
]; ];
export const SEARCH_TYPE = { export const SEARCH_TYPE = {
MUSIC: 1, // 单曲 MUSIC: 1, // 单曲
ALBUM: 10, // 专辑 ALBUM: 10, // 专辑
+11 -4
View File
@@ -19,7 +19,7 @@
<n-dropdown trigger="hover" :options="searchTypeOptions" @select="selectSearchType"> <n-dropdown trigger="hover" :options="searchTypeOptions" @select="selectSearchType">
<div class="w-20 px-3 flex justify-between items-center"> <div class="w-20 px-3 flex justify-between items-center">
<div> <div>
{{ searchTypeOptions.find((item) => item.key === searchStore.searchType)?.label }} {{ searchTypeOptions.find(item => item.key === searchStore.searchType)?.label }}
</div> </div>
<i class="iconfont icon-xiasanjiaoxing"></i> <i class="iconfont icon-xiasanjiaoxing"></i>
</div> </div>
@@ -126,7 +126,6 @@
import { computed, onMounted, ref, watch, watchEffect } from 'vue'; import { computed, onMounted, ref, watch, watchEffect } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { getSearchKeyword } from '@/api/home'; import { getSearchKeyword } from '@/api/home';
import { getUserDetail } from '@/api/login'; import { getUserDetail } from '@/api/login';
import alipay from '@/assets/alipay.png'; import alipay from '@/assets/alipay.png';
@@ -147,7 +146,7 @@ const searchStore = useSearchStore();
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const userStore = useUserStore(); const userStore = useUserStore();
const userSetOptions = ref(USER_SET_OPTIONS); const userSetOptions = ref(USER_SET_OPTIONS);
const { t } = useI18n(); const { t, locale } = useI18n();
// 使用缩放hook // 使用缩放hook
const { const {
@@ -271,7 +270,15 @@ const selectSearchType = (key: number) => {
} }
}; };
const searchTypeOptions = ref(SEARCH_TYPES); const rawSearchTypes = ref(SEARCH_TYPES)
const searchTypeOptions = computed(() => {
// 引用 locale 以创建响应式依赖
locale.value;
return rawSearchTypes.value.map(type => ({
label: t(type.label),
key: type.key
}))
});
const selectItem = async (key: string) => { const selectItem = async (key: string) => {
// switch 判断 // switch 判断