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 {
|
||||
|
|
|
@ -21,13 +21,8 @@ type Account = Misskey.entities.MeDetailed & { token: string };
|
|||
|
||||
const accountData = miLocalStorage.getItem('account');
|
||||
|
||||
function initAccount() {
|
||||
if (accountData) return reactive(JSON.parse(accountData) as Account);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 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 iAmAdmin = $i != null && $i.isAdmin;
|
||||
|
|
|
@ -21,7 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
:direction="pagination.reversed ? 'up' : 'down'"
|
||||
:reversed="pagination.reversed"
|
||||
:noGap="noGap"
|
||||
:ad="ad"
|
||||
:ad="true"
|
||||
:class="$style.notes"
|
||||
>
|
||||
<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 { infoImageUrl } from '@/instance.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
const props = defineProps<{
|
||||
pagination: Paging;
|
||||
noGap?: boolean;
|
||||
disableAutoLoad?: boolean;
|
||||
ad?: boolean;
|
||||
}>(), {
|
||||
ad: true,
|
||||
});
|
||||
}>();
|
||||
|
||||
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();
|
||||
|
||||
|
|
|
@ -32,10 +32,6 @@ type PizzaxChannelMessage<T extends StateDef> = {
|
|||
userId?: string;
|
||||
};
|
||||
|
||||
export type PizzaxConfig = {
|
||||
disableMessageChannel: boolean;
|
||||
};
|
||||
|
||||
export class Storage<T extends StateDef> {
|
||||
public readonly ready: Promise<void>;
|
||||
public readonly loaded: Promise<void>;
|
||||
|
@ -51,10 +47,6 @@ export class Storage<T extends StateDef> {
|
|||
public readonly state: State<T>;
|
||||
public readonly reactiveState: ReactiveState<T>;
|
||||
|
||||
private options: PizzaxConfig = {
|
||||
disableMessageChannel: false,
|
||||
};
|
||||
|
||||
private pizzaxChannel: BroadcastChannel<PizzaxChannelMessage<T>>;
|
||||
|
||||
// 簡易的にキューイングして占有ロックとする
|
||||
|
@ -68,13 +60,12 @@ export class Storage<T extends StateDef> {
|
|||
return promise;
|
||||
}
|
||||
|
||||
constructor(key: string, def: T, options?: Partial<PizzaxConfig>) {
|
||||
constructor(key: string, def: T) {
|
||||
this.key = key;
|
||||
this.deviceStateKeyName = `pizzax::${key}`;
|
||||
this.deviceAccountStateKeyName = $i ? `pizzax::${key}::${$i.id}` : '';
|
||||
this.registryCacheKeyName = $i ? `pizzax::${key}::cache::${$i.id}` : '';
|
||||
this.def = def;
|
||||
this.options = Object.assign(this.options, options);
|
||||
|
||||
this.pizzaxChannel = new BroadcastChannel(`pizzax::${key}`);
|
||||
|
||||
|
@ -128,7 +119,7 @@ export class Storage<T extends StateDef> {
|
|||
this.pizzaxChannel.addEventListener('message', ({ where, key, value, userId }) => {
|
||||
// アカウント変更すれば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;
|
||||
});
|
||||
|
||||
|
@ -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> {
|
||||
// IndexedDBやBroadcastChannelで扱うために単純なオブジェクトにする
|
||||
// (JSON.parse(JSON.stringify(value))の代わり)
|
||||
|
@ -207,13 +187,11 @@ export class Storage<T extends StateDef> {
|
|||
if (_DEV_) console.log(`set ${String(key)} start`);
|
||||
switch (this.def[key].where) {
|
||||
case 'device': {
|
||||
if (!this.options.disableMessageChannel) {
|
||||
this.pizzaxChannel.postMessage({
|
||||
where: 'device',
|
||||
key,
|
||||
value: rawValue,
|
||||
});
|
||||
}
|
||||
this.pizzaxChannel.postMessage({
|
||||
where: 'device',
|
||||
key,
|
||||
value: rawValue,
|
||||
});
|
||||
const deviceState = await get(this.deviceStateKeyName) || {};
|
||||
deviceState[key] = rawValue;
|
||||
await set(this.deviceStateKeyName, deviceState);
|
||||
|
@ -221,14 +199,12 @@ export class Storage<T extends StateDef> {
|
|||
}
|
||||
case 'deviceAccount': {
|
||||
if ($i == null) break;
|
||||
if (!this.options.disableMessageChannel) {
|
||||
this.pizzaxChannel.postMessage({
|
||||
where: 'deviceAccount',
|
||||
key,
|
||||
value: rawValue,
|
||||
userId: $i.id,
|
||||
});
|
||||
}
|
||||
this.pizzaxChannel.postMessage({
|
||||
where: 'deviceAccount',
|
||||
key,
|
||||
value: rawValue,
|
||||
userId: $i.id,
|
||||
});
|
||||
const deviceAccountState = await get(this.deviceAccountStateKeyName) || {};
|
||||
deviceAccountState[key] = rawValue;
|
||||
await set(this.deviceAccountStateKeyName, deviceAccountState);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { defineAsyncComponent, inject } from 'vue';
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { $i } from '@/account.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { popup } from '@/os.js';
|
||||
|
|
|
@ -9,37 +9,17 @@ export const postMessageEventTypes = [
|
|||
|
||||
export type PostMessageEventType = typeof postMessageEventTypes[number];
|
||||
|
||||
export interface PostMessageEventPayload extends Record<PostMessageEventType, any> {
|
||||
'misskey:shareForm:shareCompleted': undefined;
|
||||
}
|
||||
|
||||
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 type MiPostMessageEvent = {
|
||||
type: PostMessageEventType;
|
||||
payload?: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* 親フレームにイベントを送信
|
||||
*/
|
||||
export function postMessageToParentWindow<T extends PostMessageEventType = PostMessageEventType>(type: T, payload?: PostMessageEventPayload[T], iframeId: string | null = null): void {
|
||||
let _iframeId = iframeId;
|
||||
if (_iframeId == null) {
|
||||
_iframeId = defaultIframeId;
|
||||
}
|
||||
if (_DEV_) console.log('postMessageToParentWindow', type, _iframeId, payload);
|
||||
window.parent.postMessage({
|
||||
export function postMessageToParentWindow(type: PostMessageEventType, payload?: any): void {
|
||||
window.postMessage({
|
||||
type,
|
||||
iframeId: _iframeId,
|
||||
payload,
|
||||
}, '*');
|
||||
}
|
||||
|
|
|
@ -75,22 +75,20 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
&:not(.embed) {
|
||||
&.f-1 {
|
||||
font-size: 15px;
|
||||
}
|
||||
&.f-1 {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
&.f-2 {
|
||||
font-size: 16px;
|
||||
}
|
||||
&.f-2 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&.f-3 {
|
||||
font-size: 17px;
|
||||
}
|
||||
&.f-3 {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
&.useSystemFont {
|
||||
font-family: system-ui;
|
||||
}
|
||||
&.useSystemFont {
|
||||
font-family: system-ui;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue