parent
f3a09a0cde
commit
f00c70b44d
@ -0,0 +1,44 @@ |
||||
<template> |
||||
<el-row type="flex" justify="center"> |
||||
<el-col :span="8"> |
||||
<el-input v-model="botName" :disabled="true"> |
||||
<template v-slot:prepend>Telegram Bot</template> |
||||
</el-input> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import {defineComponent, onMounted, ref} from "vue"; |
||||
import {useStore} from "vuex"; |
||||
import {getTelegramBot, message} from "../request"; |
||||
|
||||
export default defineComponent({ |
||||
name: "Config", |
||||
setup() { |
||||
|
||||
const store = useStore() |
||||
|
||||
onMounted(() => { |
||||
store.commit('updateRoute', '/config') |
||||
}) |
||||
|
||||
const botName = ref('') |
||||
|
||||
getTelegramBot(store.state.user.email).then(res => res.json()) |
||||
.then(res => { |
||||
if (res.result === 'OK') { |
||||
botName.value = res.bot.name |
||||
} else { |
||||
message(res) |
||||
} |
||||
}) |
||||
|
||||
return {botName} |
||||
} |
||||
}) |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -1,24 +0,0 @@ |
||||
<template> |
||||
<h1>主页</h1> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import {defineComponent, onMounted} from "vue"; |
||||
import {useStore} from "vuex"; |
||||
|
||||
export default defineComponent({ |
||||
name: "Home", |
||||
setup() { |
||||
|
||||
const store = useStore() |
||||
|
||||
onMounted(() => { |
||||
store.commit('updateRoute', '/home') |
||||
}) |
||||
} |
||||
}) |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,82 @@ |
||||
<template> |
||||
<el-row type="flex" justify="center"> |
||||
<el-col :span="12"> |
||||
<el-input v-model="newBotToken"> |
||||
<template v-slot:prepend>机器人Api Token</template> |
||||
</el-input> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row type="flex" justify="center" class="mt-1"> |
||||
<el-col :span="2"> |
||||
<el-button type="primary" class="btn-block" @click="openBot" v-loading.fullscreen.lock="fullscreenLoading"> |
||||
测试token |
||||
</el-button> |
||||
</el-col> |
||||
</el-row> |
||||
<template v-if="botName!==''"> |
||||
<el-row type="flex" justify="center" class="mt-1"> |
||||
<el-col :span="12"> |
||||
<el-input v-model="botName" :disabled="true"> |
||||
<template v-slot:prepend>即将绑定的机器人</template> |
||||
</el-input> |
||||
</el-col> |
||||
</el-row> |
||||
<el-row type="flex" justify="center" class="mt-1"> |
||||
<el-col :span="2"> |
||||
<el-button type="primary" class="btn-block" @click="bindBot">绑定</el-button> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import {defineComponent, ref} from "vue"; |
||||
import {updateRoute} from "../router"; |
||||
import {bindTelegramBot, message, testTelegramBot} from "../request"; |
||||
import {useStore} from "vuex"; |
||||
import {useRouter} from "vue-router"; |
||||
|
||||
export default defineComponent({ |
||||
name: "TelegramBot", |
||||
setup() { |
||||
updateRoute() |
||||
|
||||
const fullscreenLoading = ref<boolean>(false) |
||||
|
||||
const newBotToken = ref<string>('') |
||||
|
||||
const botName = ref<string>('') |
||||
|
||||
const openBot = () => { |
||||
fullscreenLoading.value = true |
||||
testTelegramBot(newBotToken.value) |
||||
.then(res => res.json()).then(res => { |
||||
fullscreenLoading.value = false |
||||
if (res.ok) { |
||||
botName.value = res.result.username |
||||
} else { |
||||
message({result: 'FAIL', message: '无法获取机器人信息,请确认token输入正确'}) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
const store = useStore() |
||||
const router = useRouter() |
||||
|
||||
const bindBot = () => bindTelegramBot(store.state.user.email, newBotToken.value) |
||||
.then(res => res.json()) |
||||
.then(res => { |
||||
message(res) |
||||
if (res.result === 'OK') { |
||||
router.replace('/config') |
||||
} |
||||
}) |
||||
|
||||
return {newBotToken, openBot, botName, fullscreenLoading, bindBot} |
||||
} |
||||
}) |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -1,49 +0,0 @@ |
||||
<template> |
||||
<h1>{{num}}*2={{double}}</h1> |
||||
<h1>{{num2.count}}*3={{triple}}</h1> |
||||
<button @click="add">累加</button> |
||||
|
||||
<button @click="insert">插入</button> |
||||
</template> |
||||
|
||||
<script lang="ts"> |
||||
import {computed, defineComponent, reactive, ref} from 'vue' |
||||
|
||||
|
||||
export default defineComponent({ |
||||
name: "Vue3", |
||||
|
||||
setup:()=>{ |
||||
const num=ref<number>(1) |
||||
|
||||
const isAdd=ref<boolean>(false) |
||||
|
||||
const num2=reactive<{count:number}>({ |
||||
count:1 |
||||
}) |
||||
|
||||
function add() { |
||||
num.value++ |
||||
num2.count++ |
||||
} |
||||
|
||||
function insert(){ |
||||
isAdd.value=true |
||||
} |
||||
|
||||
function cancel(){ |
||||
isAdd.value=false |
||||
} |
||||
|
||||
const double=computed<number>(()=>num.value*2) |
||||
|
||||
const triple=computed<number>(()=>num2.count*3) |
||||
|
||||
return {num,add,double,num2,triple,isAdd,insert,cancel} |
||||
} |
||||
}) |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -1,3 +1,5 @@ |
||||
export const sendCodeApi = '/api/change/email/code' |
||||
export const changeEmailApi = '/api/change/email' |
||||
export const changePwdApi = '/api/change/pwd' |
||||
export const changePwdApi = '/api/change/pwd' |
||||
export const telegramBotApi = '/api/telegram/bot' |
||||
export const testTelegramBotApi = (token: string) => `https://api.telegram.org/bot${token}/getMe` |
Loading…
Reference in new issue