diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2022-05-30 05:53:40 +0000 |
|---|---|---|
| committer | tamaina <tamaina@hotmail.co.jp> | 2022-05-30 05:53:40 +0000 |
| commit | 465531d56c5475f7d0be327950c33f715477c441 (patch) | |
| tree | 223baf3bb26d44fadb105b851c2695f7644afd27 /packages/client/src/scripts | |
| parent | chore: remove packages/sw/webpack.config.js (diff) | |
| parent | fix(client): import shared ESLint config in client package (#8761) (diff) | |
| download | misskey-465531d56c5475f7d0be327950c33f715477c441.tar.gz misskey-465531d56c5475f7d0be327950c33f715477c441.tar.bz2 misskey-465531d56c5475f7d0be327950c33f715477c441.zip | |
Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
Diffstat (limited to 'packages/client/src/scripts')
| -rw-r--r-- | packages/client/src/scripts/please-login.ts | 19 | ||||
| -rw-r--r-- | packages/client/src/scripts/popout.ts | 5 | ||||
| -rw-r--r-- | packages/client/src/scripts/theme.ts | 49 |
3 files changed, 45 insertions, 28 deletions
diff --git a/packages/client/src/scripts/please-login.ts b/packages/client/src/scripts/please-login.ts index aeaafa124b..e21a6d2ed3 100644 --- a/packages/client/src/scripts/please-login.ts +++ b/packages/client/src/scripts/please-login.ts @@ -1,14 +1,21 @@ +import { defineAsyncComponent } from 'vue'; import { $i } from '@/account'; import { i18n } from '@/i18n'; -import { alert } from '@/os'; +import { popup } from '@/os'; -export function pleaseLogin() { +export function pleaseLogin(path?: string) { if ($i) return; - alert({ - title: i18n.ts.signinRequired, - text: null - }); + popup(defineAsyncComponent(() => import('@/components/signin-dialog.vue')), { + autoSet: true, + message: i18n.ts.signinRequired + }, { + cancelled: () => { + if (path) { + window.location.href = path; + } + }, + }, 'closed'); throw new Error('signin required'); } diff --git a/packages/client/src/scripts/popout.ts b/packages/client/src/scripts/popout.ts index b8286a2a76..580031d0a3 100644 --- a/packages/client/src/scripts/popout.ts +++ b/packages/client/src/scripts/popout.ts @@ -1,8 +1,9 @@ import * as config from '@/config'; +import { appendQuery } from './url'; export function popout(path: string, w?: HTMLElement) { - let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + "/" + path; - url += '?zen'; + let url = path.startsWith('http://') || path.startsWith('https://') ? path : config.url + path; + url = appendQuery(url, 'zen'); if (w) { const position = w.getBoundingClientRect(); const width = parseInt(getComputedStyle(w, '').width, 10); diff --git a/packages/client/src/scripts/theme.ts b/packages/client/src/scripts/theme.ts index b61b1684a8..e2b272405a 100644 --- a/packages/client/src/scripts/theme.ts +++ b/packages/client/src/scripts/theme.ts @@ -1,3 +1,4 @@ +import { ref } from 'vue'; import { globalEvents } from '@/events'; import tinycolor from 'tinycolor2'; @@ -10,30 +11,38 @@ export type Theme = { props: Record<string, string>; }; -export const lightTheme: Theme = await import('@/themes/_light.json5'); -export const darkTheme: Theme = await import('@/themes/_dark.json5'); +import lightTheme from '@/themes/_light.json5'; +import darkTheme from '@/themes/_dark.json5'; export const themeProps = Object.keys(lightTheme.props).filter(key => !key.startsWith('X')); -export const builtinThemes = [ - await import('@/themes/l-light.json5'), - await import('@/themes/l-coffee.json5'), - await import('@/themes/l-apricot.json5'), - await import('@/themes/l-rainy.json5'), - await import('@/themes/l-vivid.json5'), - await import('@/themes/l-cherry.json5'), - await import('@/themes/l-sushi.json5'), +export const getBuiltinThemes = () => Promise.all( + [ + 'l-light', + 'l-coffee', + 'l-apricot', + 'l-rainy', + 'l-vivid', + 'l-cherry', + 'l-sushi', - await import('@/themes/d-dark.json5'), - await import('@/themes/d-persimmon.json5'), - await import('@/themes/d-astro.json5'), - await import('@/themes/d-future.json5'), - await import('@/themes/d-botanical.json5'), - await import('@/themes/d-cherry.json5'), - await import('@/themes/d-ice.json5'), - await import('@/themes/d-pumpkin.json5'), - await import('@/themes/d-black.json5'), -] as Theme[]; + 'd-dark', + 'd-persimmon', + 'd-astro', + 'd-future', + 'd-botanical', + 'd-cherry', + 'd-ice', + 'd-pumpkin', + 'd-black', + ].map(name => import(`../themes/${name}.json5`).then(({ default: _default }): Theme => _default)) +); + +export const getBuiltinThemesRef = () => { + const builtinThemes = ref<Theme[]>([]); + getBuiltinThemes().then(themes => builtinThemes.value = themes); + return builtinThemes; +} let timeout = null; |