feat: 登录接口对接
This commit is contained in:
@@ -58,19 +58,20 @@
|
||||
</div>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button class="w-full py-2 bg-blue-600 text-white rounded-[8px] hover:bg-blue-700 disabled:bg-blue-300"
|
||||
@click="onSubmit">
|
||||
{{ loading ? '登录中…' : '登录' }}
|
||||
<button type="button"
|
||||
class="w-full py-2 bg-blue-600 cursor-pointer text-white rounded-[8px] hover:bg-blue-700 disabled:bg-blue-300"
|
||||
:loading="loading" @click="onSubmit">
|
||||
登 录
|
||||
</button>
|
||||
|
||||
<!-- 同意协议 -->
|
||||
<div class="flex items-center justify-center gap-2 mt-[24px]">
|
||||
<!-- <div class="flex items-center justify-center gap-2 mt-[24px]">
|
||||
<input type="checkbox" v-model="isAgree" class="w-[14px] h-[14px] rounded-[4px]" />
|
||||
<span class="text-[14px] text-gray-600">我已同意</span>
|
||||
<span class="text-[14px] text-sky-600 cursor-pointer">《使用协议》</span>
|
||||
<span class="text-[14px] text-gray-600">和</span>
|
||||
<span class="text-[14px] text-sky-600 cursor-pointer">《隐私协议》</span>
|
||||
</div>
|
||||
</div> -->
|
||||
</el-form>
|
||||
|
||||
<!-- Copy Right -->
|
||||
@@ -81,27 +82,17 @@
|
||||
|
||||
<img class="w-[540px]" src="@assets/images/login/logo.png" />
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { authOauth2TokenUsingPost } from "@renderer/api";
|
||||
import { useUserStore } from "@renderer/store/userinfo"
|
||||
import { RiUser3Fill, RiKey2Fill } from '@remixicon/vue'
|
||||
import { generateUUID } from "@utils/generateUUID";
|
||||
import { generateUUID } from "@utils/generateUUID"
|
||||
import { rule } from '@utils/validate'
|
||||
|
||||
|
||||
// form 表单数据类型声明
|
||||
interface LoginForm {
|
||||
username: string;
|
||||
password: string;
|
||||
randomStr: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
const router = useRouter();
|
||||
const form = reactive<LoginForm>({ username: "", password: "", randomStr: '', code: "" });
|
||||
const userStore = useUserStore()
|
||||
const form = reactive<LoginForm>({ username: "", password: "", randomStr: '', code: "", grant_type: '', scope: '' });
|
||||
const loading = ref(false);
|
||||
const showPwd = ref(false);
|
||||
const isAgree = ref(false);
|
||||
@@ -130,13 +121,10 @@ const onSubmit = async () => {
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
// localStorage.setItem("token", "dev-token");
|
||||
// const res: any = await authOauth2TokenUsingPost({ body: form });
|
||||
// const token = res && (res.token || res.data?.token || res.access_token);
|
||||
// if (!token) throw new Error("登录失败");
|
||||
// localStorage.setItem("token", token);
|
||||
// await (window as any).api.app.setFrameless('/home')
|
||||
router.push('/home');
|
||||
userStore.login(form).then(() => {
|
||||
// window.location.href = 'index.html'
|
||||
console.log(form)
|
||||
})
|
||||
} finally {
|
||||
getVerifyCode()
|
||||
loading.value = false; // 登录结束
|
||||
|
||||
Reference in New Issue
Block a user