合并人才集团代码
This commit is contained in:
60
utilsRc/plugins/auth.js
Normal file
60
utilsRc/plugins/auth.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import store from '@/store'
|
||||
|
||||
function authPermission(permission) {
|
||||
const all_permission = "*:*:*"
|
||||
const permissions = store.getters && store.getters.permissions
|
||||
if (permission && permission.length > 0) {
|
||||
return permissions.some(v => {
|
||||
return all_permission === v || v === permission
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function authRole(role) {
|
||||
const super_admin = "shequn"
|
||||
const roles = store.getters && store.getters.roles
|
||||
if (role && role.length > 0) {
|
||||
return roles.some(v => {
|
||||
return super_admin === v || v === role
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
// 验证用户是否具备某权限
|
||||
hasPermi(permission) {
|
||||
return authPermission(permission)
|
||||
},
|
||||
// 验证用户是否含有指定权限,只需包含其中一个
|
||||
hasPermiOr(permissions) {
|
||||
return permissions.some(item => {
|
||||
return authPermission(item)
|
||||
})
|
||||
},
|
||||
// 验证用户是否含有指定权限,必须全部拥有
|
||||
hasPermiAnd(permissions) {
|
||||
return permissions.every(item => {
|
||||
return authPermission(item)
|
||||
})
|
||||
},
|
||||
// 验证用户是否具备某角色
|
||||
hasRole(role) {
|
||||
return authRole(role)
|
||||
},
|
||||
// 验证用户是否含有指定角色,只需包含其中一个
|
||||
hasRoleOr(roles) {
|
||||
return roles.some(item => {
|
||||
return authRole(item)
|
||||
})
|
||||
},
|
||||
// 验证用户是否含有指定角色,必须全部拥有
|
||||
hasRoleAnd(roles) {
|
||||
return roles.every(item => {
|
||||
return authRole(item)
|
||||
})
|
||||
}
|
||||
}
|
||||
14
utilsRc/plugins/index.js
Normal file
14
utilsRc/plugins/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import tab from './tab'
|
||||
import auth from './auth'
|
||||
import modal from './modal'
|
||||
|
||||
export default {
|
||||
install(Vue) {
|
||||
// 页签操作
|
||||
Vue.prototype.$tab = tab
|
||||
// 认证对象
|
||||
Vue.prototype.$auth = auth
|
||||
// 模态框对象
|
||||
Vue.prototype.$modal = modal
|
||||
}
|
||||
}
|
||||
50
utilsRc/plugins/loadingPlugin.js
Normal file
50
utilsRc/plugins/loadingPlugin.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import ULoadingPage from 'uview-ui/components/u-loading-page/u-loading-page'; // 确保正确引入组件
|
||||
|
||||
export default {
|
||||
install(Vue) {
|
||||
// 注册 u-loading-page 组件为全局组件
|
||||
Vue.component('u-loading-page', ULoadingPage);
|
||||
|
||||
// 用于存储全局的 loading 组件实例
|
||||
let loadingInstance = null;
|
||||
|
||||
// 创建一个全局的显示 loading 的方法
|
||||
Vue.prototype.$showLoading = function () {
|
||||
// 如果没有创建过实例,则创建一个
|
||||
if (!loadingInstance) {
|
||||
const LoadingConstructor = Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
loading: true, // 控制 loading 显示的状态
|
||||
};
|
||||
},
|
||||
render(h) {
|
||||
return h('u-loading-page', {
|
||||
props: {
|
||||
loading: this.loading,
|
||||
loadingText: '',
|
||||
loadingColor: "#000",
|
||||
iconSize: '58rpx',
|
||||
},
|
||||
style: {
|
||||
zIndex: '200',
|
||||
opacity: 0.7
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
loadingInstance = new LoadingConstructor();
|
||||
loadingInstance.$mount(); // 手动挂载实例
|
||||
document.body.appendChild(loadingInstance.$el); // 将组件挂载到 body
|
||||
}
|
||||
loadingInstance.loading = true; // 显示 loading
|
||||
};
|
||||
|
||||
// 创建一个全局的隐藏 loading 的方法
|
||||
Vue.prototype.$hideLoading = function () {
|
||||
if (loadingInstance) {
|
||||
loadingInstance.loading = false; // 隐藏 loading
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
74
utilsRc/plugins/modal.js
Normal file
74
utilsRc/plugins/modal.js
Normal file
@@ -0,0 +1,74 @@
|
||||
export default {
|
||||
// 消息提示
|
||||
msg(content) {
|
||||
uni.showToast({
|
||||
title: content,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
// 错误消息
|
||||
msgError(content) {
|
||||
uni.showToast({
|
||||
title: content,
|
||||
icon: 'error'
|
||||
})
|
||||
},
|
||||
// 成功消息
|
||||
msgSuccess(content) {
|
||||
uni.showToast({
|
||||
title: content,
|
||||
icon: 'success'
|
||||
})
|
||||
},
|
||||
// 隐藏消息
|
||||
hideMsg(content) {
|
||||
uni.hideToast()
|
||||
},
|
||||
// 弹出提示
|
||||
alert(content) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: content,
|
||||
showCancel: false
|
||||
})
|
||||
},
|
||||
// 确认窗体
|
||||
confirm(content) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showModal({
|
||||
title: '系统提示',
|
||||
content: content,
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
resolve(res.confirm)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 提示信息
|
||||
showToast(option) {
|
||||
if (typeof option === "object") {
|
||||
uni.showToast(option)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: option,
|
||||
icon: "none",
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
},
|
||||
// 打开遮罩层
|
||||
loading(content) {
|
||||
uni.showLoading({
|
||||
title: content,
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
// 关闭遮罩层
|
||||
closeLoading() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
30
utilsRc/plugins/tab.js
Normal file
30
utilsRc/plugins/tab.js
Normal file
@@ -0,0 +1,30 @@
|
||||
export default {
|
||||
// 关闭所有页面,打开到应用内的某个页面
|
||||
reLaunch(url) {
|
||||
return uni.reLaunch({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 跳转到tabBar页面,并关闭其他所有非tabBar页面
|
||||
switchTab(url) {
|
||||
return uni.switchTab({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 关闭当前页面,跳转到应用内的某个页面
|
||||
redirectTo(url) {
|
||||
return uni.redirectTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 保留当前页面,跳转到应用内的某个页面
|
||||
navigateTo(url) {
|
||||
return uni.navigateTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 关闭当前页面,返回上一页面或多级页面
|
||||
navigateBack() {
|
||||
return uni.navigateBack()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user