refactor(frontend): refactor tips
This commit is contained in:
parent
4b9b3ced01
commit
be35fe468b
|
@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div style="font-weight: bold;"><i class="ti ti-bulb"></i> {{ i18n.ts.tip }}:</div>
|
<div style="font-weight: bold;"><i class="ti ti-bulb"></i> {{ i18n.ts.tip }}:</div>
|
||||||
<div><slot></slot></div>
|
<div><slot></slot></div>
|
||||||
<div>
|
<div>
|
||||||
<MkButton inline primary rounded small @click="closeTip()"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
<MkButton inline primary rounded small @click="_closeTip()"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
||||||
<button class="_button" style="padding: 8px; margin-left: 4px;" @click="showMenu"><i class="ti ti-dots"></i></button>
|
<button class="_button" style="padding: 8px; margin-left: 4px;" @click="showMenu"><i class="ti ti-dots"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,20 +19,17 @@ import { i18n } from '@/i18n.js';
|
||||||
import { store } from '@/store.js';
|
import { store } from '@/store.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { hideAllTips } from '@/store.js';
|
import { TIPS, hideAllTips, closeTip } from '@/tips.js';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
k: keyof (typeof store['s']['tips']);
|
k: typeof TIPS[number];
|
||||||
warn?: boolean;
|
warn?: boolean;
|
||||||
}>(), {
|
}>(), {
|
||||||
warn: false,
|
warn: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeTip() {
|
function _closeTip() {
|
||||||
store.set('tips', {
|
closeTip(props.k);
|
||||||
...store.r.tips.value,
|
|
||||||
[props.k]: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMenu(ev: MouseEvent) {
|
function showMenu(ev: MouseEvent) {
|
||||||
|
|
|
@ -161,8 +161,7 @@ import { prefer } from '@/preferences.js';
|
||||||
import MkRolePreview from '@/components/MkRolePreview.vue';
|
import MkRolePreview from '@/components/MkRolePreview.vue';
|
||||||
import { signout } from '@/signout.js';
|
import { signout } from '@/signout.js';
|
||||||
import { migrateOldSettings } from '@/pref-migrate.js';
|
import { migrateOldSettings } from '@/pref-migrate.js';
|
||||||
import { store } from '@/store.js';
|
import { hideAllTips as _hideAllTips, resetAllTips as _resetAllTips } from '@/tips.js';
|
||||||
import { hideAllTips as _hideAllTips } from '@/store.js';
|
|
||||||
|
|
||||||
const $i = ensureSignin();
|
const $i = ensureSignin();
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ function migrate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetAllTips() {
|
function resetAllTips() {
|
||||||
store.set('tips', {});
|
_resetAllTips();
|
||||||
os.success();
|
os.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,30 +10,11 @@ import darkTheme from '@@/themes/d-green-lime.json5';
|
||||||
import { hemisphere } from '@@/js/intl-const.js';
|
import { hemisphere } from '@@/js/intl-const.js';
|
||||||
import type { DeviceKind } from '@/utility/device-kind.js';
|
import type { DeviceKind } from '@/utility/device-kind.js';
|
||||||
import type { Plugin } from '@/plugin.js';
|
import type { Plugin } from '@/plugin.js';
|
||||||
|
import type { TIPS } from '@/tips.js';
|
||||||
import { miLocalStorage } from '@/local-storage.js';
|
import { miLocalStorage } from '@/local-storage.js';
|
||||||
import { Pizzax } from '@/lib/pizzax.js';
|
import { Pizzax } from '@/lib/pizzax.js';
|
||||||
import { DEFAULT_DEVICE_KIND } from '@/utility/device-kind.js';
|
import { DEFAULT_DEVICE_KIND } from '@/utility/device-kind.js';
|
||||||
|
|
||||||
export const TIPS = [
|
|
||||||
'drive',
|
|
||||||
'uploader',
|
|
||||||
'clips',
|
|
||||||
'userLists',
|
|
||||||
'tl.home',
|
|
||||||
'tl.local',
|
|
||||||
'tl.social',
|
|
||||||
'tl.global',
|
|
||||||
'abuses',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export function hideAllTips() {
|
|
||||||
const v = {};
|
|
||||||
for (const k of TIPS) {
|
|
||||||
v[k] = true;
|
|
||||||
}
|
|
||||||
store.set('tips', v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 「状態」を管理するストア(not「設定」)
|
* 「状態」を管理するストア(not「設定」)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { store } from '@/store.js';
|
||||||
|
|
||||||
|
export const TIPS = [
|
||||||
|
'drive',
|
||||||
|
'uploader',
|
||||||
|
'clips',
|
||||||
|
'userLists',
|
||||||
|
'tl.home',
|
||||||
|
'tl.local',
|
||||||
|
'tl.social',
|
||||||
|
'tl.global',
|
||||||
|
'abuses',
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export function closeTip(tip: typeof TIPS[number]) {
|
||||||
|
store.set('tips', {
|
||||||
|
...store.r.tips.value,
|
||||||
|
[tip]: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resetAllTips() {
|
||||||
|
store.set('tips', {});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hideAllTips() {
|
||||||
|
const v = {};
|
||||||
|
for (const k of TIPS) {
|
||||||
|
v[k] = true;
|
||||||
|
}
|
||||||
|
store.set('tips', v);
|
||||||
|
}
|
Loading…
Reference in New Issue