You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

  1. 'use strict'
  2. export default {
  3. name: 'admin-theme',
  4. props: ['themedata'],
  5. data() {
  6. return {
  7. primary: 'indigo',
  8. alt: 'blue-grey',
  9. footer: 'blue-grey',
  10. codedark: 'true',
  11. codecolorize: 'true'
  12. }
  13. },
  14. watch: {
  15. primary(val) {
  16. this.$root.changeTheme(this.$data)
  17. },
  18. alt(val) {
  19. this.$root.changeTheme(this.$data)
  20. },
  21. footer(val) {
  22. this.$root.changeTheme(this.$data)
  23. }
  24. },
  25. methods: {
  26. saveTheme() {
  27. let self = this
  28. this.$http.post(window.location.href, self.$data).then(resp => {
  29. self.$store.dispatch('alert', {
  30. style: 'green',
  31. icon: 'check',
  32. msg: 'Theme settings have been applied successfully.'
  33. })
  34. }).catch(err => {
  35. self.$store.dispatch('alert', {
  36. style: 'red',
  37. icon: 'square-cross',
  38. msg: 'Error: ' + err.body.msg
  39. })
  40. })
  41. },
  42. resetTheme() {
  43. this.primary = 'indigo'
  44. this.alt = 'blue-grey'
  45. this.footer = 'blue-grey'
  46. this.codedark = 'true'
  47. this.codecolorize = 'true'
  48. }
  49. },
  50. mounted() {
  51. let theme = JSON.parse(this.themedata)
  52. this.primary = theme.primary
  53. this.alt = theme.alt
  54. this.footer = theme.footer
  55. this.codedark = theme.code.dark.toString()
  56. this.codecolorize = theme.code.colorize.toString()
  57. }
  58. }