odc.xiaohui
2023-11-09 b3950b71def7ced271171626c4c883f66fa036e3
src/views/login.vue
@@ -63,8 +63,10 @@
import { authBinding } from '@/api/system/social/auth';
import { useUserStore } from '@/store/modules/user';
import { LoginData, TenantVO } from '@/api/types';
import { to } from 'await-to-js';
import { to as tos, to } from "await-to-js";
import { HttpStatus } from "@/enums/RespEnum";
import { createUser } from "@/api/system/oss";
import { setToken } from "@/utils/auth";
const userStore = useUserStore();
const router = useRouter();
@@ -203,12 +205,38 @@
  });
};
const setAddUser = async (val: any | number | (string | number)[]) => {
  console.log(val);
  const res = await createUser(val)
  console.log(res);
  if (res.code == 200) {
    const data = res.data;
    setToken(data.access_token);
  }
}
onMounted(() => {
  getCode();
  initTenantList();
  getLoginData();
onMounted(async () => {
  try {
    // 使用fetch API获取当前IP地址
    await fetch('https://api.ipify.org/?format=json')
      .then(response => response.json())
      .then(async data => {
        let obj = {
          username: data.ip
        }
        await setAddUser(obj)
      })
      .catch(error => {
        console.error('获取IP地址失败:', error);
      });
  } catch (error) {
    console.log(error);
  }
  router.push('index')
  // getCode();
  // initTenantList();
  // getLoginData();
});
</script>