登录页面以及字体包

main
严飞永 1 week ago
parent 5c829208d6
commit 00d5371dac

@ -0,0 +1,12 @@
@font-face {
font-family: "Alibaba PuHuiTi";
src: url("./fonts/Alibaba-PuHuiTi-Bold.ttf");
}
@font-face {
font-family: "Alimama ShuHeiTi";
src: url("./fonts/AlimamaShuHeiTi-Bold.ttf");
}
@font-face {
font-family: "Alibaba PuHuiTiR";
src: url("./fonts/Alibaba-PuHuiTi-Regular.ttf");
}

@ -5,6 +5,7 @@
@import './sidebar.scss'; @import './sidebar.scss';
@import './btn.scss'; @import './btn.scss';
@import './ruoyi.scss'; @import './ruoyi.scss';
@import "./font.css";
body { body {
height: 100%; height: 100%;

@ -1,125 +1,127 @@
import auth from '@/plugins/auth' import auth from "@/plugins/auth";
import router, { constantRoutes, dynamicRoutes } from '@/router' import router, { constantRoutes, dynamicRoutes } from "@/router";
import { getRouters } from '@/api/menu' import { getRouters } from "@/api/menu";
import Layout from '@/layout/index' import Layout from "@/layout/index";
import ParentView from '@/components/ParentView' import ParentView from "@/components/ParentView";
import InnerLink from '@/layout/components/InnerLink' import InnerLink from "@/layout/components/InnerLink";
// 匹配views里面所有的.vue文件 // 匹配views里面所有的.vue文件
const modules = import.meta.glob('./../../views/**/*.vue') const modules = import.meta.glob("./../../views/**/*.vue");
const usePermissionStore = defineStore( const usePermissionStore = defineStore("permission", {
'permission',
{
state: () => ({ state: () => ({
routes: [], routes: [],
addRoutes: [], addRoutes: [],
defaultRoutes: [], defaultRoutes: [],
topbarRouters: [], topbarRouters: [],
sidebarRouters: [] sidebarRouters: [],
}), }),
actions: { actions: {
setRoutes(routes) { setRoutes(routes) {
this.addRoutes = routes this.addRoutes = routes;
this.routes = constantRoutes.concat(routes) this.routes = constantRoutes.concat(routes);
}, },
setDefaultRoutes(routes) { setDefaultRoutes(routes) {
this.defaultRoutes = constantRoutes.concat(routes) this.defaultRoutes = constantRoutes.concat(routes);
}, },
setTopbarRoutes(routes) { setTopbarRoutes(routes) {
this.topbarRouters = routes this.topbarRouters = routes;
}, },
setSidebarRouters(routes) { setSidebarRouters(routes) {
this.sidebarRouters = routes this.sidebarRouters = routes;
}, },
generateRoutes(roles) { generateRoutes(roles) {
return new Promise(resolve => { return new Promise((resolve) => {
// 向后端请求路由数据 // 向后端请求路由数据
getRouters().then(res => { getRouters().then((res) => {
const sdata = JSON.parse(JSON.stringify(res.data)) const sdata = JSON.parse(JSON.stringify(res.data));
const rdata = JSON.parse(JSON.stringify(res.data)) const rdata = JSON.parse(JSON.stringify(res.data));
const defaultData = JSON.parse(JSON.stringify(res.data)) const defaultData = JSON.parse(JSON.stringify(res.data));
const sidebarRoutes = filterAsyncRouter(sdata) const sidebarRoutes = filterAsyncRouter(sdata);
const rewriteRoutes = filterAsyncRouter(rdata, false, true) const rewriteRoutes = filterAsyncRouter(rdata, false, true);
const defaultRoutes = filterAsyncRouter(defaultData) const defaultRoutes = filterAsyncRouter(defaultData);
const asyncRoutes = filterDynamicRoutes(dynamicRoutes) const asyncRoutes = filterDynamicRoutes(dynamicRoutes);
asyncRoutes.forEach(route => { router.addRoute(route) }) asyncRoutes.forEach((route) => {
this.setRoutes(rewriteRoutes) router.addRoute(route);
this.setSidebarRouters(constantRoutes.concat(sidebarRoutes)) });
this.setDefaultRoutes(sidebarRoutes) this.setRoutes(rewriteRoutes);
this.setTopbarRoutes(defaultRoutes) this.setSidebarRouters(constantRoutes.concat(sidebarRoutes));
resolve(rewriteRoutes) this.setDefaultRoutes(sidebarRoutes);
}) this.setTopbarRoutes(defaultRoutes);
}) resolve(rewriteRoutes);
} });
} });
}) },
},
});
// 遍历后台传来的路由字符串,转换为组件对象 // 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter(route => { return asyncRouterMap.filter((route) => {
if (type && route.children) { if (type && route.children) {
route.children = filterChildren(route.children) route.children = filterChildren(route.children);
} }
if (route.component) { if (route.component) {
// Layout ParentView 组件特殊处理 // Layout ParentView 组件特殊处理
if (route.component === 'Layout') { if (route.component === "Layout") {
route.component = Layout route.component = Layout;
} else if (route.component === 'ParentView') { } else if (route.component === "ParentView") {
route.component = ParentView route.component = ParentView;
} else if (route.component === 'InnerLink') { } else if (route.component === "InnerLink") {
route.component = InnerLink route.component = InnerLink;
} else { } else {
route.component = loadView(route.component) route.component = loadView(route.component);
} }
} }
if (route.children != null && route.children && route.children.length) { if (route.children != null && route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, route, type) route.children = filterAsyncRouter(route.children, route, type);
} else { } else {
delete route['children'] delete route["children"];
delete route['redirect'] delete route["redirect"];
} }
return true return true;
}) });
} }
function filterChildren(childrenMap, lastRouter = false) { function filterChildren(childrenMap, lastRouter = false) {
var children = [] var children = [];
childrenMap.forEach(el => { childrenMap.forEach((el) => {
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path el.path = lastRouter ? lastRouter.path + "/" + el.path : el.path;
if (el.children && el.children.length && el.component === 'ParentView') { if (el.children && el.children.length && el.component === "ParentView") {
children = children.concat(filterChildren(el.children, el)) children = children.concat(filterChildren(el.children, el));
} else { } else {
children.push(el) children.push(el);
} }
}) });
return children return children;
} }
// 动态路由遍历,验证是否具备权限 // 动态路由遍历,验证是否具备权限
export function filterDynamicRoutes(routes) { export function filterDynamicRoutes(routes) {
const res = [] const res = [];
routes.forEach(route => { routes.forEach((route) => {
if (route.permissions) { if (route.permissions) {
if (auth.hasPermiOr(route.permissions)) { if (auth.hasPermiOr(route.permissions)) {
res.push(route) res.push(route);
} }
} else if (route.roles) { } else if (route.roles) {
if (auth.hasRoleOr(route.roles)) { if (auth.hasRoleOr(route.roles)) {
res.push(route) res.push(route);
} }
} }
}) });
return res return res;
} }
export const loadView = (view) => { export const loadView = (view) => {
if (process.env.NODE_ENV === 'development') { let res;
return (resolve) => require([`@/views/${view}`], resolve) for (const path in modules) {
} else { const dir = path.split("views/")[1].split(".vue")[0];
// 使用 import 实现生产环境的路由懒加载 if (dir === view) {
return () => import(`@/views/${view}`) res = () => modules[path]();
} }
} }
return res;
};
export default usePermissionStore export default usePermissionStore;

@ -1,29 +1,38 @@
<template> <template>
<div class="login"> <div class="login">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
class="login-form"
>
<h3 class="title">太仓市网络和数据资产采集管理系统</h3> <h3 class="title">太仓市网络和数据资产采集管理系统</h3>
<el-form-item prop="username"> <el-form-item prop="username">
<el-input <el-input
v-model="loginForm.username" v-model="loginForm.username"
type="text"
auto-complete="off"
placeholder="账号" placeholder="账号"
> >
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> <template #prefix>
<el-icon><User /></el-icon>
</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input <el-input
v-model="loginForm.password" v-model="loginForm.password"
type="password" type="password"
auto-complete="off"
placeholder="密码" placeholder="密码"
@keyup.enter.native="handleLogin" @keyup.enter.native="handleLogin"
> >
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> <template #prefix>
<el-icon><Lock /></el-icon>
</template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code" v-if="captchaEnabled"> <el-form-item
prop="code"
v-if="captchaEnabled"
>
<el-input <el-input
v-model="loginForm.code" v-model="loginForm.code"
auto-complete="off" auto-complete="off"
@ -31,35 +40,58 @@
style="width: 63%" style="width: 63%"
@keyup.enter.native="handleLogin" @keyup.enter.native="handleLogin"
> >
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> <!-- <svg-icon
slot="prefix"
icon-class="validCode"
class="el-input__icon input-icon"
/> -->
<template #prefix>
<el-icon><key /></el-icon>
</template>
</el-input> </el-input>
<div class="login-code"> <div class="login-code">
<img :src="codeUrl" @click="getCode" class="login-code-img"/> <img
:src="codeUrl"
@click="getCode"
class="login-code-img"
/>
</div> </div>
</el-form-item> </el-form-item>
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;"></el-checkbox> <el-checkbox
<el-form-item style="width:100%;"> v-model="loginForm.rememberMe"
style="margin: 0px 0px 25px 0px"
>记住密码</el-checkbox
>
<el-form-item style="width: 100%">
<el-button <el-button
:loading="loading" :loading="loading"
size="medium" size="medium"
type="primary" type="primary"
style="width:100%;" style="width: 100%"
@click.native.prevent="handleLogin" @click.native.prevent="handleLogin"
> >
<span v-if="!loading"> </span> <span v-if="!loading"> </span>
<span v-else> ...</span> <span v-else> ...</span>
</el-button> </el-button>
<div style="float: right;" v-if="register"> <div
<router-link class="link-type" :to="'/register'">立即注册</router-link> style="float: right"
v-if="register"
>
<router-link
class="link-type"
:to="'/register'"
>立即注册</router-link
>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 底部 --> <!-- 底部 -->
<!-- <div class="el-login-footer"> <!-- <div class="el-login-footer">
<span>Copyright © 2018-2024 ruoyi.vip All Rights Reserved.</span> <span>Copyright © 2018-2024 ruoyi.vip All Rights Reserved.</span>
</div> --> </div> -->
<div class="dibutishi"><span>主办单位</span>中共太仓市委网信办 <span class="kongge"></span> <span>技术支持单位</span>杭州安恒信息技术股份有限公司 <div class="dibutishi">
<span>主办单位</span>中共太仓市委网信办 <span class="kongge"></span>
<span>技术支持单位</span>杭州安恒信息技术股份有限公司
</div> </div>
</div> </div>
</template> </template>
@ -67,9 +99,9 @@
<script> <script>
import { getCodeImg } from "@/api/login"; import { getCodeImg } from "@/api/login";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt' import { encrypt, decrypt } from "@/utils/jsencrypt";
import forge from 'node-forge' import forge from "node-forge";
import useUserStore from '@/store/modules/user' import useUserStore from "@/store/modules/user";
const userStore = useUserStore(); const userStore = useUserStore();
export default { export default {
name: "Login", name: "Login",
@ -81,16 +113,16 @@ export default {
password: "", password: "",
rememberMe: false, rememberMe: false,
code: "", code: "",
uuid: "" uuid: "",
}, },
loginRules: { loginRules: {
username: [ username: [
{ required: true, trigger: "blur", message: "请输入您的账号" } { required: true, trigger: "blur", message: "请输入您的账号" },
], ],
password: [ password: [
{ required: true, trigger: "blur", message: "请输入您的密码" } { required: true, trigger: "blur", message: "请输入您的密码" },
], ],
code: [{ required: true, trigger: "change", message: "请输入验证码" }] code: [{ required: true, trigger: "change", message: "请输入验证码" }],
}, },
loading: false, loading: false,
// //
@ -98,31 +130,32 @@ export default {
// //
register: false, register: false,
redirect: undefined, redirect: undefined,
publicKey:`MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl8bS1kYTiMhIS5MZU253bc0ukaxrA1lfCziABFxQrC2c09tMrQGjuH6V1x2ofNBMGhOD9uWN/qkAQy/HwOe/NKUqCw6N0ov6guSrqMDW/BdZ3Bl0rmM1/95jTC1xffFFvej7xWNffIbaPI+bJ4WLX9NViNi9HmT0BRNzJ4d2R86LPPCa+bxLaPjsh2R2tBkbLkUot9769aJaPPiwPCZHMkuQenjHSmpWL0okleqMH8EGX7j6A5A/4IUXPMNKMMzkiSRpsIJ65GJmDAbnR3ZXRfC8MzVBBJB6zr5N0F4N9xZfF+JS/Yx726tCu+rA6GDCyTxtQ/wnKpPdwFP5nUWCWQIDAQAB` publicKey: `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl8bS1kYTiMhIS5MZU253bc0ukaxrA1lfCziABFxQrC2c09tMrQGjuH6V1x2ofNBMGhOD9uWN/qkAQy/HwOe/NKUqCw6N0ov6guSrqMDW/BdZ3Bl0rmM1/95jTC1xffFFvej7xWNffIbaPI+bJ4WLX9NViNi9HmT0BRNzJ4d2R86LPPCa+bxLaPjsh2R2tBkbLkUot9769aJaPPiwPCZHMkuQenjHSmpWL0okleqMH8EGX7j6A5A/4IUXPMNKMMzkiSRpsIJ65GJmDAbnR3ZXRfC8MzVBBJB6zr5N0F4N9xZfF+JS/Yx726tCu+rA6GDCyTxtQ/wnKpPdwFP5nUWCWQIDAQAB`,
}; };
}, },
watch: { watch: {
$route: { $route: {
handler: function(route) { handler: function (route) {
this.redirect = route.query && route.query.redirect; this.redirect = route.query && route.query.redirect;
}, },
immediate: true immediate: true,
} },
}, },
created() { created() {
if(localStorage.getItem("ismypaginationTow")){ if (localStorage.getItem("ismypaginationTow")) {
localStorage.removeItem("ismypaginationTow") localStorage.removeItem("ismypaginationTow");
} }
if(localStorage.getItem("ismypagination")){ if (localStorage.getItem("ismypagination")) {
localStorage.removeItem("ismypagination") localStorage.removeItem("ismypagination");
} }
this.getCode(); this.getCode();
this.getCookie(); this.getCookie();
}, },
methods: { methods: {
getCode() { getCode() {
getCodeImg().then(res => { getCodeImg().then((res) => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled; this.captchaEnabled =
res.captchaEnabled === undefined ? true : res.captchaEnabled;
if (this.captchaEnabled) { if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img; this.codeUrl = "data:image/gif;base64," + res.img;
this.loginForm.uuid = res.uuid; this.loginForm.uuid = res.uuid;
@ -132,49 +165,57 @@ export default {
getCookie() { getCookie() {
const username = Cookies.get("username"); const username = Cookies.get("username");
const password = Cookies.get("password"); const password = Cookies.get("password");
const rememberMe = Cookies.get('rememberMe') const rememberMe = Cookies.get("rememberMe");
this.loginForm = { this.loginForm = {
username: username === undefined ? this.loginForm.username : username, username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : decrypt(password), password:
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe) password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
}; };
}, },
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate((valid) => {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
if (this.loginForm.rememberMe) { if (this.loginForm.rememberMe) {
Cookies.set("username", this.loginForm.username, { expires: 30 }); Cookies.set("username", this.loginForm.username, { expires: 30 });
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 }); Cookies.set("password", encrypt(this.loginForm.password), {
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 }); expires: 30,
});
Cookies.set("rememberMe", this.loginForm.rememberMe, {
expires: 30,
});
} else { } else {
Cookies.remove("username"); Cookies.remove("username");
Cookies.remove("password"); Cookies.remove("password");
Cookies.remove('rememberMe'); Cookies.remove("rememberMe");
} }
// 2048 RSA // 2048 RSA
const lines = []; const lines = [];
lines.push('-----BEGIN PUBLIC KEY-----'); lines.push("-----BEGIN PUBLIC KEY-----");
for (let i = 0; i < this.publicKey.length; i += 64) { for (let i = 0; i < this.publicKey.length; i += 64) {
lines.push(this.publicKey.slice(i, i + 64)); lines.push(this.publicKey.slice(i, i + 64));
} }
lines.push('-----END PUBLIC KEY-----'); lines.push("-----END PUBLIC KEY-----");
lines.join('\n') lines.join("\n");
const publicKey = forge.pki.publicKeyFromPem(lines.join('\n')); const publicKey = forge.pki.publicKeyFromPem(lines.join("\n"));
// //
var dataBytes = forge.util.encodeUtf8(this.loginForm.password); var dataBytes = forge.util.encodeUtf8(this.loginForm.password);
// //
var encryptedBytes = publicKey.encrypt(dataBytes, 'RSA-OAEP', { var encryptedBytes = publicKey.encrypt(dataBytes, "RSA-OAEP", {
md: forge.md.sha256.create(), md: forge.md.sha256.create(),
mgf1: { mgf1: {
md: forge.md.sha1.create() md: forge.md.sha1.create(),
} },
}); });
// Base64 // Base64
var encryptedBase64 = forge.util.encode64(encryptedBytes); var encryptedBase64 = forge.util.encode64(encryptedBytes);
userStore.login({...this.loginForm, password: encryptedBase64}).then(() => { userStore
this.$router.push({ path: this.redirect || "/" }).catch(()=>{}); .login({ ...this.loginForm, password: encryptedBase64 })
}).catch(() => { .then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
})
.catch(() => {
this.loading = false; this.loading = false;
if (this.captchaEnabled) { if (this.captchaEnabled) {
this.getCode(); this.getCode();
@ -182,8 +223,8 @@ export default {
}); });
} }
}); });
} },
} },
}; };
</script> </script>
@ -251,6 +292,7 @@ export default {
} }
.login-code-img { .login-code-img {
height: 38px; height: 38px;
margin-left: 27%;
} }
.dibutishi { .dibutishi {
position: absolute; position: absolute;
@ -265,7 +307,6 @@ export default {
span { span {
color: #ffffff; color: #ffffff;
} }
} }
</style> </style>

Loading…
Cancel
Save