(refactor) better types

This commit is contained in:
kakkokari-gtyih 2023-11-12 13:21:23 +09:00
parent f019a38fb4
commit e8a256e667
2 changed files with 11 additions and 4 deletions

View File

@ -9,7 +9,7 @@ import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
const baseUrl = 'https://misskey-hub.net'; const baseUrl = 'https://misskey-hub.net';
// 言語定義 // 言語定義
export const locales = [ export const localesConst = [
{ code: 'ja', iso: 'ja-JP', name: '日本語' }, { code: 'ja', iso: 'ja-JP', name: '日本語' },
{ code: 'en', iso: 'en-US', name: 'English' }, { code: 'en', iso: 'en-US', name: 'English' },
{ code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' }, { code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' },
@ -19,7 +19,11 @@ export const locales = [
{ code: 'fr', iso: 'fr-FR', name: 'Français' }, { code: 'fr', iso: 'fr-FR', name: 'Français' },
{ code: 'cn', iso: 'zh-CN', name: '简体中文' }, { code: 'cn', iso: 'zh-CN', name: '简体中文' },
{ code: 'tw', iso: 'zh-TW', name: '繁体中文' }, { code: 'tw', iso: 'zh-TW', name: '繁体中文' },
] as LocaleObject[]; ] as const;
export type LocaleCodes = typeof localesConst[number]['code'];
export const locales = localesConst as unknown as LocaleObject[];
export default defineNuxtConfig({ export default defineNuxtConfig({
runtimeConfig: { runtimeConfig: {

7
types/misc.d.ts vendored
View File

@ -1,3 +1,5 @@
import type { LocaleCodes } from './../nuxt.config';
declare module '*.svg' { declare module '*.svg' {
import { FunctionalComponent, SVGAttributes } from 'vue' import { FunctionalComponent, SVGAttributes } from 'vue'
const src: FunctionalComponent<SVGAttributes> const src: FunctionalComponent<SVGAttributes>
@ -5,7 +7,8 @@ declare module '*.svg' {
} }
declare module 'nuxt/schema' { declare module 'nuxt/schema' {
interface AppConfig {
interface CustomAppConfig {
/** お知らせ */ /** お知らせ */
notice?: { notice?: {
@ -27,7 +30,7 @@ declare module 'nuxt/schema' {
* ``` * ```
* *
**/ **/
title: { ja: string; } & Record<string, string>; title: { ja: string; } & Partial<Record<LocaleCodes, string>>;
/** /**
* *