Bye bye subdomains
This commit is contained in:
parent
d0c875c1e0
commit
f298fc6eb3
8 changed files with 81 additions and 74 deletions
|
|
@ -21,13 +21,13 @@
|
|||
// Get the current url information
|
||||
const url = new URL(location.href);
|
||||
|
||||
// Extarct the (sub) domain part of the current url
|
||||
//
|
||||
// e.g.
|
||||
// misskey.alice => misskey
|
||||
// misskey.strawberry.pasta => misskey
|
||||
// dev.misskey.arisu.tachibana => dev
|
||||
let app = url.host === HOST ? 'misskey' : url.host.substr(0, -HOST.length);
|
||||
//#region Detect app name
|
||||
let app = null;
|
||||
|
||||
if (url.pathname == '/docs') app = 'docs';
|
||||
if (url.pathname == '/dev') app = 'dev';
|
||||
if (url.pathname == '/auth') app = 'auth';
|
||||
//#endregion
|
||||
|
||||
// Detect the user language
|
||||
// Note: The default language is English
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
}
|
||||
|
||||
// Switch desktop or mobile version
|
||||
if (app == 'misskey') {
|
||||
if (app == null) {
|
||||
app = isMobile ? 'mobile' : 'desktop';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@
|
|||
* Desktop Client
|
||||
*/
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
// Style
|
||||
import './style.styl';
|
||||
import '../../element.scss';
|
||||
|
||||
import init from '../init';
|
||||
import fuckAdBlock from '../common/scripts/fuck-ad-block';
|
||||
import HomeStreamManager from '../common/scripts/streaming/home-stream-manager';
|
||||
import { HomeStreamManager } from '../common/scripts/streaming/home';
|
||||
import composeNotification from '../common/scripts/compose-notification';
|
||||
|
||||
import chooseDriveFolder from './api/choose-drive-folder';
|
||||
|
|
@ -41,8 +43,26 @@ init(async (launch) => {
|
|||
require('./views/components');
|
||||
require('./views/widgets');
|
||||
|
||||
// Init router
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{ path: '/', name: 'index', component: MkIndex },
|
||||
{ path: '/i/customize-home', component: MkHomeCustomize },
|
||||
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
||||
{ path: '/i/drive', component: MkDrive },
|
||||
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
||||
{ path: '/selectdrive', component: MkSelectDrive },
|
||||
{ path: '/search', component: MkSearch },
|
||||
{ path: '/othello', component: MkOthello },
|
||||
{ path: '/othello/:game', component: MkOthello },
|
||||
{ path: '/@:user', component: MkUser },
|
||||
{ path: '/@:user/:post', component: MkPost }
|
||||
]
|
||||
});
|
||||
|
||||
// Launch the app
|
||||
const [app, os] = launch(os => ({
|
||||
const [, os] = launch(router, os => ({
|
||||
chooseDriveFolder,
|
||||
chooseDriveFile,
|
||||
dialog,
|
||||
|
|
@ -71,21 +91,6 @@ init(async (launch) => {
|
|||
registerNotifications(os.stream);
|
||||
}
|
||||
}
|
||||
|
||||
// Routing
|
||||
app.$router.addRoutes([
|
||||
{ path: '/', name: 'index', component: MkIndex },
|
||||
{ path: '/i/customize-home', component: MkHomeCustomize },
|
||||
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
||||
{ path: '/i/drive', component: MkDrive },
|
||||
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
||||
{ path: '/selectdrive', component: MkSelectDrive },
|
||||
{ path: '/search', component: MkSearch },
|
||||
{ path: '/othello', component: MkOthello },
|
||||
{ path: '/othello/:game', component: MkOthello },
|
||||
{ path: '/@:user', component: MkUser },
|
||||
{ path: '/@:user/:post', component: MkPost }
|
||||
]);
|
||||
}, true);
|
||||
|
||||
function registerNotifications(stream: HomeStreamManager) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import BootstrapVue from 'bootstrap-vue';
|
||||
import 'bootstrap/dist/css/bootstrap.css';
|
||||
import 'bootstrap-vue/dist/bootstrap-vue.css';
|
||||
|
|
@ -26,14 +27,18 @@ Vue.component('mk-ui', ui);
|
|||
* init
|
||||
*/
|
||||
init(launch => {
|
||||
// Launch the app
|
||||
const [app] = launch();
|
||||
// Init router
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: '/dev/',
|
||||
routes: [
|
||||
{ path: '/', component: Index },
|
||||
{ path: '/apps', component: Apps },
|
||||
{ path: '/app/new', component: AppNew },
|
||||
{ path: '/app/:id', component: App },
|
||||
]
|
||||
});
|
||||
|
||||
// Routing
|
||||
app.$router.addRoutes([
|
||||
{ path: '/', component: Index },
|
||||
{ path: '/apps', component: Apps },
|
||||
{ path: '/app/new', component: AppNew },
|
||||
{ path: '/app/:id', component: App },
|
||||
]);
|
||||
// Launch the app
|
||||
launch(router);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -91,14 +91,14 @@ if (localStorage.getItem('should-refresh') == 'true') {
|
|||
}
|
||||
|
||||
// MiOSを初期化してコールバックする
|
||||
export default (callback: (launch: (api?: (os: MiOS) => API) => [Vue, MiOS]) => void, sw = false) => {
|
||||
export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API) => [Vue, MiOS]) => void, sw = false) => {
|
||||
const os = new MiOS(sw);
|
||||
|
||||
os.init(() => {
|
||||
// アプリ基底要素マウント
|
||||
document.body.innerHTML = '<div id="app"></div>';
|
||||
|
||||
const launch = (api?: (os: MiOS) => API) => {
|
||||
const launch = (router: VueRouter, api?: (os: MiOS) => API) => {
|
||||
os.apis = api ? api(os) : null;
|
||||
|
||||
Vue.mixin({
|
||||
|
|
@ -112,9 +112,7 @@ export default (callback: (launch: (api?: (os: MiOS) => API) => [Vue, MiOS]) =>
|
|||
});
|
||||
|
||||
const app = new Vue({
|
||||
router: new VueRouter({
|
||||
mode: 'history'
|
||||
}),
|
||||
router,
|
||||
created() {
|
||||
this.$watch('os.i', i => {
|
||||
// キャッシュ更新
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
* Mobile Client
|
||||
*/
|
||||
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
// Style
|
||||
import './style.styl';
|
||||
import '../../element.scss';
|
||||
|
|
@ -45,8 +47,33 @@ init((launch) => {
|
|||
// http://qiita.com/junya/items/3ff380878f26ca447f85
|
||||
document.body.setAttribute('ontouchstart', '');
|
||||
|
||||
// Init router
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{ path: '/', name: 'index', component: MkIndex },
|
||||
{ path: '/signup', name: 'signup', component: MkSignup },
|
||||
{ path: '/i/settings', component: MkSettings },
|
||||
{ path: '/i/settings/profile', component: MkProfileSetting },
|
||||
{ path: '/i/notifications', component: MkNotifications },
|
||||
{ path: '/i/messaging', component: MkMessaging },
|
||||
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
||||
{ path: '/i/drive', component: MkDrive },
|
||||
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
||||
{ path: '/i/drive/file/:file', component: MkDrive },
|
||||
{ path: '/selectdrive', component: MkSelectDrive },
|
||||
{ path: '/search', component: MkSearch },
|
||||
{ path: '/othello', component: MkOthello },
|
||||
{ path: '/othello/:game', component: MkOthello },
|
||||
{ path: '/@:user', component: MkUser },
|
||||
{ path: '/@:user/followers', component: MkFollowers },
|
||||
{ path: '/@:user/following', component: MkFollowing },
|
||||
{ path: '/@:user/:post', component: MkPost }
|
||||
]
|
||||
});
|
||||
|
||||
// Launch the app
|
||||
const [app] = launch(os => ({
|
||||
launch(router, os => ({
|
||||
chooseDriveFolder,
|
||||
chooseDriveFile,
|
||||
dialog,
|
||||
|
|
@ -54,26 +81,4 @@ init((launch) => {
|
|||
post: post(os),
|
||||
notify
|
||||
}));
|
||||
|
||||
// Routing
|
||||
app.$router.addRoutes([
|
||||
{ path: '/', name: 'index', component: MkIndex },
|
||||
{ path: '/signup', name: 'signup', component: MkSignup },
|
||||
{ path: '/i/settings', component: MkSettings },
|
||||
{ path: '/i/settings/profile', component: MkProfileSetting },
|
||||
{ path: '/i/notifications', component: MkNotifications },
|
||||
{ path: '/i/messaging', component: MkMessaging },
|
||||
{ path: '/i/messaging/:username', component: MkMessagingRoom },
|
||||
{ path: '/i/drive', component: MkDrive },
|
||||
{ path: '/i/drive/folder/:folder', component: MkDrive },
|
||||
{ path: '/i/drive/file/:file', component: MkDrive },
|
||||
{ path: '/selectdrive', component: MkSelectDrive },
|
||||
{ path: '/search', component: MkSearch },
|
||||
{ path: '/othello', component: MkOthello },
|
||||
{ path: '/othello/:game', component: MkOthello },
|
||||
{ path: '/@:user', component: MkUser },
|
||||
{ path: '/@:user/followers', component: MkFollowers },
|
||||
{ path: '/@:user/following', component: MkFollowing },
|
||||
{ path: '/@:user/:post', component: MkPost }
|
||||
]);
|
||||
}, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue