Storage improve (#6976)
* wip
* wip
* wip
* wip
* wip
* Update storage.ts
* wip
* wip
* wip
* wip
* Update storage.ts
* Update storage.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update storage.ts
* wip
* wip
* wip
* wip
* 🍕
* wip
* wip
* wip
* wip
* wip
* wip
* Update deck-storage.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update store.ts
* wip
* wip
* wip
* wip
* Update init.ts
* wip
* wip
* Update pizzax.ts
* wip
* wip
* Update timeline.vue
* Update init.ts
* wip
* wip
* Update init.ts
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
<section class="_card">
|
||||
<div class="_title"><Fa :icon="faLock"/> {{ $t('twoStepAuthentication') }}</div>
|
||||
<div class="_content">
|
||||
<MkButton v-if="!data && !$store.state.i.twoFactorEnabled" @click="register">{{ $t('_2fa.registerDevice') }}</MkButton>
|
||||
<template v-if="$store.state.i.twoFactorEnabled">
|
||||
<MkButton v-if="!data && !$i.twoFactorEnabled" @click="register">{{ $t('_2fa.registerDevice') }}</MkButton>
|
||||
<template v-if="$i.twoFactorEnabled">
|
||||
<p>{{ $t('_2fa.alreadyRegistered') }}</p>
|
||||
<MkButton @click="unregister">{{ $t('unregister') }}</MkButton>
|
||||
|
||||
@ -13,14 +13,14 @@
|
||||
<h2 class="heading">{{ $t('securityKey') }}</h2>
|
||||
<p>{{ $t('_2fa.securityKeyInfo') }}</p>
|
||||
<div class="key-list">
|
||||
<div class="key" v-for="key in $store.state.i.securityKeysList">
|
||||
<div class="key" v-for="key in $i.securityKeysList">
|
||||
<h3>{{ key.name }}</h3>
|
||||
<div class="last-used">{{ $t('lastUsed') }}<MkTime :time="key.lastUsed"/></div>
|
||||
<MkButton @click="unregisterKey(key)">{{ $t('unregister') }}</MkButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MkSwitch v-model:value="usePasswordLessLogin" @update:value="updatePasswordLessLogin" v-if="$store.state.i.securityKeysList.length > 0">{{ $t('passwordLessLogin') }}</MkSwitch>
|
||||
<MkSwitch v-model:value="usePasswordLessLogin" @update:value="updatePasswordLessLogin" v-if="$i.securityKeysList.length > 0">{{ $t('passwordLessLogin') }}</MkSwitch>
|
||||
|
||||
<MkInfo warn v-if="registration && registration.error">{{ $t('error') }} {{ registration.error }}</MkInfo>
|
||||
<MkButton v-if="!registration || registration.error" @click="addSecurityKey">{{ $t('_2fa.registerKey') }}</MkButton>
|
||||
@ -42,7 +42,7 @@
|
||||
</ol>
|
||||
</template>
|
||||
</template>
|
||||
<div v-if="data && !$store.state.i.twoFactorEnabled">
|
||||
<div v-if="data && !$i.twoFactorEnabled">
|
||||
<ol style="margin: 0; padding: 0 0 0 1em;">
|
||||
<li>
|
||||
<i18n-t keypath="_2fa.step1" tag="span">
|
||||
@ -96,7 +96,7 @@ export default defineComponent({
|
||||
},
|
||||
data: null,
|
||||
supportsCredentials: !!navigator.credentials,
|
||||
usePasswordLessLogin: this.$store.state.i.usePasswordLessLogin,
|
||||
usePasswordLessLogin: this.$i.usePasswordLessLogin,
|
||||
registration: null,
|
||||
keyName: '',
|
||||
token: null,
|
||||
@ -136,7 +136,7 @@ export default defineComponent({
|
||||
this.updatePasswordLessLogin();
|
||||
}).then(() => {
|
||||
os.success();
|
||||
this.$store.state.i.twoFactorEnabled = false;
|
||||
this.$i.twoFactorEnabled = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
@ -146,7 +146,7 @@ export default defineComponent({
|
||||
token: this.token
|
||||
}).then(() => {
|
||||
os.success();
|
||||
this.$store.state.i.twoFactorEnabled = true;
|
||||
this.$i.twoFactorEnabled = true;
|
||||
}).catch(e => {
|
||||
os.dialog({
|
||||
type: 'error',
|
||||
@ -213,9 +213,9 @@ export default defineComponent({
|
||||
name: 'Misskey'
|
||||
},
|
||||
user: {
|
||||
id: byteify(this.$store.state.i.id, 'ascii'),
|
||||
name: this.$store.state.i.username,
|
||||
displayName: this.$store.state.i.name,
|
||||
id: byteify(this.$i.id, 'ascii'),
|
||||
name: this.$i.username,
|
||||
displayName: this.$i.name,
|
||||
},
|
||||
pubKeyCredParams: [{ alg: -7, type: 'public-key' }],
|
||||
timeout: 60000,
|
||||
|
@ -2,13 +2,13 @@
|
||||
<FormBase>
|
||||
<FormKeyValueView>
|
||||
<template #key>ID</template>
|
||||
<template #value><span class="_monospace">{{ $store.state.i.id }}</span></template>
|
||||
<template #value><span class="_monospace">{{ $i.id }}</span></template>
|
||||
</FormKeyValueView>
|
||||
|
||||
<FormGroup>
|
||||
<FormKeyValueView>
|
||||
<template #key>{{ $t('registeredDate') }}</template>
|
||||
<template #value><MkTime :time="$store.state.i.createdAt" mode="detail"/></template>
|
||||
<template #value><MkTime :time="$i.createdAt" mode="detail"/></template>
|
||||
</FormKeyValueView>
|
||||
</FormGroup>
|
||||
|
||||
@ -104,27 +104,27 @@
|
||||
<template #label>{{ $t('other') }}</template>
|
||||
<FormKeyValueView>
|
||||
<template #key>emailVerified</template>
|
||||
<template #value>{{ $store.state.i.emailVerified ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.emailVerified ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
<FormKeyValueView>
|
||||
<template #key>twoFactorEnabled</template>
|
||||
<template #value>{{ $store.state.i.twoFactorEnabled ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.twoFactorEnabled ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
<FormKeyValueView>
|
||||
<template #key>securityKeys</template>
|
||||
<template #value>{{ $store.state.i.securityKeys ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.securityKeys ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
<FormKeyValueView>
|
||||
<template #key>usePasswordLessLogin</template>
|
||||
<template #value>{{ $store.state.i.usePasswordLessLogin ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.usePasswordLessLogin ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
<FormKeyValueView>
|
||||
<template #key>isModerator</template>
|
||||
<template #value>{{ $store.state.i.isModerator ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.isModerator ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
<FormKeyValueView>
|
||||
<template #key>isAdmin</template>
|
||||
<template #value>{{ $store.state.i.isAdmin ? $t('yes') : $t('no') }}</template>
|
||||
<template #value>{{ $i.isAdmin ? $t('yes') : $t('no') }}</template>
|
||||
</FormKeyValueView>
|
||||
</FormGroup>
|
||||
</FormBase>
|
||||
@ -171,7 +171,7 @@ export default defineComponent({
|
||||
this.$emit('info', this.INFO);
|
||||
|
||||
os.api('users/stats', {
|
||||
userId: this.$store.state.i.id
|
||||
userId: this.$i.id
|
||||
}).then(stats => {
|
||||
this.stats = stats;
|
||||
});
|
||||
|
@ -5,17 +5,17 @@
|
||||
<div class="_title"><Fa :icon="faColumns"/> </div>
|
||||
<div class="_content">
|
||||
<div>{{ $t('defaultNavigationBehaviour') }}</div>
|
||||
<MkSwitch v-model:value="deckNavWindow">{{ $t('openInWindow') }}</MkSwitch>
|
||||
<MkSwitch v-model:value="navWindow">{{ $t('openInWindow') }}</MkSwitch>
|
||||
</div>
|
||||
<div class="_content">
|
||||
<MkSwitch v-model:value="deckAlwaysShowMainColumn">
|
||||
<MkSwitch v-model:value="alwaysShowMainColumn">
|
||||
{{ $t('_deck.alwaysShowMainColumn') }}
|
||||
</MkSwitch>
|
||||
</div>
|
||||
<div class="_content">
|
||||
<div>{{ $t('_deck.columnAlign') }}</div>
|
||||
<MkRadio v-model="deckColumnAlign" value="left">{{ $t('left') }}</MkRadio>
|
||||
<MkRadio v-model="deckColumnAlign" value="center">{{ $t('center') }}</MkRadio>
|
||||
<MkRadio v-model="columnAlign" value="left">{{ $t('left') }}</MkRadio>
|
||||
<MkRadio v-model="columnAlign" value="center">{{ $t('center') }}</MkRadio>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -38,6 +38,7 @@ import FormBase from '@/components/form/base.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import { clientDb, set } from '@/db';
|
||||
import * as os from '@/os';
|
||||
import { deckStore } from '@/ui/deck/deck-store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -67,20 +68,9 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
computed: {
|
||||
deckNavWindow: {
|
||||
get() { return this.$store.state.device.deckNavWindow; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'deckNavWindow', value }); }
|
||||
},
|
||||
|
||||
deckAlwaysShowMainColumn: {
|
||||
get() { return this.$store.state.device.deckAlwaysShowMainColumn; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'deckAlwaysShowMainColumn', value }); }
|
||||
},
|
||||
|
||||
deckColumnAlign: {
|
||||
get() { return this.$store.state.device.deckColumnAlign; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'deckColumnAlign', value }); }
|
||||
},
|
||||
navWindow: deckStore.makeGetterSetter('navWindow'),
|
||||
alwaysShowMainColumn: deckStore.makeGetterSetter('alwaysShowMainColumn'),
|
||||
columnAlign: deckStore.makeGetterSetter('columnAlign'),
|
||||
},
|
||||
|
||||
mounted() {
|
||||
|
@ -28,9 +28,9 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
async created() {
|
||||
if (this.$store.state.settings.uploadFolder) {
|
||||
if (this.$store.state.uploadFolder) {
|
||||
this.uploadFolder = await os.api('drive/folders/show', {
|
||||
folderId: this.$store.state.settings.uploadFolder
|
||||
folderId: this.$store.state.uploadFolder
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -38,11 +38,11 @@ export default defineComponent({
|
||||
methods: {
|
||||
chooseUploadFolder() {
|
||||
os.selectDriveFolder(false).then(async folder => {
|
||||
await this.$store.dispatch('settings/set', { key: 'uploadFolder', value: folder ? folder.id : null });
|
||||
this.$store.set('uploadFolder', folder ? folder.id : null);
|
||||
os.success();
|
||||
if (this.$store.state.settings.uploadFolder) {
|
||||
if (this.$store.state.uploadFolder) {
|
||||
this.uploadFolder = await os.api('drive/folders/show', {
|
||||
folderId: this.$store.state.settings.uploadFolder
|
||||
folderId: this.$store.state.uploadFolder
|
||||
});
|
||||
} else {
|
||||
this.uploadFolder = null;
|
||||
|
@ -3,8 +3,8 @@
|
||||
<FormGroup>
|
||||
<FormInput v-model:value="emailAddress" type="email">
|
||||
{{ $t('emailAddress') }}
|
||||
<template #desc v-if="$store.state.i.email && !$store.state.i.emailVerified">{{ $t('verificationEmailSent') }}</template>
|
||||
<template #desc v-else-if="emailAddress === $store.state.i.email && $store.state.i.emailVerified">{{ $t('emailVerified') }}</template>
|
||||
<template #desc v-if="$i.email && !$i.emailVerified">{{ $t('verificationEmailSent') }}</template>
|
||||
<template #desc v-else-if="emailAddress === $i.email && $i.emailVerified">{{ $t('emailVerified') }}</template>
|
||||
</FormInput>
|
||||
</FormGroup>
|
||||
<FormButton @click="save" primary>{{ $t('save') }}</FormButton>
|
||||
@ -44,7 +44,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
created() {
|
||||
this.emailAddress = this.$store.state.i.email;
|
||||
this.emailAddress = this.$i.email;
|
||||
},
|
||||
|
||||
mounted() {
|
||||
|
@ -3,9 +3,9 @@
|
||||
<FormGroup>
|
||||
<template #label>{{ $t('emailAddress') }}</template>
|
||||
<FormLink to="/settings/email/address">
|
||||
<template v-if="$store.state.i.email && !$store.state.i.emailVerified" #icon><Fa :icon="faExclamationTriangle" style="color: var(--warn);"/></template>
|
||||
<template v-else-if="$store.state.i.email && $store.state.i.emailVerified" #icon><Fa :icon="faCheck" style="color: var(--success);"/></template>
|
||||
{{ $store.state.i.email || $t('notSet') }}
|
||||
<template v-if="$i.email && !$i.emailVerified" #icon><Fa :icon="faExclamationTriangle" style="color: var(--warn);"/></template>
|
||||
<template v-else-if="$i.email && $i.emailVerified" #icon><Fa :icon="faCheck" style="color: var(--success);"/></template>
|
||||
{{ $i.email || $t('notSet') }}
|
||||
</FormLink>
|
||||
</FormGroup>
|
||||
</FormBase>
|
||||
|
@ -38,7 +38,7 @@
|
||||
<FormSwitch v-model:value="disableShowingAnimatedImages">{{ $t('disableShowingAnimatedImages') }}</FormSwitch>
|
||||
<FormSwitch v-model:value="useSystemFont">{{ $t('useSystemFont') }}</FormSwitch>
|
||||
<FormSwitch v-model:value="useOsNativeEmojis">{{ $t('useOsNativeEmojis') }}
|
||||
<div><Mfm text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div>
|
||||
<div><Mfm text="🍮🍦🍭🍩🍰🍫🍬🥞🍪" :key="useOsNativeEmojis"/></div>
|
||||
</FormSwitch>
|
||||
</FormGroup>
|
||||
|
||||
@ -96,6 +96,8 @@ import MkLink from '@/components/link.vue';
|
||||
import { langs } from '@/config';
|
||||
import { clientDb, set } from '@/db';
|
||||
import * as os from '@/os';
|
||||
import { defaultStore } from '@/store';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -126,85 +128,22 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
computed: {
|
||||
serverDisconnectedBehavior: {
|
||||
get() { return this.$store.state.device.serverDisconnectedBehavior; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'serverDisconnectedBehavior', value }); }
|
||||
},
|
||||
|
||||
reduceAnimation: {
|
||||
get() { return !this.$store.state.device.animation; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'animation', value: !value }); }
|
||||
},
|
||||
|
||||
useBlurEffectForModal: {
|
||||
get() { return this.$store.state.device.useBlurEffectForModal; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'useBlurEffectForModal', value: value }); }
|
||||
},
|
||||
|
||||
showGapBetweenNotesInTimeline: {
|
||||
get() { return this.$store.state.device.showGapBetweenNotesInTimeline; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'showGapBetweenNotesInTimeline', value: value }); }
|
||||
},
|
||||
|
||||
disableAnimatedMfm: {
|
||||
get() { return !this.$store.state.device.animatedMfm; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'animatedMfm', value: !value }); }
|
||||
},
|
||||
|
||||
useOsNativeEmojis: {
|
||||
get() { return this.$store.state.device.useOsNativeEmojis; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'useOsNativeEmojis', value }); }
|
||||
},
|
||||
|
||||
imageNewTab: {
|
||||
get() { return this.$store.state.device.imageNewTab; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'imageNewTab', value }); }
|
||||
},
|
||||
|
||||
disablePagesScript: {
|
||||
get() { return this.$store.state.device.disablePagesScript; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'disablePagesScript', value }); }
|
||||
},
|
||||
|
||||
showFixedPostForm: {
|
||||
get() { return this.$store.state.device.showFixedPostForm; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'showFixedPostForm', value }); }
|
||||
},
|
||||
|
||||
defaultSideView: {
|
||||
get() { return this.$store.state.device.defaultSideView; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'defaultSideView', value }); }
|
||||
},
|
||||
|
||||
chatOpenBehavior: {
|
||||
get() { return this.$store.state.device.chatOpenBehavior; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'chatOpenBehavior', value }); }
|
||||
},
|
||||
|
||||
instanceTicker: {
|
||||
get() { return this.$store.state.device.instanceTicker; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'instanceTicker', value }); }
|
||||
},
|
||||
|
||||
loadRawImages: {
|
||||
get() { return this.$store.state.device.loadRawImages; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'loadRawImages', value }); }
|
||||
},
|
||||
|
||||
disableShowingAnimatedImages: {
|
||||
get() { return this.$store.state.device.disableShowingAnimatedImages; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'disableShowingAnimatedImages', value }); }
|
||||
},
|
||||
|
||||
nsfw: {
|
||||
get() { return this.$store.state.device.nsfw; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'nsfw', value }); }
|
||||
},
|
||||
|
||||
enableInfiniteScroll: {
|
||||
get() { return this.$store.state.device.enableInfiniteScroll; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'enableInfiniteScroll', value }); }
|
||||
},
|
||||
serverDisconnectedBehavior: defaultStore.makeGetterSetter('serverDisconnectedBehavior'),
|
||||
reduceAnimation: defaultStore.makeGetterSetter('animation', v => !v, v => !v),
|
||||
useBlurEffectForModal: defaultStore.makeGetterSetter('useBlurEffectForModal'),
|
||||
showGapBetweenNotesInTimeline: defaultStore.makeGetterSetter('showGapBetweenNotesInTimeline'),
|
||||
disableAnimatedMfm: defaultStore.makeGetterSetter('animatedMfm', v => !v, v => !v),
|
||||
useOsNativeEmojis: defaultStore.makeGetterSetter('useOsNativeEmojis'),
|
||||
disableShowingAnimatedImages: defaultStore.makeGetterSetter('disableShowingAnimatedImages'),
|
||||
loadRawImages: defaultStore.makeGetterSetter('loadRawImages'),
|
||||
imageNewTab: defaultStore.makeGetterSetter('imageNewTab'),
|
||||
nsfw: defaultStore.makeGetterSetter('nsfw'),
|
||||
disablePagesScript: defaultStore.makeGetterSetter('disablePagesScript'),
|
||||
showFixedPostForm: defaultStore.makeGetterSetter('showFixedPostForm'),
|
||||
defaultSideView: defaultStore.makeGetterSetter('defaultSideView'),
|
||||
chatOpenBehavior: ColdDeviceStorage.makeGetterSetter('chatOpenBehavior'),
|
||||
instanceTicker: defaultStore.makeGetterSetter('instanceTicker'),
|
||||
enableInfiniteScroll: defaultStore.makeGetterSetter('enableInfiniteScroll'),
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
@ -41,13 +41,13 @@
|
||||
import { computed, defineAsyncComponent, defineComponent, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { faCog, faPalette, faPlug, faUser, faListUl, faLock, faCommentSlash, faMusic, faCogs, faEllipsisH, faBan, faShareAlt, faLockOpen, faKey, faBoxes } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faLaugh, faBell, faEnvelope } from '@fortawesome/free-regular-svg-icons';
|
||||
import { store } from '@/store';
|
||||
import { i18n } from '@/i18n';
|
||||
import FormLink from '@/components/form/link.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import FormBase from '@/components/form/base.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import { scroll } from '../../scripts/scroll';
|
||||
import { scroll } from '@/scripts/scroll';
|
||||
import { signout } from '@/account';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -101,7 +101,6 @@ export default defineComponent({
|
||||
case 'plugins': return defineAsyncComponent(() => import('./plugins.vue'));
|
||||
case 'import-export': return defineAsyncComponent(() => import('./import-export.vue'));
|
||||
case 'account-info': return defineAsyncComponent(() => import('./account-info.vue'));
|
||||
case 'regedit': return defineAsyncComponent(() => import('./regedit.vue'));
|
||||
case 'experimental-features': return defineAsyncComponent(() => import('./experimental-features.vue'));
|
||||
default: return null;
|
||||
}
|
||||
@ -125,8 +124,7 @@ export default defineComponent({
|
||||
onInfo,
|
||||
component,
|
||||
logout: () => {
|
||||
store.dispatch('logout');
|
||||
location.href = '/';
|
||||
signout();
|
||||
},
|
||||
faPalette, faPlug, faUser, faListUl, faLock, faLaugh, faCommentSlash, faMusic, faBell, faCogs, faEllipsisH, faBan, faShareAlt, faLockOpen, faKey, faBoxes, faEnvelope,
|
||||
};
|
||||
|
@ -57,11 +57,11 @@ export default defineComponent({
|
||||
|
||||
computed: {
|
||||
integrations() {
|
||||
return this.$store.state.i.integrations;
|
||||
return this.$i.integrations;
|
||||
},
|
||||
|
||||
meta() {
|
||||
return this.$store.state.instance.meta;
|
||||
return this.$instance;
|
||||
},
|
||||
},
|
||||
|
||||
@ -74,7 +74,7 @@ export default defineComponent({
|
||||
mounted() {
|
||||
this.$emit('info', this.INFO);
|
||||
|
||||
document.cookie = `igi=${this.$store.state.i.token}; path=/;` +
|
||||
document.cookie = `igi=${this.$i.token}; path=/;` +
|
||||
` max-age=31536000;` +
|
||||
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
||||
|
||||
|
@ -58,7 +58,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
configure() {
|
||||
const includingTypes = notificationTypes.filter(x => !this.$store.state.i.mutingNotificationTypes.includes(x));
|
||||
const includingTypes = notificationTypes.filter(x => !this.$i.mutingNotificationTypes.includes(x));
|
||||
os.popup(import('@/components/notification-setting-window.vue'), {
|
||||
includingTypes,
|
||||
showGlobalToggle: false,
|
||||
@ -68,7 +68,7 @@ export default defineComponent({
|
||||
await os.apiWithDialog('i/update', {
|
||||
mutingNotificationTypes: notificationTypes.filter(x => !value.includes(x)),
|
||||
}).then(i => {
|
||||
this.$store.state.i.mutingNotificationTypes = i.mutingNotificationTypes;
|
||||
this.$i.mutingNotificationTypes = i.mutingNotificationTypes;
|
||||
});
|
||||
}
|
||||
}, 'closed');
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<FormBase>
|
||||
<FormSwitch :value="$store.state.i.injectFeaturedNote" @update:value="onChangeInjectFeaturedNote">
|
||||
<FormSwitch :value="$i.injectFeaturedNote" @update:value="onChangeInjectFeaturedNote">
|
||||
{{ $t('showFeaturedNotesInTimeline') }}
|
||||
</FormSwitch>
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
<details>
|
||||
<summary><Fa :icon="faFolderOpen"/> {{ $t('manage') }}</summary>
|
||||
<MkSelect v-model:value="selectedPluginId">
|
||||
<option v-for="x in $store.state.deviceUser.plugins" :value="x.id" :key="x.id">{{ x.name }}</option>
|
||||
<option v-for="x in plugins" :value="x.id" :key="x.id">{{ x.name }}</option>
|
||||
</MkSelect>
|
||||
<template v-if="selectedPlugin">
|
||||
<div style="margin: -8px 0 8px 0;">
|
||||
@ -55,6 +55,7 @@ import MkSelect from '@/components/ui/select.vue';
|
||||
import MkInfo from '@/components/ui/info.vue';
|
||||
import MkSwitch from '@/components/ui/switch.vue';
|
||||
import * as os from '@/os';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -68,6 +69,7 @@ export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
script: '',
|
||||
plugins: ColdDeviceStorage.get('plugins'),
|
||||
selectedPluginId: null,
|
||||
faPlug, faSave, faTrashAlt, faFolderOpen, faDownload, faCog
|
||||
}
|
||||
@ -76,11 +78,22 @@ export default defineComponent({
|
||||
computed: {
|
||||
selectedPlugin() {
|
||||
if (this.selectedPluginId == null) return null;
|
||||
return this.$store.state.deviceUser.plugins.find(x => x.id === this.selectedPluginId);
|
||||
return this.plugins.find(x => x.id === this.selectedPluginId);
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
installPlugin({ id, meta, ast, token }) {
|
||||
ColdDeviceStorage.set('plugins', this.plugins.concat({
|
||||
...meta,
|
||||
id,
|
||||
active: true,
|
||||
configData: {},
|
||||
token: token,
|
||||
ast: ast
|
||||
}));
|
||||
},
|
||||
|
||||
async install() {
|
||||
let ast;
|
||||
try {
|
||||
@ -137,7 +150,7 @@ export default defineComponent({
|
||||
}, 'closed');
|
||||
});
|
||||
|
||||
this.$store.commit('deviceUser/installPlugin', {
|
||||
this.installPlugin({
|
||||
id: uuid(),
|
||||
meta: {
|
||||
name, version, author, description, permissions, config
|
||||
@ -154,7 +167,7 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
uninstall() {
|
||||
this.$store.commit('deviceUser/uninstallPlugin', this.selectedPluginId);
|
||||
ColdDeviceStorage.set('plugins', this.plugins.filter(x => x.id !== this.selectedPluginId));
|
||||
os.success();
|
||||
this.$nextTick(() => {
|
||||
location.reload();
|
||||
@ -171,10 +184,9 @@ export default defineComponent({
|
||||
const { canceled, result } = await os.form(this.selectedPlugin.name, config);
|
||||
if (canceled) return;
|
||||
|
||||
this.$store.commit('deviceUser/configPlugin', {
|
||||
id: this.selectedPluginId,
|
||||
config: result
|
||||
});
|
||||
const plugins = ColdDeviceStorage.get('plugins');
|
||||
plugins.find(p => p.id === this.selectedPluginId).configData = result;
|
||||
ColdDeviceStorage.set('plugins', plugins);
|
||||
|
||||
this.$nextTick(() => {
|
||||
location.reload();
|
||||
@ -182,10 +194,9 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
changeActive(plugin, active) {
|
||||
this.$store.commit('deviceUser/changePluginActive', {
|
||||
id: plugin.id,
|
||||
active: active
|
||||
});
|
||||
const plugins = ColdDeviceStorage.get('plugins');
|
||||
plugins.find(p => p.id === plugin.id).active = active;
|
||||
ColdDeviceStorage.set('plugins', plugins);
|
||||
|
||||
this.$nextTick(() => {
|
||||
location.reload();
|
||||
|
@ -35,6 +35,7 @@ import FormSelect from '@/components/form/select.vue';
|
||||
import FormBase from '@/components/form/base.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import * as os from '@/os';
|
||||
import { defaultStore } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -60,27 +61,16 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
computed: {
|
||||
defaultNoteVisibility: {
|
||||
get() { return this.$store.state.settings.defaultNoteVisibility; },
|
||||
set(value) { this.$store.dispatch('settings/set', { key: 'defaultNoteVisibility', value }); }
|
||||
},
|
||||
|
||||
defaultNoteLocalOnly: {
|
||||
get() { return this.$store.state.settings.defaultNoteLocalOnly; },
|
||||
set(value) { this.$store.dispatch('settings/set', { key: 'defaultNoteLocalOnly', value }); }
|
||||
},
|
||||
|
||||
rememberNoteVisibility: {
|
||||
get() { return this.$store.state.settings.rememberNoteVisibility; },
|
||||
set(value) { this.$store.dispatch('settings/set', { key: 'rememberNoteVisibility', value }); }
|
||||
},
|
||||
defaultNoteVisibility: defaultStore.makeGetterSetter('defaultNoteVisibility'),
|
||||
defaultNoteLocalOnly: defaultStore.makeGetterSetter('defaultNoteLocalOnly'),
|
||||
rememberNoteVisibility: defaultStore.makeGetterSetter('rememberNoteVisibility'),
|
||||
},
|
||||
|
||||
created() {
|
||||
this.isLocked = this.$store.state.i.isLocked;
|
||||
this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
|
||||
this.noCrawle = this.$store.state.i.noCrawle;
|
||||
this.isExplorable = this.$store.state.i.isExplorable;
|
||||
this.isLocked = this.$i.isLocked;
|
||||
this.autoAcceptFollowed = this.$i.autoAcceptFollowed;
|
||||
this.noCrawle = this.$i.noCrawle;
|
||||
this.isExplorable = this.$i.isExplorable;
|
||||
},
|
||||
|
||||
mounted() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<FormBase>
|
||||
<FormGroup>
|
||||
<div class="_formItem _formPanel llvierxe" :style="{ backgroundImage: $store.state.i.bannerUrl ? `url(${ $store.state.i.bannerUrl })` : null }">
|
||||
<MkAvatar class="avatar" :user="$store.state.i"/>
|
||||
<div class="_formItem _formPanel llvierxe" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
|
||||
<MkAvatar class="avatar" :user="$i"/>
|
||||
</div>
|
||||
<FormButton @click="changeAvatar" primary>{{ $t('_profile.changeAvatar') }}</FormButton>
|
||||
<FormButton @click="changeBanner" primary>{{ $t('_profile.changeBanner') }}</FormButton>
|
||||
@ -100,24 +100,24 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
created() {
|
||||
this.name = this.$store.state.i.name;
|
||||
this.description = this.$store.state.i.description;
|
||||
this.location = this.$store.state.i.location;
|
||||
this.birthday = this.$store.state.i.birthday;
|
||||
this.avatarId = this.$store.state.i.avatarId;
|
||||
this.bannerId = this.$store.state.i.bannerId;
|
||||
this.isBot = this.$store.state.i.isBot;
|
||||
this.isCat = this.$store.state.i.isCat;
|
||||
this.alwaysMarkNsfw = this.$store.state.i.alwaysMarkNsfw;
|
||||
this.name = this.$i.name;
|
||||
this.description = this.$i.description;
|
||||
this.location = this.$i.location;
|
||||
this.birthday = this.$i.birthday;
|
||||
this.avatarId = this.$i.avatarId;
|
||||
this.bannerId = this.$i.bannerId;
|
||||
this.isBot = this.$i.isBot;
|
||||
this.isCat = this.$i.isCat;
|
||||
this.alwaysMarkNsfw = this.$i.alwaysMarkNsfw;
|
||||
|
||||
this.fieldName0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].name : null;
|
||||
this.fieldValue0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].value : null;
|
||||
this.fieldName1 = this.$store.state.i.fields[1] ? this.$store.state.i.fields[1].name : null;
|
||||
this.fieldValue1 = this.$store.state.i.fields[1] ? this.$store.state.i.fields[1].value : null;
|
||||
this.fieldName2 = this.$store.state.i.fields[2] ? this.$store.state.i.fields[2].name : null;
|
||||
this.fieldValue2 = this.$store.state.i.fields[2] ? this.$store.state.i.fields[2].value : null;
|
||||
this.fieldName3 = this.$store.state.i.fields[3] ? this.$store.state.i.fields[3].name : null;
|
||||
this.fieldValue3 = this.$store.state.i.fields[3] ? this.$store.state.i.fields[3].value : null;
|
||||
this.fieldName0 = this.$i.fields[0] ? this.$i.fields[0].name : null;
|
||||
this.fieldValue0 = this.$i.fields[0] ? this.$i.fields[0].value : null;
|
||||
this.fieldName1 = this.$i.fields[1] ? this.$i.fields[1].name : null;
|
||||
this.fieldValue1 = this.$i.fields[1] ? this.$i.fields[1].value : null;
|
||||
this.fieldName2 = this.$i.fields[2] ? this.$i.fields[2].name : null;
|
||||
this.fieldValue2 = this.$i.fields[2] ? this.$i.fields[2].value : null;
|
||||
this.fieldName3 = this.$i.fields[3] ? this.$i.fields[3].name : null;
|
||||
this.fieldValue3 = this.$i.fields[3] ? this.$i.fields[3].value : null;
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -227,10 +227,10 @@ export default defineComponent({
|
||||
alwaysMarkNsfw: !!this.alwaysMarkNsfw,
|
||||
}).then(i => {
|
||||
this.saving = false;
|
||||
this.$store.state.i.avatarId = i.avatarId;
|
||||
this.$store.state.i.avatarUrl = i.avatarUrl;
|
||||
this.$store.state.i.bannerId = i.bannerId;
|
||||
this.$store.state.i.bannerUrl = i.bannerUrl;
|
||||
this.$i.avatarId = i.avatarId;
|
||||
this.$i.avatarUrl = i.avatarUrl;
|
||||
this.$i.bannerId = i.bannerId;
|
||||
this.$i.bannerUrl = i.bannerUrl;
|
||||
|
||||
if (notify) {
|
||||
os.success();
|
||||
|
@ -43,8 +43,8 @@ import FormInput from '@/components/form/input.vue';
|
||||
import FormRadios from '@/components/form/radios.vue';
|
||||
import FormBase from '@/components/form/base.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import { defaultSettings } from '@/store';
|
||||
import * as os from '@/os';
|
||||
import { defaultStore } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -67,24 +67,14 @@ export default defineComponent({
|
||||
handler: this.preview
|
||||
}
|
||||
},
|
||||
reactions: JSON.parse(JSON.stringify(this.$store.state.settings.reactions)),
|
||||
reactions: JSON.parse(JSON.stringify(this.$store.state.reactions)),
|
||||
faLaugh, faSave, faEye, faUndo, faPlus
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
useFullReactionPicker: {
|
||||
get() { return this.$store.state.device.useFullReactionPicker; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'useFullReactionPicker', value: value }); }
|
||||
},
|
||||
reactionPickerWidth: {
|
||||
get() { return this.$store.state.device.reactionPickerWidth; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'reactionPickerWidth', value: value }); }
|
||||
},
|
||||
reactionPickerHeight: {
|
||||
get() { return this.$store.state.device.reactionPickerHeight; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'reactionPickerHeight', value: value }); }
|
||||
},
|
||||
reactionPickerWidth: defaultStore.makeGetterSetter('reactionPickerWidth'),
|
||||
reactionPickerHeight: defaultStore.makeGetterSetter('reactionPickerHeight'),
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -102,7 +92,7 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
save() {
|
||||
this.$store.dispatch('settings/set', { key: 'reactions', value: this.reactions });
|
||||
this.$store.set('reactions', this.reactions);
|
||||
},
|
||||
|
||||
remove(reaction, ev) {
|
||||
@ -129,7 +119,7 @@ export default defineComponent({
|
||||
});
|
||||
if (canceled) return;
|
||||
|
||||
this.reactions = JSON.parse(JSON.stringify(defaultSettings.reactions));
|
||||
this.reactions = JSON.parse(JSON.stringify(this.$store.def.reactions.default));
|
||||
},
|
||||
|
||||
chooseEmoji(ev) {
|
||||
|
@ -1,75 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="_section">
|
||||
<MkInfo warn>{{ $t('editTheseSettingsMayBreakAccount') }}</MkInfo>
|
||||
</div>
|
||||
<div class="_section">
|
||||
<div class="_title">Account</div>
|
||||
<div class="_content">
|
||||
<MkTextarea v-model:value="settings" code tall></MkTextarea>
|
||||
<!--<MkButton @click="saveSettings">Save</MkButton>-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="_section">
|
||||
<div class="_title">Device</div>
|
||||
<div class="_content">
|
||||
<MkTextarea v-model:value="deviceSettings" code tall></MkTextarea>
|
||||
<MkButton @click="saveDeviceSettings">Save</MkButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="_section">
|
||||
<div class="_title">Device (per account)</div>
|
||||
<div class="_content">
|
||||
<MkTextarea v-model:value="deviceUserSettings" code tall></MkTextarea>
|
||||
<MkButton @click="saveDeviceUserSettings">Save</MkButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { faCode } from '@fortawesome/free-solid-svg-icons';
|
||||
import * as JSON5 from 'json5';
|
||||
import MkInfo from '@/components/ui/info.vue';
|
||||
import MkButton from '@/components/ui/button.vue';
|
||||
import MkTextarea from '@/components/ui/textarea.vue';
|
||||
import * as os from '@/os';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
MkInfo, MkButton, MkTextarea
|
||||
},
|
||||
|
||||
emits: ['info'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
INFO: {
|
||||
title: 'RegEdit',
|
||||
icon: faCode
|
||||
},
|
||||
|
||||
settings: JSON5.stringify(this.$store.state.settings, null, '\t'),
|
||||
deviceSettings: JSON5.stringify(this.$store.state.device, null, '\t'),
|
||||
deviceUserSettings: JSON5.stringify(this.$store.state.deviceUser, null, '\t'),
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$emit('info', this.INFO);
|
||||
},
|
||||
|
||||
methods: {
|
||||
saveDeviceSettings() {
|
||||
const obj = JSON5.parse(this.deviceSettings);
|
||||
this.$store.commit('device/overwrite', obj);
|
||||
},
|
||||
|
||||
saveDeviceUserSettings() {
|
||||
const obj = JSON5.parse(this.deviceUserSettings);
|
||||
this.$store.commit('deviceUser/overwrite', obj);
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
@ -26,9 +26,9 @@ import FormRadios from '@/components/form/radios.vue';
|
||||
import FormBase from '@/components/form/base.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import { defaultDeviceUserSettings } from '@/store';
|
||||
import * as os from '@/os';
|
||||
import { sidebarDef } from '@/sidebar';
|
||||
import { defaultStore } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -57,14 +57,11 @@ export default defineComponent({
|
||||
return this.items.trim().split('\n').filter(x => x.trim() !== '');
|
||||
},
|
||||
|
||||
sidebarDisplay: {
|
||||
get() { return this.$store.state.device.sidebarDisplay; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'sidebarDisplay', value }); }
|
||||
},
|
||||
sidebarDisplay: defaultStore.makeGetterSetter('sidebarDisplay')
|
||||
},
|
||||
|
||||
created() {
|
||||
this.items = this.$store.state.deviceUser.menu.join('\n');
|
||||
this.items = this.$store.state.menu.join('\n');
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -73,7 +70,7 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
async addItem() {
|
||||
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.deviceUser.menu.includes(k));
|
||||
const menu = Object.keys(this.menuDef).filter(k => !this.$store.state.menu.includes(k));
|
||||
const { canceled, result: item } = await os.dialog({
|
||||
type: null,
|
||||
title: this.$t('addItem'),
|
||||
@ -92,12 +89,12 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
save() {
|
||||
this.$store.commit('deviceUser/setMenu', this.splited);
|
||||
this.$store.set('menu', this.splited);
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.$store.commit('deviceUser/setMenu', defaultDeviceUserSettings.menu);
|
||||
this.items = this.$store.state.deviceUser.menu.join('\n');
|
||||
this.$store.reset('menu');
|
||||
this.items = this.$store.state.menu.join('\n');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ import FormBase from '@/components/form/base.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import * as os from '@/os';
|
||||
import { device, defaultDeviceSettings } from '@/cold-storage';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
import { playFile } from '@/scripts/sound';
|
||||
|
||||
const soundsTypes = [
|
||||
@ -79,8 +79,8 @@ export default defineComponent({
|
||||
|
||||
computed: {
|
||||
masterVolume: { // TODO: (外部)関数にcomputedを使うのはアレなので直す
|
||||
get() { return device.get('sound_masterVolume'); },
|
||||
set(value) { device.set('sound_masterVolume', value); }
|
||||
get() { return ColdDeviceStorage.get('sound_masterVolume'); },
|
||||
set(value) { ColdDeviceStorage.set('sound_masterVolume', value); }
|
||||
},
|
||||
volumeIcon() {
|
||||
return this.masterVolume === 0 ? faVolumeMute : faVolumeUp;
|
||||
@ -88,15 +88,15 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
created() {
|
||||
this.sounds.note = device.get('sound_note');
|
||||
this.sounds.noteMy = device.get('sound_noteMy');
|
||||
this.sounds.notification = device.get('sound_notification');
|
||||
this.sounds.chat = device.get('sound_chat');
|
||||
this.sounds.chatBg = device.get('sound_chatBg');
|
||||
this.sounds.antenna = device.get('sound_antenna');
|
||||
this.sounds.channel = device.get('sound_channel');
|
||||
this.sounds.reversiPutBlack = device.get('sound_reversiPutBlack');
|
||||
this.sounds.reversiPutWhite = device.get('sound_reversiPutWhite');
|
||||
this.sounds.note = ColdDeviceStorage.get('sound_note');
|
||||
this.sounds.noteMy = ColdDeviceStorage.get('sound_noteMy');
|
||||
this.sounds.notification = ColdDeviceStorage.get('sound_notification');
|
||||
this.sounds.chat = ColdDeviceStorage.get('sound_chat');
|
||||
this.sounds.chatBg = ColdDeviceStorage.get('sound_chatBg');
|
||||
this.sounds.antenna = ColdDeviceStorage.get('sound_antenna');
|
||||
this.sounds.channel = ColdDeviceStorage.get('sound_channel');
|
||||
this.sounds.reversiPutBlack = ColdDeviceStorage.get('sound_reversiPutBlack');
|
||||
this.sounds.reversiPutWhite = ColdDeviceStorage.get('sound_reversiPutWhite');
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@ -138,14 +138,14 @@ export default defineComponent({
|
||||
volume: result.volume,
|
||||
};
|
||||
|
||||
device.set('sound_' + type, v);
|
||||
ColdDeviceStorage.set('sound_' + type, v);
|
||||
this.sounds[type] = v;
|
||||
},
|
||||
|
||||
reset() {
|
||||
for (const sound of Object.keys(this.sounds)) {
|
||||
const v = defaultDeviceSettings['sound_' + sound];
|
||||
device.set('sound_' + sound, v);
|
||||
const v = ColdDeviceStorage.default['sound_' + sound];
|
||||
ColdDeviceStorage.set('sound_' + sound, v);
|
||||
this.sounds[sound] = v;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import FormLink from '@/components/form/link.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import { applyTheme, validateTheme } from '@/scripts/theme';
|
||||
import * as os from '@/os';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -73,7 +74,7 @@ export default defineComponent({
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (this.$store.state.device.themes.some(t => t.id === theme.id)) {
|
||||
if (ColdDeviceStorage.get('themes').some(t => t.id === theme.id)) {
|
||||
os.dialog({
|
||||
type: 'info',
|
||||
text: this.$t('_theme.alreadyInstalled')
|
||||
@ -92,10 +93,8 @@ export default defineComponent({
|
||||
install(code) {
|
||||
const theme = this.parseThemeCode(code);
|
||||
if (!theme) return;
|
||||
const themes = this.$store.state.device.themes.concat(theme);
|
||||
this.$store.commit('device/set', {
|
||||
key: 'themes', value: themes
|
||||
});
|
||||
const themes = ColdDeviceStorage.get('themes').concat(theme);
|
||||
ColdDeviceStorage.set('themes', themes);
|
||||
os.dialog({
|
||||
type: 'success',
|
||||
text: this.$t('_theme.installed', { name: theme.name })
|
||||
|
@ -34,6 +34,7 @@ import FormButton from '@/components/form/button.vue';
|
||||
import { Theme, builtinThemes } from '@/scripts/theme';
|
||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||
import * as os from '@/os';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@ -54,6 +55,7 @@ export default defineComponent({
|
||||
title: this.$t('_theme.manage'),
|
||||
icon: faFolderOpen
|
||||
},
|
||||
installedThemes: ColdDeviceStorage.ref('themes'),
|
||||
builtinThemes,
|
||||
selectedThemeId: null,
|
||||
faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye
|
||||
@ -62,11 +64,7 @@ export default defineComponent({
|
||||
|
||||
computed: {
|
||||
themes(): Theme[] {
|
||||
return builtinThemes.concat(this.$store.state.device.themes);
|
||||
},
|
||||
|
||||
installedThemes(): Theme[] {
|
||||
return this.$store.state.device.themes;
|
||||
return this.builtinThemes.concat(this.installedThemes.value);
|
||||
},
|
||||
|
||||
selectedTheme() {
|
||||
@ -92,10 +90,8 @@ export default defineComponent({
|
||||
|
||||
uninstall() {
|
||||
const theme = this.selectedTheme;
|
||||
const themes = this.$store.state.device.themes.filter(t => t.id != theme.id);
|
||||
this.$store.commit('device/set', {
|
||||
key: 'themes', value: themes
|
||||
});
|
||||
const themes = ColdDeviceStorage.get('themes').filter(t => t.id != theme.id);
|
||||
ColdDeviceStorage.set('themes', themes);
|
||||
os.success();
|
||||
},
|
||||
}
|
||||
|
@ -60,25 +60,25 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { computed, defineComponent, onMounted, ref, watch } from 'vue';
|
||||
import { faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye } from '@fortawesome/free-solid-svg-icons';
|
||||
import FormSwitch from '@/components/form/switch.vue';
|
||||
import FormSelect from '@/components/form/select.vue';
|
||||
import FormRadios from '@/components/form/radios.vue';
|
||||
import FormBase from '@/components/form/base.vue';
|
||||
import FormGroup from '@/components/form/group.vue';
|
||||
import FormLink from '@/components/form/link.vue';
|
||||
import FormButton from '@/components/form/button.vue';
|
||||
import { Theme, builtinThemes, applyTheme } from '@/scripts/theme';
|
||||
import { builtinThemes, applyTheme } from '@/scripts/theme';
|
||||
import { selectFile } from '@/scripts/select-file';
|
||||
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode';
|
||||
import * as os from '@/os';
|
||||
import { ColdDeviceStorage } from '@/store';
|
||||
import { i18n } from '@/i18n';
|
||||
import { defaultStore } from '@/store';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
FormSwitch,
|
||||
FormSelect,
|
||||
FormRadios,
|
||||
FormBase,
|
||||
FormGroup,
|
||||
FormLink,
|
||||
@ -86,96 +86,70 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
emits: ['info'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
INFO: {
|
||||
title: this.$t('theme'),
|
||||
icon: faPalette
|
||||
},
|
||||
builtinThemes,
|
||||
wallpaper: localStorage.getItem('wallpaper'),
|
||||
faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
themes(): Theme[] {
|
||||
return builtinThemes.concat(this.$store.state.device.themes);
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const INFO = {
|
||||
title: i18n.global.t('theme'),
|
||||
icon: faPalette
|
||||
};
|
||||
|
||||
installedThemes(): Theme[] {
|
||||
return this.$store.state.device.themes;
|
||||
},
|
||||
|
||||
darkThemes(): Theme[] {
|
||||
return this.themes.filter(t => t.base == 'dark' || t.kind == 'dark');
|
||||
},
|
||||
const installedThemes = ColdDeviceStorage.ref('themes');
|
||||
const themes = computed(() => builtinThemes.concat(installedThemes.value));
|
||||
const darkThemes = computed(() => themes.value.filter(t => t.base == 'dark' || t.kind == 'dark'));
|
||||
const lightThemes = computed(() => themes.value.filter(t => t.base == 'light' || t.kind == 'light'));
|
||||
const darkTheme = computed(ColdDeviceStorage.makeGetterSetter('darkTheme'));
|
||||
const lightTheme = computed(ColdDeviceStorage.makeGetterSetter('lightTheme'));
|
||||
const darkMode = computed(defaultStore.makeGetterSetter('darkMode'));
|
||||
const syncDeviceDarkMode = computed(ColdDeviceStorage.makeGetterSetter('syncDeviceDarkMode'));
|
||||
const wallpaper = ref(localStorage.getItem('wallpaper'));
|
||||
|
||||
lightThemes(): Theme[] {
|
||||
return this.themes.filter(t => t.base == 'light' || t.kind == 'light');
|
||||
},
|
||||
|
||||
darkTheme: {
|
||||
get() { return this.$store.state.device.darkTheme; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'darkTheme', value }); }
|
||||
},
|
||||
|
||||
lightTheme: {
|
||||
get() { return this.$store.state.device.lightTheme; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'lightTheme', value }); }
|
||||
},
|
||||
|
||||
darkMode: {
|
||||
get() { return this.$store.state.device.darkMode; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'darkMode', value }); }
|
||||
},
|
||||
|
||||
syncDeviceDarkMode: {
|
||||
get() { return this.$store.state.device.syncDeviceDarkMode; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'syncDeviceDarkMode', value }); }
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
darkTheme() {
|
||||
if (this.$store.state.device.darkMode) {
|
||||
applyTheme(this.themes.find(x => x.id === this.darkTheme));
|
||||
watch(darkTheme, () => {
|
||||
if (defaultStore.state.darkMode) {
|
||||
applyTheme(themes.value.find(x => x.id === darkTheme.value));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
lightTheme() {
|
||||
if (!this.$store.state.device.darkMode) {
|
||||
applyTheme(this.themes.find(x => x.id === this.lightTheme));
|
||||
watch(lightTheme, () => {
|
||||
if (!defaultStore.state.darkMode) {
|
||||
applyTheme(themes.value.find(x => x.id === lightTheme.value));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
syncDeviceDarkMode() {
|
||||
if (this.$store.state.device.syncDeviceDarkMode) {
|
||||
this.$store.commit('device/set', { key: 'darkMode', value: isDeviceDarkmode() });
|
||||
watch(syncDeviceDarkMode, () => {
|
||||
if (syncDeviceDarkMode) {
|
||||
defaultStore.set('darkMode', isDeviceDarkmode());
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
wallpaper() {
|
||||
if (this.wallpaper == null) {
|
||||
watch(wallpaper, () => {
|
||||
if (wallpaper.value == null) {
|
||||
localStorage.removeItem('wallpaper');
|
||||
} else {
|
||||
localStorage.setItem('wallpaper', this.wallpaper);
|
||||
localStorage.setItem('wallpaper', wallpaper.value);
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
mounted() {
|
||||
this.$emit('info', this.INFO);
|
||||
},
|
||||
onMounted(() => {
|
||||
emit('info', INFO);
|
||||
});
|
||||
|
||||
methods: {
|
||||
setWallpaper(e) {
|
||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
||||
this.wallpaper = file.url;
|
||||
});
|
||||
},
|
||||
return {
|
||||
INFO,
|
||||
darkThemes,
|
||||
lightThemes,
|
||||
darkTheme,
|
||||
lightTheme,
|
||||
darkMode,
|
||||
syncDeviceDarkMode,
|
||||
wallpaper,
|
||||
setWallpaper(e) {
|
||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
||||
wallpaper.value = file.url;
|
||||
});
|
||||
},
|
||||
faPalette, faDownload, faFolderOpen, faCheck, faTrashAlt, faEye
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -85,8 +85,8 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
async created() {
|
||||
this.softMutedWords = this.$store.state.settings.mutedWords.map(x => x.join(' ')).join('\n');
|
||||
this.hardMutedWords = this.$store.state.i.mutedWords.map(x => x.join(' ')).join('\n');
|
||||
this.softMutedWords = this.$store.state.mutedWords.map(x => x.join(' ')).join('\n');
|
||||
this.hardMutedWords = this.$i.mutedWords.map(x => x.join(' ')).join('\n');
|
||||
|
||||
this.hardWordMutedNotesCount = (await os.api('i/get-word-muted-notes-count', {})).count;
|
||||
},
|
||||
@ -97,7 +97,7 @@ export default defineComponent({
|
||||
|
||||
methods: {
|
||||
async save() {
|
||||
this.$store.dispatch('settings/set', { key: 'mutedWords', value: this.softMutedWords.trim().split('\n').map(x => x.trim().split(' ')) });
|
||||
this.$store.set('mutedWords', this.softMutedWords.trim().split('\n').map(x => x.trim().split(' ')));
|
||||
await os.api('i/update', {
|
||||
mutedWords: this.hardMutedWords.trim().split('\n').map(x => x.trim().split(' ')),
|
||||
});
|
||||
|
Reference in New Issue
Block a user