summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-06-06 21:03:35 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-06-06 21:03:35 +0900
commitbe35fe468b5093fb7395e176a0d8361a45f2529b (patch)
tree1298968318b4a769375b70dd109f5b3226993b36
parentenhance(frontend): improve MkTip usability (diff)
downloadmisskey-be35fe468b5093fb7395e176a0d8361a45f2529b.tar.gz
misskey-be35fe468b5093fb7395e176a0d8361a45f2529b.tar.bz2
misskey-be35fe468b5093fb7395e176a0d8361a45f2529b.zip
refactor(frontend): refactor tips
-rw-r--r--packages/frontend/src/components/global/MkTip.vue13
-rw-r--r--packages/frontend/src/pages/settings/other.vue5
-rw-r--r--packages/frontend/src/store.ts21
-rw-r--r--packages/frontend/src/tips.ts37
4 files changed, 45 insertions, 31 deletions
diff --git a/packages/frontend/src/components/global/MkTip.vue b/packages/frontend/src/components/global/MkTip.vue
index afe204cfcb..231957a232 100644
--- a/packages/frontend/src/components/global/MkTip.vue
+++ b/packages/frontend/src/components/global/MkTip.vue
@@ -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><slot></slot></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>
</div>
</div>
@@ -19,20 +19,17 @@ import { i18n } from '@/i18n.js';
import { store } from '@/store.js';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
-import { hideAllTips } from '@/store.js';
+import { TIPS, hideAllTips, closeTip } from '@/tips.js';
const props = withDefaults(defineProps<{
- k: keyof (typeof store['s']['tips']);
+ k: typeof TIPS[number];
warn?: boolean;
}>(), {
warn: false,
});
-function closeTip() {
- store.set('tips', {
- ...store.r.tips.value,
- [props.k]: true,
- });
+function _closeTip() {
+ closeTip(props.k);
}
function showMenu(ev: MouseEvent) {
diff --git a/packages/frontend/src/pages/settings/other.vue b/packages/frontend/src/pages/settings/other.vue
index f729903a88..ac432e9f32 100644
--- a/packages/frontend/src/pages/settings/other.vue
+++ b/packages/frontend/src/pages/settings/other.vue
@@ -161,8 +161,7 @@ import { prefer } from '@/preferences.js';
import MkRolePreview from '@/components/MkRolePreview.vue';
import { signout } from '@/signout.js';
import { migrateOldSettings } from '@/pref-migrate.js';
-import { store } from '@/store.js';
-import { hideAllTips as _hideAllTips } from '@/store.js';
+import { hideAllTips as _hideAllTips, resetAllTips as _resetAllTips } from '@/tips.js';
const $i = ensureSignin();
@@ -206,7 +205,7 @@ function migrate() {
}
function resetAllTips() {
- store.set('tips', {});
+ _resetAllTips();
os.success();
}
diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts
index 03ef37ced5..9afaf2c9b9 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -10,30 +10,11 @@ import darkTheme from '@@/themes/d-green-lime.json5';
import { hemisphere } from '@@/js/intl-const.js';
import type { DeviceKind } from '@/utility/device-kind.js';
import type { Plugin } from '@/plugin.js';
+import type { TIPS } from '@/tips.js';
import { miLocalStorage } from '@/local-storage.js';
import { Pizzax } from '@/lib/pizzax.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「設定」)
*/
diff --git a/packages/frontend/src/tips.ts b/packages/frontend/src/tips.ts
new file mode 100644
index 0000000000..a6850d0406
--- /dev/null
+++ b/packages/frontend/src/tips.ts
@@ -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);
+}