From e39e1282586c78d8628bab79628a54776c93cdde Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 6 Jun 2018 02:48:26 +0900 Subject: [PATCH] wip --- .../app/desktop/views/components/home.vue | 52 +++++++++++++++++++ src/client/app/store.ts | 15 ++++++ src/server/api/private/signup.ts | 48 ----------------- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/src/client/app/desktop/views/components/home.vue b/src/client/app/desktop/views/components/home.vue index 636ed871c..d3ba84a4b 100644 --- a/src/client/app/desktop/views/components/home.vue +++ b/src/client/app/desktop/views/components/home.vue @@ -76,6 +76,50 @@ import Vue from 'vue'; import * as XDraggable from 'vuedraggable'; import * as uuid from 'uuid'; +const defaultDesktopHomeWidgets = { + left: [ + 'profile', + 'calendar', + 'activity', + 'rss', + 'trends', + '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 + export default Vue.extend({ components: { XDraggable @@ -119,6 +163,14 @@ export default Vue.extend({ } }, + created() { + if (this.$store.state.i.clientSettings == null || this.$store.state.i.clientSettings.home == null) { + this.api('i/update_home', { + home: _defaultDesktopHomeWidgets + }); + } + }, + mounted() { this.connection = (this as any).os.stream.getConnection(); this.connectionId = (this as any).os.stream.use(); diff --git a/src/client/app/store.ts b/src/client/app/store.ts index 905ec0501..00cae3b85 100644 --- a/src/client/app/store.ts +++ b/src/client/app/store.ts @@ -7,6 +7,20 @@ import { hostname } from './config'; const defaultSettings = { home: [], mobileHome: [], + deck: { + columns: [/*{ + type: 'widgets', + widgets: [] + }, */{ + type: 'home' + }, { + type: 'notifications' + }, { + type: 'local' + }, { + type: 'global' + }] + }, fetchOnScroll: true, showMaps: true, showPostFormOnTopOfTl: false, @@ -156,6 +170,7 @@ export default (os: MiOS) => new Vuex.Store({ actions: { merge(ctx, settings) { + if (settings == null) return; Object.entries(settings).forEach(([key, value]) => { ctx.commit('set', { key, value }); }); diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index cf51dec4d..14d4b8a3f 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -1,4 +1,3 @@ -import * as uuid from 'uuid'; import * as Koa from 'koa'; import * as bcrypt from 'bcryptjs'; import { generate as generateKeypair } from '../../../crypto_key'; @@ -11,28 +10,6 @@ recaptcha.init({ secret_key: config.recaptcha.secret_key }); -const home = { - left: [ - 'profile', - 'calendar', - 'activity', - 'rss', - 'trends', - 'photo-stream', - 'version' - ], - right: [ - 'broadcast', - 'notifications', - 'users', - 'polls', - 'server', - 'donation', - 'nav', - 'tips' - ] -}; - export default async (ctx: Koa.Context) => { // Verify recaptcha // ただしテスト時はこの機構は障害となるため無効にする @@ -82,28 +59,6 @@ export default async (ctx: Koa.Context) => { // Generate secret const secret = generateUserToken(); - //#region Construct home data - const homeData = []; - - home.left.forEach(widget => { - homeData.push({ - name: widget, - id: uuid(), - place: 'left', - data: {} - }); - }); - - home.right.forEach(widget => { - homeData.push({ - name: widget, - id: uuid(), - place: 'right', - data: {} - }); - }); - //#endregion - // Create account const account: IUser = await User.insert({ avatarId: null, @@ -135,9 +90,6 @@ export default async (ctx: Koa.Context) => { }, settings: { autoWatch: true - }, - clientSettings: { - home: homeData } });