2024-09-19 10:46:07 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
2024-11-11 22:26:55 +08:00
|
|
|
|
<el-card :title="T('Userinfo')" shadow="hover">
|
2024-12-25 19:59:41 +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-11-02 04:02:38 +08:00
|
|
|
|
<el-form-item :label="T('Email')">
|
|
|
|
|
|
<div>{{ userStore.email }}</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-11-02 04:02:38 +08:00
|
|
|
|
<el-table-column :label="T('IdP')" prop="op" align="center"></el-table-column>
|
2024-09-25 22:24:16 +08:00
|
|
|
|
<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>
|
2024-11-11 22:26:55 +08:00
|
|
|
|
<el-card shadow="hover" style="margin-top: 20px">
|
2024-12-25 19:21:14 +08:00
|
|
|
|
<div v-html="html"></div>
|
2024-11-11 22:26:55 +08:00
|
|
|
|
</el-card>
|
2024-09-19 10:46:07 +08:00
|
|
|
|
<changePwdDialog v-model:visible="changePwdVisible"></changePwdDialog>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import changePwdDialog from '@/components/changePwdDialog.vue'
|
2024-12-25 19:59:41 +08:00
|
|
|
|
import { computed, ref } from 'vue'
|
2024-09-19 10:46:07 +08:00
|
|
|
|
import { useUserStore } from '@/store/user'
|
2024-11-11 22:26:55 +08:00
|
|
|
|
import { useAppStore } from '@/store/app'
|
2024-09-19 10:46:07 +08:00
|
|
|
|
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-12-25 19:21:14 +08:00
|
|
|
|
import { marked } from 'marked'
|
2024-09-19 10:46:07 +08:00
|
|
|
|
|
2024-11-11 22:26:55 +08:00
|
|
|
|
const appStore = useAppStore()
|
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) => {
|
2024-12-25 19:59:41 +08:00
|
|
|
|
const res = await bind({ op: row.op }).catch(_ => false)
|
2024-09-19 10:46:07 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
2024-11-02 04:02:38 +08:00
|
|
|
|
const res = await unbind({ op: row.op }).catch(_ => false)
|
2024-09-19 10:46:07 +08:00
|
|
|
|
if (res) {
|
|
|
|
|
|
getMyOauth()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-12-25 19:21:14 +08:00
|
|
|
|
|
2025-05-25 17:11:57 +08:00
|
|
|
|
const html = computed(_ => marked(appStore.setting.hello||''))
|
2024-12-25 19:21:14 +08:00
|
|
|
|
|
2024-09-19 10:46:07 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.info-form {
|
|
|
|
|
|
width: 600px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|