<template>
  <div class="page">
    <router-view />
  </div>
</template>

<script setup>
// 引入css
import "vant/es/toast/style";
import "vant/es/notify/style";
// 确认框同理，其它不显示的样式同理引入相关css即可
import "vant/es/dialog/style";
import { ref, reactive, unref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useI18n } from "vue-i18n";
const { t, locale } = useI18n();
function getUrlParams(url) {
  if(!url) return {}
  // 通过 ? 分割获取后面的参数字符串
  console.log("getUrlParams", url);
  let urlStr = url.split("?")[1];
  // 创建空对象存储参数
  let obj = {};
  // 再通过 & 将每一个参数单独分割出来
  let paramsArr = urlStr.split("&");
  for (let i = 0, len = paramsArr.length; i < len; i++) {
    // 再通过 = 将每一个参数分割为 key:value 的形式
    let arr = paramsArr[i].split("=");
    obj[arr[0]] = arr[1];
  }
  return obj;
}
import { useStore } from "../src/store/user";
const router = getUrlParams(window.location.search);
const route = useRoute();
console.log("useRoute", router);
const userState = useStore();
router.rtkSnCode && userState.setRtkSnCode(router.rtkSnCode);
// 切换
handleLang(router.lang || 'zh')
function handleLang(val) {
  console.log("handleLang", val);
  locale.value = val;
  localStorage.setItem("lang", val);
}
// console.log("route",unref(route).query,  route.query);
</script>

<style lang="less">
* {
  margin: 0;
  padding: 0;
}
body,
html {
  margin: 0;
  padding: 0;
}
.page {
  background: #161a1a;
  min-height: 100vh;
  width: 100%;
}
.van-nav-bar__title {
  color: #ffffff !important;
}
.van-nav-bar__content {
  font-size: 17px;
  color: #ffffff;
  line-height: 23px;
  text-align: left;
  font-style: normal;
}
.van-field__value {
  padding: 14px;
  background: #252828;
  border-radius: 6px;
}
.van-cell__right-icon {
  line-height: 50px !important;
}
.van-field__control {
  background: none !important;
  color: #ffffff !important;
}
.input:-webkit-autofill {
  -webkit-text-fill-color: #fff !important;
  transition: background-color 5000s ease-in-out 0s;
}
:root {
  --van-cell-background: #161a1a !important;
  --van-field-label-color: #ffffff !important;
  --van-button-primary-background: #00c8af !important;
  --van-button-round-radius: 6px !important;
}
</style>
