项目原始demo,不改动
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import Vue from 'vue';
  2. export function functionalThemeClasses(context) {
  3. const vm = { ...context.props,
  4. ...context.injections
  5. };
  6. const isDark = Themeable.options.computed.isDark.call(vm);
  7. return Themeable.options.computed.themeClasses.call({
  8. isDark
  9. });
  10. }
  11. /* @vue/component */
  12. const Themeable = Vue.extend().extend({
  13. name: 'themeable',
  14. provide() {
  15. return {
  16. theme: this.themeableProvide
  17. };
  18. },
  19. inject: {
  20. theme: {
  21. default: {
  22. isDark: false
  23. }
  24. }
  25. },
  26. props: {
  27. dark: {
  28. type: Boolean,
  29. default: null
  30. },
  31. light: {
  32. type: Boolean,
  33. default: null
  34. }
  35. },
  36. data() {
  37. return {
  38. themeableProvide: {
  39. isDark: false
  40. }
  41. };
  42. },
  43. computed: {
  44. appIsDark() {
  45. return this.$vuetify.theme.dark || false;
  46. },
  47. isDark() {
  48. if (this.dark === true) {
  49. // explicitly dark
  50. return true;
  51. } else if (this.light === true) {
  52. // explicitly light
  53. return false;
  54. } else {
  55. // inherit from parent, or default false if there is none
  56. return this.theme.isDark;
  57. }
  58. },
  59. themeClasses() {
  60. return {
  61. 'theme--dark': this.isDark,
  62. 'theme--light': !this.isDark
  63. };
  64. },
  65. /** Used by menus and dialogs, inherits from v-app instead of the parent */
  66. rootIsDark() {
  67. if (this.dark === true) {
  68. // explicitly dark
  69. return true;
  70. } else if (this.light === true) {
  71. // explicitly light
  72. return false;
  73. } else {
  74. // inherit from v-app
  75. return this.appIsDark;
  76. }
  77. },
  78. rootThemeClasses() {
  79. return {
  80. 'theme--dark': this.rootIsDark,
  81. 'theme--light': !this.rootIsDark
  82. };
  83. }
  84. },
  85. watch: {
  86. isDark: {
  87. handler(newVal, oldVal) {
  88. if (newVal !== oldVal) {
  89. this.themeableProvide.isDark = this.isDark;
  90. }
  91. },
  92. immediate: true
  93. }
  94. }
  95. });
  96. export default Themeable;
  97. //# sourceMappingURL=index.js.map