初始化仓库

This commit is contained in:
tao
2025-12-18 14:11:48 +08:00
parent e96f277a68
commit 54ec472bd4
1107 changed files with 158756 additions and 0 deletions

60
plugins/auth.js Normal file
View 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 = "admin"
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)
})
}
}

79
plugins/config.js Normal file
View File

@@ -0,0 +1,79 @@
const COLOR = [
"#EE6A66", "#6BC588", "#FFC300", "#24ABFD"
];
var ISCANVAS2D = true;
switch (uni.getSystemInfoSync().platform) {
case 'android':
ISCANVAS2D = true
break;
case 'ios':
ISCANVAS2D = true
break;
default:
ISCANVAS2D = false
break;
}
const RESPOND = {
success: 0,
warn: 301,
error: 500,
};
const TIMEARRAY = [
{
text: '当天',
value: 'today'
},
{
text: '昨天',
value: 'yesterday'
},
{
text: '本周',
value: 'week'
},
{
text: '上周',
value: 'weeklast'
},
{
text: '本月',
value: 'month'
},
{
text: '上月',
value: 'monthlast'
},
{
text: '指定日期',
value: 'auto'
}
];
const TABLIST = [
{name:"企业微信",type:"WECHAT"},
{name:"会员运营",type:"OPERATE"},
{name:"会员健康",type:"GJJK"},
{name:"会员服务",type:"SERVICE"},
];
const CARD_MENU = [
{title:"会员报表中心",author:"howcode",img:"https://s1.ax1x.com/2023/03/31/ppRp4iV.jpg",url:"/myPackageA/pages/main/index"},
{title:"智慧教育报表中心",author:"howcode",img:"https://s1.ax1x.com/2023/03/31/ppRp5GT.jpg",url:"/myPackageA/pages/school/index"},
{title:"差旅报表中心",author:"秋云",img:"https://s1.ax1x.com/2023/03/31/ppRpfI0.jpg",url:""},
{title:"运动报表中心",author:"howcode",img:"https://s1.ax1x.com/2023/03/31/ppRpWaq.jpg",url:"/myPackageA/pages/sport/index"},
{title:"财务报表中心",author:"howcode",img:"https://s1.ax1x.com/2023/03/31/ppRpozF.jpg",url:"/myPackageA/pages/finance/index"},
]
module.exports = {
COLOR,
TIMEARRAY,
TABLIST,
RESPOND,
ISCANVAS2D,
CARD_MENU
}

20
plugins/index.js Normal file
View File

@@ -0,0 +1,20 @@
import tab from './tab'
import auth from './auth'
import time from './time'
import modal from './modal'
import config from './config.js'
export default {
install(Vue) {
// 页签操作
Vue.prototype.$tab = tab
// 认证对象
Vue.prototype.$auth = auth
// 时间对象
Vue.prototype.$time = time
// 模态框对象
Vue.prototype.$modal = modal
// 配置对象
Vue.prototype.$config = config
}
}

146
plugins/modal.js Normal file
View File

@@ -0,0 +1,146 @@
export default {
// 消息提示
msg(content) {
uni.showToast({
title: content,
icon: 'none'
})
},
// 错误消息
msgError(content) {
uni.showToast({
title: content,
icon: 'error',
mask: true,
duration: 2000,
})
},
msgFail(content) {
uni.showToast({
title: content,
icon: 'fail',
})
},
// 成功消息
msgSuccess(content, complete) {
uni.showToast({
title: content,
icon: 'success'
})
},
// 隐藏消息
hideMsg(content) {
uni.hideToast()
},
// 弹出提示
// alert(content) {
// uni.showModal({
// title: '提示',
// content: content,
// showCancel: false
// })
// },
alert(...args) {
let config = {
title: '提示',
content: '',
showCancel: false
};
// 如果第一个参数是对象,说明是完整配置
if (typeof args[0] === 'object') {
config = args[0];
}
// alert(content)
else if (args.length === 1 && typeof args[0] === 'string') {
config.content = args[0];
}
// alert(title, content)
else if (args.length === 2 && typeof args[0] === 'string' && typeof args[1] === 'string') {
config.title = args[0];
config.content = args[1];
}
// alert(title, content, success)
else if (args.length === 3 && typeof args[0] === 'string' && typeof args[1] === 'string' && typeof args[2] ===
'function') {
config.title = args[0];
config.content = args[1];
config.success = args[2];
}
// alert(content, success?, fail?, complete?)
else {
config.content = args[0];
const [success, fail, complete] = args.slice(1);
if (typeof success === 'function') config.success = success;
if (typeof fail === 'function') config.fail = fail;
if (typeof complete === 'function') config.complete = complete;
}
uni.showModal(config);
},
/*
* 使用方法
* this.$modal.scanCode((res) => {
let result = res.result;
})
*/
scanCode(...args) {
let config = {
onlyFromCamera: true,
scanType: ['barCode', 'qrCode']
}
if (args.length === 1 && typeof args[0] === 'object') {
config = args;
} else {
const [success, fail, complete] = args;
if (typeof success === 'function') config.success = success;
if (typeof fail === 'function') config.fail = fail;
if (typeof complete === 'function') config.complete = complete;
}
uni.scanCode(config);
},
// 确认窗体
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',
mask: true
})
},
// 关闭遮罩层
closeLoading() {
uni.hideLoading()
}
}

30
plugins/tab.js Normal file
View 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()
}
}

57
plugins/time.js Normal file
View File

@@ -0,0 +1,57 @@
export default {
// 格式化时间函数
getTime(format = "YYYY-MM-DD hh:mm:ss", date = new Date()) {
const pad = (num, len = 2) => num.toString().padStart(len, "0");
const parts = {
YYYY: date.getFullYear().toString(),
MM: pad(date.getMonth() + 1),
DD: pad(date.getDate()),
hh: pad(date.getHours()),
mm: pad(date.getMinutes()),
ss: pad(date.getSeconds())
};
// 分组规则:日期部分和时间部分分别检查
const datePattern = /(YYYY)([^A-Za-z]?)(MM)([^A-Za-z]?)(DD)?/;
const timePattern = /(hh)([^A-Za-z]?)(mm)([^A-Za-z]?)(ss)?/;
// 检查日期部分
const dateMatch = format.match(datePattern);
if (dateMatch) {
const dateSeps = [dateMatch[2], dateMatch[4]].filter(Boolean);
if (new Set(dateSeps).size > 1) {
console.error(
`❌ 格式错误:日期部分存在多种连接符 (${dateSeps.join(", ")})。\n👉 解决方案:请统一日期部分的连接符,例如 "YYYY-MM-DD" 或 "YYYY/MM/DD"`
);
return "";
}
}
// 检查时间部分
const timeMatch = format.match(timePattern);
if (timeMatch) {
const timeSeps = [timeMatch[2], timeMatch[4]].filter(Boolean);
if (new Set(timeSeps).size > 1) {
console.error(
`❌ 格式错误:时间部分存在多种连接符 (${timeSeps.join(", ")})。\n👉 解决方案:请统一时间部分的连接符,例如 "hh:mm:ss" 或 "hh-mm-ss"`
);
return "";
}
}
// 替换格式
let result = format;
for (const key in parts) {
result = result.replace(new RegExp(key, "g"), parts[key]);
}
return result;
},
// 获取北京时间
getBeijingTime(date = new Date()) {
const f = n => String(n).padStart(2, '0');
const t = new Date(date.toLocaleString('en-US', { timeZone: 'Asia/Shanghai' }));
return `${t.getFullYear()}-${f(t.getMonth()+1)}-${f(t.getDate())} ${f(t.getHours())}:${f(t.getMinutes())}:${f(t.getSeconds())}`;
}
}