enhance(dev): 開発モード時にlocaleと型定義が自動的に再生成されるように (#12481)

* enhance: localeを任意のタイミングでリビルドできるように

* enhance: localeも監視し、必要であればlocaleをリビルドするように

* feat: devモードの時のみナビゲーションバーからキャッシュクリアができるように

* refactor: キャッシュクリア部分を共通化

* fix: localesのファイル変更イベントが取れないのを修正

* fix: replaceAllでコケるのを修正

* change: 開発モードに関係なくナビゲーションバーからキャッシュクリアできるように

* refactor: 必要のないリビルドをしないように

* update: CHANGELOG.md

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
yukineko
2023-11-30 14:48:02 +09:00
committed by GitHub
parent 4f6e098542
commit 22d6fa1fdf
8 changed files with 80 additions and 44 deletions

View File

@@ -12,6 +12,7 @@ import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { ui } from '@/config.js';
import { unisonReload } from '@/scripts/unison-reload.js';
import { clearCache } from './scripts/clear-cache.js';
export const navbarItemDef = reactive({
notifications: {
@@ -171,4 +172,11 @@ export const navbarItemDef = reactive({
show: computed(() => $i != null),
to: `/@${$i?.username}`,
},
cacheClear: {
title: i18n.ts.cacheClear,
icon: 'ti ti-trash',
action: (ev) => {
clearCache();
},
},
});

View File

@@ -33,13 +33,11 @@ import { i18n } from '@/i18n.js';
import MkInfo from '@/components/MkInfo.vue';
import MkSuperMenu from '@/components/MkSuperMenu.vue';
import { signout, $i } from '@/account.js';
import { unisonReload } from '@/scripts/unison-reload.js';
import { clearCache } from '@/scripts/clear-cache.js';
import { instance } from '@/instance.js';
import { useRouter } from '@/router.js';
import { definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
import * as os from '@/os.js';
import { miLocalStorage } from '@/local-storage.js';
import { fetchCustomEmojis } from '@/custom-emojis.js';
const indexInfo = {
title: i18n.ts.settings,
@@ -182,13 +180,7 @@ const menuDef = computed(() => [{
icon: 'ti ti-trash',
text: i18n.ts.clearCache,
action: async () => {
os.waiting();
miLocalStorage.removeItem('locale');
miLocalStorage.removeItem('theme');
miLocalStorage.removeItem('emojis');
miLocalStorage.removeItem('lastEmojisFetchedAt');
await fetchCustomEmojis(true);
unisonReload();
await clearCache();
},
}, {
type: 'button',

View File

@@ -0,0 +1,14 @@
import { unisonReload } from '@/scripts/unison-reload.js';
import * as os from '@/os.js';
import { miLocalStorage } from '@/local-storage.js';
import { fetchCustomEmojis } from '@/custom-emojis.js';
export async function clearCache() {
os.waiting();
miLocalStorage.removeItem('locale');
miLocalStorage.removeItem('theme');
miLocalStorage.removeItem('emojis');
miLocalStorage.removeItem('lastEmojisFetchedAt');
await fetchCustomEmojis(true);
unisonReload();
}