改用mysql
This commit is contained in:
@@ -7,6 +7,11 @@ const router = createRouter({
|
||||
name: 'Login',
|
||||
component: () => import('@/views/Login.vue'),
|
||||
},
|
||||
{
|
||||
path: '/internal-login',
|
||||
name: 'InternalLogin',
|
||||
component: () => import('@/views/InternalLogin.vue'),
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'Register',
|
||||
|
||||
@@ -8,6 +8,11 @@ const router = createRouter({
|
||||
name: 'Login',
|
||||
component: () => import('@/views/Login.vue'),
|
||||
},
|
||||
{
|
||||
path: '/internal-login',
|
||||
name: 'InternalLogin',
|
||||
component: () => import('@/views/InternalLogin.vue'),
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'Register',
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import apiClient from '@/api/client'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const form = ref({
|
||||
username_or_email: '',
|
||||
password: '',
|
||||
})
|
||||
const loading = ref(false)
|
||||
|
||||
async function handleLogin() {
|
||||
loading.value = true
|
||||
try {
|
||||
const { data } = await apiClient.post('/auth/internal-login', form.value)
|
||||
userStore.setUser(data)
|
||||
ElMessage.success('内部登录成功!')
|
||||
router.push('/')
|
||||
} catch {
|
||||
// 错误由拦截器处理
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="internal-login-page">
|
||||
<el-card class="login-card">
|
||||
<template #header>
|
||||
<div style="text-align: center">
|
||||
<h2 style="margin: 0">🔐 内部登录</h2>
|
||||
<p style="color: #999; font-size: 13px; margin: 8px 0 0">仅限公司内部员工使用</p>
|
||||
</div>
|
||||
</template>
|
||||
<el-form :model="form" label-position="top" @submit.prevent="handleLogin">
|
||||
<el-form-item label="用户名或邮箱">
|
||||
<el-input v-model="form.username_or_email" placeholder="请输入用户名或邮箱" size="large" />
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input v-model="form.password" type="password" placeholder="请输入密码" show-password size="large" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" style="width: 100%" native-type="submit" size="large">
|
||||
登录
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: center; margin-top: 10px">
|
||||
<router-link to="/login" style="color: #409eff; font-size: 14px">客户登录 →</router-link>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.internal-login-page {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
}
|
||||
.login-card {
|
||||
width: 420px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,192 @@
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import apiClient from '@/api/client';
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const form = ref({
|
||||
username_or_email: '',
|
||||
password: '',
|
||||
});
|
||||
const loading = ref(false);
|
||||
async function handleLogin() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await apiClient.post('/auth/internal-login', form.value);
|
||||
userStore.setUser(data);
|
||||
ElMessage.success('内部登录成功!');
|
||||
router.push('/');
|
||||
}
|
||||
catch {
|
||||
// 错误由拦截器处理
|
||||
}
|
||||
finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
|
||||
const __VLS_ctx = {};
|
||||
let __VLS_components;
|
||||
let __VLS_directives;
|
||||
// CSS variable injection
|
||||
// CSS variable injection end
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ class: "internal-login-page" },
|
||||
});
|
||||
const __VLS_0 = {}.ElCard;
|
||||
/** @type {[typeof __VLS_components.ElCard, typeof __VLS_components.elCard, typeof __VLS_components.ElCard, typeof __VLS_components.elCard, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({
|
||||
...{ class: "login-card" },
|
||||
}));
|
||||
const __VLS_2 = __VLS_1({
|
||||
...{ class: "login-card" },
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_1));
|
||||
__VLS_3.slots.default;
|
||||
{
|
||||
const { header: __VLS_thisSlot } = __VLS_3.slots;
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ style: {} },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.h2, __VLS_intrinsicElements.h2)({
|
||||
...{ style: {} },
|
||||
});
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.p, __VLS_intrinsicElements.p)({
|
||||
...{ style: {} },
|
||||
});
|
||||
}
|
||||
const __VLS_4 = {}.ElForm;
|
||||
/** @type {[typeof __VLS_components.ElForm, typeof __VLS_components.elForm, typeof __VLS_components.ElForm, typeof __VLS_components.elForm, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_5 = __VLS_asFunctionalComponent(__VLS_4, new __VLS_4({
|
||||
...{ 'onSubmit': {} },
|
||||
model: (__VLS_ctx.form),
|
||||
labelPosition: "top",
|
||||
}));
|
||||
const __VLS_6 = __VLS_5({
|
||||
...{ 'onSubmit': {} },
|
||||
model: (__VLS_ctx.form),
|
||||
labelPosition: "top",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_5));
|
||||
let __VLS_8;
|
||||
let __VLS_9;
|
||||
let __VLS_10;
|
||||
const __VLS_11 = {
|
||||
onSubmit: (__VLS_ctx.handleLogin)
|
||||
};
|
||||
__VLS_7.slots.default;
|
||||
const __VLS_12 = {}.ElFormItem;
|
||||
/** @type {[typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({
|
||||
label: "用户名或邮箱",
|
||||
}));
|
||||
const __VLS_14 = __VLS_13({
|
||||
label: "用户名或邮箱",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_13));
|
||||
__VLS_15.slots.default;
|
||||
const __VLS_16 = {}.ElInput;
|
||||
/** @type {[typeof __VLS_components.ElInput, typeof __VLS_components.elInput, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_17 = __VLS_asFunctionalComponent(__VLS_16, new __VLS_16({
|
||||
modelValue: (__VLS_ctx.form.username_or_email),
|
||||
placeholder: "请输入用户名或邮箱",
|
||||
size: "large",
|
||||
}));
|
||||
const __VLS_18 = __VLS_17({
|
||||
modelValue: (__VLS_ctx.form.username_or_email),
|
||||
placeholder: "请输入用户名或邮箱",
|
||||
size: "large",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_17));
|
||||
var __VLS_15;
|
||||
const __VLS_20 = {}.ElFormItem;
|
||||
/** @type {[typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_21 = __VLS_asFunctionalComponent(__VLS_20, new __VLS_20({
|
||||
label: "密码",
|
||||
}));
|
||||
const __VLS_22 = __VLS_21({
|
||||
label: "密码",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_21));
|
||||
__VLS_23.slots.default;
|
||||
const __VLS_24 = {}.ElInput;
|
||||
/** @type {[typeof __VLS_components.ElInput, typeof __VLS_components.elInput, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({
|
||||
modelValue: (__VLS_ctx.form.password),
|
||||
type: "password",
|
||||
placeholder: "请输入密码",
|
||||
showPassword: true,
|
||||
size: "large",
|
||||
}));
|
||||
const __VLS_26 = __VLS_25({
|
||||
modelValue: (__VLS_ctx.form.password),
|
||||
type: "password",
|
||||
placeholder: "请输入密码",
|
||||
showPassword: true,
|
||||
size: "large",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_25));
|
||||
var __VLS_23;
|
||||
const __VLS_28 = {}.ElFormItem;
|
||||
/** @type {[typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, typeof __VLS_components.ElFormItem, typeof __VLS_components.elFormItem, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_29 = __VLS_asFunctionalComponent(__VLS_28, new __VLS_28({}));
|
||||
const __VLS_30 = __VLS_29({}, ...__VLS_functionalComponentArgsRest(__VLS_29));
|
||||
__VLS_31.slots.default;
|
||||
const __VLS_32 = {}.ElButton;
|
||||
/** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_33 = __VLS_asFunctionalComponent(__VLS_32, new __VLS_32({
|
||||
type: "primary",
|
||||
loading: (__VLS_ctx.loading),
|
||||
...{ style: {} },
|
||||
nativeType: "submit",
|
||||
size: "large",
|
||||
}));
|
||||
const __VLS_34 = __VLS_33({
|
||||
type: "primary",
|
||||
loading: (__VLS_ctx.loading),
|
||||
...{ style: {} },
|
||||
nativeType: "submit",
|
||||
size: "large",
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_33));
|
||||
__VLS_35.slots.default;
|
||||
var __VLS_35;
|
||||
var __VLS_31;
|
||||
var __VLS_7;
|
||||
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
|
||||
...{ style: {} },
|
||||
});
|
||||
const __VLS_36 = {}.RouterLink;
|
||||
/** @type {[typeof __VLS_components.RouterLink, typeof __VLS_components.routerLink, typeof __VLS_components.RouterLink, typeof __VLS_components.routerLink, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_37 = __VLS_asFunctionalComponent(__VLS_36, new __VLS_36({
|
||||
to: "/login",
|
||||
...{ style: {} },
|
||||
}));
|
||||
const __VLS_38 = __VLS_37({
|
||||
to: "/login",
|
||||
...{ style: {} },
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_37));
|
||||
__VLS_39.slots.default;
|
||||
var __VLS_39;
|
||||
var __VLS_3;
|
||||
/** @type {__VLS_StyleScopedClasses['internal-login-page']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['login-card']} */ ;
|
||||
var __VLS_dollars;
|
||||
const __VLS_self = (await import('vue')).defineComponent({
|
||||
setup() {
|
||||
return {
|
||||
form: form,
|
||||
loading: loading,
|
||||
handleLogin: handleLogin,
|
||||
};
|
||||
},
|
||||
});
|
||||
export default (await import('vue')).defineComponent({
|
||||
setup() {
|
||||
return {};
|
||||
},
|
||||
});
|
||||
; /* PartiallyEnd: #4569/main.vue */
|
||||
@@ -46,8 +46,9 @@ async function handleLogin() {
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align: center">
|
||||
<div style="text-align: center; display: flex; flex-direction: column; gap: 8px">
|
||||
<router-link to="/register">没有账号?立即注册</router-link>
|
||||
<router-link to="/internal-login" style="color: #764ba2; font-size: 13px">🔐 内部员工登录</router-link>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
@@ -155,6 +155,19 @@ const __VLS_38 = __VLS_37({
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_37));
|
||||
__VLS_39.slots.default;
|
||||
var __VLS_39;
|
||||
const __VLS_40 = {}.RouterLink;
|
||||
/** @type {[typeof __VLS_components.RouterLink, typeof __VLS_components.routerLink, typeof __VLS_components.RouterLink, typeof __VLS_components.routerLink, ]} */ ;
|
||||
// @ts-ignore
|
||||
const __VLS_41 = __VLS_asFunctionalComponent(__VLS_40, new __VLS_40({
|
||||
to: "/internal-login",
|
||||
...{ style: {} },
|
||||
}));
|
||||
const __VLS_42 = __VLS_41({
|
||||
to: "/internal-login",
|
||||
...{ style: {} },
|
||||
}, ...__VLS_functionalComponentArgsRest(__VLS_41));
|
||||
__VLS_43.slots.default;
|
||||
var __VLS_43;
|
||||
var __VLS_3;
|
||||
/** @type {__VLS_StyleScopedClasses['login-page']} */ ;
|
||||
/** @type {__VLS_StyleScopedClasses['login-card']} */ ;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"root":["./src/env.d.ts","./src/main.ts","./src/api/client.ts","./src/router/index.ts","./src/stores/user.ts","./src/utils/clipboard.ts","./src/app.vue","./src/layouts/defaultlayout.vue","./src/views/dashboard.vue","./src/views/kbdetail.vue","./src/views/knowledgebases.vue","./src/views/login.vue","./src/views/register.vue","./src/views/settings.vue"],"version":"5.9.3"}
|
||||
{"root":["./src/env.d.ts","./src/main.ts","./src/api/client.ts","./src/router/index.ts","./src/stores/user.ts","./src/utils/clipboard.ts","./src/app.vue","./src/layouts/defaultlayout.vue","./src/views/dashboard.vue","./src/views/internallogin.vue","./src/views/kbdetail.vue","./src/views/knowledgebases.vue","./src/views/login.vue","./src/views/register.vue","./src/views/settings.vue"],"version":"5.9.3"}
|
||||
Reference in New Issue
Block a user