wip
This commit is contained in:
parent
0a0c93df2a
commit
bc02fd5c4d
|
@ -127,7 +127,9 @@ rt {
|
||||||
}
|
}
|
||||||
|
|
||||||
._button {
|
._button {
|
||||||
@extend ._noSelect;
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
@ -7,15 +7,10 @@
|
||||||
// よって、devモードとして起動されるときはビルド時に組み込む形としておく。
|
// よって、devモードとして起動されるときはビルド時に組み込む形としておく。
|
||||||
// (pnpm start時はpugファイルの中で静的リソースとして読み込むようになっており、この問題は起こっていない)
|
// (pnpm start時はpugファイルの中で静的リソースとして読み込むようになっており、この問題は起こっていない)
|
||||||
import '@tabler/icons-webfont/dist/tabler-icons.scss';
|
import '@tabler/icons-webfont/dist/tabler-icons.scss';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
await main();
|
await main();
|
||||||
|
|
||||||
if (embedPage) {
|
import('@/_boot_.js');
|
||||||
import('@/_embed_boot_.js');
|
|
||||||
} else {
|
|
||||||
import('@/_boot_.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backend/src/server/web/boot.jsで差し込まれている起動処理のうち、最低限必要なものを模倣するための処理
|
* backend/src/server/web/boot.jsで差し込まれている起動処理のうち、最低限必要なものを模倣するための処理
|
||||||
|
|
|
@ -14,7 +14,6 @@ import { apiUrl } from '@/config.js';
|
||||||
import { waiting, popup, popupMenu, success, alert } from '@/os.js';
|
import { waiting, popup, popupMenu, success, alert } from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js';
|
import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
// TODO: 他のタブと永続化されたstateを同期
|
// TODO: 他のタブと永続化されたstateを同期
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ type Account = Misskey.entities.MeDetailed & { token: string };
|
||||||
const accountData = miLocalStorage.getItem('account');
|
const accountData = miLocalStorage.getItem('account');
|
||||||
|
|
||||||
function initAccount() {
|
function initAccount() {
|
||||||
if (embedPage) return null;
|
|
||||||
if (accountData) return reactive(JSON.parse(accountData) as Account);
|
if (accountData) return reactive(JSON.parse(accountData) as Account);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -85,14 +83,10 @@ export async function signout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAccounts(): Promise<{ id: Account['id'], token: Account['token'] }[]> {
|
export async function getAccounts(): Promise<{ id: Account['id'], token: Account['token'] }[]> {
|
||||||
if (embedPage) return [];
|
|
||||||
|
|
||||||
return (await get('accounts')) || [];
|
return (await get('accounts')) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addAccount(id: Account['id'], token: Account['token']) {
|
export async function addAccount(id: Account['id'], token: Account['token']) {
|
||||||
if (embedPage) return;
|
|
||||||
|
|
||||||
const accounts = await getAccounts();
|
const accounts = await getAccounts();
|
||||||
if (!accounts.some(x => x.id === id)) {
|
if (!accounts.some(x => x.id === id)) {
|
||||||
await set('accounts', accounts.concat([{ id, token }]));
|
await set('accounts', accounts.concat([{ id, token }]));
|
||||||
|
@ -194,8 +188,6 @@ export async function refreshAccount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function login(token: Account['token'], redirect?: string) {
|
export async function login(token: Account['token'], redirect?: string) {
|
||||||
if (embedPage) return;
|
|
||||||
|
|
||||||
const showing = ref(true);
|
const showing = ref(true);
|
||||||
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkWaitingDialog.vue')), {
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkWaitingDialog.vue')), {
|
||||||
success: false,
|
success: false,
|
||||||
|
|
|
@ -8,7 +8,6 @@ import * as Misskey from 'misskey-js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js';
|
import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
// TODO: 他のタブと永続化されたstateを同期
|
// TODO: 他のタブと永続化されたstateを同期
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ export const infoImageUrl = computed(() => instance.infoImageUrl ?? DEFAULT_INFO
|
||||||
|
|
||||||
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
|
export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFAULT_NOT_FOUND_IMAGE_URL);
|
||||||
|
|
||||||
export const isEnabledUrlPreview = computed(() => (instance.enableUrlPreview ?? true) && !embedPage);
|
export const isEnabledUrlPreview = computed(() => instance.enableUrlPreview ?? true);
|
||||||
|
|
||||||
export async function fetchInstance(force = false): Promise<Misskey.entities.MetaDetailed> {
|
export async function fetchInstance(force = false): Promise<Misskey.entities.MetaDetailed> {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
set as iset,
|
set as iset,
|
||||||
del as idel,
|
del as idel,
|
||||||
} from 'idb-keyval';
|
} from 'idb-keyval';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
|
|
||||||
const PREFIX = 'idbfallback::';
|
const PREFIX = 'idbfallback::';
|
||||||
|
@ -27,10 +26,7 @@ if (window.Cypress) {
|
||||||
console.log('Cypress detected. It will use localStorage.');
|
console.log('Cypress detected. It will use localStorage.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embedPage) {
|
if (idbAvailable) {
|
||||||
idbAvailable = false;
|
|
||||||
console.log('Embed page detected. It will use safeSessionStorage.');
|
|
||||||
} else if (idbAvailable) {
|
|
||||||
await iset('idb-test', 'test')
|
await iset('idb-test', 'test')
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('idb error', err);
|
console.error('idb error', err);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { defineAsyncComponent, inject } from 'vue';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { popup } from '@/os.js';
|
import { popup } from '@/os.js';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
export type OpenOnRemoteOptions = {
|
export type OpenOnRemoteOptions = {
|
||||||
/**
|
/**
|
||||||
|
@ -48,22 +47,18 @@ export type OpenOnRemoteOptions = {
|
||||||
export function pleaseLogin(path?: string, openOnRemote?: OpenOnRemoteOptions) {
|
export function pleaseLogin(path?: string, openOnRemote?: OpenOnRemoteOptions) {
|
||||||
if ($i) return;
|
if ($i) return;
|
||||||
|
|
||||||
if (embedPage) {
|
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
|
||||||
window.open(path ?? '/', '_blank', 'noopener');
|
autoSet: true,
|
||||||
} else {
|
message: openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired,
|
||||||
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
|
openOnRemote,
|
||||||
autoSet: true,
|
}, {
|
||||||
message: openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired,
|
cancelled: () => {
|
||||||
openOnRemote,
|
if (path) {
|
||||||
}, {
|
window.location.href = path;
|
||||||
cancelled: () => {
|
}
|
||||||
if (path) {
|
},
|
||||||
window.location.href = path;
|
closed: () => dispose(),
|
||||||
}
|
});
|
||||||
},
|
|
||||||
closed: () => dispose(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error('signin required');
|
throw new Error('signin required');
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { globalEvents } from '@/events.js';
|
||||||
import lightTheme from '@/themes/_light.json5';
|
import lightTheme from '@/themes/_light.json5';
|
||||||
import darkTheme from '@/themes/_dark.json5';
|
import darkTheme from '@/themes/_dark.json5';
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
export type Theme = {
|
export type Theme = {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -96,9 +95,7 @@ export function applyTheme(theme: Theme, persist = true) {
|
||||||
document.documentElement.style.setProperty(`--${k}`, v.toString());
|
document.documentElement.style.setProperty(`--${k}`, v.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!embedPage) {
|
document.documentElement.style.setProperty('color-scheme', colorScheme);
|
||||||
document.documentElement.style.setProperty('color-scheme', colorScheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (persist) {
|
if (persist) {
|
||||||
miLocalStorage.setItem('theme', JSON.stringify(props));
|
miLocalStorage.setItem('theme', JSON.stringify(props));
|
||||||
|
|
|
@ -7,8 +7,7 @@ import * as Misskey from 'misskey-js';
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
import { wsOrigin } from '@/config.js';
|
import { wsOrigin } from '@/config.js';
|
||||||
import { StreamMock } from '@/scripts/stream-mock.js';
|
//import { StreamMock } from '@/scripts/stream-mock.js';
|
||||||
import { embedPage } from '@/config.js';
|
|
||||||
|
|
||||||
// heart beat interval in ms
|
// heart beat interval in ms
|
||||||
const HEART_BEAT_INTERVAL = 1000 * 60;
|
const HEART_BEAT_INTERVAL = 1000 * 60;
|
||||||
|
@ -21,14 +20,9 @@ export function useStream(): Misskey.IStream {
|
||||||
if (stream) return stream;
|
if (stream) return stream;
|
||||||
|
|
||||||
// TODO: No Websocketモードもここで判定
|
// TODO: No Websocketモードもここで判定
|
||||||
if (embedPage) {
|
stream = markRaw(new Misskey.Stream(wsOrigin, $i ? {
|
||||||
stream = markRaw(new StreamMock(wsOrigin, null));
|
token: $i.token,
|
||||||
return stream;
|
} : null));
|
||||||
} else {
|
|
||||||
stream = markRaw(new Misskey.Stream(wsOrigin, $i ? {
|
|
||||||
token: $i.token,
|
|
||||||
} : null));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat);
|
if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat);
|
||||||
timeoutHeartBeat = window.setTimeout(heartbeat, HEART_BEAT_INTERVAL);
|
timeoutHeartBeat = window.setTimeout(heartbeat, HEART_BEAT_INTERVAL);
|
||||||
|
|
Loading…
Reference in a new issue