-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.html
114 lines (96 loc) · 3.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!--
:project: telegram-onedrive
:author: L-ING
:copyright: (C) 2023 L-ING <hlf01@icloud.com>
:license: MIT, see LICENSE for more details.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Telegram Code</title>
<script src="https://unpkg.com/vue@3.4.31/dist/vue.global.js"></script>
<script src="https://unpkg.com/naive-ui@2.38.2/dist/index.js"></script>
<script src="https://unpkg.com/axios@1.7.2/dist/axios.min.js"></script>
<script src="https://unpkg.com/@element-plus/icons-vue@2.3.1/dist/index.iife.min.js"></script>
<style lang="text/css">
#app {
width: 400px;
margin: 200px auto 0 auto;
}
</style>
</head>
<body>
<div id="app">
<n-form ref="formRef" :model="form" inline :label-width="80" :rules="rules" size="medium">
<n-form-item label="Telegram Code" path="code">
<n-input v-model:value="form.code"></n-input>
</n-form-item>
<n-form-item>
<n-button attr-type="button" type="info" @click="submitForm">
<span v-if="!submitted">Submit</span>
<n-icon v-else>
<Check />
</n-icon>
</n-button>
</n-form-item>
</n-form>
</div>
</body>
<script>
const { createApp, ref } = Vue;
const app = createApp({
setup() {
const formRef = ref();
const form = ref({ code: "" });
const submitted = ref(false);
const rules = {
code: {
required: true,
message: "Code is required.",
trigger: ['input'],
},
};
async function validateForm() {
try {
await formRef.value.validate();
return true;
} catch (errors) {
for (let error of errors)
console.error(error[0].message);
return false;
}
}
async function submitForm(e) {
e.preventDefault();
const isValid = await validateForm();
if (!isValid)
return;
axios.post("./tg", {
code: form.value.code
}).then(res => {
form.value.code = "";
submitted.value = true;
setTimeout(() => submitted.value = false, 1000);
});
}
return {
formRef,
form,
submitted,
submitForm,
rules,
};
}
})
app.use(naive);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
if (key === "Check") {
app.component(key, component);
break;
}
}
app.mount('#app');
</script>
</html>