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:
syuilo
2020-12-19 10:55:52 +09:00
committed by GitHub
parent 57d0c19a98
commit 43930e6a84
146 changed files with 1458 additions and 1519 deletions

View File

@@ -12,7 +12,7 @@
<nav class="nav" :class="{ iconOnly, hidden }" v-show="showing">
<div>
<button class="item _button account" @click="openAccountMenu">
<MkAvatar :user="$store.state.i" class="avatar"/><MkAcct class="text" :user="$store.state.i"/>
<MkAvatar :user="$i" class="avatar"/><MkAcct class="text" :user="$i"/>
</button>
<MkA class="item index" active-class="active" to="/" exact>
<Fa :icon="faHome" fixed-width/><span class="text">{{ $t('timeline') }}</span>
@@ -25,7 +25,7 @@
</component>
</template>
<div class="divider"></div>
<button class="item _button" :class="{ active: $route.path === '/instance' || $route.path.startsWith('/instance/') }" v-if="$store.state.i.isAdmin || $store.state.i.isModerator" @click="oepnInstanceMenu">
<button class="item _button" :class="{ active: $route.path === '/instance' || $route.path.startsWith('/instance/') }" v-if="$i.isAdmin || $i.isModerator" @click="oepnInstanceMenu">
<Fa :icon="faServer" fixed-width/><span class="text">{{ $t('instance') }}</span>
</button>
<button class="item _button" @click="more">
@@ -49,6 +49,7 @@ import { host } from '@/config';
import { search } from '@/scripts/search';
import * as os from '@/os';
import { sidebarDef } from '@/sidebar';
import { getAccounts, addAccount, login } from '@/account';
export default defineComponent({
data() {
@@ -67,7 +68,7 @@ export default defineComponent({
computed: {
menu(): string[] {
return this.$store.state.deviceUser.menu;
return this.$store.state.menu;
},
otherNavItemIndicated(): boolean {
@@ -84,7 +85,7 @@ export default defineComponent({
this.showing = false;
},
'$store.state.device.sidebarDisplay'() {
'$store.reactiveState.sidebarDisplay'() {
this.calcViewState();
},
@@ -108,8 +109,8 @@ export default defineComponent({
methods: {
calcViewState() {
this.iconOnly = (window.innerWidth <= 1279) || (this.$store.state.device.sidebarDisplay === 'icon');
this.hidden = (window.innerWidth <= 650) || (this.$store.state.device.sidebarDisplay === 'hide');
this.iconOnly = (window.innerWidth <= 1279) || (this.$store.state.sidebarDisplay === 'icon');
this.hidden = (window.innerWidth <= 650);
},
show() {
@@ -133,7 +134,8 @@ export default defineComponent({
},
async openAccountMenu(ev) {
const accounts = (await os.api('users/show', { userIds: this.$store.state.device.accounts.map(x => x.id) })).filter(x => x.id !== this.$store.state.i.id);
const storedAccounts = getAccounts();
const accounts = (await os.api('users/show', { userIds: storedAccounts.map(x => x.id) })).filter(x => x.id !== this.$i.id);
const accountItems = accounts.map(account => ({
type: 'user',
@@ -144,8 +146,8 @@ export default defineComponent({
os.modalMenu([...[{
type: 'link',
text: this.$t('profile'),
to: `/@${ this.$store.state.i.username }`,
avatar: this.$store.state.i,
to: `/@${ this.$i.username }`,
avatar: this.$i,
}, null, ...accountItems, {
icon: faPlus,
text: this.$t('addAcount'),
@@ -169,7 +171,7 @@ export default defineComponent({
text: this.$t('dashboard'),
to: '/instance',
icon: faTachometerAlt,
}, null, this.$store.state.i.isAdmin ? {
}, null, this.$i.isAdmin ? {
type: 'link',
text: this.$t('settings'),
to: '/instance/settings',
@@ -230,7 +232,7 @@ export default defineComponent({
addAcount() {
os.popup(import('./signin-dialog.vue'), {}, {
done: res => {
this.$store.dispatch('addAcount', res);
addAccount(res.id, res.i);
os.success();
},
}, 'closed');
@@ -239,30 +241,20 @@ export default defineComponent({
createAccount() {
os.popup(import('./signup-dialog.vue'), {}, {
done: res => {
this.$store.dispatch('addAcount', res);
addAccount(res.id, res.i);
this.switchAccountWithToken(res.i);
},
}, 'closed');
},
switchAccount(account: any) {
const token = this.$store.state.device.accounts.find((x: any) => x.id === account.id).token;
const storedAccounts = getAccounts();
const token = storedAccounts.find(x => x.id === account.id).token;
this.switchAccountWithToken(token);
},
switchAccountWithToken(token: string) {
os.waiting();
os.api('i', {}, token).then((i: any) => {
this.$store.dispatch('switchAccount', {
...i,
token: token
}).then(() => {
this.$nextTick(() => {
location.reload();
});
});
});
login(token);
},
}
});