This commit is contained in:
syuilo 2018-02-22 21:39:36 +09:00
parent 84c157913a
commit 7816282318
12 changed files with 24 additions and 462 deletions

View file

@ -1,143 +0,0 @@
/**
* Mobile App Router
*/
import * as riot from 'riot';
import * as route from 'page';
import MiOS from '../common/mios';
let page = null;
export default (mios: MiOS) => {
route('/', index);
route('/selectdrive', selectDrive);
route('/i/notifications', notifications);
route('/i/messaging', messaging);
route('/i/messaging/:username', messaging);
route('/i/drive', drive);
route('/i/drive/folder/:folder', drive);
route('/i/drive/file/:file', drive);
route('/i/settings', settings);
route('/i/settings/profile', settingsProfile);
route('/i/settings/signin-history', settingsSignin);
route('/i/settings/twitter', settingsTwitter);
route('/i/settings/authorized-apps', settingsAuthorizedApps);
route('/post/new', newPost);
route('/post::post', post);
route('/search', search);
route('/:user', user.bind(null, 'overview'));
route('/:user/graphs', user.bind(null, 'graphs'));
route('/:user/followers', userFollowers);
route('/:user/following', userFollowing);
route('/:user/:post', post);
route('*', notFound);
function index() {
mios.isSignedIn ? home() : entrance();
}
function home() {
mount(document.createElement('mk-home-page'));
}
function entrance() {
mount(document.createElement('mk-entrance'));
}
function notifications() {
mount(document.createElement('mk-notifications-page'));
}
function messaging(ctx) {
if (ctx.params.username) {
const el = document.createElement('mk-messaging-room-page');
el.setAttribute('username', ctx.params.username);
mount(el);
} else {
mount(document.createElement('mk-messaging-page'));
}
}
function newPost() {
mount(document.createElement('mk-new-post-page'));
}
function settings() {
mount(document.createElement('mk-settings-page'));
}
function settingsProfile() {
mount(document.createElement('mk-profile-setting-page'));
}
function settingsSignin() {
mount(document.createElement('mk-signin-history-page'));
}
function settingsTwitter() {
mount(document.createElement('mk-twitter-setting-page'));
}
function settingsAuthorizedApps() {
mount(document.createElement('mk-authorized-apps-page'));
}
function search(ctx) {
const el = document.createElement('mk-search-page');
el.setAttribute('query', ctx.querystring.substr(2));
mount(el);
}
function user(page, ctx) {
const el = document.createElement('mk-user-page');
el.setAttribute('user', ctx.params.user);
el.setAttribute('page', page);
mount(el);
}
function userFollowing(ctx) {
const el = document.createElement('mk-user-following-page');
el.setAttribute('user', ctx.params.user);
mount(el);
}
function userFollowers(ctx) {
const el = document.createElement('mk-user-followers-page');
el.setAttribute('user', ctx.params.user);
mount(el);
}
function post(ctx) {
const el = document.createElement('mk-post-page');
el.setAttribute('post', ctx.params.post);
mount(el);
}
function drive(ctx) {
const el = document.createElement('mk-drive-page');
if (ctx.params.folder) el.setAttribute('folder', ctx.params.folder);
if (ctx.params.file) el.setAttribute('file', ctx.params.file);
mount(el);
}
function selectDrive() {
mount(document.createElement('mk-selectdrive-page'));
}
function notFound() {
mount(document.createElement('mk-not-found'));
}
(riot as any).mixin('page', {
page: route
});
// EXEC
(route as any)();
};
function mount(content) {
document.documentElement.style.background = '#fff';
if (page) page.unmount();
const body = document.getElementById('app');
page = riot.mount(body.appendChild(content))[0];
}

View file

@ -23,6 +23,9 @@ import MkNotifications from './views/pages/notifications.vue';
import MkMessaging from './views/pages/messaging.vue';
import MkMessagingRoom from './views/pages/messaging-room.vue';
import MkPost from './views/pages/post.vue';
import MkSearch from './views/pages/search.vue';
import MkFollowers from './views/pages/followers.vue';
import MkFollowing from './views/pages/following.vue';
/**
* init
@ -58,7 +61,10 @@ init((launch) => {
{ path: '/i/drive/folder/:folder', component: MkDrive },
{ path: '/i/drive/file/:file', component: MkDrive },
{ path: '/selectdrive', component: MkSelectDrive },
{ path: '/search', component: MkSearch },
{ path: '/:user', component: MkUser },
{ path: '/:user/followers', component: MkFollowers },
{ path: '/:user/following', component: MkFollowing },
{ path: '/:user/:post', component: MkPost }
]);
}, true);

View file

@ -1,66 +0,0 @@
<mk-entrance>
<main><img src="/assets/title.svg" alt="Misskey"/>
<mk-entrance-signin v-if="mode == 'signin'"/>
<mk-entrance-signup v-if="mode == 'signup'"/>
<div class="introduction" v-if="mode == 'introduction'">
<mk-introduction/>
<button @click="signin">%i18n:common.ok%</button>
</div>
</main>
<footer>
<p class="c">{ _COPYRIGHT_ }</p>
</footer>
<style lang="stylus" scoped>
:scope
display block
height 100%
> main
display block
> img
display block
width 130px
height 120px
margin 0 auto
> .introduction
max-width 300px
margin 0 auto
color #666
> button
display block
margin 16px auto 0 auto
> footer
> .c
margin 0
text-align center
line-height 64px
font-size 10px
color rgba(#000, 0.5)
</style>
<script lang="typescript">
this.mode = 'signin';
this.signup = () => {
this.update({
mode: 'signup'
});
};
this.signin = () => {
this.update({
mode: 'signin'
});
};
this.introduction = () => {
this.update({
mode: 'introduction'
});
};
</script>
</mk-entrance>

View file

@ -1,52 +0,0 @@
<mk-entrance-signin>
<mk-signin/>
<a href={ _API_URL_ + '/signin/twitter' }>Twitterでサインイン</a>
<div class="divider"><span>or</span></div>
<button class="signup" @click="parent.signup">%i18n:mobile.tags.mk-entrance-signin.signup%</button><a class="introduction" @click="parent.introduction">%i18n:mobile.tags.mk-entrance-signin.about%</a>
<style lang="stylus" scoped>
:scope
display block
margin 0 auto
padding 0 8px
max-width 350px
text-align center
> .signup
padding 16px
width 100%
font-size 1em
color #fff
background $theme-color
border-radius 3px
> .divider
padding 16px 0
text-align center
&:after
content ""
display block
position absolute
top 50%
width 100%
height 1px
border-top solid 1px rgba(0, 0, 0, 0.1)
> *
z-index 1
padding 0 8px
color rgba(0, 0, 0, 0.5)
background #fdfdfd
> .introduction
display inline-block
margin-top 16px
font-size 12px
color #666
</style>
</mk-entrance-signin>

View file

@ -1,38 +0,0 @@
<mk-entrance-signup>
<mk-signup/>
<button class="cancel" type="button" @click="parent.signin" title="%i18n:mobile.tags.mk-entrance-signup.cancel%">%fa:times%</button>
<style lang="stylus" scoped>
:scope
display block
margin 0 auto
padding 0 8px
max-width 350px
> .cancel
cursor pointer
display block
position absolute
top 0
right 0
z-index 1
margin 0
padding 0
font-size 1.2em
color #999
border none
outline none
box-shadow none
background transparent
transition opacity 0.1s ease
&:hover
color #555
&:active
color #222
> [data-fa]
padding 14px
</style>
</mk-entrance-signup>

View file

@ -1,17 +0,0 @@
<mk-authorized-apps-page>
<mk-ui ref="ui">
<mk-authorized-apps/>
</mk-ui>
<style lang="stylus" scoped>
:scope
display block
</style>
<script lang="typescript">
import ui from '../../../scripts/ui-event';
this.on('mount', () => {
document.title = 'Misskey | %i18n:mobile.tags.mk-authorized-apps-page.application%';
ui.trigger('title', '%fa:puzzle-piece%%i18n:mobile.tags.mk-authorized-apps-page.application%');
});
</script>
</mk-authorized-apps-page>

View file

@ -1,17 +0,0 @@
<mk-signin-history-page>
<mk-ui ref="ui">
<mk-signin-history/>
</mk-ui>
<style lang="stylus" scoped>
:scope
display block
</style>
<script lang="typescript">
import ui from '../../../scripts/ui-event';
this.on('mount', () => {
document.title = 'Misskey | %i18n:mobile.tags.mk-signin-history-page.signin-history%';
ui.trigger('title', '%fa:sign-in-alt%%i18n:mobile.tags.mk-signin-history-page.signin-history%');
});
</script>
</mk-signin-history-page>

View file

@ -1,17 +0,0 @@
<mk-twitter-setting-page>
<mk-ui ref="ui">
<mk-twitter-setting/>
</mk-ui>
<style lang="stylus" scoped>
:scope
display block
</style>
<script lang="typescript">
import ui from '../../../scripts/ui-event';
this.on('mount', () => {
document.title = 'Misskey | %i18n:mobile.tags.mk-twitter-setting-page.twitter-integration%';
ui.trigger('title', '%fa:B twitter%%i18n:mobile.tags.mk-twitter-setting-page.twitter-integration%');
});
</script>
</mk-twitter-setting-page>