2018-02-09 09:46:23 +09:00
|
|
|
<template>
|
2018-02-11 13:02:35 +09:00
|
|
|
<div class="mk-home" :data-customize="customize">
|
2018-02-09 13:11:30 +09:00
|
|
|
<div class="customize" v-if="customize">
|
2018-11-09 03:44:35 +09:00
|
|
|
<router-link to="/"><fa icon="check"/>{{ $t('done') }}</router-link>
|
2018-02-09 13:11:30 +09:00
|
|
|
<div>
|
|
|
|
<div class="adder">
|
2018-11-09 03:44:35 +09:00
|
|
|
<p>{{ $t('add-widget') }}</p>
|
2018-02-11 13:02:35 +09:00
|
|
|
<select v-model="widgetAdderSelected">
|
2018-11-09 03:44:35 +09:00
|
|
|
<option value="profile">{{ $t('@.widgets.profile') }}</option>
|
|
|
|
<option value="analog-clock">{{ $t('@.widgets.analog-clock') }}</option>
|
|
|
|
<option value="calendar">{{ $t('@.widgets.calendar') }}</option>
|
|
|
|
<option value="timemachine">{{ $t('@.widgets.timemachine') }}</option>
|
|
|
|
<option value="activity">{{ $t('@.widgets.activity') }}</option>
|
|
|
|
<option value="rss">{{ $t('@.widgets.rss') }}</option>
|
|
|
|
<option value="trends">{{ $t('@.widgets.trends') }}</option>
|
|
|
|
<option value="photo-stream">{{ $t('@.widgets.photo-stream') }}</option>
|
|
|
|
<option value="slideshow">{{ $t('@.widgets.slideshow') }}</option>
|
|
|
|
<option value="version">{{ $t('@.widgets.version') }}</option>
|
|
|
|
<option value="broadcast">{{ $t('@.widgets.broadcast') }}</option>
|
|
|
|
<option value="notifications">{{ $t('@.widgets.notifications') }}</option>
|
|
|
|
<option value="users">{{ $t('@.widgets.users') }}</option>
|
|
|
|
<option value="polls">{{ $t('@.widgets.polls') }}</option>
|
|
|
|
<option value="post-form">{{ $t('@.widgets.post-form') }}</option>
|
|
|
|
<option value="messaging">{{ $t('@.widgets.messaging') }}</option>
|
|
|
|
<option value="memo">{{ $t('@.widgets.memo') }}</option>
|
|
|
|
<option value="hashtags">{{ $t('@.widgets.hashtags') }}</option>
|
|
|
|
<option value="posts-monitor">{{ $t('@.widgets.posts-monitor') }}</option>
|
|
|
|
<option value="server">{{ $t('@.widgets.server') }}</option>
|
|
|
|
<option value="donation">{{ $t('@.widgets.donation') }}</option>
|
|
|
|
<option value="nav">{{ $t('@.widgets.nav') }}</option>
|
|
|
|
<option value="tips">{{ $t('@.widgets.tips') }}</option>
|
2018-02-09 13:11:30 +09:00
|
|
|
</select>
|
2018-11-09 03:44:35 +09:00
|
|
|
<button @click="addWidget">{{ $t('add') }}</button>
|
2018-02-09 13:11:30 +09:00
|
|
|
</div>
|
|
|
|
<div class="trash">
|
2018-02-22 00:07:37 +09:00
|
|
|
<x-draggable v-model="trash" :options="{ group: 'x' }" @add="onTrash"></x-draggable>
|
2018-11-09 03:44:35 +09:00
|
|
|
<p>{{ $t('@.trash') }}</p>
|
2018-02-09 13:11:30 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-15 06:03:15 +09:00
|
|
|
<div class="main" :class="{ side: widgets.left.length == 0 || widgets.right.length == 0 }">
|
2018-02-22 00:07:37 +09:00
|
|
|
<template v-if="customize">
|
|
|
|
<x-draggable v-for="place in ['left', 'right']"
|
|
|
|
:list="widgets[place]"
|
|
|
|
:class="place"
|
|
|
|
:data-place="place"
|
|
|
|
:options="{ group: 'x', animation: 150 }"
|
|
|
|
@sort="onWidgetSort"
|
|
|
|
:key="place"
|
|
|
|
>
|
|
|
|
<div v-for="widget in widgets[place]" class="customize-container" :key="widget.id" @contextmenu.stop.prevent="onWidgetContextmenu(widget.id)">
|
2018-06-06 19:22:45 +09:00
|
|
|
<component :is="`mkw-${widget.name}`" :widget="widget" :ref="widget.id" :is-customize-mode="true" platform="desktop"/>
|
2018-02-22 00:07:37 +09:00
|
|
|
</div>
|
|
|
|
</x-draggable>
|
|
|
|
<div class="main">
|
2018-11-09 03:44:35 +09:00
|
|
|
<a @click="hint">{{ $t('@.customization-tips.title') }}</a>
|
2018-02-23 02:06:35 +09:00
|
|
|
<div>
|
2018-05-27 13:49:09 +09:00
|
|
|
<mk-post-form v-if="$store.state.settings.showPostFormOnTopOfTl"/>
|
2018-02-23 02:06:35 +09:00
|
|
|
<mk-timeline ref="tl" @loaded="onTlLoaded"/>
|
|
|
|
</div>
|
2018-02-22 00:07:37 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<div v-for="place in ['left', 'right']" :class="place">
|
2018-06-06 19:22:45 +09:00
|
|
|
<component v-for="widget in widgets[place]" :is="`mkw-${widget.name}`" :key="widget.id" :ref="widget.id" :widget="widget" @chosen="warp" platform="desktop"/>
|
2018-02-22 00:07:37 +09:00
|
|
|
</div>
|
|
|
|
<div class="main">
|
2018-05-31 16:44:11 +09:00
|
|
|
<mk-post-form class="form" v-if="$store.state.settings.showPostFormOnTopOfTl"/>
|
2018-06-23 12:09:09 +09:00
|
|
|
<mk-timeline class="tl" ref="tl" @loaded="onTlLoaded" v-if="mode == 'timeline'"/>
|
2018-02-22 00:07:37 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
2018-02-09 09:46:23 +09:00
|
|
|
</div>
|
2018-02-09 13:11:30 +09:00
|
|
|
</div>
|
2018-02-09 09:46:23 +09:00
|
|
|
</template>
|
|
|
|
|
2018-02-11 13:09:46 +09:00
|
|
|
<script lang="ts">
|
2018-02-11 13:02:35 +09:00
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-22 00:07:37 +09:00
|
|
|
import * as XDraggable from 'vuedraggable';
|
2018-02-11 13:09:46 +09:00
|
|
|
import * as uuid from 'uuid';
|
2018-02-09 13:11:30 +09:00
|
|
|
|
2018-06-06 02:48:26 +09:00
|
|
|
const defaultDesktopHomeWidgets = {
|
|
|
|
left: [
|
|
|
|
'profile',
|
|
|
|
'calendar',
|
|
|
|
'activity',
|
|
|
|
'rss',
|
2018-06-17 06:57:50 +09:00
|
|
|
'hashtags',
|
2018-06-06 02:48:26 +09:00
|
|
|
'photo-stream',
|
|
|
|
'version'
|
|
|
|
],
|
|
|
|
right: [
|
|
|
|
'broadcast',
|
|
|
|
'notifications',
|
|
|
|
'users',
|
|
|
|
'polls',
|
|
|
|
'server',
|
|
|
|
'donation',
|
|
|
|
'nav',
|
|
|
|
'tips'
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
//#region Construct home data
|
|
|
|
const _defaultDesktopHomeWidgets = [];
|
|
|
|
|
|
|
|
defaultDesktopHomeWidgets.left.forEach(widget => {
|
|
|
|
_defaultDesktopHomeWidgets.push({
|
|
|
|
name: widget,
|
|
|
|
id: uuid(),
|
|
|
|
place: 'left',
|
|
|
|
data: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
defaultDesktopHomeWidgets.right.forEach(widget => {
|
|
|
|
_defaultDesktopHomeWidgets.push({
|
|
|
|
name: widget,
|
|
|
|
id: uuid(),
|
|
|
|
place: 'right',
|
|
|
|
data: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//#endregion
|
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('desktop/views/components/home.vue'),
|
2018-02-22 00:07:37 +09:00
|
|
|
components: {
|
|
|
|
XDraggable
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
props: {
|
2018-04-08 03:58:11 +09:00
|
|
|
customize: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
2018-02-09 13:11:30 +09:00
|
|
|
mode: {
|
|
|
|
type: String,
|
|
|
|
default: 'timeline'
|
|
|
|
}
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2018-02-24 07:49:03 +09:00
|
|
|
connection: null,
|
2018-02-22 00:07:37 +09:00
|
|
|
widgetAdderSelected: null,
|
2018-04-29 17:17:15 +09:00
|
|
|
trash: []
|
2018-02-09 13:11:30 +09:00
|
|
|
};
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-19 18:26:20 +09:00
|
|
|
computed: {
|
2018-04-29 17:17:15 +09:00
|
|
|
home(): any[] {
|
2018-06-06 03:03:56 +09:00
|
|
|
return this.$store.state.settings.home || [];
|
2018-02-21 20:55:03 +09:00
|
|
|
},
|
2018-02-22 00:07:37 +09:00
|
|
|
left(): any[] {
|
2018-02-21 20:55:03 +09:00
|
|
|
return this.home.filter(w => w.place == 'left');
|
2018-02-19 18:26:20 +09:00
|
|
|
},
|
2018-02-22 00:07:37 +09:00
|
|
|
right(): any[] {
|
2018-02-21 20:55:03 +09:00
|
|
|
return this.home.filter(w => w.place == 'right');
|
2018-04-29 17:17:15 +09:00
|
|
|
},
|
|
|
|
widgets(): any {
|
|
|
|
return {
|
|
|
|
left: this.left,
|
|
|
|
right: this.right
|
|
|
|
};
|
2018-02-19 18:26:20 +09:00
|
|
|
}
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-06-06 02:48:26 +09:00
|
|
|
created() {
|
2018-06-06 03:03:56 +09:00
|
|
|
if (this.$store.state.settings.home == null) {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.api('i/update_home', {
|
2018-06-06 02:48:26 +09:00
|
|
|
home: _defaultDesktopHomeWidgets
|
2018-06-06 03:03:56 +09:00
|
|
|
}).then(() => {
|
|
|
|
this.$store.commit('settings/setHome', _defaultDesktopHomeWidgets);
|
2018-06-06 02:48:26 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-24 07:49:03 +09:00
|
|
|
mounted() {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.connection = this.$root.stream.useSharedConnection('main');
|
2018-02-24 07:49:03 +09:00
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-24 07:49:03 +09:00
|
|
|
beforeDestroy() {
|
2018-10-07 11:06:17 +09:00
|
|
|
this.connection.dispose();
|
2018-02-24 07:49:03 +09:00
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
methods: {
|
2018-02-23 02:06:35 +09:00
|
|
|
hint() {
|
2018-12-02 15:28:52 +09:00
|
|
|
this.$root.dialog({
|
2018-11-09 03:44:35 +09:00
|
|
|
title: this.$t('@.customization-tips.title'),
|
2018-11-14 16:30:58 +09:00
|
|
|
text: this.$t('@.customization-tips.paragraph')
|
2018-02-23 02:06:35 +09:00
|
|
|
});
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
onTlLoaded() {
|
|
|
|
this.$emit('loaded');
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
onWidgetContextmenu(widgetId) {
|
2018-02-22 01:08:49 +09:00
|
|
|
const w = (this.$refs[widgetId] as any)[0];
|
|
|
|
if (w.func) w.func();
|
2018-02-09 13:11:30 +09:00
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-22 00:07:37 +09:00
|
|
|
onWidgetSort() {
|
|
|
|
this.saveHome();
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-22 00:07:37 +09:00
|
|
|
onTrash(evt) {
|
|
|
|
this.saveHome();
|
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
addWidget() {
|
2018-04-29 17:17:15 +09:00
|
|
|
this.$store.dispatch('settings/addHomeWidget', {
|
2018-02-11 13:02:35 +09:00
|
|
|
name: this.widgetAdderSelected,
|
2018-02-09 13:11:30 +09:00
|
|
|
id: uuid(),
|
|
|
|
place: 'left',
|
|
|
|
data: {}
|
2018-04-29 17:17:15 +09:00
|
|
|
});
|
2018-02-09 13:11:30 +09:00
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-09 13:11:30 +09:00
|
|
|
saveHome() {
|
2018-02-22 00:07:37 +09:00
|
|
|
const left = this.widgets.left;
|
|
|
|
const right = this.widgets.right;
|
2018-04-29 17:17:15 +09:00
|
|
|
this.$store.commit('settings/setHome', left.concat(right));
|
2018-02-22 00:07:37 +09:00
|
|
|
left.forEach(w => w.place = 'left');
|
|
|
|
right.forEach(w => w.place = 'right');
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.api('i/update_home', {
|
2018-02-21 15:30:03 +09:00
|
|
|
home: this.home
|
2018-02-11 13:02:35 +09:00
|
|
|
});
|
2018-02-09 13:11:30 +09:00
|
|
|
},
|
2018-04-29 17:17:15 +09:00
|
|
|
|
2018-02-19 18:26:20 +09:00
|
|
|
warp(date) {
|
2018-02-24 23:56:57 +09:00
|
|
|
(this.$refs.tl as any).warp(date);
|
2018-09-18 05:35:06 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
2018-02-09 13:11:30 +09:00
|
|
|
}
|
|
|
|
}
|
2018-02-11 13:02:35 +09:00
|
|
|
});
|
2018-02-09 13:11:30 +09:00
|
|
|
</script>
|
|
|
|
|
2018-02-09 09:46:23 +09:00
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 15:58:23 +09:00
|
|
|
.mk-home
|
2018-02-11 13:02:35 +09:00
|
|
|
display block
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
&[data-customize]
|
|
|
|
padding-top 48px
|
|
|
|
background-image url('/assets/desktop/grid.svg')
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-22 00:21:07 +09:00
|
|
|
> .main > .main
|
2018-02-23 02:06:35 +09:00
|
|
|
> a
|
|
|
|
display block
|
|
|
|
margin-bottom 8px
|
|
|
|
text-align center
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-23 02:06:35 +09:00
|
|
|
> div
|
|
|
|
cursor not-allowed !important
|
|
|
|
|
|
|
|
> *
|
|
|
|
pointer-events none
|
2018-02-11 13:02:35 +09:00
|
|
|
|
|
|
|
&:not([data-customize])
|
|
|
|
> .main > *:empty
|
|
|
|
display none
|
|
|
|
|
|
|
|
> .customize
|
|
|
|
position fixed
|
|
|
|
z-index 1000
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
width 100%
|
|
|
|
height 48px
|
2018-09-28 15:58:23 +09:00
|
|
|
color var(--text)
|
2018-09-27 01:32:04 +09:00
|
|
|
background var(--desktopHeaderBg)
|
2018-04-29 08:51:17 +09:00
|
|
|
box-shadow 0 1px 1px rgba(#000, 0.075)
|
2018-02-11 13:02:35 +09:00
|
|
|
|
|
|
|
> a
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
z-index 1001
|
|
|
|
top 0
|
|
|
|
right 0
|
|
|
|
padding 0 16px
|
|
|
|
line-height 48px
|
|
|
|
text-decoration none
|
2018-09-26 20:19:35 +09:00
|
|
|
color var(--primaryForeground)
|
|
|
|
background var(--primary)
|
2018-02-11 13:02:35 +09:00
|
|
|
transition background 0.1s ease
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
&:hover
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryLighten10)
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
&:active
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryDarken10)
|
2018-02-11 13:02:35 +09:00
|
|
|
transition background 0s ease
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-11-06 01:40:11 +09:00
|
|
|
> [data-icon]
|
2018-02-11 13:02:35 +09:00
|
|
|
margin-right 8px
|
|
|
|
|
|
|
|
> div
|
2018-02-09 09:46:23 +09:00
|
|
|
display flex
|
|
|
|
margin 0 auto
|
2018-04-30 11:59:58 +09:00
|
|
|
max-width 1220px - 32px
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
> div
|
|
|
|
width 50%
|
|
|
|
|
|
|
|
&.adder
|
|
|
|
> p
|
|
|
|
display inline
|
|
|
|
line-height 48px
|
|
|
|
|
|
|
|
&.trash
|
2018-09-28 15:58:23 +09:00
|
|
|
border-left solid 1px var(--faceDivider)
|
2018-02-11 13:02:35 +09:00
|
|
|
|
|
|
|
> div
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
|
|
|
|
> p
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
width 100%
|
|
|
|
line-height 48px
|
|
|
|
margin 0
|
|
|
|
text-align center
|
2018-02-09 09:46:23 +09:00
|
|
|
pointer-events none
|
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
> .main
|
|
|
|
display flex
|
|
|
|
justify-content center
|
|
|
|
margin 0 auto
|
2018-09-20 16:21:51 +09:00
|
|
|
max-width 1240px
|
2018-09-20 16:16:01 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
> *
|
|
|
|
.customize-container
|
|
|
|
cursor move
|
2018-02-22 21:29:04 +09:00
|
|
|
border-radius 6px
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
box-shadow 0 0 8px rgba(64, 120, 200, 0.3)
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
> *
|
|
|
|
pointer-events none
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-19 18:26:20 +09:00
|
|
|
> .main
|
2018-02-11 13:02:35 +09:00
|
|
|
padding 16px
|
2018-09-20 16:21:51 +09:00
|
|
|
width calc(100% - 280px * 2)
|
2018-02-22 00:07:37 +09:00
|
|
|
order 2
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-05-31 16:44:11 +09:00
|
|
|
> .form
|
2018-02-23 02:06:35 +09:00
|
|
|
margin-bottom 16px
|
2018-09-24 16:07:23 +09:00
|
|
|
box-shadow var(--shadow)
|
|
|
|
border-radius var(--round)
|
2018-02-23 02:06:35 +09:00
|
|
|
|
2018-10-15 06:03:15 +09:00
|
|
|
&.side
|
|
|
|
> .main
|
|
|
|
width calc(100% - 280px)
|
|
|
|
max-width 680px
|
2018-05-31 16:44:11 +09:00
|
|
|
|
2018-02-22 22:03:44 +09:00
|
|
|
> *:not(.main)
|
2018-09-20 16:21:51 +09:00
|
|
|
width 280px
|
2018-02-19 18:26:20 +09:00
|
|
|
padding 16px 0 16px 0
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-19 18:26:20 +09:00
|
|
|
> *:not(:last-child)
|
|
|
|
margin-bottom 16px
|
2018-02-09 09:46:23 +09:00
|
|
|
|
2018-02-11 13:02:35 +09:00
|
|
|
> .left
|
|
|
|
padding-left 16px
|
2018-02-22 00:07:37 +09:00
|
|
|
order 1
|
2018-02-11 13:02:35 +09:00
|
|
|
|
|
|
|
> .right
|
|
|
|
padding-right 16px
|
2018-02-22 00:07:37 +09:00
|
|
|
order 3
|
2018-02-11 13:02:35 +09:00
|
|
|
|
2018-10-15 06:03:15 +09:00
|
|
|
&.side
|
|
|
|
@media (max-width 1000px)
|
|
|
|
> *:not(.main)
|
|
|
|
display none
|
|
|
|
|
|
|
|
> .main
|
|
|
|
width 100%
|
|
|
|
max-width 700px
|
|
|
|
margin 0 auto
|
|
|
|
|
|
|
|
&:not(.side)
|
|
|
|
@media (max-width 1200px)
|
|
|
|
> *:not(.main)
|
|
|
|
display none
|
|
|
|
|
|
|
|
> .main
|
|
|
|
width 100%
|
|
|
|
max-width 700px
|
|
|
|
margin 0 auto
|
2018-02-09 09:46:23 +09:00
|
|
|
|
|
|
|
</style>
|