wip
This commit is contained in:
parent
a5f2163b07
commit
3143cf388e
|
@ -45,24 +45,6 @@ html {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.embed) {
|
|
||||||
&.f-1 {
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.f-2 {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.f-3 {
|
|
||||||
font-size: 17px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.useSystemFont {
|
|
||||||
font-family: system-ui;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
|
|
|
@ -21,13 +21,8 @@ type Account = Misskey.entities.MeDetailed & { token: string };
|
||||||
|
|
||||||
const accountData = miLocalStorage.getItem('account');
|
const accountData = miLocalStorage.getItem('account');
|
||||||
|
|
||||||
function initAccount() {
|
|
||||||
if (accountData) return reactive(JSON.parse(accountData) as Account);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: 外部からはreadonlyに
|
// TODO: 外部からはreadonlyに
|
||||||
export const $i = initAccount();
|
export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;
|
||||||
|
|
||||||
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
|
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
|
||||||
export const iAmAdmin = $i != null && $i.isAdmin;
|
export const iAmAdmin = $i != null && $i.isAdmin;
|
||||||
|
|
|
@ -21,7 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:direction="pagination.reversed ? 'up' : 'down'"
|
:direction="pagination.reversed ? 'up' : 'down'"
|
||||||
:reversed="pagination.reversed"
|
:reversed="pagination.reversed"
|
||||||
:noGap="noGap"
|
:noGap="noGap"
|
||||||
:ad="ad"
|
:ad="true"
|
||||||
:class="$style.notes"
|
:class="$style.notes"
|
||||||
>
|
>
|
||||||
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note" :withHardMute="true"/>
|
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note" :withHardMute="true"/>
|
||||||
|
@ -39,14 +39,11 @@ import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = defineProps<{
|
||||||
pagination: Paging;
|
pagination: Paging;
|
||||||
noGap?: boolean;
|
noGap?: boolean;
|
||||||
disableAutoLoad?: boolean;
|
disableAutoLoad?: boolean;
|
||||||
ad?: boolean;
|
}>();
|
||||||
}>(), {
|
|
||||||
ad: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();
|
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,6 @@ type PizzaxChannelMessage<T extends StateDef> = {
|
||||||
userId?: string;
|
userId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PizzaxConfig = {
|
|
||||||
disableMessageChannel: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Storage<T extends StateDef> {
|
export class Storage<T extends StateDef> {
|
||||||
public readonly ready: Promise<void>;
|
public readonly ready: Promise<void>;
|
||||||
public readonly loaded: Promise<void>;
|
public readonly loaded: Promise<void>;
|
||||||
|
@ -51,10 +47,6 @@ export class Storage<T extends StateDef> {
|
||||||
public readonly state: State<T>;
|
public readonly state: State<T>;
|
||||||
public readonly reactiveState: ReactiveState<T>;
|
public readonly reactiveState: ReactiveState<T>;
|
||||||
|
|
||||||
private options: PizzaxConfig = {
|
|
||||||
disableMessageChannel: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
private pizzaxChannel: BroadcastChannel<PizzaxChannelMessage<T>>;
|
private pizzaxChannel: BroadcastChannel<PizzaxChannelMessage<T>>;
|
||||||
|
|
||||||
// 簡易的にキューイングして占有ロックとする
|
// 簡易的にキューイングして占有ロックとする
|
||||||
|
@ -68,13 +60,12 @@ export class Storage<T extends StateDef> {
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(key: string, def: T, options?: Partial<PizzaxConfig>) {
|
constructor(key: string, def: T) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.deviceStateKeyName = `pizzax::${key}`;
|
this.deviceStateKeyName = `pizzax::${key}`;
|
||||||
this.deviceAccountStateKeyName = $i ? `pizzax::${key}::${$i.id}` : '';
|
this.deviceAccountStateKeyName = $i ? `pizzax::${key}::${$i.id}` : '';
|
||||||
this.registryCacheKeyName = $i ? `pizzax::${key}::cache::${$i.id}` : '';
|
this.registryCacheKeyName = $i ? `pizzax::${key}::cache::${$i.id}` : '';
|
||||||
this.def = def;
|
this.def = def;
|
||||||
this.options = Object.assign(this.options, options);
|
|
||||||
|
|
||||||
this.pizzaxChannel = new BroadcastChannel(`pizzax::${key}`);
|
this.pizzaxChannel = new BroadcastChannel(`pizzax::${key}`);
|
||||||
|
|
||||||
|
@ -128,7 +119,7 @@ export class Storage<T extends StateDef> {
|
||||||
this.pizzaxChannel.addEventListener('message', ({ where, key, value, userId }) => {
|
this.pizzaxChannel.addEventListener('message', ({ where, key, value, userId }) => {
|
||||||
// アカウント変更すればunisonReloadが効くため、このreturnが発火することは
|
// アカウント変更すればunisonReloadが効くため、このreturnが発火することは
|
||||||
// まずないと思うけど一応弾いておく
|
// まずないと思うけど一応弾いておく
|
||||||
if ((where === 'deviceAccount' && !($i && userId !== $i.id) || this.options.disableMessageChannel)) return;
|
if (where === 'deviceAccount' && !($i && userId !== $i.id)) return;
|
||||||
this.reactiveState[key].value = this.state[key] = value;
|
this.reactiveState[key].value = this.state[key] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,17 +174,6 @@ export class Storage<T extends StateDef> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the configuration options for Pizzax.
|
|
||||||
*
|
|
||||||
* 特にinitを待ったりとかはしないので、boot.jsなど、ロード初期段階で呼ぶ必要がある
|
|
||||||
*
|
|
||||||
* @param config - The partial configuration object.
|
|
||||||
*/
|
|
||||||
public setConfig(config: Partial<PizzaxConfig>) {
|
|
||||||
this.options = Object.assign(this.options, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public set<K extends keyof T>(key: K, value: T[K]['default']): Promise<void> {
|
public set<K extends keyof T>(key: K, value: T[K]['default']): Promise<void> {
|
||||||
// IndexedDBやBroadcastChannelで扱うために単純なオブジェクトにする
|
// IndexedDBやBroadcastChannelで扱うために単純なオブジェクトにする
|
||||||
// (JSON.parse(JSON.stringify(value))の代わり)
|
// (JSON.parse(JSON.stringify(value))の代わり)
|
||||||
|
@ -207,13 +187,11 @@ export class Storage<T extends StateDef> {
|
||||||
if (_DEV_) console.log(`set ${String(key)} start`);
|
if (_DEV_) console.log(`set ${String(key)} start`);
|
||||||
switch (this.def[key].where) {
|
switch (this.def[key].where) {
|
||||||
case 'device': {
|
case 'device': {
|
||||||
if (!this.options.disableMessageChannel) {
|
this.pizzaxChannel.postMessage({
|
||||||
this.pizzaxChannel.postMessage({
|
where: 'device',
|
||||||
where: 'device',
|
key,
|
||||||
key,
|
value: rawValue,
|
||||||
value: rawValue,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
const deviceState = await get(this.deviceStateKeyName) || {};
|
const deviceState = await get(this.deviceStateKeyName) || {};
|
||||||
deviceState[key] = rawValue;
|
deviceState[key] = rawValue;
|
||||||
await set(this.deviceStateKeyName, deviceState);
|
await set(this.deviceStateKeyName, deviceState);
|
||||||
|
@ -221,14 +199,12 @@ export class Storage<T extends StateDef> {
|
||||||
}
|
}
|
||||||
case 'deviceAccount': {
|
case 'deviceAccount': {
|
||||||
if ($i == null) break;
|
if ($i == null) break;
|
||||||
if (!this.options.disableMessageChannel) {
|
this.pizzaxChannel.postMessage({
|
||||||
this.pizzaxChannel.postMessage({
|
where: 'deviceAccount',
|
||||||
where: 'deviceAccount',
|
key,
|
||||||
key,
|
value: rawValue,
|
||||||
value: rawValue,
|
userId: $i.id,
|
||||||
userId: $i.id,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
const deviceAccountState = await get(this.deviceAccountStateKeyName) || {};
|
const deviceAccountState = await get(this.deviceAccountStateKeyName) || {};
|
||||||
deviceAccountState[key] = rawValue;
|
deviceAccountState[key] = rawValue;
|
||||||
await set(this.deviceAccountStateKeyName, deviceAccountState);
|
await set(this.deviceAccountStateKeyName, deviceAccountState);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { defineAsyncComponent, inject } from 'vue';
|
import { defineAsyncComponent } 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';
|
||||||
|
|
|
@ -9,37 +9,17 @@ export const postMessageEventTypes = [
|
||||||
|
|
||||||
export type PostMessageEventType = typeof postMessageEventTypes[number];
|
export type PostMessageEventType = typeof postMessageEventTypes[number];
|
||||||
|
|
||||||
export interface PostMessageEventPayload extends Record<PostMessageEventType, any> {
|
export type MiPostMessageEvent = {
|
||||||
'misskey:shareForm:shareCompleted': undefined;
|
type: PostMessageEventType;
|
||||||
}
|
payload?: any;
|
||||||
|
};
|
||||||
export type MiPostMessageEvent<T extends PostMessageEventType = PostMessageEventType> = {
|
|
||||||
type: T;
|
|
||||||
iframeId?: string;
|
|
||||||
payload?: PostMessageEventPayload[T];
|
|
||||||
}
|
|
||||||
|
|
||||||
let defaultIframeId: string | null = null;
|
|
||||||
|
|
||||||
export function setIframeId(id: string): void {
|
|
||||||
if (defaultIframeId != null) return;
|
|
||||||
|
|
||||||
if (_DEV_) console.log('setIframeId', id);
|
|
||||||
defaultIframeId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 親フレームにイベントを送信
|
* 親フレームにイベントを送信
|
||||||
*/
|
*/
|
||||||
export function postMessageToParentWindow<T extends PostMessageEventType = PostMessageEventType>(type: T, payload?: PostMessageEventPayload[T], iframeId: string | null = null): void {
|
export function postMessageToParentWindow(type: PostMessageEventType, payload?: any): void {
|
||||||
let _iframeId = iframeId;
|
window.postMessage({
|
||||||
if (_iframeId == null) {
|
|
||||||
_iframeId = defaultIframeId;
|
|
||||||
}
|
|
||||||
if (_DEV_) console.log('postMessageToParentWindow', type, _iframeId, payload);
|
|
||||||
window.parent.postMessage({
|
|
||||||
type,
|
type,
|
||||||
iframeId: _iframeId,
|
|
||||||
payload,
|
payload,
|
||||||
}, '*');
|
}, '*');
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,22 +75,20 @@ html {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.embed) {
|
&.f-1 {
|
||||||
&.f-1 {
|
font-size: 15px;
|
||||||
font-size: 15px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&.f-2 {
|
&.f-2 {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.f-3 {
|
&.f-3 {
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.useSystemFont {
|
&.useSystemFont {
|
||||||
font-family: system-ui;
|
font-family: system-ui;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue