refactor(projects): 精简版+动态路由权限初步

This commit is contained in:
Soybean
2022-01-03 22:20:10 +08:00
parent 7a0648dba5
commit de2057f141
354 changed files with 2053 additions and 22117 deletions

View File

@ -1,46 +0,0 @@
interface BrowserInfo {
type: string;
version: string;
}
/** 获取浏览器版本信息 */
export function getBrowserInfo() {
const explorer = window.navigator.userAgent.toLowerCase();
const info: BrowserInfo = {
type: '',
version: ''
};
function setInfo(data: BrowserInfo) {
Object.assign(info, data);
}
// ie
if (explorer.indexOf('msie') >= 0) {
const [version] = explorer.match(/msie ([\d.]+)/) || [''];
setInfo({ type: 'IE', version });
}
// firefox
if (explorer.indexOf('firefox') >= 0) {
const [version] = explorer.match(/firefox\/([\d.]+)/) || [''];
setInfo({ type: 'Firefox', version });
}
// Chrome
if (explorer.indexOf('chrome') >= 0) {
const [version] = explorer.match(/chrome\/([\d.]+)/) || [''];
setInfo({ type: 'Chrome', version });
if (explorer.indexOf('qqbrowser') >= 0) {
const [version] = explorer.match(/qqbrowser\/([\d.]+)/) || [''];
setInfo({ type: 'QQ浏览器', version });
}
}
// Opera
if (explorer.indexOf('opera') >= 0) {
const [version] = explorer.match(/opera.([\d.]+)/) || [''];
setInfo({ type: 'Opera', version });
}
// Safari
if (explorer.indexOf('Safari') >= 0) {
const [version] = explorer.match(/version\/([\d.]+)/) || [''];
setInfo({ type: 'Safari', version });
}
return info;
}

View File

@ -1,38 +0,0 @@
import chroma from 'chroma-js';
/**
* 更亮的颜色
* @param color - 颜色
* @param deep - 效果层次
*/
export function brightenColor(color: string, deep: number = 0.5) {
return chroma(color).brighten(deep).hex();
}
/**
* 更暗的颜色
* @param color - 颜色
* @param deep - 效果层次
*/
export function darkenColor(color: string, deep: number = 0.5) {
return chroma(color).darken(deep).hex();
}
/**
* 给颜色加透明度
* @param color - 颜色
* @param alpha - 透明度
*/
export function addColorAlpha(color: string, alpha: number) {
return chroma(color).alpha(alpha).hex();
}
/**
* 颜色混合
* @param firstColor - 第一个颜色
* @param secondColor - 第二个颜色
* @param ratio - 第二个颜色占比
*/
export function mixColor(firstColor: string, secondColor: string, ratio: number) {
return chroma.mix(firstColor, secondColor, ratio).hex();
}

View File

@ -0,0 +1,10 @@
/** 执行策略模式 */
export function exeStrategyActions(actions: Common.StrategyAction[]) {
actions.some(item => {
const [flag, action] = item;
if (flag) {
action();
}
return flag;
});
}

View File

@ -1,19 +0,0 @@
import { h } from 'vue';
import { Icon } from '@iconify/vue';
/**
* 动态渲染iconify
* @param icon - 图标名称
* @param color - 图标颜色
* @param size - 图标大小
*/
export function iconifyRender(icon: string, color?: string, size?: number) {
const style: { color?: string; size?: string } = {};
if (color) {
style.color = color;
}
if (size) {
style.size = `${size}px`;
}
return () => h(Icon, { icon, style });
}

View File

@ -1,6 +1,3 @@
export * from './typeof';
export * from './color';
export * from './icon';
export * from './browser';
export * from './console';
export * from './number';
export * from './design-pattern';

View File

@ -1,10 +0,0 @@
/**
* 获取指定整数范围内的随机整数
* @param start - 开始范围
* @param end - 结束范围
*/
export function getRandomInterger(end: number, start: number = 0) {
const range = end - start;
const random = Math.floor(Math.random() * range + start);
return random;
}