From 36c11e1f0f24f5fc451ad1a38fd054c2cfa4d508 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 25 Feb 2018 00:18:09 +0900 Subject: [PATCH] Refactor --- package.json | 3 -- src/web/app/app.vue | 2 +- src/web/app/auth/script.ts | 23 ------------- src/web/app/common/mios.ts | 15 +++------ src/web/app/common/views/components/index.ts | 28 ---------------- .../{components => }/widgets/access-log.vue | 2 +- .../{components => }/widgets/broadcast.vue | 4 +-- .../{components => }/widgets/calendar.vue | 2 +- .../{components => }/widgets/donation.vue | 2 +- src/web/app/common/views/widgets/index.ts | 25 +++++++++++++++ .../views/{components => }/widgets/nav.vue | 2 +- .../{components => }/widgets/photo-stream.vue | 2 +- .../views/{components => }/widgets/rss.vue | 2 +- .../widgets/server.cpu-memory.vue | 0 .../{components => }/widgets/server.cpu.vue | 0 .../{components => }/widgets/server.disk.vue | 0 .../{components => }/widgets/server.info.vue | 0 .../widgets/server.memory.vue | 0 .../{components => }/widgets/server.pie.vue | 0 .../widgets/server.uptimes.vue | 0 .../views/{components => }/widgets/server.vue | 2 +- .../{components => }/widgets/slideshow.vue | 2 +- .../views/{components => }/widgets/tips.vue | 2 +- .../{components => }/widgets/version.vue | 4 +-- src/web/app/desktop/script.ts | 1 + src/web/app/desktop/views/components/index.ts | 26 --------------- .../{components => }/widgets/activity.vue | 2 +- .../widgets/channel.channel.form.vue | 0 .../widgets/channel.channel.post.vue | 0 .../widgets/channel.channel.vue | 2 +- .../{components => }/widgets/channel.vue | 2 +- src/web/app/desktop/views/widgets/index.ts | 23 +++++++++++++ .../{components => }/widgets/messaging.vue | 4 +-- .../widgets/notifications.vue | 2 +- .../views/{components => }/widgets/polls.vue | 2 +- .../{components => }/widgets/post-form.vue | 2 +- .../{components => }/widgets/profile.vue | 2 +- .../{components => }/widgets/timemachine.vue | 2 +- .../views/{components => }/widgets/trends.vue | 2 +- .../views/{components => }/widgets/users.vue | 2 +- src/web/app/init.ts | 32 +++++++++---------- src/web/app/mobile/script.ts | 1 + src/web/app/mobile/views/components/index.ts | 10 ------ .../{components => }/widgets/activity.vue | 2 +- src/web/app/mobile/views/widgets/index.ts | 7 ++++ .../{components => }/widgets/profile.vue | 2 +- src/web/app/stats/script.ts | 23 ------------- src/web/app/status/script.ts | 23 ------------- 48 files changed, 105 insertions(+), 191 deletions(-) delete mode 100644 src/web/app/auth/script.ts rename src/web/app/common/views/{components => }/widgets/access-log.vue (97%) rename src/web/app/common/views/{components => }/widgets/broadcast.vue (97%) rename src/web/app/common/views/{components => }/widgets/calendar.vue (98%) rename src/web/app/common/views/{components => }/widgets/donation.vue (95%) create mode 100644 src/web/app/common/views/widgets/index.ts rename src/web/app/common/views/{components => }/widgets/nav.vue (86%) rename src/web/app/common/views/{components => }/widgets/photo-stream.vue (97%) rename src/web/app/common/views/{components => }/widgets/rss.vue (96%) rename src/web/app/common/views/{components => }/widgets/server.cpu-memory.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.cpu.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.disk.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.info.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.memory.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.pie.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.uptimes.vue (100%) rename src/web/app/common/views/{components => }/widgets/server.vue (97%) rename src/web/app/common/views/{components => }/widgets/slideshow.vue (98%) rename src/web/app/common/views/{components => }/widgets/tips.vue (98%) rename src/web/app/common/views/{components => }/widgets/version.vue (75%) rename src/web/app/desktop/views/{components => }/widgets/activity.vue (89%) rename src/web/app/desktop/views/{components => }/widgets/channel.channel.form.vue (100%) rename src/web/app/desktop/views/{components => }/widgets/channel.channel.post.vue (100%) rename src/web/app/desktop/views/{components => }/widgets/channel.channel.vue (95%) rename src/web/app/desktop/views/{components => }/widgets/channel.vue (97%) create mode 100644 src/web/app/desktop/views/widgets/index.ts rename src/web/app/desktop/views/{components => }/widgets/messaging.vue (88%) rename src/web/app/desktop/views/{components => }/widgets/notifications.vue (95%) rename src/web/app/desktop/views/{components => }/widgets/polls.vue (97%) rename src/web/app/desktop/views/{components => }/widgets/post-form.vue (97%) rename src/web/app/desktop/views/{components => }/widgets/profile.vue (97%) rename src/web/app/desktop/views/{components => }/widgets/timemachine.vue (88%) rename src/web/app/desktop/views/{components => }/widgets/trends.vue (97%) rename src/web/app/desktop/views/{components => }/widgets/users.vue (98%) rename src/web/app/mobile/views/{components => }/widgets/activity.vue (90%) create mode 100644 src/web/app/mobile/views/widgets/index.ts rename src/web/app/mobile/views/{components => }/widgets/profile.vue (95%) delete mode 100644 src/web/app/stats/script.ts delete mode 100644 src/web/app/status/script.ts diff --git a/package.json b/package.json index e097960395..274962c368 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "@types/redis": "2.8.5", "@types/request": "2.47.0", "@types/rimraf": "2.0.2", - "@types/riot": "3.6.1", "@types/seedrandom": "2.4.27", "@types/serve-favicon": "2.2.30", "@types/speakeasy": "2.0.2", @@ -148,8 +147,6 @@ "redis": "2.8.0", "request": "2.83.0", "rimraf": "2.6.2", - "riot": "3.8.1", - "riot-tag-loader": "2.0.2", "rndstr": "1.0.0", "s-age": "1.1.2", "seedrandom": "2.4.3", diff --git a/src/web/app/app.vue b/src/web/app/app.vue index 321e003930..7a46e7dea0 100644 --- a/src/web/app/app.vue +++ b/src/web/app/app.vue @@ -1,3 +1,3 @@ diff --git a/src/web/app/auth/script.ts b/src/web/app/auth/script.ts deleted file mode 100644 index dd598d1ed6..0000000000 --- a/src/web/app/auth/script.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Authorize Form - */ - -// Style -import './style.styl'; - -import * as riot from 'riot'; -require('./tags'); -import init from '../init'; - -document.title = 'Misskey | アプリの連携'; - -/** - * init - */ -init(() => { - mount(document.createElement('mk-index')); -}); - -function mount(content) { - riot.mount(document.getElementById('app').appendChild(content)); -} diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index e20f4bfe4e..6c95e5b9b5 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -1,5 +1,7 @@ import Vue from 'vue'; import { EventEmitter } from 'eventemitter3'; + +import { apiUrl, swPublickey, version, lang } from '../config'; import api from './scripts/api'; import signout from './scripts/signout'; import Progress from './scripts/loading'; @@ -11,13 +13,6 @@ import MessagingIndexStreamManager from './scripts/streaming/messaging-index-str import Err from '../common/views/components/connect-failed.vue'; -//#region environment variables -declare const _VERSION_: string; -declare const _LANG_: string; -declare const _API_URL_: string; -declare const _SW_PUBLICKEY_: string; -//#endregion - export type API = { chooseDriveFile: (opts: { title?: string; @@ -204,7 +199,7 @@ export default class MiOS extends EventEmitter { } // Fetch user - fetch(`${_API_URL_}/i`, { + fetch(`${apiUrl}/i`, { method: 'POST', body: JSON.stringify({ i: token @@ -311,7 +306,7 @@ export default class MiOS extends EventEmitter { // A public key your push server will use to send // messages to client apps via a push server. - applicationServerKey: urlBase64ToUint8Array(_SW_PUBLICKEY_) + applicationServerKey: urlBase64ToUint8Array(swPublickey) }; // Subscribe push notification @@ -348,7 +343,7 @@ export default class MiOS extends EventEmitter { }); // The path of service worker script - const sw = `/sw.${_VERSION_}.${_LANG_}.js`; + const sw = `/sw.${version}.${lang}.js`; // Register service worker navigator.serviceWorker.register(sw).then(registration => { diff --git a/src/web/app/common/views/components/index.ts b/src/web/app/common/views/components/index.ts index 5460d75779..ab0f1767d4 100644 --- a/src/web/app/common/views/components/index.ts +++ b/src/web/app/common/views/components/index.ts @@ -21,20 +21,6 @@ import urlPreview from './url-preview.vue'; import twitterSetting from './twitter-setting.vue'; import fileTypeIcon from './file-type-icon.vue'; -//#region widgets -import wAccessLog from './widgets/access-log.vue'; -import wVersion from './widgets/version.vue'; -import wRss from './widgets/rss.vue'; -import wServer from './widgets/server.vue'; -import wBroadcast from './widgets/broadcast.vue'; -import wCalendar from './widgets/calendar.vue'; -import wPhotoStream from './widgets/photo-stream.vue'; -import wSlideshow from './widgets/slideshow.vue'; -import wTips from './widgets/tips.vue'; -import wDonation from './widgets/donation.vue'; -import wNav from './widgets/nav.vue'; -//#endregion - Vue.component('mk-signin', signin); Vue.component('mk-signup', signup); Vue.component('mk-forkit', forkit); @@ -55,17 +41,3 @@ Vue.component('mk-messaging-room', messagingRoom); Vue.component('mk-url-preview', urlPreview); Vue.component('mk-twitter-setting', twitterSetting); Vue.component('mk-file-type-icon', fileTypeIcon); - -//#region widgets -Vue.component('mkw-nav', wNav); -Vue.component('mkw-calendar', wCalendar); -Vue.component('mkw-photo-stream', wPhotoStream); -Vue.component('mkw-slideshow', wSlideshow); -Vue.component('mkw-tips', wTips); -Vue.component('mkw-donation', wDonation); -Vue.component('mkw-broadcast', wBroadcast); -Vue.component('mkw-server', wServer); -Vue.component('mkw-rss', wRss); -Vue.component('mkw-version', wVersion); -Vue.component('mkw-access-log', wAccessLog); -//#endregion diff --git a/src/web/app/common/views/components/widgets/access-log.vue b/src/web/app/common/views/widgets/access-log.vue similarity index 97% rename from src/web/app/common/views/components/widgets/access-log.vue rename to src/web/app/common/views/widgets/access-log.vue index c810c2d157..f7bb17d833 100644 --- a/src/web/app/common/views/components/widgets/access-log.vue +++ b/src/web/app/common/views/widgets/access-log.vue @@ -15,7 +15,7 @@