Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp
This commit is contained in:
@@ -66,7 +66,7 @@ namespace Yi.Framework.Rbac.Application.Services.Authentication
|
|||||||
{
|
{
|
||||||
(var openId, var name) = await GetOpenIdAndNameAsync(scheme);
|
(var openId, var name) = await GetOpenIdAndNameAsync(scheme);
|
||||||
var userId = CurrentUser.Id;
|
var userId = CurrentUser.Id;
|
||||||
var authEntityAny = await _repository.AnyAsync(x => x.OpenId == openId && x.AuthType == scheme);
|
var authEntityAny = await _repository.IsAnyAsync(x => x.OpenId == openId && x.AuthType == scheme);
|
||||||
if (authEntityAny)
|
if (authEntityAny)
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException("绑定失败,该第三方账号已被注册");
|
throw new UserFriendlyException("绑定失败,该第三方账号已被注册");
|
||||||
|
|||||||
@@ -115,3 +115,16 @@ export function getOtherAuthInfo(params) {
|
|||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除第三方授权
|
||||||
|
* @param {*} ids
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function delOtherAuth(ids) {
|
||||||
|
return request({
|
||||||
|
url: `/auth`,
|
||||||
|
method: "delete",
|
||||||
|
params: { id: ids },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ const code = ref(route.query.code);
|
|||||||
const type = ref(route.query.state);
|
const type = ref(route.query.state);
|
||||||
|
|
||||||
const message = ref("");
|
const message = ref("");
|
||||||
|
const scheme = ref("");
|
||||||
|
const authData = ref("");
|
||||||
watch(
|
watch(
|
||||||
() => code.value,
|
() => code.value,
|
||||||
async (val) => {
|
async (val) => {
|
||||||
@@ -20,15 +22,28 @@ watch(
|
|||||||
// 使用正则表达式提取路由参数
|
// 使用正则表达式提取路由参数
|
||||||
const regex = /\/auth\/([\w-]+)[?]?/;
|
const regex = /\/auth\/([\w-]+)[?]?/;
|
||||||
const result = regex.exec(route.fullPath);
|
const result = regex.exec(route.fullPath);
|
||||||
const authParam = result != null ? result[1].toUpperCase() : null;
|
const authParam = result != null ? result[1] : null;
|
||||||
console.log(type.value, "类型");
|
switch (authParam) {
|
||||||
if (type.value === "0") {
|
case "gitee":
|
||||||
const res = await authOtherLogin({ code: val }, authParam);
|
scheme.value = "Gitee";
|
||||||
} else if (type.value === "1") {
|
break;
|
||||||
const res = await authOtherBind({ code: val }, authParam);
|
case "qq":
|
||||||
|
scheme.value = "QQ";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (type.value === "0") {
|
||||||
|
const { data } = await authOtherLogin({ code: val }, scheme.value);
|
||||||
|
authData.value = data;
|
||||||
|
} else if (type.value === "1") {
|
||||||
|
const { data } = await authOtherBind({ code: val }, scheme.value);
|
||||||
|
authData.value = data;
|
||||||
|
}
|
||||||
|
window.opener.postMessage({
|
||||||
|
authData: JSON.stringify(authData.value),
|
||||||
|
type: scheme.value,
|
||||||
|
});
|
||||||
|
console.log(authData.value, "我是打开的窗口页");
|
||||||
message.value = "授权成功";
|
message.value = "授权成功";
|
||||||
// window.close();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ const isPointFinished = ref(false);
|
|||||||
const friendList = ref([]);
|
const friendList = ref([]);
|
||||||
const isFriendFinished = ref(false);
|
const isFriendFinished = ref(false);
|
||||||
const themeList = ref([]);
|
const themeList = ref([]);
|
||||||
const isThemeFinished = ref([]);
|
const isThemeFinished = ref(false);
|
||||||
const allDiscussList = ref([]);
|
const allDiscussList = ref([]);
|
||||||
const isAllDiscussFinished = ref(false);
|
const isAllDiscussFinished = ref(false);
|
||||||
const userAnalyseInfo = ref({});
|
const userAnalyseInfo = ref({});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="friend-box">
|
<div class="friend-box">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<div class="icon"><img :src="userImageSrc" alt="" /></div>
|
<UserInfoCard :userInfo="friendData" :iconUrl="userImageSrc" />
|
||||||
</div>
|
</div>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
<script setup name="RecommendFriend">
|
<script setup name="RecommendFriend">
|
||||||
import { defineProps, computed } from "vue";
|
import { defineProps, computed } from "vue";
|
||||||
|
import UserInfoCard from "@/components/UserInfoCard/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
friendData: {
|
friendData: {
|
||||||
|
|||||||
@@ -21,14 +21,15 @@
|
|||||||
:table-data="tableData"
|
:table-data="tableData"
|
||||||
:options="tableOptions"
|
:options="tableOptions"
|
||||||
:columns="tableColumn"
|
:columns="tableColumn"
|
||||||
|
@command="handleAction"
|
||||||
></yi-table>
|
></yi-table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted } from "vue";
|
import { ref, computed, onMounted } from "vue";
|
||||||
import { getOtherAuthInfo } from "@/apis/auth.js";
|
import { getOtherAuthInfo, delOtherAuth } from "@/apis/auth.js";
|
||||||
import YiTable from "@/components/yi-table/index.vue";
|
import YiTable from "@/components/yi-table/index.vue";
|
||||||
import useUserStore from "@/stores/user";
|
import useUserStore from "@/stores/user";
|
||||||
|
|
||||||
@@ -48,29 +49,23 @@ const tableColumn = [
|
|||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: "timeInterval",
|
prop: "authType",
|
||||||
label: "绑定账号信息",
|
label: "绑定账号信息",
|
||||||
minWidth: "110",
|
minWidth: "110",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: "timeInterval",
|
prop: "name",
|
||||||
label: "详情",
|
label: "详情",
|
||||||
minWidth: "110",
|
minWidth: "110",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: "timeInterval",
|
prop: "creationTime",
|
||||||
label: "绑定时间",
|
label: "绑定时间",
|
||||||
minWidth: "110",
|
minWidth: "110",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
prop: "timeInterval",
|
|
||||||
label: "状态",
|
|
||||||
minWidth: "110",
|
|
||||||
align: "center",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "操作",
|
label: "操作",
|
||||||
align: "center",
|
align: "center",
|
||||||
@@ -78,18 +73,46 @@ const tableColumn = [
|
|||||||
fixed: "right",
|
fixed: "right",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
name: "绑定",
|
name: "解除绑定",
|
||||||
type: "text",
|
type: "danger",
|
||||||
command: "edit",
|
command: "delete",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
onMounted(async () => {
|
const tableData = ref([]);
|
||||||
|
const checkList = async () => {
|
||||||
const { data } = await getOtherAuthInfo({ userId: userInfo.id });
|
const { data } = await getOtherAuthInfo({ userId: userInfo.id });
|
||||||
|
tableData.value = data;
|
||||||
|
};
|
||||||
|
onMounted(() => {
|
||||||
|
checkList();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 操作事件
|
||||||
|
const handleAction = (command, row) => {
|
||||||
|
switch (command) {
|
||||||
|
case "delete":
|
||||||
|
ElMessageBox.confirm(`确定解除${row.authType}的绑定吗?`, "警告", {
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning",
|
||||||
|
}).then(async () => {
|
||||||
|
await delOtherAuth(row.id);
|
||||||
|
await checkList();
|
||||||
|
ElMessage({
|
||||||
|
message: `已解除${row.authType}绑定!`,
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleQQLogin = () => {
|
const handleQQLogin = () => {
|
||||||
window.open(
|
window.open(
|
||||||
"https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=102087446&redirect_uri=https://ccnetcore.com/auth/qq&state=1&scope=get_user_info",
|
"https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=102087446&redirect_uri=https://ccnetcore.com/auth/qq&state=1&scope=get_user_info",
|
||||||
@@ -102,29 +125,40 @@ const handleGiteeLogin = () => {
|
|||||||
window.open(
|
window.open(
|
||||||
"https://gitee.com/oauth/authorize?client_id=949f3519969adc5cfe82c209b71300e8e0868e8536f3d7f59195c8f1e5b72502&redirect_uri=https%3A%2F%2Fccnetcore.com%2Fauth%2Fgitee&state=1&response_type=code",
|
"https://gitee.com/oauth/authorize?client_id=949f3519969adc5cfe82c209b71300e8e0868e8536f3d7f59195c8f1e5b72502&redirect_uri=https%3A%2F%2Fccnetcore.com%2Fauth%2Fgitee&state=1&response_type=code",
|
||||||
undefined,
|
undefined,
|
||||||
"width=500,height=500,left=50,top=50"
|
"width=500,height=500,left=50,top=50",
|
||||||
|
"_black"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.addEventListener("message", async (e) => {
|
||||||
|
console.log(e, "我是账号设置页");
|
||||||
|
const { authData, type } = e.data;
|
||||||
|
if (e.data) {
|
||||||
|
console.log(authData, type, "2333");
|
||||||
|
await checkList();
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.account-box {
|
.account-box {
|
||||||
.title {
|
.title {
|
||||||
font-size: 20px;
|
font-size: 1.25rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.image-list {
|
.image-list {
|
||||||
margin: 10px;
|
margin: 0.625rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
.item {
|
.item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-right: 20px;
|
margin-right: 1.25rem;
|
||||||
.image {
|
.image {
|
||||||
width: 30px;
|
width: 1.875rem;
|
||||||
height: 30px;
|
height: 1.875rem;
|
||||||
img {
|
img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -133,10 +167,10 @@ const handleGiteeLogin = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.table {
|
.table {
|
||||||
margin-top: 10px;
|
margin-top: 0.625rem;
|
||||||
:deep(.yi-table) {
|
:deep(.yi-table) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 200px;
|
height: 12.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user