Compare commits

...

3 Commits

3 changed files with 28 additions and 13 deletions

View File

@ -64,6 +64,8 @@ function toBase62(n: number): string {
}
export function getConfig(): UserConfig {
const localesHash = toBase62(hash(JSON.stringify(locales)));
return {
base: '/embed_vite/',
@ -148,9 +150,9 @@ export function getConfig(): UserConfig {
// dependencies of i18n.ts
'config': ['@@/js/config.js'],
},
entryFileNames: 'scripts/[hash:8].js',
chunkFileNames: 'scripts/[hash:8].js',
assetFileNames: 'assets/[hash:8][extname]',
entryFileNames: `scripts/${localesHash}-[hash:8].js`,
chunkFileNames: `scripts/${localesHash}-[hash:8].js`,
assetFileNames: `assets/${localesHash}-[hash:8][extname]`,
paths(id) {
for (const p of externalPackages) {
if (p.match.test(id)) {

View File

@ -133,7 +133,7 @@ function applyThemeInternal(theme: Theme, persist: boolean) {
let timeout: number | null = null;
let currentTheme: Theme | null = null;
export function applyTheme(theme: Theme, persist = true) {
export async function applyTheme(theme: Theme, persist = true) {
if (timeout) {
window.clearTimeout(timeout);
timeout = null;
@ -144,15 +144,26 @@ export function applyTheme(theme: Theme, persist = true) {
currentTheme = deepClone(theme);
if (window.document.startViewTransition != null) {
window.document.documentElement.classList.add('_themeChanging_');
window.document.startViewTransition(async () => {
applyThemeInternal(theme, persist);
await nextTick();
}).finished.then(() => {
// startViewTransitionはいくつかの理由でエラーになることがあり、特にここはブートエラーになりやすいのでエラーハンドリングする
// See https://github.com/misskey-dev/misskey/issues/16562
let applied = false;
try {
window.document.documentElement.classList.add('_themeChanging_');
await window.document.startViewTransition(async () => {
applyThemeInternal(theme, persist);
applied = true;
await nextTick();
}).finished;
} catch (e) {
console.error('applyTheme: something happened while ViewTransition', e);
if (!applied) applyThemeInternal(theme, persist);
} finally {
window.document.documentElement.classList.remove('_themeChanging_');
// 色計算など再度行えるようにクライアント全体に通知
globalEvents.emit('themeChanged');
});
}
} else {
applyThemeInternal(theme, persist);
// 色計算など再度行えるようにクライアント全体に通知

View File

@ -85,6 +85,8 @@ export function toBase62(n: number): string {
}
export function getConfig(): UserConfig {
const localesHash = toBase62(hash(JSON.stringify(locales)));
return {
base: '/vite/',
@ -188,9 +190,9 @@ export function getConfig(): UserConfig {
// dependencies of i18n.ts
'config': ['@@/js/config.js'],
},
entryFileNames: 'scripts/[hash:8].js',
chunkFileNames: 'scripts/[hash:8].js',
assetFileNames: 'assets/[hash:8][extname]',
entryFileNames: `scripts/${localesHash}-[hash:8].js`,
chunkFileNames: `scripts/${localesHash}-[hash:8].js`,
assetFileNames: `assets/${localesHash}-[hash:8][extname]`,
paths(id) {
for (const p of externalPackages) {
if (p.match.test(id)) {