Files
rustdesk-api-web/src/views/my/info.vue
T

88 lines
2.8 KiB
Vue
Raw Normal View History

2024-09-19 10:46:07 +08:00
<template>
<div>
2024-09-25 22:24:16 +08:00
<el-card :title="T('Userinfo')">
2024-09-19 10:46:07 +08:00
<el-form class="info-form" ref="form" label-width="120px" label-suffix="">
2024-09-25 22:24:16 +08:00
<el-form-item :label="T('Username')">
2024-09-19 10:46:07 +08:00
<div>{{ userStore.username }}</div>
</el-form-item>
2024-09-25 22:24:16 +08:00
<el-form-item :label="T('Password')" prop="password">
<el-button type="danger" @click="showChangePwd">{{ T('ChangePassword') }}</el-button>
2024-09-19 10:46:07 +08:00
</el-form-item>
<el-form-item label="OIDC">
<el-table :data="oidcData" border fit>
2024-09-25 22:24:16 +08:00
<el-table-column :label="T('Platform')" prop="third_type" align="center"></el-table-column>
<el-table-column :label="T('Status')" prop="status" align="center">
2024-09-19 10:46:07 +08:00
<template #default="{ row }">
2024-09-25 22:24:16 +08:00
<el-tag v-if="row.status === 1" type="success">{{ T('HasBind') }}</el-tag>
<el-tag v-else type="danger">{{ T('NoBind') }}</el-tag>
2024-09-19 10:46:07 +08:00
</template>
</el-table-column>
2024-09-25 22:24:16 +08:00
<el-table-column :label="T('Actions')" align="center" width="200">
2024-09-19 10:46:07 +08:00
<template #default="{ row }">
2024-09-25 22:24:16 +08:00
<el-button v-if="row.status === 1" type="danger" size="small" @click="toUnBind(row)">{{ T('UnBind') }}</el-button>
<el-button v-else type="success" size="small" @click="toBind(row)">{{ T('ToBind') }}</el-button>
2024-09-19 10:46:07 +08:00
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
</el-card>
<changePwdDialog v-model:visible="changePwdVisible"></changePwdDialog>
</div>
</template>
<script setup>
import changePwdDialog from '@/components/changePwdDialog.vue'
import { ref } from 'vue'
import { useUserStore } from '@/store/user'
import { bind, unbind } from '@/api/oauth'
import { myOauth } from '@/api/user'
import { ElMessageBox } from 'element-plus'
2024-09-25 22:24:16 +08:00
import { T } from '@/utils/i18n'
2024-09-19 10:46:07 +08:00
const userStore = useUserStore()
const changePwdVisible = ref(false)
const showChangePwd = () => {
changePwdVisible.value = true
}
const oidcData = ref([])
const getMyOauth = async () => {
const res = await myOauth().catch(_ => false)
if (res) {
oidcData.value = res.data
}
}
getMyOauth()
const toBind = async (row) => {
const res = await bind({ op: row.third_type }).catch(_ => false)
if (res) {
const { code, url } = res.data
window.open(url)
}
}
const toUnBind = async (row) => {
2024-09-25 22:24:16 +08:00
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('UnBind') }), {
confirmButtonText: T('Confirm'),
cancelButtonText: T('Cancel'),
2024-09-19 10:46:07 +08:00
type: 'warning',
}).catch(_ => false)
if (!cf) {
return false
}
const res = await unbind({ op: row.third_type }).catch(_ => false)
if (res) {
getMyOauth()
}
}
</script>
<style scoped lang="scss">
.info-form {
width: 600px;
margin: 0 auto;
}
</style>