update
This commit is contained in:
parent
95e6bccec5
commit
dfc5f170c6
1 changed files with 67 additions and 51 deletions
118
src/main.js
118
src/main.js
|
@ -93,63 +93,79 @@ window.fetch('/api/statusnet/config.json')
|
||||||
store.dispatch('setOption', { name: 'server', value: server })
|
store.dispatch('setOption', { name: 'server', value: server })
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fetch('/static/config.json')
|
window.fetch('/api/statusnet/config.json')
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const {theme, background, logo, showWhoToFollowPanel, whoToFollowProvider, whoToFollowLink, showInstanceSpecificPanel, scopeOptionsEnabled, collapseMessageWithSubject} = data
|
var apiStatusnetConfigSitePleromafe = data.site.pleromafe
|
||||||
store.dispatch('setOption', { name: 'theme', value: theme })
|
window.fetch('/static/sonfig.json')
|
||||||
store.dispatch('setOption', { name: 'background', value: background })
|
.then((data) => {
|
||||||
store.dispatch('setOption', { name: 'logo', value: logo })
|
var staticConfig = data
|
||||||
store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: showWhoToFollowPanel })
|
|
||||||
store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
|
|
||||||
store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
|
|
||||||
store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
|
||||||
store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
|
|
||||||
store.dispatch('setOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject })
|
|
||||||
if (data['chatDisabled']) {
|
|
||||||
store.dispatch('disableChat')
|
|
||||||
}
|
|
||||||
|
|
||||||
const routes = [
|
var theme = (apiStatusnetConfigSitePleromafe.theme || staticConfig.theme)
|
||||||
{ name: 'root',
|
var background = (apiStatusnetConfigSitePleromafe.background || staticConfig.background)
|
||||||
path: '/',
|
var logo = (apiStatusnetConfigSitePleromafe.logo || staticConfig.logo)
|
||||||
redirect: to => {
|
var redirectRootNoLogin = (apiStatusnetConfigSitePleromafe.redirectRootNoLogin || staticConfig.redirectRootNoLogin)
|
||||||
var redirectRootLogin = data['redirectRootLogin']
|
var redirectRootLogin = (apiStatusnetConfigSitePleromafe.redirectRootLogin || staticConfig.redirectRootLogin)
|
||||||
var redirectRootNoLogin = data['redirectRootNoLogin']
|
var chatDisabled = (apiStatusnetConfigSitePleromafe.chatDisabled || staticConfig.chatDisabled)
|
||||||
return (store.state.users.currentUser ? redirectRootLogin : redirectRootNoLogin) || '/main/all'
|
var showWhoToFollowPanel = (apiStatusnetConfigSitePleromafe.showWhoToFollowPanel || staticConfig.showWhoToFollowPanel)
|
||||||
}},
|
var whoToFollowProvider = (apiStatusnetConfigSitePleromafe.whoToFollowProvider || staticConfig.whoToFollowProvider)
|
||||||
{ path: '/main/all', component: PublicAndExternalTimeline },
|
var whoToFollowLink = (apiStatusnetConfigSitePleromafe.whoToFollowLink || staticConfig.whoToFollowLink)
|
||||||
{ path: '/main/public', component: PublicTimeline },
|
var showInstanceSpecificPanel = (apiStatusnetConfigSitePleromafe.showInstanceSpecificPanel || staticConfig.showInstanceSpecificPanel)
|
||||||
{ path: '/main/friends', component: FriendsTimeline },
|
var scopeOptionsEnabled = (apiStatusnetConfigSitePleromafe.scopeOptionsEnabled || staticConfig.scopeOptionsEnabled)
|
||||||
{ path: '/tag/:tag', component: TagTimeline },
|
var collapseMessageWithSubject = (apiStatusnetConfigSitePleromafe.collapseMessageWithSubject || staticConfig.collapseMessageWithSubject)
|
||||||
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
|
||||||
{ name: 'user-profile', path: '/users/:id', component: UserProfile },
|
|
||||||
{ name: 'mentions', path: '/:username/mentions', component: Mentions },
|
|
||||||
{ name: 'settings', path: '/settings', component: Settings },
|
|
||||||
{ name: 'registration', path: '/registration', component: Registration },
|
|
||||||
{ name: 'registration', path: '/registration/:token', component: Registration },
|
|
||||||
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
|
|
||||||
{ name: 'user-settings', path: '/user-settings', component: UserSettings }
|
|
||||||
]
|
|
||||||
|
|
||||||
const router = new VueRouter({
|
store.dispatch('setOption', { name: 'theme', value: theme })
|
||||||
mode: 'history',
|
store.dispatch('setOption', { name: 'background', value: background })
|
||||||
routes,
|
store.dispatch('setOption', { name: 'logo', value: logo })
|
||||||
scrollBehavior: (to, from, savedPosition) => {
|
store.dispatch('setOption', { name: 'showWhoToFollowPanel', value: showWhoToFollowPanel })
|
||||||
if (to.matched.some(m => m.meta.dontScroll)) {
|
store.dispatch('setOption', { name: 'whoToFollowProvider', value: whoToFollowProvider })
|
||||||
return false
|
store.dispatch('setOption', { name: 'whoToFollowLink', value: whoToFollowLink })
|
||||||
}
|
store.dispatch('setOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel })
|
||||||
return savedPosition || { x: 0, y: 0 }
|
store.dispatch('setOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled })
|
||||||
|
store.dispatch('setOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject })
|
||||||
|
if (chatDisabled) {
|
||||||
|
store.dispatch('disableChat')
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
/* eslint-disable no-new */
|
const routes = [
|
||||||
new Vue({
|
{ name: 'root',
|
||||||
router,
|
path: '/',
|
||||||
store,
|
redirect: to => {
|
||||||
i18n,
|
return (store.state.users.currentUser ? redirectRootLogin : redirectRootNoLogin) || '/main/all'
|
||||||
el: '#app',
|
}},
|
||||||
render: h => h(App)
|
{ path: '/main/all', component: PublicAndExternalTimeline },
|
||||||
|
{ path: '/main/public', component: PublicTimeline },
|
||||||
|
{ path: '/main/friends', component: FriendsTimeline },
|
||||||
|
{ path: '/tag/:tag', component: TagTimeline },
|
||||||
|
{ name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } },
|
||||||
|
{ name: 'user-profile', path: '/users/:id', component: UserProfile },
|
||||||
|
{ name: 'mentions', path: '/:username/mentions', component: Mentions },
|
||||||
|
{ name: 'settings', path: '/settings', component: Settings },
|
||||||
|
{ name: 'registration', path: '/registration', component: Registration },
|
||||||
|
{ name: 'registration', path: '/registration/:token', component: Registration },
|
||||||
|
{ name: 'friend-requests', path: '/friend-requests', component: FollowRequests },
|
||||||
|
{ name: 'user-settings', path: '/user-settings', component: UserSettings }
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = new VueRouter({
|
||||||
|
mode: 'history',
|
||||||
|
routes,
|
||||||
|
scrollBehavior: (to, from, savedPosition) => {
|
||||||
|
if (to.matched.some(m => m.meta.dontScroll)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return savedPosition || { x: 0, y: 0 }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
/* eslint-disable no-new */
|
||||||
|
new Vue({
|
||||||
|
router,
|
||||||
|
store,
|
||||||
|
i18n,
|
||||||
|
el: '#app',
|
||||||
|
render: h => h(App)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue