代码格式化格式调整

pull/170/head^2
zhangdaiscott 2022-09-22 14:05:12 +08:00
parent ba98c26b01
commit 5f5207b4aa
32 changed files with 381 additions and 216 deletions

View File

@ -30,7 +30,12 @@ export function getThemeColors(color?: string) {
return [...lightColors, ...modeColors]; return [...lightColors, ...modeColors];
} }
export function generateColors({ color = primaryColor, mixLighten, mixDarken, tinycolor }: GenerateColorsParams) { export function generateColors({
color = primaryColor,
mixLighten,
mixDarken,
tinycolor,
}: GenerateColorsParams) {
const arr = new Array(19).fill(0); const arr = new Array(19).fill(0);
const lightens = arr.map((_t, i) => { const lightens = arr.map((_t, i) => {
return mixLighten(color, i / 5); return mixLighten(color, i / 5);
@ -63,5 +68,12 @@ export function generateColors({ color = primaryColor, mixLighten, mixDarken, ti
.toHexString(); .toHexString();
}) })
.filter((item) => item !== '#000000'); .filter((item) => item !== '#000000');
return [...lightens, ...darkens, ...alphaColors, ...shortAlphaColors, ...tinycolorDarkens, ...tinycolorLightens].filter((item) => !item.includes('-')); return [
...lightens,
...darkens,
...alphaColors,
...shortAlphaColors,
...tinycolorDarkens,
...tinycolorLightens,
].filter((item) => !item.includes('-'));
} }

View File

@ -9,7 +9,12 @@ export function resultSuccess<T = Recordable>(result: T, { message = 'ok' } = {}
}; };
} }
export function resultPageSuccess<T = any>(pageNo: number, pageSize: number, list: T[], { message = 'ok' } = {}) { export function resultPageSuccess<T = any>(
pageNo: number,
pageSize: number,
list: T[],
{ message = 'ok' } = {}
) {
const pageData = pagination(pageNo, pageSize, list); const pageData = pagination(pageNo, pageSize, list);
return { return {
@ -32,7 +37,10 @@ export function resultError(message = 'Request failed', { code = -1, result = nu
export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]): T[] { export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]): T[] {
const offset = (pageNo - 1) * Number(pageSize); const offset = (pageNo - 1) * Number(pageSize);
const ret = offset + Number(pageSize) >= array.length ? array.slice(offset, array.length) : array.slice(offset, offset + Number(pageSize)); const ret =
offset + Number(pageSize) >= array.length
? array.slice(offset, array.length)
: array.slice(offset, offset + Number(pageSize));
return ret; return ret;
} }

View File

@ -20,9 +20,9 @@ export default [
timeout: 1000, timeout: 1000,
method: 'get', method: 'get',
response: ({ query }) => { response: ({ query }) => {
const { keyword, count } = query; const { keyword,count} = query;
console.log(keyword); console.log(keyword);
return resultSuccess(demoList(keyword, count)); return resultSuccess(demoList(keyword,count));
}, },
}, },
] as MockMethod[]; ] as MockMethod[];

View File

@ -2,183 +2,196 @@ import { MockMethod } from 'vite-plugin-mock';
import { resultError, resultPageSuccess, resultSuccess, baseUrl } from '../_util'; import { resultError, resultPageSuccess, resultSuccess, baseUrl } from '../_util';
const accountList = (() => { const accountList = (() => {
const result: any[] = []; const result: any[] = [];
for (let index = 0; index < 20; index++) { for (let index = 0; index < 20; index++) {
result.push({ result.push({
id: `${index}`, id: `${index}`,
account: '@first', account: '@first',
email: '@email', email: '@email',
nickname: '@cname()', nickname: '@cname()',
role: '@first', role: '@first',
createTime: '@datetime',
remark: '@cword(10,20)',
'status|1': ['0', '1'],
});
}
return result;
})();
const userList = (() => {
const result: any[] = [];
for (let index = 0; index < 20; index++) {
result.push({
id: `${index}`,
username: '@first',
email: '@email',
realname: '@cname()',
createTime: '@datetime',
remark: '@cword(10,20)',
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640',
});
}
return result;
})();
const roleList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
roleValue: '@first',
createTime: '@datetime',
remark: '@cword(10,20)',
menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index],
'status|1': ['0', '1'],
});
}
return result;
})();
const newRoleList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
roleCode: '@first',
createTime: '@datetime',
remark: '@cword(10,20)',
});
}
return result;
})();
const testList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
testName: ['数据1', '数据2', '数据3', '数据4'][index],
testValue: '@first',
createTime: '@datetime',
});
}
return result;
})();
const tableDemoList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderCode: '2008200' + `${index + 1}`,
orderMoney: '@natural(1000,3000)',
ctype: '@natural(1,2)',
content: '@cword(10,20)',
orderDate: '@datetime',
});
}
return result;
})();
const deptList = (() => {
const result: any[] = [];
for (let index = 0; index < 3; index++) {
result.push({
id: `${index}`,
deptName: ['华东分部', '华南分部', '西北分部'][index],
orderNo: index + 1,
createTime: '@datetime',
remark: '@cword(10,20)',
'status|1': ['0', '0', '1'],
children: (() => {
const children: any[] = [];
for (let j = 0; j < 4; j++) {
children.push({
id: `${index}-${j}`,
deptName: ['研发部', '市场部', '商务部', '财务部'][j],
orderNo: j + 1,
createTime: '@datetime', createTime: '@datetime',
remark: '@cword(10,20)', remark: '@cword(10,20)',
'status|1': ['0', '1'], 'status|1': ['0', '1'],
parentDept: `${index}`, });
children: undefined, }
}); return result;
} })();
return children;
})(), const userList = (() => {
}); const result: any[] = [];
} for (let index = 0; index < 20; index++) {
return result; result.push({
id: `${index}`,
username: '@first',
email: '@email',
realname: '@cname()',
createTime: '@datetime',
remark: '@cword(10,20)',
avatar: 'https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640'
});
}
return result;
})();
const roleList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
roleValue: '@first',
createTime: '@datetime',
remark: '@cword(10,20)',
menu: [['0', '1', '2'], ['0', '1'], ['0', '2'], ['2']][index],
'status|1': ['0', '1'],
});
}
return result;
})();
const newRoleList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
roleCode: '@first',
createTime: '@datetime',
remark: '@cword(10,20)'
});
}
return result;
})();
const testList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderNo: `${index + 1}`,
testName: ['数据1', '数据2', '数据3', '数据4'][index],
testValue: '@first',
createTime: '@datetime'
});
}
return result;
})();
const tableDemoList = (() => {
const result: any[] = [];
for (let index = 0; index < 4; index++) {
result.push({
id: index + 1,
orderCode: '2008200' + `${index + 1}`,
orderMoney: '@natural(1000,3000)',
ctype: '@natural(1,2)',
content: '@cword(10,20)',
orderDate: '@datetime'
});
}
return result;
})();
const deptList = (() => {
const result: any[] = [];
for (let index = 0; index < 3; index++) {
result.push({
id: `${index}`,
deptName: ['华东分部', '华南分部', '西北分部'][index],
orderNo: index + 1,
createTime: '@datetime',
remark: '@cword(10,20)',
'status|1': ['0', '0', '1'],
children: (() => {
const children: any[] = [];
for (let j = 0; j < 4; j++) {
children.push({
id: `${index}-${j}`,
deptName: ['研发部', '市场部', '商务部', '财务部'][j],
orderNo: j + 1,
createTime: '@datetime',
remark: '@cword(10,20)',
'status|1': ['0', '1'],
parentDept: `${index}`,
children: undefined,
});
}
return children;
})(),
});
}
return result;
})(); })();
const menuList = (() => { const menuList = (() => {
const result: any[] = []; const result: any[] = [];
for (let index = 0; index < 3; index++) { for (let index = 0; index < 3; index++) {
result.push({ result.push({
id: `${index}`, id: `${index}`,
icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index], icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index],
component: 'LAYOUT', component: 'LAYOUT',
type: '0', type: '0',
menuName: ['Dashboard', '权限管理', '功能'][index], menuName: ['Dashboard', '权限管理', '功能'][index],
permission: '', permission: '',
orderNo: index + 1, orderNo: index + 1,
createTime: '@datetime',
'status|1': ['0', '0', '1'],
children: (() => {
const children: any[] = [];
for (let j = 0; j < 4; j++) {
children.push({
id: `${index}-${j}`,
type: '1',
menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
icon: 'ion:document',
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j],
orderNo: j + 1,
createTime: '@datetime', createTime: '@datetime',
'status|1': ['0', '1'], 'status|1': ['0', '0', '1'],
parentMenu: `${index}`,
children: (() => { children: (() => {
const children: any[] = []; const children: any[] = [];
for (let k = 0; k < 4; k++) { for (let j = 0; j < 4; j++) {
children.push({ children.push({
id: `${index}-${j}-${k}`, id: `${index}-${j}`,
type: '2', type: '1',
menuName: '按钮' + (j + 1) + '-' + (k + 1), menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
icon: '', icon: 'ion:document',
permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] + ':btn' + (k + 1), permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
component: ['/dashboard/welcome/index', '/dashboard/Analysis/index', '/dashboard/workbench/index', '/dashboard/test/index'][j], component: [
orderNo: j + 1, '/dashboard/welcome/index',
createTime: '@datetime', '/dashboard/Analysis/index',
'status|1': ['0', '1'], '/dashboard/workbench/index',
parentMenu: `${index}-${j}`, '/dashboard/test/index',
children: undefined, ][j],
}); orderNo: j + 1,
} createTime: '@datetime',
return children; 'status|1': ['0', '1'],
parentMenu: `${index}`,
children: (() => {
const children: any[] = [];
for (let k = 0; k < 4; k++) {
children.push({
id: `${index}-${j}-${k}`,
type: '2',
menuName: '按钮' + (j + 1) + '-' + (k + 1),
icon: '',
permission:
['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index] +
':btn' +
(k + 1),
component: [
'/dashboard/welcome/index',
'/dashboard/Analysis/index',
'/dashboard/workbench/index',
'/dashboard/test/index',
][j],
orderNo: j + 1,
createTime: '@datetime',
'status|1': ['0', '1'],
parentMenu: `${index}-${j}`,
children: undefined,
});
}
return children;
})(),
});
}
return children;
})(), })(),
}); });
} }
return children; return result;
})(),
});
}
return result;
})(); })();
export default [ export default [

View File

@ -1,4 +1,4 @@
import { resultSuccess, resultError, getRequestToken, requestParams, baseUrl } from '../_util'; import { resultSuccess, resultError, getRequestToken, requestParams,baseUrl} from '../_util';
import { MockMethod } from 'vite-plugin-mock'; import { MockMethod } from 'vite-plugin-mock';
import { createFakeUserList } from './user'; import { createFakeUserList } from './user';

View File

@ -51,7 +51,9 @@ export default [
method: 'post', method: 'post',
response: ({ body }) => { response: ({ body }) => {
const { username, password } = body; const { username, password } = body;
const checkUser = createFakeUserList().find((item) => item.username === username && password === item.password); const checkUser = createFakeUserList().find(
(item) => item.username === username && password === item.password
);
if (!checkUser) { if (!checkUser) {
return resultError('Incorrect account or password'); return resultError('Incorrect account or password');
} }

View File

@ -1,5 +1,5 @@
module.exports = { module.exports = {
printWidth: 200, printWidth: 150,
tabWidth: 2, tabWidth: 2,
useTabs: false, useTabs: false,
semi: true, //语句末尾使用分号 semi: true, //语句末尾使用分号

View File

@ -3,7 +3,14 @@
* @Description: Multi-language switching component * @Description: Multi-language switching component
--> -->
<template> <template>
<Dropdown placement="bottomCenter" :trigger="['click']" :dropMenuList="localeList" :selectedKeys="selectedKeys" @menuEvent="handleMenuEvent" overlayClassName="app-locale-picker-overlay"> <Dropdown
placement="bottom"
:trigger="['click']"
:dropMenuList="localeList"
:selectedKeys="selectedKeys"
@menuEvent="handleMenuEvent"
overlayClassName="app-locale-picker-overlay"
>
<span class="cursor-pointer flex items-center"> <span class="cursor-pointer flex items-center">
<Icon icon="ion:language" /> <Icon icon="ion:language" />
<span v-if="showText" class="ml-1">{{ getLocaleText }}</span> <span v-if="showText" class="ml-1">{{ getLocaleText }}</span>

View File

@ -10,7 +10,9 @@
<div class="flex justify-end space-x-2" <div class="flex justify-end space-x-2"
><slot name="header"></slot> ><slot name="header"></slot>
<Tooltip> <Tooltip>
<template #title> <div class="w-50">每行显示数量</div><Slider id="slider" v-bind="sliderProp" v-model:value="grid" @change="sliderChange" /></template> <template #title>
<div class="w-50">每行显示数量</div><Slider id="slider" v-bind="sliderProp" v-model:value="grid" @change="sliderChange"
/></template>
<Button><TableOutlined /></Button> <Button><TableOutlined /></Button>
</Tooltip> </Tooltip>
<Tooltip @click="fetch"> <Tooltip @click="fetch">

View File

@ -1,5 +1,13 @@
<template> <template>
<BasicModal v-bind="$attrs" @register="register" :title="t('component.cropper.modalTitle')" width="800px" :canFullscreen="false" @ok="handleOk" :okText="t('component.cropper.okText')"> <BasicModal
v-bind="$attrs"
@register="register"
:title="t('component.cropper.modalTitle')"
width="800px"
:canFullscreen="false"
@ok="handleOk"
:okText="t('component.cropper.okText')"
>
<div :class="prefixCls"> <div :class="prefixCls">
<div :class="`${prefixCls}-left`"> <div :class="`${prefixCls}-left`">
<div :class="`${prefixCls}-cropper`"> <div :class="`${prefixCls}-cropper`">
@ -17,10 +25,22 @@
<a-button type="primary" preIcon="ant-design:reload-outlined" size="small" :disabled="!src" @click="handlerToolbar('reset')" /> <a-button type="primary" preIcon="ant-design:reload-outlined" size="small" :disabled="!src" @click="handlerToolbar('reset')" />
</Tooltip> </Tooltip>
<Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom"> <Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom">
<a-button type="primary" preIcon="ant-design:rotate-left-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', -45)" /> <a-button
type="primary"
preIcon="ant-design:rotate-left-outlined"
size="small"
:disabled="!src"
@click="handlerToolbar('rotate', -45)"
/>
</Tooltip> </Tooltip>
<Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom"> <Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom">
<a-button type="primary" preIcon="ant-design:rotate-right-outlined" size="small" :disabled="!src" @click="handlerToolbar('rotate', 45)" /> <a-button
type="primary"
preIcon="ant-design:rotate-right-outlined"
size="small"
:disabled="!src"
@click="handlerToolbar('rotate', 45)"
/>
</Tooltip> </Tooltip>
<Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom"> <Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom">
<a-button type="primary" preIcon="vaadin:arrows-long-h" size="small" :disabled="!src" @click="handlerToolbar('scaleX')" /> <a-button type="primary" preIcon="vaadin:arrows-long-h" size="small" :disabled="!src" @click="handlerToolbar('scaleX')" />

View File

@ -6,7 +6,12 @@
<template #overlay> <template #overlay>
<a-menu :class="[`${prefixCls}-menu`]" :selectedKeys="selectedKeys"> <a-menu :class="[`${prefixCls}-menu`]" :selectedKeys="selectedKeys">
<template v-for="item in dropMenuList" :key="`${item.event}`"> <template v-for="item in dropMenuList" :key="`${item.event}`">
<a-menu-item v-bind="getAttr(item.event)" @click="handleClickMenu(item)" :disabled="item.disabled" :class="[{ 'is-pop-confirm': item.popConfirm }, item.class ?? []]"> <a-menu-item
v-bind="getAttr(item.event)"
@click="handleClickMenu(item)"
:disabled="item.disabled"
:class="[{ 'is-pop-confirm': item.popConfirm }, (item.class ?? [])]"
>
<a-popconfirm v-if="popconfirm && item.popConfirm" v-bind="getPopConfirmAttrs(item.popConfirm)"> <a-popconfirm v-if="popconfirm && item.popConfirm" v-bind="getPopConfirmAttrs(item.popConfirm)">
<template #icon v-if="item.popConfirm.icon"> <template #icon v-if="item.popConfirm.icon">
<Icon :icon="item.popConfirm.icon" /> <Icon :icon="item.popConfirm.icon" />

View File

@ -4,7 +4,22 @@ import type { ComponentType } from './types/index';
/** /**
* Component list, register here to setting it in the form * Component list, register here to setting it in the form
*/ */
import { Input, Select, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, TreeSelect, Slider, Rate, Divider } from 'ant-design-vue'; import {
Input,
Select,
Radio,
Checkbox,
AutoComplete,
Cascader,
DatePicker,
InputNumber,
Switch,
TimePicker,
TreeSelect,
Slider,
Rate,
Divider,
} from 'ant-design-vue';
import ApiRadioGroup from './components/ApiRadioGroup.vue'; import ApiRadioGroup from './components/ApiRadioGroup.vue';
import RadioButtonGroup from './components/RadioButtonGroup.vue'; import RadioButtonGroup from './components/RadioButtonGroup.vue';
import ApiSelect from './components/ApiSelect.vue'; import ApiSelect from './components/ApiSelect.vue';

View File

@ -16,7 +16,13 @@ export function createPlaceholderMessage(component: ComponentType) {
if (component.includes('Picker')) { if (component.includes('Picker')) {
return t('common.chooseText'); return t('common.chooseText');
} }
if (component.includes('Select') || component.includes('Cascader') || component.includes('Checkbox') || component.includes('Radio') || component.includes('Switch')) { if (
component.includes('Select') ||
component.includes('Cascader') ||
component.includes('Checkbox') ||
component.includes('Radio') ||
component.includes('Switch')
) {
// return `请选择${label}`; // return `请选择${label}`;
return t('common.chooseText'); return t('common.chooseText');
} }

View File

@ -57,7 +57,8 @@ export default function ({ advanceState, emit, getProps, getSchema, formModel, d
function getAdvanced(itemCol: Partial<ColEx>, itemColSum = 0, isLastAction = false, index = 0) { function getAdvanced(itemCol: Partial<ColEx>, itemColSum = 0, isLastAction = false, index = 0) {
const width = unref(realWidthRef); const width = unref(realWidthRef);
const mdWidth = parseInt(itemCol.md as string) || parseInt(itemCol.xs as string) || parseInt(itemCol.sm as string) || (itemCol.span as number) || BASIC_COL_LEN; const mdWidth =
parseInt(itemCol.md as string) || parseInt(itemCol.xs as string) || parseInt(itemCol.sm as string) || (itemCol.span as number) || BASIC_COL_LEN;
const lgWidth = parseInt(itemCol.lg as string) || mdWidth; const lgWidth = parseInt(itemCol.lg as string) || mdWidth;
const xlWidth = parseInt(itemCol.xl as string) || lgWidth; const xlWidth = parseInt(itemCol.xl as string) || lgWidth;

View File

@ -86,8 +86,8 @@ export function useForm(props?: Props): UseFormReturnType {
getFieldsValue: <T>() => { getFieldsValue: <T>() => {
//update-begin-author:taoyan date:2022-7-5 for: VUEN-1341【流程】编码方式 流程节点编辑表单时,填写数据报错 包括用户组件、部门组件、省市区 //update-begin-author:taoyan date:2022-7-5 for: VUEN-1341【流程】编码方式 流程节点编辑表单时,填写数据报错 包括用户组件、部门组件、省市区
let values = unref(formRef)?.getFieldsValue() as T; let values = unref(formRef)?.getFieldsValue() as T;
if (values) { if(values){
Object.keys(values).map((key) => { Object.keys(values).map(key=>{
if (values[key] instanceof Array) { if (values[key] instanceof Array) {
values[key] = values[key].join(','); values[key] = values[key].join(',');
} }

View File

@ -19,7 +19,16 @@ interface UseFormActionContext {
schemaRef: Ref<FormSchema[]>; schemaRef: Ref<FormSchema[]>;
handleFormValues: Fn; handleFormValues: Fn;
} }
export function useFormEvents({ emit, getProps, formModel, getSchema, defaultValueRef, formElRef, schemaRef, handleFormValues }: UseFormActionContext) { export function useFormEvents({
emit,
getProps,
formModel,
getSchema,
defaultValueRef,
formElRef,
schemaRef,
handleFormValues,
}: UseFormActionContext) {
async function resetFields(): Promise<void> { async function resetFields(): Promise<void> {
const { resetFunc, submitOnReset } = unref(getProps); const { resetFunc, submitOnReset } = unref(getProps);
resetFunc && isFunction(resetFunc) && (await resetFunc()); resetFunc && isFunction(resetFunc) && (await resetFunc());
@ -48,6 +57,11 @@ export function useFormEvents({ emit, getProps, formModel, getSchema, defaultVal
const schema = unref(getSchema).find((item) => item.field === key); const schema = unref(getSchema).find((item) => item.field === key);
let value = values[key]; let value = values[key];
//antd3升级后online表单时间控件选中值报js错 TypeError: Reflect.has called on non-object
if(!(values instanceof Object)){
return;
}
const hasKey = Reflect.has(values, key); const hasKey = Reflect.has(values, key);
value = handleInputNumberValue(schema?.component, value); value = handleInputNumberValue(schema?.component, value);

View File

@ -1,5 +1,10 @@
<template> <template>
<section class="full-loading" :class="{ absolute, [theme]: !!theme }" :style="[background ? `background-color: ${background}` : '']" v-show="loading"> <section
class="full-loading"
:class="{ absolute, [theme]: !!theme }"
:style="[background ? `background-color: ${background}` : '']"
v-show="loading"
>
<Spin v-bind="$attrs" :tip="tip" :size="size" :spinning="loading" /> <Spin v-bind="$attrs" :tip="tip" :size="size" :spinning="loading" />
</section> </section>
</template> </template>

View File

@ -33,7 +33,12 @@
const getShowMenu = computed(() => !props.item.meta?.hideMenu); const getShowMenu = computed(() => !props.item.meta?.hideMenu);
function menuHasChildren(menuTreeItem: MenuType): boolean { function menuHasChildren(menuTreeItem: MenuType): boolean {
return !menuTreeItem.meta?.hideChildrenInMenu && Reflect.has(menuTreeItem, 'children') && !!menuTreeItem.children && menuTreeItem.children.length > 0; return (
!menuTreeItem.meta?.hideChildrenInMenu &&
Reflect.has(menuTreeItem, 'children') &&
!!menuTreeItem.children &&
menuTreeItem.children.length > 0
);
} }
return { return {
prefixCls, prefixCls,

View File

@ -45,7 +45,9 @@
let type = props.type === null ? props.value >= props.target : props.type; let type = props.type === null ? props.value >= props.target : props.type;
return type ? 'up' : 'down'; return type ? 'up' : 'down';
}); });
const rate = computed(() => (props.percentage === null ? (Math.abs(props.value - props.target) * 100) / props.target : props.percentage).toFixed(props.fixed)); const rate = computed(() =>
(props.percentage === null ? (Math.abs(props.value - props.target) * 100) / props.target : props.percentage).toFixed(props.fixed)
);
return { return {
trend, trend,
rate, rate,

View File

@ -46,7 +46,9 @@ function createDocumentHandler(el: HTMLElement, binding: DirectiveBinding): Docu
const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget); const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget);
const isSelf = el === mouseUpTarget; const isSelf = el === mouseUpTarget;
const isTargetExcluded = (excludes.length && excludes.some((item) => item?.contains(mouseUpTarget))) || (excludes.length && excludes.includes(mouseDownTarget as HTMLElement)); const isTargetExcluded =
(excludes.length && excludes.some((item) => item?.contains(mouseUpTarget))) ||
(excludes.length && excludes.includes(mouseDownTarget as HTMLElement));
const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget)); const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget));
if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) { if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) {
return; return;

View File

@ -6,7 +6,7 @@ export function useRuleFormItem<T extends Recordable, K extends keyof T, V = Unw
props: T, props: T,
key?: K, key?: K,
changeEvent?, changeEvent?,
emitData?: Ref<any[]> emitData?: Ref<any[] | undefined>
): [WritableComputedRef<V>, (val: V) => void, DeepReadonly<V>]; ): [WritableComputedRef<V>, (val: V) => void, DeepReadonly<V>];
export function useRuleFormItem<T extends Recordable>(props: T, key: keyof T = 'value', changeEvent = 'change', emitData?: Ref<any[]>) { export function useRuleFormItem<T extends Recordable>(props: T, key: keyof T = 'value', changeEvent = 'change', emitData?: Ref<any[]>) {
const instance = getCurrentInstance(); const instance = getCurrentInstance();

View File

@ -99,7 +99,8 @@ export function useMenuSetting() {
unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden)) unref(getIsTopMenu) || !unref(getShowMenu) || (unref(getSplit) && unref(getMenuHidden))
? 0 ? 0
: unref(getIsMixSidebar) : unref(getIsMixSidebar)
? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) + (unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0) ? (unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH) +
(unref(getMixSideFixed) && unref(mixSideHasChildren) ? unref(getRealWidth) : 0)
: unref(getRealWidth); : unref(getRealWidth);
return `calc(100% - ${unref(width)}px)`; return `calc(100% - ${unref(width)}px)`;

View File

@ -38,7 +38,11 @@ export function useThirdLogin() {
//第三方登录 //第三方登录
function onThirdLogin(source) { function onThirdLogin(source) {
let url = `${glob.uploadUrl}/sys/thirdLogin/render/${source}`; let url = `${glob.uploadUrl}/sys/thirdLogin/render/${source}`;
window.open(url, `login ${source}`, 'height=500, width=500, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no'); window.open(
url,
`login ${source}`,
'height=500, width=500, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no'
);
thirdType.value = source; thirdType.value = source;
thirdLoginInfo.value = {}; thirdLoginInfo.value = {};
thirdLoginState.value = false; thirdLoginState.value = false;

View File

@ -12,7 +12,14 @@ export interface CreateStorageParams extends EncryptionParams {
hasEncrypt: boolean; hasEncrypt: boolean;
timeout?: Nullable<number>; timeout?: Nullable<number>;
} }
export const createStorage = ({ prefixKey = '', storage = sessionStorage, key = cacheCipher.key, iv = cacheCipher.iv, timeout = null, hasEncrypt = true }: Partial<CreateStorageParams> = {}) => { export const createStorage = ({
prefixKey = '',
storage = sessionStorage,
key = cacheCipher.key,
iv = cacheCipher.iv,
timeout = null,
hasEncrypt = true,
}: Partial<CreateStorageParams> = {}) => {
if (hasEncrypt && [key.length, iv.length].some((item) => item !== 16)) { if (hasEncrypt && [key.length, iv.length].some((item) => item !== 16)) {
throw new Error('When hasEncrypt is true, the key or iv must be 16 bits!'); throw new Error('When hasEncrypt is true, the key or iv must be 16 bits!');
} }

View File

@ -67,7 +67,10 @@ export function colorIsDark(color: string) {
export function darken(color: string, amount: number) { export function darken(color: string, amount: number) {
color = color.indexOf('#') >= 0 ? color.substring(1, color.length) : color; color = color.indexOf('#') >= 0 ? color.substring(1, color.length) : color;
amount = Math.trunc((255 * amount) / 100); amount = Math.trunc((255 * amount) / 100);
return `#${subtractLight(color.substring(0, 2), amount)}${subtractLight(color.substring(2, 4), amount)}${subtractLight(color.substring(4, 6), amount)}`; return `#${subtractLight(color.substring(0, 2), amount)}${subtractLight(color.substring(2, 4), amount)}${subtractLight(
color.substring(4, 6),
amount
)}`;
} }
/** /**

View File

@ -20,7 +20,9 @@ export const rules = {
} }
if ( if (
value && value &&
!new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/).test(value) !new RegExp(
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
).test(value)
) { ) {
return Promise.reject('请输入正确邮箱格式!'); return Promise.reject('请输入正确邮箱格式!');
} }

View File

@ -92,7 +92,9 @@ export class VAxios {
}, undefined); }, undefined);
// 请求拦截器错误捕获 // 请求拦截器错误捕获
requestInterceptorsCatch && isFunction(requestInterceptorsCatch) && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch); requestInterceptorsCatch &&
isFunction(requestInterceptorsCatch) &&
this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
// 响应结果拦截器处理 // 响应结果拦截器处理
this.axiosInstance.interceptors.response.use((res: AxiosResponse<any>) => { this.axiosInstance.interceptors.response.use((res: AxiosResponse<any>) => {
@ -104,7 +106,9 @@ export class VAxios {
}, undefined); }, undefined);
// 响应结果拦截器错误捕获 // 响应结果拦截器错误捕获
responseInterceptorsCatch && isFunction(responseInterceptorsCatch) && this.axiosInstance.interceptors.response.use(undefined, responseInterceptorsCatch); responseInterceptorsCatch &&
isFunction(responseInterceptorsCatch) &&
this.axiosInstance.interceptors.response.use(undefined, responseInterceptorsCatch);
} }
/** /**
@ -243,4 +247,25 @@ export class VAxios {
}); });
}); });
} }
/**
* -
* @param url
* @param formData
*/
uploadMyFile<T = any>(url, formData) {
const glob = useGlobSetting();
return this.axiosInstance
.request<T>({
url: url,
baseURL: glob.uploadUrl,
method: 'POST',
data: formData,
headers: {
'Content-type': ContentTypeEnum.FORM_DATA,
ignoreCancelToken: true,
},
});
}
} }

View File

@ -175,6 +175,7 @@ const transform: AxiosTransform = {
} }
// update-end--author:sunjianlei---date:20220624--for: 添加低代码应用ID // update-end--author:sunjianlei---date:20220624--for: 添加低代码应用ID
// ======================================================================================== // ========================================================================================
} }
return config; return config;
}, },

View File

@ -293,6 +293,7 @@ export function importViewsFile(path): Promise<any> {
} }
//update-end-author:taoyan date:2022-6-8 for:解决老的vue2动态导入文件语法 vite不支持的问题 //update-end-author:taoyan date:2022-6-8 for:解决老的vue2动态导入文件语法 vite不支持的问题
/** /**
* *
* @param url * @param url
@ -301,13 +302,13 @@ export function importViewsFile(path): Promise<any> {
*/ */
export function goJmReportViewPage(url, id, token) { export function goJmReportViewPage(url, id, token) {
// URL支持{{ window.xxx }}占位符变量 // URL支持{{ window.xxx }}占位符变量
url = url.replace(/{{([^}]+)?}}/g, (_s1, s2) => eval(s2)); url = url.replace(/{{([^}]+)?}}/g, (_s1, s2) => eval(s2))
if (url.includes('?')) { if (url.includes('?')) {
url += '&'; url += '&'
} else { } else {
url += '?'; url += '?'
} }
url += `id=${id}`; url += `id=${id}`
url += `&token=${token}`; url += `&token=${token}`
window.open(url); window.open(url)
} }

View File

@ -102,6 +102,7 @@ export const isServer = typeof window === 'undefined';
export const isClient = !isServer; export const isClient = !isServer;
export function isUrl(path: string): boolean { export function isUrl(path: string): boolean {
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; const reg =
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
return reg.test(path); return reg.test(path);
} }

9
types/config.d.ts vendored
View File

@ -1,5 +1,12 @@
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum'; import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
import { ContentEnum, PermissionModeEnum, ThemeEnum, RouterTransitionEnum, SettingButtonPositionEnum, SessionTimeoutProcessingEnum } from '/@/enums/appEnum'; import {
ContentEnum,
PermissionModeEnum,
ThemeEnum,
RouterTransitionEnum,
SettingButtonPositionEnum,
SessionTimeoutProcessingEnum,
} from '/@/enums/appEnum';
import { CacheTypeEnum } from '/@/enums/cacheEnum'; import { CacheTypeEnum } from '/@/enums/cacheEnum';

6
types/module.d.ts vendored
View File

@ -10,12 +10,6 @@ declare module 'ant-design-vue/es/locale/*' {
export default locale as Locale & ReadonlyRecordable; export default locale as Locale & ReadonlyRecordable;
} }
declare module 'moment/dist/locale/*' {
import { LocaleSpecification } from 'moment';
const locale: LocaleSpecification & ReadonlyRecordable;
export default locale;
}
declare module 'virtual:*' { declare module 'virtual:*' {
const result: any; const result: any;
export default result; export default result;