3434 <v-icon >$estop</v-icon >
3535 </v-btn >
3636
37- <v-main >
37+ <v-main :style = " customBackgroundImageStyle " >
3838 <!-- <pre>authenticated {{ authenticated }}, socketConnected {{ socketConnected }}, apiConnected {{ apiConnected }}</pre> -->
3939 <v-container
4040 fluid
7979</template >
8080
8181<script lang="ts">
82- import { Component , Mixins } from ' vue-property-decorator'
82+ import { Component , Mixins , Watch } from ' vue-property-decorator'
8383import { EventBus , FlashMessage } from ' @/eventBus'
84- import StateMixin from ' ./mixins/state'
85- import { Waits } from ' ./globals'
84+ import StateMixin from ' @/mixins/state'
85+ import FilesMixin from ' @/mixins/files'
86+ import { Waits } from ' @/globals'
8687import { LinkPropertyHref } from ' vue-meta'
8788
8889@Component <App >({
@@ -99,10 +100,11 @@ import { LinkPropertyHref } from 'vue-meta'
99100 }
100101 }
101102})
102- export default class App extends Mixins (StateMixin ) {
103+ export default class App extends Mixins (StateMixin , FilesMixin ) {
103104 toolsdrawer: boolean | null = null
104105 navdrawer: boolean | null = null
105106 showUpdateUI = false
107+ customBackgroundImageStyle: Record <string , string > = {}
106108
107109 flashMessage: FlashMessage = {
108110 open: false ,
@@ -213,6 +215,55 @@ export default class App extends Mixins(StateMixin) {
213215 return theme .currentTheme .primary
214216 }
215217
218+ get customStyleSheet () {
219+ return this .$store .getters [' config/getCustomThemeFile' ](' custom' , [' .css' ])
220+ }
221+
222+ @Watch (' customStyleSheet' )
223+ async onCustomStyleSheet (value : string ) {
224+ if (! value ) {
225+ return
226+ }
227+
228+ const url = await this .createFileUrl (value , ' config' )
229+
230+ const oldCustomStylesheet = document .getElementById (' customStylesheet' )
231+
232+ if (oldCustomStylesheet ) {
233+ oldCustomStylesheet .setAttribute (' href' , url )
234+ return
235+ }
236+
237+ const linkElement = document .createElement (' link' )
238+
239+ linkElement .rel = ' stylesheet'
240+ linkElement .type = ' text/css'
241+ linkElement .id = ' customStylesheet'
242+ linkElement .href = url
243+
244+ document .head .appendChild (linkElement )
245+ }
246+
247+ get customBackgroundImage () {
248+ return this .$store .getters [' config/getCustomThemeFile' ](' background' , [' .png' , ' .jpg' , ' .jpeg' , ' .gif' ])
249+ }
250+
251+ @Watch (' customBackgroundImage' )
252+ async onCustomBackgroundImage (value : string ) {
253+ if (! value ) {
254+ return
255+ }
256+
257+ const url = await this .createFileUrl (value , ' config' )
258+
259+ this .customBackgroundImageStyle = {
260+ backgroundImage: ` url(${url }) ` ,
261+ backgroundSize: ' cover' ,
262+ backgroundAttachment: ' fixed' ,
263+ backgroundRepeat: ' no-repeat'
264+ }
265+ }
266+
216267 mounted () {
217268 // this.onLoadLocale(this.$i18n.locale)
218269 EventBus .bus .$on (' flashMessage' , (payload : FlashMessage ) => {
0 commit comments