1
2026-05-23 30d1ee7be942d7a2201e1ab2ca7d96badff8bf50
src/App.vue
@@ -1,18 +1,41 @@
<template>
  <div class="pt-5">
    <router-view />
  <div class="app-root">
    <div class="app-content-wrap" :class="{ 'app-content-wrap--no-bottom-padding': noBottomPadding, 'app-content-wrap--account-change': accountChangeWrap }">
      <router-view />
    </div>
  </div>
  <fx-footer v-if="route.meta.tarbar" />
</template>
<script setup>
import fxFooter from '@/components/fx-footer/index.vue'
import { authorizedLogin } from "@/service/login.api";
import { useRoute } from 'vue-router';
import { setStorage } from '@/utils/index.js'
import { onMounted } from 'vue'
import { onMounted, computed } from 'vue'
import { useRouter } from 'vue-router';
import { useUserStore } from '@/store/user';
import store from '@/store/store'
import { GET_USERINFO } from '@/store/types.store'
const router = useRouter()
const route = useRoute()
// /quotes/index 页面不需要顶部 pt-5
const applyTopPadding = computed(() => {
  const path = route.path
  return path !== '/quotes' && path !== '/quotes/index'
})
// 某些页面(如 aiDetail、airdrop)不需要底部 padding,由路由控制
const noBottomPadding = computed(() => {
  const path = route.path
  return path === '/my/aiDetail' || path === '/my/airdrop'
})
// 账变记录页 .app-content-wrap 背景色 #F6F5FA
const accountChangeWrap = computed(() => route.path === '/cryptos/accountChange')
const geturlkey = (name) => {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null;
@@ -22,19 +45,21 @@
if (usercode) {
  setStorage('usercode', usercode);
}
const userStore = useUserStore();
onMounted(() => {
  if (window.ethereum !== undefined || window.web3 !== undefined || window.injectedWeb3 !== undefined) {
    loginButton(); // 如果支持 Web3,调用登录函数
  } else {
    window.location.href = 'https://dapp.trullcpro.top'; // 否则重定向
  }
});
// 狐狸钱包登录逻辑
// onMounted(() => {
//   if (window.ethereum !== undefined || window.web3 !== undefined || window.injectedWeb3 !== undefined) {
//     loginButton(); // 如果支持 Web3,调用登录函数
//   } else {
//     window.location.href = 'https://trustwallet.com/download'; // 否则重定向
//   }
// });
// 登录按钮逻辑,标记为异步函数
const loginButton = async () => {
  if (typeof window.ethereum !== 'undefined') {
    if (!usercode) {
    if (!(userStore.userInfo && userStore.userInfo.token)) {
      try {
        // 请求用户授权
        const accounts = await window.ethereum.request({
@@ -67,30 +92,21 @@
    }
  } else {
    alert('Please install Little Fox Wallet!');
    // this.$router.go(-1)
    // this.$router.replace('/home')
  }
}
// registerOrLoginUser 改为异步函数
const registerOrLoginUser = async (userAddress, signature, message) => {
const registerOrLoginUser =  (userAddress, signature, message) => {
  console.log(userAddress);
  console.log(signature);
  console.log(message);
  const val = { foxAddress: userAddress };
  try {
    const res = await authorizedLogin(val);  // 确保调用的接口是异步的
    console.log(res.data);
    // this.GET_USERINFO(res.data)
    // this.gouser(res.data)
    // setStorage('usercode', usercode);
    // this.SET_CONFIG() //获取判断是否乘以杠杆字段
    // this.$router.push('/home')
  } catch (error) {
    console.error('登录时出错:', error);
  }
  const res = authorizedLogin({foxAddress: userAddress}).then((res) => {
        userStore[GET_USERINFO](res)
        store.commit('user/SET_USERINFO', res)
        router.push('/')
    }).catch((res) => {
        console.log(res)
    })  // 确保调用的接口是异步的
};
</script>
@@ -98,6 +114,24 @@
   @import "assets/init";
   @import "assets/mixin";
   @import "assets/css/variable.scss";
   @import "assets/theme/index.scss";
   .app-root {
      min-height: 100vh;
      background-color: #f6f5fa;
   }
   .app-content-wrap {
      background-color: #ffffff;
      border-radius: 12px 12px 0 0;
      min-height: calc(100vh - 8px);
      padding-bottom: 70px;
   }
   .app-content-wrap--no-bottom-padding {
      padding-bottom: 0 !important;
   }
   .app-content-wrap--account-change {
      background-color: #F6F5FA;
   }
   .nationList {
      .van-action-sheet {
@@ -117,12 +151,16 @@
      border-bottom: none;
   }
   .van-tabbar-item__text {
      color: #BEC1D2;
   }
      .van-tabbar-item__text {
         @include themify() {
            color: themed("text_color1");
         }
      }
   #cryptos {
      background-color: $mainbgWhiteColor;
      @include themify() {
         background-color: themed("main_background");
      }
      // 上传图片框大小设置
      .van-uploader__upload {
@@ -135,13 +173,17 @@
      }
      .van-uploader__upload {
         background-color: $upload_bg !important;
         @include themify() {
            background-color: themed("upload_bg") !important;
         }
         border: 2px dashed #b8bcc5;
      }
      // tab标签短横线颜色
      .van-tabs__line {
         background-color: $active_line !important;
         @include themify() {
            background-color: themed("active_line") !important;
         }
      }
      .van-tabs__wrap {
@@ -221,8 +263,9 @@
      .list-quatation {
         .van-cell {
            padding: 15px 0 !important;
            background: $mainbgWhiteColor;
            // background: $inp-b;
            @include themify() {
               background: themed("main_background");
            }
            &::after {
               border: none;
@@ -281,13 +324,17 @@
         }
         .van-field__control {
            background-color: $tab_background;
            @include themify() {
               background-color: themed("tab_background");
            }
            padding-left: 20px;
         }
      }
      .vue-auth-box_ .auth-control_ .range-box {
         background-color: #EAEAEA !important;
         @include themify() {
            background-color: themed("tab_background") !important;
         }
         height: 30px !important;
         margin-bottom: 40px;
      }
@@ -295,7 +342,9 @@
      .vue-auth-box_ .auth-control_ .range-box .range-slider .range-btn {
         width: 140px !important;
         height: 74px !important;
         background: $color_main !important;
         @include themify() {
            background: themed("color_main") !important;
         }
         border-radius: 96px !important;
         top: -50%;
      }
@@ -338,24 +387,32 @@
      .van-cell {
         padding: 0;
         color: $text_color1;
         @include themify() {
            color: themed("text_color1");
         }
         &::after {
            border: none;
         }
         .van-cell__value {
            color: $black;
            @include themify() {
               color: themed("text_color");
            }
         }
      }
      .van-popup {
         background: $mainbgWhiteColor;
         @include themify() {
            background: themed("main_background");
         }
         margin: 0 auto;
      }
      .van-nav-bar__title {
         color: $log-c;
         @include themify() {
            color: themed("text_color");
         }
      }
      .van-hairline--top-bottom::after,
@@ -364,20 +421,27 @@
      }
      .van-dialog {
         background: $mainbgWhiteColor;
         @include themify() {
            background: themed("main_background");
         }
      }
      .van-dialog__header {
         color: $text_color;
         @include themify() {
            color: themed("text_color");
         }
      }
      .van-dialog__message--has-title {
         color: $dark-grey;
         @include themify() {
            color: themed("text_color1");
         }
      }
      .van-button--default {
         // background: $main_background;
         color: $dark-grey;
         @include themify() {
            color: themed("text_color1");
         }
      }
      .van-nav-bar {
@@ -386,11 +450,15 @@
      }
      .van-dropdown-menu__title {
         color: $text_color !important;
         @include themify() {
            color: themed("text_color") !important;
         }
      }
      .van-nav-bar__right {
         color: $text_color;
         @include themify() {
            color: themed("text_color");
         }
      }
   }