revert 636e60157e379095e110851e5b2150f44a6e6fc4

revert feat:oauth代码提交
This commit is contained in:
罗澜大帅哥 2025-06-30 22:28:37 +08:00
parent 636e60157e
commit 9929352ae4
8 changed files with 16 additions and 93 deletions

1
.gitignore vendored
View File

@ -10,7 +10,6 @@ lerna-debug.log*
node_modules node_modules
dist dist
dist-ssr dist-ssr
secret.js
*.local *.local
.vscode .vscode
# Editor directories and files # Editor directories and files

View File

@ -1,38 +1,22 @@
// 引入私钥
import { DO_MAIN, CLIENT_ID } from "@/utils/secret";
// 样式引入 // 样式引入
import "@/assets/styles/reset.scss"; import '@/assets/styles/reset.scss'
import "@/assets/styles/variable.scss"; import '@/assets/styles/variable.scss';
import "@/assets/styles/common.scss"; import '@/assets/styles/common.scss';
// 引入仓库 // 引入仓库
import pinia from "@/store"; import pinia from '@/store';
//引入路由 //引入路由
import router from "@/router"; import router from "@/router";
// 引入UI组件库相关 // 引入UI组件库相关
import naive from "naive-ui"; import naive from 'naive-ui';
import "vfonts/Lato.css"; // 通用字体 import 'vfonts/Lato.css'// 通用字体
import "vfonts/FiraCode.css"; // 等宽字体 import 'vfonts/FiraCode.css'// 等宽字体
// 登录授权相关 // 登录授权相关
import { createAuth0 } from "@auth0/auth0-vue";
import { createApp } from "vue"; import { createApp } from 'vue'
import App from "./App.vue"; import App from './App.vue';
const app = createApp(App); const app = createApp(App);
app.use(
createAuth0({
domain: DO_MAIN,
clientId: CLIENT_ID,
authorizationParams: {
redirect_uri: `${window.location.origin}/callback`,
audience: "https://dev-f8lrenkd107vqnti.us.auth0.com/api/v2",
scope: 'read:data', // 请求用户基本信息
}
})
);
app.use(pinia); app.use(pinia);
app.use(router); app.use(router);
app.use(naive); app.use(naive);
app.mount("#app"); app.mount('#app')

View File

@ -1,7 +1,5 @@
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Login from "@/views/login/index.vue"; //登录组件 import Login from "@/views/login/index.vue"; //登录组件
import Layout from '@/views/layout/index.vue';
import CallBack from '@/views/login/OauthCallBack.vue';
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
@ -9,16 +7,6 @@ const routes: Array<RouteRecordRaw> = [
name: "Login", name: "Login",
component: Login, component: Login,
}, },
{
path:'/callback',
name:'CallBack',
component:CallBack
},
{
path: "/layout",
name: "Layout",
component: Layout,
},
]; ];
const router = createRouter({ const router = createRouter({

View File

@ -1,3 +0,0 @@
export const DO_MAIN = 'dev-f8lrenkd107vqnti.us.auth0.com';
export const CLIENT_ID = 'VasF4bqvT7iC5Va2ibBT39hu71gdtA9K';
export const CLINET_KEY = 'hIdwcnNLmc6fPIBxHKqP16LYo3q7hCtB_Cg2R3enylHH28AHM1SEAkOky5zFUTI5';

View File

@ -1,9 +0,0 @@
<template>
<div>首页</div>
</template>
<script setup>
</script>
<style lang="scss" scoped></style>

View File

@ -1,28 +0,0 @@
<template>
<div>这是callback页面 {{ token }}</div>
</template>
<script setup>
import { useAuth0 } from '@auth0/auth0-vue';
import { useMessage } from 'naive-ui';
const { getAccessTokenSilently } = useAuth0();
const token = ref('');
const router = useRouter();
const message = useMessage();
const oSomethingWithToken = async () => {
try {
token.value = await getAccessTokenSilently();
message.success('登录成功!');
router.push('/layout');
}catch(error){
router.push('/');
message.error('错误!');
}
}
onMounted(()=>{
oSomethingWithToken();
})
</script>
<style lang="scss" scoped></style>

View File

@ -1,19 +1,11 @@
<template> <template>
<n-button type="primary" @click="login">登录</n-button>
<n-button @click="handleLogin">Log out</n-button>
</template> </template>
<script setup> <script setup>
import { useAuth0 } from '@auth0/auth0-vue';
const { loginWithRedirect,logout } = useAuth0();
const login = () => {
loginWithRedirect();
}
const handleLogin = () => {
logout({ logoutParams: { returnTo: window.location.origin } });
}
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped>
</style>

View File

@ -11,7 +11,7 @@ export default defineConfig({
imports: ["vue", "vue-router"], imports: ["vue", "vue-router"],
defaultExportByFilename: true, defaultExportByFilename: true,
dirs: ["./src/api"], dirs: ["./src/api"],
}) }),
], ],
resolve: { resolve: {
alias: { alias: {