import { ref } from 'vue'

// 主题状态
const isDarkMode = ref(false)

// 切换主题
export const toggleTheme = () => {
  isDarkMode.value = !isDarkMode.value
  if (isDarkMode.value) {
    document.documentElement.classList.add('dark-theme')
  } else {
    document.documentElement.classList.remove('dark-theme')
  }
}

// 获取主题状态
export const getThemeMode = () => {
  return isDarkMode.value
}

// 设置主题状态
export const setThemeMode = (dark) => {
  isDarkMode.value = dark
  if (dark) {
    document.documentElement.classList.add('dark-theme')
  } else {
    document.documentElement.classList.remove('dark-theme')
  }
}

export default {
  isDarkMode,
  toggleTheme,
  getThemeMode,
  setThemeMode
} 