pleroma-fe/src/App.js

139 lines
5.0 KiB
JavaScript
Raw Normal View History

2016-10-27 18:01:48 +02:00
import UserPanel from './components/user_panel/user_panel.vue'
2016-11-06 20:11:23 +01:00
import NavPanel from './components/nav_panel/nav_panel.vue'
2016-11-27 19:44:56 +01:00
import Notifications from './components/notifications/notifications.vue'
2019-07-15 18:42:27 +02:00
import SearchBar from './components/search_bar/search_bar.vue'
2018-02-03 16:27:33 +01:00
import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
2018-09-03 08:57:22 +02:00
import FeaturesPanel from './components/features_panel/features_panel.vue'
2018-09-03 07:43:10 +02:00
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'
2018-01-26 15:11:34 +01:00
import ChatPanel from './components/chat_panel/chat_panel.vue'
2020-05-03 16:36:12 +02:00
import SettingsModal from './components/settings_modal/settings_modal.vue'
import MediaModal from './components/media_modal/media_modal.vue'
import SideDrawer from './components/side_drawer/side_drawer.vue'
2019-09-19 19:59:34 +02:00
import MobilePostStatusButton from './components/mobile_post_status_button/mobile_post_status_button.vue'
import MobileNav from './components/mobile_nav/mobile_nav.vue'
2019-03-19 09:53:11 +01:00
import UserReportingModal from './components/user_reporting_modal/user_reporting_modal.vue'
import PostStatusModal from './components/post_status_modal/post_status_modal.vue'
import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
2020-05-07 15:10:53 +02:00
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
2016-10-26 19:03:55 +02:00
export default {
name: 'app',
components: {
2016-11-06 20:11:23 +01:00
UserPanel,
2016-11-27 19:44:56 +01:00
NavPanel,
2017-05-12 18:54:12 +02:00
Notifications,
2019-07-15 18:42:27 +02:00
SearchBar,
2018-02-11 15:12:05 +01:00
InstanceSpecificPanel,
2018-09-03 08:57:22 +02:00
FeaturesPanel,
2018-09-03 07:55:40 +02:00
WhoToFollowPanel,
ChatPanel,
MediaModal,
SideDrawer,
2019-09-19 19:59:34 +02:00
MobilePostStatusButton,
2019-03-19 09:53:11 +01:00
MobileNav,
2020-05-03 16:36:12 +02:00
SettingsModal,
UserReportingModal,
PostStatusModal,
GlobalNoticeList
2016-11-03 16:58:32 +01:00
},
2017-01-17 17:27:39 +01:00
data: () => ({
mobileActivePanel: 'timeline',
2019-07-15 18:42:27 +02:00
searchBarHidden: true,
supportsMask: window.CSS && window.CSS.supports && (
window.CSS.supports('mask-size', 'contain') ||
window.CSS.supports('-webkit-mask-size', 'contain') ||
window.CSS.supports('-moz-mask-size', 'contain') ||
window.CSS.supports('-ms-mask-size', 'contain') ||
window.CSS.supports('-o-mask-size', 'contain')
)
2017-01-17 17:27:39 +01:00
}),
created () {
// Load the locale from the storage
const val = this.$store.getters.mergedConfig.interfaceLanguage
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
2019-03-03 15:33:40 +01:00
window.addEventListener('resize', this.updateMobileState)
},
destroyed () {
window.removeEventListener('resize', this.updateMobileState)
},
2016-11-03 16:58:32 +01:00
computed: {
2016-11-27 19:44:56 +01:00
currentUser () { return this.$store.state.users.currentUser },
2017-02-16 16:59:06 +01:00
background () {
2018-09-09 21:02:22 +02:00
return this.currentUser.background_image || this.$store.state.instance.background
2017-02-16 16:59:06 +01:00
},
2018-09-09 21:02:22 +02:00
enableMask () { return this.supportsMask && this.$store.state.instance.logoMask },
logoStyle () {
return {
'visibility': this.enableMask ? 'hidden' : 'visible'
}
},
logoMaskStyle () {
return this.enableMask ? {
2018-09-09 21:02:22 +02:00
'mask-image': `url(${this.$store.state.instance.logo})`
} : {
'background-color': this.enableMask ? '' : 'transparent'
}
},
logoBgStyle () {
return Object.assign({
'margin': `${this.$store.state.instance.logoMargin} 0`,
2019-07-15 18:42:27 +02:00
opacity: this.searchBarHidden ? 1 : 0
}, this.enableMask ? {} : {
'background-color': this.enableMask ? '' : 'transparent'
})
},
2018-09-09 21:02:22 +02:00
logo () { return this.$store.state.instance.logo },
2019-02-03 21:32:24 +01:00
bgStyle () {
return {
'background-image': `url(${this.background})`
}
},
2019-02-15 13:20:52 +01:00
bgAppStyle () {
return {
'--body-background-image': `url(${this.background})`
}
},
2018-09-09 20:21:23 +02:00
sitename () { return this.$store.state.instance.name },
2018-02-04 00:36:10 +01:00
chat () { return this.$store.state.chat.channel.state === 'joined' },
hideSitename () { return this.$store.state.instance.hideSitename },
2018-09-09 20:21:23 +02:00
suggestionsEnabled () { return this.$store.state.instance.suggestionsEnabled },
2019-08-12 20:29:11 +02:00
showInstanceSpecificPanel () {
return this.$store.state.instance.showInstanceSpecificPanel &&
!this.$store.getters.mergedConfig.hideISP &&
2019-08-12 20:29:11 +02:00
this.$store.state.instance.instanceSpecificPanelContent
},
2019-03-03 15:33:40 +01:00
showFeaturesPanel () { return this.$store.state.instance.showFeaturesPanel },
isMobileLayout () { return this.$store.state.interface.mobileLayout },
privateMode () { return this.$store.state.instance.private },
sidebarAlign () {
return {
'order': this.$store.state.instance.sidebarRight ? 99 : 0
}
}
2017-01-17 17:27:39 +01:00
},
methods: {
scrollToTop () {
window.scrollTo(0, 0)
2017-07-02 12:25:34 +02:00
},
logout () {
2018-11-10 10:43:25 +01:00
this.$router.replace('/main/public')
2017-07-02 12:25:34 +02:00
this.$store.dispatch('logout')
},
2019-07-15 18:42:27 +02:00
onSearchBarToggled (hidden) {
this.searchBarHidden = hidden
},
2020-05-03 16:36:12 +02:00
openSettingsModal () {
this.$store.dispatch('openSettingsModal')
},
2019-03-03 15:33:40 +01:00
updateMobileState () {
2019-04-01 21:41:34 +02:00
const mobileLayout = windowWidth() <= 800
2020-05-07 15:10:53 +02:00
const layoutHeight = windowHeight()
2019-04-01 21:41:34 +02:00
const changed = mobileLayout !== this.isMobileLayout
2019-03-03 15:33:40 +01:00
if (changed) {
2019-04-01 21:41:34 +02:00
this.$store.dispatch('setMobileLayout', mobileLayout)
2019-03-03 15:33:40 +01:00
}
2020-05-07 15:10:53 +02:00
this.$store.dispatch('setLayoutHeight', layoutHeight)
}
2016-10-26 19:03:55 +02:00
}
}