Skip to content

Commit

Permalink
登入帳號的樣式
Browse files Browse the repository at this point in the history
  • Loading branch information
xiao-e-yun committed Oct 16, 2021
1 parent fbe48bc commit 5f0845d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
31 changes: 26 additions & 5 deletions server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,33 @@ export default function (ws: _ws) {
//輸入帳號密碼
Promise.all(inputs)
.then(async()=>(await page.$("#login_btn_signin>button"))?.click());
let login = false

page.waitForNavigation().then(async()=>{
page.waitForNavigation({
timeout:5000,
}).then(async()=>{
login = true
//轉址等同成功
await save()
resolve({
success:true,
guard:{need:false}
})
}).catch(()=>{})
}).catch(()=>{
if(login) return
login = true
resolve({
success:false,
guard:{need:false},
error:"account or password incorrect"
})
})

page.waitForSelector(".loginTwoFactorCodeModal",{
visible:true
visible:true,
timeout:5000,
}).then(()=>{
login = true
const get = "login_guard$" + hash()
ws.on(get as "login_guard",async(data)=>{
await page.$eval("#twofactorcode_entry",(el,val)=>{
Expand All @@ -167,8 +181,15 @@ export default function (ws: _ws) {
success:true,
guard:{get,need:true}
})

}).catch(()=>{})
}).catch(()=>{
if(login) return
login = true
resolve({
success:false,
guard:{need:false},
error:"account or password incorrect"
})
})

async function save() {
const $config = await config("cookies") || {}
Expand Down
44 changes: 41 additions & 3 deletions view/src/components/login_steam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<form class="login_steam" autocomplete="on">
<h2>登入至Steam</h2>
<template v-if="send_to === ''">
<p>帳號:<input v-model="account.username" type="text" /></p>
<p>帳號 <input v-model="account.username" type="text" /></p>
<p>
密碼:<input
密碼 <input
v-model="account.password"
type="password"
autocomplete="on"
/>
</p>
</template>
<p v-else>驗證碼:<input v-model="guard" type="text" /></p>
<p v-else>驗證碼 <input v-model="guard" type="text" /></p>
<button
type="submit"
@click.prevent="login(send_to !== '')"
Expand All @@ -38,6 +38,7 @@ export default defineComponent({
},
methods: {
async login(guard: boolean) {
this.loading(true)
if (!guard) {
const data = (await this.$ws.get("login_steam", this.account)).data;
if (data.success) {
Expand All @@ -59,6 +60,7 @@ export default defineComponent({
console.warn(data.error);
}
}
this.loading(false)
},
},
watch: {
Expand All @@ -71,4 +73,40 @@ export default defineComponent({

<style lang="scss" scoped>
@import "@/app.scss";
.login_steam{
background-color: $side-3;
font-size: 2rem;
padding:.2em 1.2em .6em;
width: max-content;
&>h2{
margin: .4em 0;
}
&>p{
margin: .4em 0;
&>input{
background-color: $side-2;
font-size: 1em;
border: none;
color: $main;
}
}
&>button{
font-size: .8em;
font-weight: 800;
background-color: $side-2;
color:$main;
padding:.2em .6em;
transition-property: color,background-color;
transition-timing-function: ease-in-out;
transition-duration: .2s;
border-radius: 0;
cursor: pointer;
border:none;
&:hover{
color: $main;
background-color: $bg;
}
}
}
</style>
2 changes: 0 additions & 2 deletions view/src/views/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default defineComponent({
screenshot: "螢幕截圖",
workshop: "工作坊",
},
show_type_list: false,
active: "",
imgs: [] as { name: string; path: string; file?: File }[],
cookies: {} as { [user: string]: Protocol.Network.Cookie[] },
Expand All @@ -87,7 +86,6 @@ export default defineComponent({
const reader = new FileReader();
const imgs = [] as DataType["build"]["req"]["imgs"];
console.log(this.imgs);
if (this.edit_setting.base64) {
for (const img of this.imgs) {
const data = (await read_img(img.file as File)) as string;
Expand Down

0 comments on commit 5f0845d

Please sign in to comment.