<!--
  ## File: /src/pages/splashScreen/index.vue

  Project: uniapp_vue3_vite_ts

  Created Date: 2024-06-24 11:30:88

  Author: KuroSago

  ## Last Modified: 2024-06-24 11:30:88

  Modified By: kurosago

  ## Copyright (c) 2024 self.

  Use To: 启动页面
-->
<script lang="ts" setup>
import WeekGantViewDemo from '@/components/WeekGantView/demo.vue';
import { useSystemInfoStore } from '@/stores/modules/system';
import { useUserStore } from '@/stores/modules/user';

const { changeThemeModel } = useSystemInfoStore();

const router = useRouter();
onMounted(async () => {
  const userStore = useUserStore();
  const { isLogined } = userStore;
  // 如果已经登录，跳转到首页
  if (isLogined) {
    userStore.initUserInfo();
    router.pushTab({
      name: 'Home',
    });
  } else {
    // router.replace({
    //   name: 'Login',
    //   params: {
    //     redirect: 'Home',
    //     tabBar: 'true',
    //   },
    // });
  }
});

// fuc : 切换主题
function changeTheme() {
  const { themeModel } = useSystemInfoStore();
  changeThemeModel({
    model: themeModel === 'DARK' ? 'LIGHT' : 'DARK',
  });
}

// fnc : 跳转到色卡页面
function toColorCard() {
  router.push({
    name: 'ColorCard',
  });
}

// fnc : toNumerology
function toNumerology() {
  router.push({
    name: 'Numerology',
  });
}
</script>

<template>
  <view class=" flex-1">
    <div class="flex flex-col gap-4 mt-32rpx">
      <WeekGantViewDemo />

      <button @click="changeTheme">
        changeTheme
      </button>

      <button @click="toColorCard">
        色卡
      </button>

      <button @click="toNumerology">
        算命
      </button>
    </div>
  </view>
</template>

<style lang="scss">
page {
  --at-aplly: bg-background;
  background-color: var(--background) /* var(--background) */;
}
</style>
