├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { defineStore } from 'pinia'
  2. import { ref, computed } from 'vue'
  3. export const useThemeStore = defineStore('theme', {
  4. state: () => ({
  5. themes: {
  6. default: {
  7. '--primary-color': '#1890ff',
  8. '--bg-color': '#f8f9fa',
  9. '--text-color': '#333',
  10. '--card-bg': '#ffffff'
  11. },
  12. aydzBlue: {
  13. '--primary-color': '#2a5caa',
  14. '--bg-color': '#e6f7ff',
  15. '--text-color': '#1a3353',
  16. '--card-bg': '#d0e8ff'
  17. },
  18. darkMode: {
  19. '--primary-color': '#52c41a',
  20. '--bg-color': '#1a1a1a',
  21. '--text-color': '#e6e6e6',
  22. '--card-bg': '#2a2a2a'
  23. }
  24. },
  25. currentTheme: 'aydzBlue'
  26. }),
  27. actions: {
  28. initTheme() {
  29. const savedTheme = uni.getStorageSync('selectedTheme') || 'aydzBlue'
  30. this.setTheme(savedTheme)
  31. },
  32. setTheme(themeName) {
  33. if (!this.themes[themeName]) return
  34. this.currentTheme = themeName
  35. uni.setStorageSync('selectedTheme', themeName)
  36. // 应用CSS变量
  37. const root = document.documentElement
  38. const themeVars = this.themes[themeName]
  39. Object.keys(themeVars).forEach(key => {
  40. root.style.setProperty(key, themeVars[key])
  41. })
  42. // 动态设置导航栏颜色
  43. if (themeName === 'darkMode') {
  44. uni.setNavigationBarColor({
  45. frontColor: '#ffffff',
  46. backgroundColor: '#1a1a1a'
  47. })
  48. } else if (themeName === 'aydzBlue') {
  49. uni.setNavigationBarColor({
  50. frontColor: '#ffffff',
  51. backgroundColor: '#2a5caa'
  52. })
  53. } else {
  54. uni.setNavigationBarColor({
  55. frontColor: '#000000',
  56. backgroundColor: '#f8f9fa'
  57. })
  58. }
  59. },
  60. getThemeLabel(themeKey) {
  61. const labels = {
  62. default: '默认主题',
  63. aydzBlue: '哎呀科技蓝',
  64. darkMode: '深色模式'
  65. }
  66. return labels[themeKey] || themeKey
  67. }
  68. },
  69. getters: {
  70. themeOptions: (state) => {
  71. return Object.keys(state.themes).map(key => ({
  72. name: key,
  73. label: state.getThemeLabel(key),
  74. colors: state.themes[key]
  75. }))
  76. }
  77. }
  78. })