Compare commits

...

14 Commits

Author SHA1 Message Date
橙子
537b39b3c4 Update README.md 2022-05-08 14:46:53 +08:00
橙子
47e6e48729 Merge branch 'sqlsugar-dev' into sqlsugar 2022-05-08 14:46:35 +08:00
橙子
d252229777 完善动态菜单、设置角色等功能,修复登录问题 2022-05-08 14:46:22 +08:00
橙子
7f4c7f607d Update README.md 2022-05-06 22:57:36 +08:00
橙子
994ba5dd1a Merge branch 'sqlsugar-dev' into sqlsugar 2022-05-06 22:56:40 +08:00
橙子
e3a06b28dd 更新数据库 2022-05-06 22:56:26 +08:00
橙子
10d512470e 合并冲突 2022-05-06 22:51:45 +08:00
橙子
c1d8040fd5 合并冲突 2022-05-06 22:49:12 +08:00
橙子
e4b81da386 Merge branch 'sqlsugar-dev' of https://gitee.com/ccnetcore/Yi into sqlsugar-dev 2022-05-06 22:47:35 +08:00
橙子
fd7360e6f4 预添加前端权限控制 2022-05-06 22:47:26 +08:00
chenchun
62f15e218e Merge branch 'sqlsugar-dev' into sqlsugar 2022-05-05 17:05:12 +08:00
chenchun
5c1b91f348 完善权限 2022-05-05 17:04:49 +08:00
橙子
378cbd580f Update README.md 2022-05-04 15:55:19 +08:00
橙子
3994f14010 通用对象查询封装、权限封装 2022-05-04 15:54:40 +08:00
30 changed files with 235 additions and 331 deletions

View File

@@ -22,7 +22,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
适合.Net6学习、Sqlsugar学习 、项目二次开发。
集大成者,终究轮子
Yi框架最新版本标签`v1.1.1`,具体版本可以查看标签迭代
Yi框架最新版本标签`v1.1.4`,具体版本可以查看标签迭代
项目与Sqlsugar同步更新但这作者老杰哥代码天天爆肝到凌晨两点我们也尽量会跟上他的脚步。更新频繁所以可watching持续关注。

Binary file not shown.

View File

@@ -47,7 +47,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
UserEntity user = new();
if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
{
return Result.Success("登录成功!").SetData(new { token = _jwtInvoker.GetAccessToken(user) });
var userRoleMenu= await _iUserService.GetUserAllInfo(user.Id);
return Result.Success("登录成功!").SetData(new { token = _jwtInvoker.GetAccessToken(userRoleMenu.User,userRoleMenu.Menus) });
}
return Result.SuccessError("登录失败!用户名或者密码错误!");
}
@@ -80,6 +81,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<Result> GetUserAllInfo()
{
//通过鉴权jwt获取到用户的id

View File

@@ -32,7 +32,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:get:one")]
[Permission($"{nameof(T)}:get:list")]
[HttpGet]
public virtual async Task<Result> GetById(long id)
{
@@ -55,7 +55,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary>
/// <param name="queryCondition"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:get:page")]
[Permission($"{nameof(T)}:get:list")]
[HttpPost]
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
{
@@ -91,7 +91,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[Permission($"{nameof(T)}:delete:list")]
[Permission($"{nameof(T)}:del")]
[HttpDelete]
public virtual async Task<Result> DeleteList(List<long> ids)
{

View File

@@ -45,7 +45,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns>
[HttpGet]
// 特点:化繁为简!意框架仓储代理上下文对象,用起来就是爽,但最好按规范来爽!
// 规范:控制器不建议使用切换仓储方法、控制器严禁使用DB上下文对象其它怎么爽怎么来
// 规范控制器严禁使用DB上下文对象其它怎么爽怎么来
public async Task<Result> DbTest()
{
//非常好使用UserService的特有方法
@@ -60,7 +60,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//挺不错,依赖注入其他仓储
await _iRoleService._repository.GetListAsync();
//不建议操作,直接切换其他仓储
//还行,直接切换其他仓储,怎么爽怎么来
await _iUserService._repository.ChangeRepository<Repository<RoleEntity>>().GetListAsync();
//最好不要直接操作Db对象
@@ -74,7 +74,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary>
/// <returns></returns>
[HttpGet]
//简单语句不推荐!
//简单语句不推荐使用sql
public async Task<Result> SqlTest()
{
return Result.Success().SetData(await _iUserService._repository.UseSqlAsync<UserEntity>("select * from User"));

View File

@@ -23,15 +23,15 @@ namespace Yi.Framework.Core
}
public string GetRefreshToken(UserEntity user)
{
return this.GetToken(_JWTTokenOptions.ReExpiration, user, true);
return this.GetToken(_JWTTokenOptions.ReExpiration, user,null, true);
}
public string GetAccessToken(UserEntity user)
public string GetAccessToken(UserEntity user,HashSet<MenuEntity> menus)
{
return this.GetToken(_JWTTokenOptions.Expiration, user);
return this.GetToken(_JWTTokenOptions.Expiration, user, menus);
}
private string GetToken(int minutes, UserEntity user, bool isRefresh = false)
private string GetToken(int minutes, UserEntity user, HashSet<MenuEntity> menus,bool isRefresh = false)
{
List<Claim> claims = new List<Claim>();
claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"));
@@ -39,8 +39,11 @@ namespace Yi.Framework.Core
claims.Add(new Claim(JwtRegisteredClaimNames.Sid, user.Id.ToString()));
//-----------------------------以下从user的权限表中添加权限-----------------------例如:
claims.Add(new Claim("permission", "userentity:get:list"));
claims.Add(new Claim("permission", "userentity:get:one"));
foreach (var m in menus)
{
claims.Add(new Claim("permission", m.PermissionCode.ToString()));
}
if (isRefresh)
{

View File

@@ -32,7 +32,7 @@ namespace Yi.Framework.Model.Models
/// <summary>
///
///</summary>
[SugarColumn(ColumnName= "PermissionCode")]
[SugarColumn(ColumnName="PermissionCode" )]
public string PermissionCode { get; set; }
/// <summary>
///
@@ -69,5 +69,15 @@ namespace Yi.Framework.Model.Models
///</summary>
[SugarColumn(ColumnName="TenantId" )]
public long? TenantId { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="MenuIcon" )]
public string MenuIcon { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Router" )]
public string Router { get; set; }
}
}

View File

@@ -54,5 +54,10 @@ namespace Yi.Framework.Model.Models
///</summary>
[SugarColumn(ColumnName="ModifyUser" )]
public long? ModifyUser { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="RoleCode" )]
public string RoleCode { get; set; }
}
}

View File

@@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="NEST" Version="7.16.0" />
<PackageReference Include="SqlSugarCore" Version="5.0.7.5" />
<PackageReference Include="SqlSugarCore" Version="5.0.7.8" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,6 +1,7 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Yi.Framework.Common.Helper;
@@ -112,7 +113,7 @@ namespace Yi.Framework.Service
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)
//得到用户
var user = await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles, r => r.Menus).InSingleAsync(userId);
var user = await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles.Where(r=>r.IsDeleted==false).ToList(), r => r.Menus.Where(m=>m.IsDeleted==false).ToList()).InSingleAsync(userId);
//得到角色集合
var roleList = user.Roles;

View File

@@ -3,6 +3,7 @@ using Microsoft.IdentityModel.JsonWebTokens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Yi.Framework.WebCore.AttributeExtend
@@ -40,11 +41,24 @@ namespace Yi.Framework.WebCore.AttributeExtend
var perList = context.HttpContext.User.Claims.Where(u => u.Type == "permission").Select(u=> u.Value.ToString().ToLower()). ToList();
//判断权限是否存在Redis中,或者jwt中
//if (perList.Contains(permission.ToLower()))
//{
// result = true;
//}
result = true;
//进行正则表达式的匹配以code开头
Regex regex = new Regex($"^{permission.ToLower()}");
foreach (var p in perList)
{
//过滤多余的标签
p.Replace("Entity","");
p.Replace("entity","");
if (regex.IsMatch(p))
{
result = true;
break;
}
}
//用户的增删改查直接可以user:*即可
//这里暂时全部放行即可
result = true;
if (!result)

View File

@@ -1,22 +1,11 @@
import myaxios from '@/util/myaxios'
import {objctToDic} from '@/util/objctHandle'
export default {
getList() {
return myaxios({
url: '/Role/GetList',
method: 'post',
data: {
parameters: [
{
key: "isDeleted",
value: "0",
type: 0
}
],
orderBys: [
"id"
]
}
data: objctToDic()
})
},
giveRoleSetMenu(roleList, menuList) {

View File

@@ -1,14 +1,5 @@
import myaxios from '@/util/myaxios'
export default {
SetRoleByUser(userIds, roleIds) {
return myaxios({
url: '/User/SetRoleByUser',
method: 'post',
data: { "ids1": userIds, "ids2": roleIds }
})
},
GetUserInRolesByHttpUser() {
return myaxios({
@@ -28,4 +19,12 @@ export default {
method: 'get'
})
},
GiveUserSetRole(UserIds,RoleIds)
{
return myaxios({
url: `/User/GiveUserSetRole`,
method: 'put',
data:{UserIds,RoleIds}
})
}
}

View File

@@ -1,22 +1,11 @@
import myaxios from '@/util/myaxios'
import {objctToDic} from '@/util/objctHandle'
export default {
getItem(url) {
return myaxios({
url: url,
method: 'post',
data: {
parameters: [
{
key: "isDeleted",
value: "0",
type: 0
}
],
orderBys: [
"id"
]
}
data: objctToDic()
})
},
addItem(url, data) {

View File

@@ -2,7 +2,7 @@
<v-avatar :size="size" >
<!-- <img src="https://z3.ax1x.com/2021/05/09/gJadhD.jpg" /> -->
<img
:src="baseurl +'/image/'+$store.state.user.user.icon"
:src="baseurl +'/image/'+$store.state.user.user.user.icon"
/>
</v-avatar>
</template>

View File

@@ -58,6 +58,8 @@ export default {
watch:{
select:{//深度监听,可监听到对象、数组的变化
handler(val, oldVal){
console.log(oldVal)
console.log(val)
this.$emit("select",val);
},
deep:true

View File

@@ -52,11 +52,15 @@
hoverable
item-text="menuName"
>
<template v-slot:prepend="{ item }">
<v-icon>
{{ item.menuIcon }}
</v-icon>
</template>
<template v-slot:append="{ item }">
<v-btn class="mr-2">编号:{{ item.id }}</v-btn>
<v-btn class="mr-2">权限:{{ item.permissionCode }}</v-btn>
<v-btn v-show="item.menuType==1" class="mr-2">权限:{{ item.permissionCode }}</v-btn>
<!-- <v-btn class="mr-2">图标:{{ item.icon }}</v-btn> -->
<!-- <v-btn class="mr-2">路由:{{ item.router }}</v-btn> -->
<v-btn v-show="item.menuType!=1" class="mr-2">路由:{{ item.router }}</v-btn>
<!-- <v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn>
<v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> -->
<!-- <ccCombobox
@@ -102,9 +106,10 @@ export default {
editedItem: {},
editedIndex: -1,
defaultItem: {
// icon: "mdi-start",
menuIcon: "mdi-view-dashboard",
permissionCode: "test",
menuName: "管理",
router:"/",
parentId: 0,
MenuType:0
},
@@ -122,21 +127,16 @@ export default {
this.$refs.tree.updateAll(true);
},
// setMould(item) {
// menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
// this.$dialog.notify.info(resp.msg, {
// position: "top-right",
// timeout: 5000,
// });
// this.init();
// });
// },
getSelect(data) {
this.mouldSelect = data;
},
async deleteItem(item) {
this.editedIndex = 1;
if(item!=null)
{
this.editedIndex = 1;
}
this.editedItem = Object.assign({}, item);
var p = await this.$dialog.warning({
text: "你确定要删除此条记录吗??",
@@ -155,7 +155,7 @@ export default {
if (this.editedIndex > -1) {
Ids.push(this.editedItem.id);
} else {
this.selection.forEach(function (item) {
this.selection.forEach( (item) =>{
Ids.push(item.id);
});
}
@@ -201,6 +201,7 @@ export default {
selection: {
//深度监听,可监听到对象、数组的变化
handler(val, oldVal) {
this.$emit("selection", val);
},
deep: true,

View File

@@ -49,180 +49,16 @@
<script>
// Utilities
// import { get, sync } from 'vuex-pathify'
import userApi from "@/api/userApi";
import store from "@/store/index.js";
import { toTree } from "@/util/menuHandle";
export default {
methods: {
init() {
//这里动态获取菜单,暂时写死
// userApi.GetMenuByHttpUser().then((resp) => {
// this.items = resp.data.children;
// });
this.items =
[
{
icon: "mdi-view-dashboard",
router: "/",
menu_name: "首页",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 1,
children: null,
id: 2,
is_delete: 0,
},
{
icon: "mdi-account-box-multiple",
router: null,
menu_name: "用户角色管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 1,
children: [
{
icon: "mdi-account-box",
router: "/AdmUser/",
menu_name: "用户管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 3,
children: null,
id: 4,
is_delete: 0,
},
{
icon: "mdi-account-circle",
router: "/admrole/",
menu_name: "角色管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 3,
children: null,
id: 9,
is_delete: 0,
},
],
id: 3,
is_delete: 0,
},
{
icon: "mdi-account-cash",
router: null,
menu_name: "角色接口管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 1,
children: [
{
icon: "mdi-clipboard-check-multiple",
router: "/AdmMenu/",
menu_name: "菜单管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 14,
children: null,
id: 15,
is_delete: 0,
},
{
icon: "mdi-circle-slice-8",
router: "/admMould/",
menu_name: "接口管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 14,
children: null,
id: 20,
is_delete: 0,
},
{
icon: "mdi-clipboard-account",
router: "/admRoleMenu/",
menu_name: "角色菜单分配管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 14,
children: null,
id: 25,
is_delete: 0,
},
],
id: 14,
is_delete: 0,
},
{
icon: "mdi-clipboard-flow-outline",
router: null,
menu_name: "路由管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 1,
children: [
{
icon: "mdi-account-eye",
router: "/userinfo/",
menu_name: "用户信息",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 26,
children: null,
id: 27,
is_delete: 0,
},
{
icon: "mdi-account-eye",
router: "/pan",
menu_name: "云盘管理",
roles: null,
mould: null,
is_top: 0,
sort: 0,
is_show: 1,
parentId: 26,
children: null,
id: 28,
is_delete: 0,
},
],
id: 26,
is_delete: 0,
},
]
this.items=toTree( store.state.user.user.menus);
},
logout() {
this.$store.dispatch("Logout");
this.$router.push({ path: "/login" });
this.$store.dispatch("Logout")
this.$router.push({ path: "/login/" });
},
},
created() {

View File

@@ -1,8 +1,8 @@
<template>
<v-list-group :group="group" :prepend-icon="item.icon" eager v-bind="$attrs">
<v-list-group :group="group" :prepend-icon="item.menuIcon" eager v-bind="$attrs">
<template v-slot:activator>
<v-list-item-icon
v-if="!item.icon && !item.avatar"
v-if="!item.menuIcon && !item.avatar"
class="text-caption text-uppercase text-center my-2 align-self-center"
style="margin-top: 14px"
>
@@ -13,8 +13,8 @@
<v-img :src="item.avatar" />
</v-list-item-avatar>
<v-list-item-content v-if="item.menu_name">
<v-list-item-title v-text="item.menu_name" />
<v-list-item-content v-if="item.menuName">
<v-list-item-title v-text="item.menuName" />
</v-list-item-content>
</template>
@@ -57,7 +57,7 @@ export default {
return this.genGroup(this.item.children);
},
title() {
const matches = this.item.menu_name.match(/\b(\w)/g);
const matches = this.item.menuName.match(/\b(\w)/g);
if (matches != null) {
return matches.join("");
}

View File

@@ -11,7 +11,7 @@
v-on="$listeners"
>
<v-list-item-icon
v-if="!item.icon"
v-if="!item.menuIcon"
class="text-caption text-uppercase justify-center ml-1 my-2 align-self-center"
>
{{ title }}
@@ -22,14 +22,14 @@
</v-list-item-avatar>
<v-list-item-icon
v-if="item.icon"
v-if="item.menuIcon"
class="my-2 align-self-center"
>
<v-icon v-text="item.icon" />
<v-icon v-text="item.menuIcon" />
</v-list-item-icon>
<v-list-item-content v-if="item.menu_name">
<v-list-item-title v-text="item.menu_name" />
<v-list-item-content v-if="item.menuName">
<v-list-item-title v-text="item.menuName" />
</v-list-item-content>
</v-list-item>
</template>
@@ -47,7 +47,7 @@
computed: {
title () {
const matches = this.item.menu_name.match(/\b(\w)/g)
const matches = this.item.menuName.match(/\b(\w)/g)
if(matches!=null)
{
return matches.join('')

View File

@@ -4,6 +4,10 @@ import store from './store/index'
router.beforeEach((to, from, next) => {
// console.log(to)
// console.log(from)
// console.log(next)
const user = store.state.user.user; //获取是有user
if (!user) { //如果没有登入
if (to.path == '/login/' || to.path == '/register/' || to.path == '/reset_password/' || to.path == '/qq/') {

View File

@@ -38,7 +38,6 @@ const mutations = { //变化//载荷
},
SET_USER(state, user) {
state.user = user
console.log(user)
setUser(user)
},
SetGradient(state, gradient) {
@@ -87,19 +86,21 @@ const actions = { //动作
accountApi.getUserAllInfo().then(resp2=>{
commit('SET_USER', resp2.data.user)
commit('SET_USER', resp2.data)
var code=[];
resp2.data.menus.forEach(element => {
code.push(element.permissionCode)
});
commit('SET_PER', code)
resolv(resp)
})
}
else
{
resolv(resp)
}
}).catch(error => {
reject(error)
})

View File

@@ -0,0 +1,31 @@
//匹配菜单让code变成路由
const menuDic=
{
"user:get:list": "/admuser",
"role:get:list": "/admrole",
"menu:get:list":"/admmenu",
"rolemenu:set:list":"/admrolemenu"
}
//匹配按钮,判断是否有按钮存在
const btnDic=
{
"user:add":"",
"user:update":"",
"user:del":"",
}
export default {menuDic,btnDic};
//菜单可以区分使用code来进行匹配
//记得:关于*的使用,要单独判断
//比如,
//按钮是user:*或者*:*:*直接全部放行即可
//菜单就不一样了,如果是*:*:*
//有两种方案:
//1:直接使用一个默认的全部菜单(会和后端给的菜单冲突)
//2:前端直接无视,*:*:*相当于只管后端权限(如果后端没有配置菜单前端将没有菜单了)
//如果查询找到的是user:*,可以先把*全部替换成get:list再进行比对即可
//等待持续更新中

View File

@@ -1,29 +1,26 @@
export function setTreeMenu(menuList) {
if (menuList != null && menuList.length > 0) {
export function toTree(data) {
// 删除 所有 children,以防止多次调用
data.forEach(function (item) {
delete item.children;
});
//结果
var res;
//获取最小的parentId
var minParentId = 0;
//获取id=最小的parentId的菜单列表
var menuList1=menuList.filter((item)=>{item.parentId==minParentId}) ;
menuList1.forEach(element=>{
res.push(element)
var children=menuList.filter((item)=>{item.parentId==element.id}) ;
if (children.length > 0) {
setTreeChildren(menuList, children,element)
}
})
}
}
function setTreeChildren(menuList, childrenList,model) {
childrenList.forEach(element => {
model.Childs.push(element);
var childrenList2=menuList.filter((item)=>{item.parentId==element.id}) ;
if (childrenList2.length > 0) {
setTreeChildren(menuList, childrenList2,element)
// 将数据存储为 以 id 为 KEY 的 map 索引数据列
var map = {};
data.forEach(function (item) {
map[item.id] = item;
});
// console.log(map);
var val = [];
data.forEach(function (item) {
// 以当前遍历项的pid,去map对象中找到索引的id
var parent = map[item.parentId];
// 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
if (parent) {
(parent.children || ( parent.children = [] )).push(item);
} else {
//如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中作为顶级
val.push(item);
}
});
return val;
}

View File

@@ -31,14 +31,14 @@ myaxios.interceptors.request.use(function(config) {
// 响应拦截器
myaxios.interceptors.response.use(async function(response) {
const resp = response.data
if (resp.code == undefined && resp.msg == undefined) {
if (resp.code == undefined && resp.message == undefined) {
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
position: "top-right",
timeout: 5000,
});
} else if (resp.code == 401) {
const res = await vm.$dialog.error({
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
title: '错误',
actions: {
'false': '取消',
@@ -50,7 +50,7 @@ myaxios.interceptors.response.use(async function(response) {
}
} else if (resp.code !== 200) {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
position: "top-right",
timeout: 5000,
});
@@ -60,14 +60,14 @@ myaxios.interceptors.response.use(async function(response) {
return resp;
}, async function(error) {
const resp = error.response.data
if (resp.code == undefined && resp.msg == undefined) {
if (resp.code == undefined && resp.message == undefined) {
vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
position: "top-right",
timeout: 5000,
});
} else if (resp.code == 401) {
const res = await vm.$dialog.error({
text: `错误代码:${resp.code},原因:${resp.msg}<br>是否重新进行登录?`,
text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
title: '错误',
actions: {
'false': '取消',
@@ -81,7 +81,7 @@ myaxios.interceptors.response.use(async function(response) {
}
} else if (resp.code !== 200) {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.msg}`, {
vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
position: "top-right",
timeout: 5000,
});

View File

@@ -8,6 +8,11 @@ export function deepCopy(obj) {
//转换数据,0是相等1是模糊查询
export function objctToDic(object, isByPage) {
if (object == undefined) {
object = {};
}
if (isByPage) {
var paramPage = {
"index": object.pageIndex,
@@ -19,8 +24,8 @@ export function objctToDic(object, isByPage) {
var newData = deepCopy(object);
delete newData.pageIndex;
delete newData.pageSize;
var newList = [Object.keys(newData).map(val => {
var newList = [Object.keys(newData).map(val => {
return {
key: val,
value: object[val],
@@ -30,11 +35,9 @@ export function objctToDic(object, isByPage) {
//过滤封装
newList[0].forEach((item, index) => {
if(item.value.length>0)
{
if(item.key=='isDeleted')
{
item.type=0;
if (item.value.length > 0) {
if (item.key == 'isDeleted') {
item.type = 0;
}
paramPage.parameters.push(item);
}
@@ -55,11 +58,9 @@ export function objctToDic(object, isByPage) {
}
})]
thisList[0].forEach((item, index) => {
if(item.value.length>0)
{
if(item.key=='isDeleted')
{
item.type=0;
if (item.value.length > 0) {
if (item.key == 'isDeleted') {
item.type = 0;
}
params.parameters.push(item);
}

View File

@@ -31,7 +31,8 @@ export default {
axiosUrls: {
},
headers: [
{ text: "编号", align: "start", value: "id" },
// { text: "编号", align: "start", value: "id" },
{ text: "角色编号", value: "roleCode", sortable: false },
{ text: "角色名", value: "roleName", sortable: false },
// { text: "云盘地址", value: "file_path", sortable: false },
// { text: "简介", value: "introduce", sortable: false },

View File

@@ -7,7 +7,7 @@
headers="设置角色"
:items="roleItems"
@select="getSelect"
itemText="role_name"
itemText="roleName"
>
<template v-slot:save>
<v-btn @click="setRole" color="blue darken-1" text> 保存</v-btn>
@@ -27,6 +27,7 @@
</template>
<script>
import userApi from "../api/userApi";
import roleApi from "../api/roleApi";
export default {
created() {
this.init();
@@ -59,8 +60,7 @@ export default {
});
},
init() {
//这里可以遍历后台的菜单code根据对应的菜单code来给axiosUrls的增删改查赋值即可
//这里可以遍历后台的菜单code根据对应的菜单code来给axiosUrls的增删改查赋值即可
this.axiosUrls = {
get: "/user/GetList",
@@ -69,9 +69,10 @@ export default {
add: "/user/Add",
};
// roleApi.getRole().then((resp) => {
// this.roleItems = resp.data;
// });
roleApi.getList().then((resp) => {
console.log(resp.data)
this.roleItems=JSON.parse(JSON.stringify(resp.data));
});
},
setRole() {
var userIds = [];
@@ -82,8 +83,8 @@ export default {
this.select.forEach((item) => {
roleIds.push(item.id);
});
userApi.SetRoleByUser(userIds, roleIds).then((resp) => {
this.$dialog.notify.success(resp.msg, {
userApi.GiveUserSetRole(userIds, roleIds).then((resp) => {
this.$dialog.notify.success(resp.message, {
position: "top-right",
timeout: 5000,
});
@@ -104,7 +105,7 @@ export default {
axiosUrls: {},
headers: [
{ text: "用户名", value: "userName", sortable: false },
{ text: "密码", value: "password", sortable: false },
{ text: "图标", value: "icon", sortable: false },
{ text: "昵称", value: "nick", sortable: true },
{ text: "邮箱", value: "email", sortable: true },

View File

@@ -52,7 +52,16 @@
<a href="javascript:void(0)" class="mt-1"> 忘记密码? </a>
</div>
<v-btn block color="primary" @click="login" class="mt-6" :loading="loader" :disabled="btn_dis"> 登录 </v-btn>
<v-btn
block
color="primary"
@click="login"
class="mt-6"
:loading="loader"
:disabled="btn_dis"
>
登录
</v-btn>
</v-form>
</v-card-text>
@@ -70,7 +79,7 @@
</v-card-text>
<!-- social links -->
<v-card-actions class="d-flex justify-center ">
<v-card-actions class="d-flex justify-center">
<v-btn v-for="link in socialLink" :key="link.icon" icon class="ms-1">
<v-icon :color="$vuetify.theme.dark ? link.colorInDark : link.color">
{{ link.icon }}
@@ -81,11 +90,11 @@
</template>
<script>
export default {
created(){
created() {
this.enterSearch();
},
data: () => ({
btn_dis:false,
btn_dis: false,
loader: null,
socialLink: [
{
@@ -122,8 +131,7 @@ export default {
},
}),
methods: {
enterSearch() {
enterSearch() {
document.onkeydown = (e) => {
//13表示回车键baseURI是当前页面的地址为了更严谨也可以加别的可以打印e看一下
if (e.keyCode === 13 && e.target.baseURI.match("/")) {
@@ -133,20 +141,29 @@ export default {
};
},
login() {
this.loader = true;
this.btn_dis=true;
this.$store.dispatch("Login", this.form).then((resp) => {
if (resp.status) {
this.$router.push("/");
} else {
this.loader=null;
this.btn_dis=false;
this.$dialog.notify.error(resp.msg, {
position: "top-right",
timeout: 5000,
});
}
});
this.loader = true;
this.btn_dis = true;
this.$store
.dispatch("Login", this.form)
.then((resp) => {
if (resp.status) {
this.$router.push("/");
} else {
this.loader = null;
this.btn_dis = false;
this.$dialog.notify.error(resp.message, {
position: "top-right",
timeout: 5000,
});
}
})
.catch((error) => {
this.loader = false;
this.btn_dis = false;
});
},
},
};