登录页面以及字体包

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 './btn.scss';
@import './ruoyi.scss';
@import "./font.css";
body {
height: 100%;

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

@ -1,29 +1,38 @@
<template>
<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>
<el-form-item prop="username">
<el-input
v-model="loginForm.username"
type="text"
auto-complete="off"
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-form-item>
<el-form-item prop="password">
<el-input
v-model="loginForm.password"
type="password"
auto-complete="off"
placeholder="密码"
@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-form-item>
<el-form-item prop="code" v-if="captchaEnabled">
<el-form-item
prop="code"
v-if="captchaEnabled"
>
<el-input
v-model="loginForm.code"
auto-complete="off"
@ -31,35 +40,58 @@
style="width: 63%"
@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>
<div class="login-code">
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
<img
:src="codeUrl"
@click="getCode"
class="login-code-img"
/>
</div>
</el-form-item>
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;"></el-checkbox>
<el-form-item style="width:100%;">
<el-checkbox
v-model="loginForm.rememberMe"
style="margin: 0px 0px 25px 0px"
>记住密码</el-checkbox
>
<el-form-item style="width: 100%">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width:100%;"
style="width: 100%"
@click.native.prevent="handleLogin"
>
<span v-if="!loading"> </span>
<span v-else> ...</span>
</el-button>
<div style="float: right;" v-if="register">
<router-link class="link-type" :to="'/register'">立即注册</router-link>
<div
style="float: right"
v-if="register"
>
<router-link
class="link-type"
:to="'/register'"
>立即注册</router-link
>
</div>
</el-form-item>
</el-form>
<!-- 底部 -->
<!-- <div class="el-login-footer">
<span>Copyright © 2018-2024 ruoyi.vip All Rights Reserved.</span>
</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>
</template>
@ -67,9 +99,9 @@
<script>
import { getCodeImg } from "@/api/login";
import Cookies from "js-cookie";
import { encrypt, decrypt } from '@/utils/jsencrypt'
import forge from 'node-forge'
import useUserStore from '@/store/modules/user'
import { encrypt, decrypt } from "@/utils/jsencrypt";
import forge from "node-forge";
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
export default {
name: "Login",
@ -81,16 +113,16 @@ export default {
password: "",
rememberMe: false,
code: "",
uuid: ""
uuid: "",
},
loginRules: {
username: [
{ required: true, trigger: "blur", message: "请输入您的账号" }
{ required: true, trigger: "blur", message: "请输入您的账号" },
],
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,
//
@ -98,31 +130,32 @@ export default {
//
register: false,
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: {
$route: {
handler: function(route) {
handler: function (route) {
this.redirect = route.query && route.query.redirect;
},
immediate: true
}
immediate: true,
},
},
created() {
if(localStorage.getItem("ismypaginationTow")){
localStorage.removeItem("ismypaginationTow")
if (localStorage.getItem("ismypaginationTow")) {
localStorage.removeItem("ismypaginationTow");
}
if(localStorage.getItem("ismypagination")){
localStorage.removeItem("ismypagination")
if (localStorage.getItem("ismypagination")) {
localStorage.removeItem("ismypagination");
}
this.getCode();
this.getCookie();
},
methods: {
getCode() {
getCodeImg().then(res => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
getCodeImg().then((res) => {
this.captchaEnabled =
res.captchaEnabled === undefined ? true : res.captchaEnabled;
if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img;
this.loginForm.uuid = res.uuid;
@ -132,49 +165,57 @@ export default {
getCookie() {
const username = Cookies.get("username");
const password = Cookies.get("password");
const rememberMe = Cookies.get('rememberMe')
const rememberMe = Cookies.get("rememberMe");
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
password:
password === undefined ? this.loginForm.password : decrypt(password),
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
};
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
Cookies.set("username", this.loginForm.username, { expires: 30 });
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
Cookies.set("password", encrypt(this.loginForm.password), {
expires: 30,
});
Cookies.set("rememberMe", this.loginForm.rememberMe, {
expires: 30,
});
} else {
Cookies.remove("username");
Cookies.remove("password");
Cookies.remove('rememberMe');
Cookies.remove("rememberMe");
}
// 2048 RSA
const lines = [];
lines.push('-----BEGIN PUBLIC KEY-----');
lines.push("-----BEGIN PUBLIC KEY-----");
for (let i = 0; i < this.publicKey.length; i += 64) {
lines.push(this.publicKey.slice(i, i + 64));
}
lines.push('-----END PUBLIC KEY-----');
lines.join('\n')
const publicKey = forge.pki.publicKeyFromPem(lines.join('\n'));
lines.push("-----END PUBLIC KEY-----");
lines.join("\n");
const publicKey = forge.pki.publicKeyFromPem(lines.join("\n"));
//
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(),
mgf1: {
md: forge.md.sha1.create()
}
md: forge.md.sha1.create(),
},
});
// Base64
var encryptedBase64 = forge.util.encode64(encryptedBytes);
userStore.login({...this.loginForm, password: encryptedBase64}).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}).catch(() => {
userStore
.login({ ...this.loginForm, password: encryptedBase64 })
.then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
})
.catch(() => {
this.loading = false;
if (this.captchaEnabled) {
this.getCode();
@ -182,8 +223,8 @@ export default {
});
}
});
}
}
},
},
};
</script>
@ -251,6 +292,7 @@ export default {
}
.login-code-img {
height: 38px;
margin-left: 27%;
}
.dibutishi {
position: absolute;
@ -265,7 +307,6 @@ export default {
span {
color: #ffffff;
}
}
</style>

Loading…
Cancel
Save