refactor: @vben/shared

This commit is contained in:
vben 2023-04-08 00:01:05 +08:00
parent 70e44af191
commit 4cddaee88a
107 changed files with 287 additions and 275 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v18

View File

@ -2,6 +2,7 @@ dist
.local .local
.output.js .output.js
node_modules node_modules
.nvmrc
**/*.svg **/*.svg
**/*.sh **/*.sh

View File

@ -165,7 +165,7 @@
"*.tsx": "$(capture).test.ts, $(capture).test.tsx", "*.tsx": "$(capture).test.ts, $(capture).test.tsx",
"*.env": "$(capture).env.*", "*.env": "$(capture).env.*",
"CHANGELOG.md": "CHANGELOG*", "CHANGELOG.md": "CHANGELOG*",
"package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,README*,.npmrc,.browserslistrc", "package.json": "pnpm-lock.yaml,pnpm-workspace.yaml,LICENSE,.gitattributes,.gitignore,.gitpod.yml,CNAME,README*,.npmrc,.browserslistrc,.nvmrc",
".eslintrc.js": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.js,.prettierrc.js,.stylelintrc.js" ".eslintrc.js": ".eslintignore,.prettierignore,.stylelintignore,.commitlintrc.js,.prettierrc.js,.stylelintrc.js"
}, },
"terminal.integrated.scrollback": 10000 "terminal.integrated.scrollback": 10000

View File

@ -63,6 +63,7 @@ export default {
'vue/attribute-hyphenation': 'off', 'vue/attribute-hyphenation': 'off',
'vue/require-default-prop': 'off', 'vue/require-default-prop': 'off',
'vue/require-explicit-emits': 'off', 'vue/require-explicit-emits': 'off',
'vue/prefer-import-from-vue': 'off',
'vue/html-self-closing': [ 'vue/html-self-closing': [
'error', 'error',
{ {

View File

@ -1,10 +1,13 @@
export default { export default {
extends: ['@vben'], extends: ['@vben', 'plugin:import/recommended'],
plugins: ['simple-import-sort'], plugins: ['simple-import-sort'],
rules: { rules: {
'object-shorthand': ['error', 'always', { ignoreConstructors: false, avoidQuotes: true }],
'import/no-unresolved': 'off',
'simple-import-sort/imports': 'error', 'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error', 'simple-import-sort/exports': 'error',
'@typescript-eslint/ban-ts-comment': [ '@typescript-eslint/ban-ts-comment': [
'error', 'error',
{ {
@ -54,4 +57,10 @@ export default {
'vue/attributes-order': 'error', 'vue/attributes-order': 'error',
'vue/require-default-prop': 'error', 'vue/require-default-prop': 'error',
}, },
settings: {
'import/resolver': {
node: { extensions: ['.ts', '.d.ts', '.tsx'] },
},
},
}; };

View File

@ -71,7 +71,8 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
output: { output: {
manualChunks: { manualChunks: {
vue: ['vue', 'pinia', 'vue-router'], vue: ['vue', 'pinia', 'vue-router'],
antd: ['ant-design-vue', '@ant-design/icons-vue'], // antd: ['ant-design-vue', '@ant-design/icons-vue'],
// vxe: ['vxe-table', 'vxe-table-plugin-export-xlsx', 'xe-utils'],
}, },
}, },
}, },

View File

@ -71,6 +71,7 @@
"@logicflow/core": "^1.2.1", "@logicflow/core": "^1.2.1",
"@logicflow/extension": "^1.2.1", "@logicflow/extension": "^1.2.1",
"@vben/hooks": "workspace:*", "@vben/hooks": "workspace:*",
"@vben/shared": "workspace:*",
"@vue/shared": "^3.2.47", "@vue/shared": "^3.2.47",
"@vueuse/core": "^9.13.0", "@vueuse/core": "^9.13.0",
"@vueuse/shared": "^9.13.0", "@vueuse/shared": "^9.13.0",

View File

@ -28,6 +28,10 @@
"clean": "pnpm rimraf .turbo node_modules dist", "clean": "pnpm rimraf .turbo node_modules dist",
"lint": "pnpm eslint ." "lint": "pnpm eslint ."
}, },
"dependencies": {}, "dependencies": {
"devDependencies": {} "vue": "^3.2.47"
},
"devDependencies": {
"@vue/shared": "^3.2.47"
}
} }

View File

@ -0,0 +1 @@
export * from './types';

View File

@ -0,0 +1,75 @@
import { isArray, isFunction, isObject, isString } from '@vue/shared';
import { isBoolean, isNumber } from '@vueuse/core';
const toString = Object.prototype.toString;
function is(val: unknown, type: string) {
return toString.call(val) === `[object ${type}]`;
}
function isUndefined(val: unknown): val is undefined {
return val === undefined;
}
function isNull(val: unknown): val is null {
return val === null;
}
function isNullOrUndefined(val: unknown): val is undefined | null {
return isUndefined(val) || isNull(val);
}
function isEmpty<T = unknown>(val: T): val is T {
if (!val && val !== 0) {
return true;
}
if (isArray(val) || isString(val)) {
return val.length === 0;
}
if (val instanceof Map || val instanceof Set) {
return val.size === 0;
}
if (isObject(val)) {
return Object.keys(val).length === 0;
}
return false;
}
/**
* url类型 http/http,
* @param pathname
* @returns
*/
function isHttpUrl(pathname: string): boolean {
const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/;
return reg.test(pathname);
}
function isMap(val: unknown): val is Map<any, any> {
return is(val, 'Map');
}
function isWindow(val: any): val is Window {
return typeof window !== 'undefined' && is(val, 'Window');
}
export {
is,
isArray,
isBoolean,
isEmpty,
isFunction,
isHttpUrl,
isMap,
isNull,
isNullOrUndefined,
isNumber,
isObject,
isString,
isUndefined,
isWindow,
};

View File

@ -19,6 +19,9 @@ importers:
'@vben/hooks': '@vben/hooks':
specifier: workspace:* specifier: workspace:*
version: link:packages/hooks version: link:packages/hooks
'@vben/shared':
specifier: workspace:*
version: link:packages/shared
'@vue/shared': '@vue/shared':
specifier: ^3.2.47 specifier: ^3.2.47
version: 3.2.47 version: 3.2.47
@ -471,7 +474,15 @@ importers:
specifier: workspace:* specifier: workspace:*
version: link:../types version: link:../types
packages/shared: {} packages/shared:
dependencies:
vue:
specifier: ^3.2.47
version: 3.2.47
devDependencies:
'@vue/shared':
specifier: ^3.2.47
version: 3.2.47
packages/types: packages/types:
dependencies: dependencies:

View File

@ -6,6 +6,7 @@ import { cloneDeep } from 'lodash-es';
import { filter, forEach } from '/@/utils/helper/treeHelper'; import { filter, forEach } from '/@/utils/helper/treeHelper';
import { useGo } from '/@/hooks/web/usePage'; import { useGo } from '/@/hooks/web/usePage';
import { useScrollTo } from '@vben/hooks'; import { useScrollTo } from '@vben/hooks';
import { isArray } from '@vben/shared';
import { onKeyStroke, useDebounceFn } from '@vueuse/core'; import { onKeyStroke, useDebounceFn } from '@vueuse/core';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
@ -73,7 +74,7 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref, emit: A
icon, icon,
}); });
} }
if (!meta?.hideChildrenInMenu && Array.isArray(children) && children.length) { if (!meta?.hideChildrenInMenu && isArray(children) && children.length) {
ret.push(...handlerSearchResult(children, reg, item)); ret.push(...handlerSearchResult(children, reg, item));
} }
}); });
@ -110,7 +111,7 @@ export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref, emit: A
// the scroll bar needs to scroll automatically // the scroll bar needs to scroll automatically
function handleScroll() { function handleScroll() {
const refList = unref(refs); const refList = unref(refs);
if (!refList || !Array.isArray(refList) || refList.length === 0 || !unref(scrollWrap)) { if (!refList || !isArray(refList) || refList.length === 0 || !unref(scrollWrap)) {
return; return;
} }

View File

@ -4,7 +4,7 @@
import { Tooltip } from 'ant-design-vue'; import { Tooltip } from 'ant-design-vue';
import { InfoCircleOutlined } from '@ant-design/icons-vue'; import { InfoCircleOutlined } from '@ant-design/icons-vue';
import { getPopupContainer } from '/@/utils'; import { getPopupContainer } from '/@/utils';
import { isString, isArray } from '/@/utils/is'; import { isArray, isString } from '@vben/shared';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';

View File

@ -88,7 +88,7 @@
import { BasicForm, useForm } from '/@/components/Form'; import { BasicForm, useForm } from '/@/components/Form';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { Button } from '/@/components/Button'; import { Button } from '/@/components/Button';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { useSlider, grid } from './data'; import { useSlider, grid } from './data';
const ListItem = List.Item; const ListItem = List.Item;

View File

@ -9,9 +9,9 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from 'vue'; import { type PropType, computed } from 'vue';
import CodeMirrorEditor from './codemirror/CodeMirror.vue'; import CodeMirrorEditor from './codemirror/CodeMirror.vue';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { MODE } from './typing'; import { MODE } from './typing';
const props = defineProps({ const props = defineProps({

View File

@ -1,5 +1,4 @@
import contextMenuVue from './ContextMenu.vue'; import contextMenuVue from './ContextMenu.vue';
import { isClient } from '/@/utils/is';
import { CreateContextOptions, ContextMenuProps } from './typing'; import { CreateContextOptions, ContextMenuProps } from './typing';
import { createVNode, render } from 'vue'; import { createVNode, render } from 'vue';
@ -16,9 +15,6 @@ export const createContextMenu = function (options: CreateContextOptions) {
event && event?.preventDefault(); event && event?.preventDefault();
if (!isClient) {
return;
}
return new Promise((resolve) => { return new Promise((resolve) => {
const body = document.body; const body = document.body;

View File

@ -4,10 +4,10 @@
</Button> </Button>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, watchEffect, computed, unref } from 'vue'; import { type PropType, defineComponent, ref, watchEffect, computed, unref } from 'vue';
import { Button } from 'ant-design-vue'; import { Button } from 'ant-design-vue';
import { useCountdown } from './useCountdown'; import { useCountdown } from './useCountdown';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
const props = { const props = {

View File

@ -6,7 +6,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, computed, watchEffect, unref, onMounted, watch } from 'vue'; import { defineComponent, ref, computed, watchEffect, unref, onMounted, watch } from 'vue';
import { useTransition, TransitionPresets } from '@vueuse/core'; import { useTransition, TransitionPresets } from '@vueuse/core';
import { isNumber } from '/@/utils/is'; import { isNumber } from '@vben/shared';
const props = { const props = {
startVal: { type: Number, default: 0 }, startVal: { type: Number, default: 0 },

View File

@ -119,7 +119,7 @@
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { dataURLtoBlob } from '/@/utils/file/base64Conver'; import { dataURLtoBlob } from '/@/utils/file/base64Conver';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
type apiFunParams = { file: Blob; name: string; filename: string }; type apiFunParams = { file: Blob; name: string; filename: string };

View File

@ -15,7 +15,7 @@
import { Descriptions } from 'ant-design-vue'; import { Descriptions } from 'ant-design-vue';
import { CollapseContainer } from '/@/components/Container/index'; import { CollapseContainer } from '/@/components/Container/index';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
import { useAttrs } from '@vben/hooks'; import { useAttrs } from '@vben/hooks';

View File

@ -45,7 +45,7 @@
} from 'vue'; } from 'vue';
import { Drawer } from 'ant-design-vue'; import { Drawer } from 'ant-design-vue';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { isFunction, isNumber } from '/@/utils/is'; import { isFunction, isNumber } from '@vben/shared';
import { deepMerge } from '/@/utils'; import { deepMerge } from '/@/utils';
import DrawerFooter from './components/DrawerFooter.vue'; import DrawerFooter from './components/DrawerFooter.vue';
import DrawerHeader from './components/DrawerHeader.vue'; import DrawerHeader from './components/DrawerHeader.vue';

View File

@ -16,7 +16,7 @@ import {
computed, computed,
} from 'vue'; } from 'vue';
import { isProdMode } from '/@/utils/env'; import { isProdMode } from '/@/utils/env';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { tryOnUnmounted } from '@vueuse/core'; import { tryOnUnmounted } from '@vueuse/core';
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
import { error } from '/@/utils/log'; import { error } from '/@/utils/log';

View File

@ -42,7 +42,7 @@
import { Dropdown, Menu, Popconfirm } from 'ant-design-vue'; import { Dropdown, Menu, Popconfirm } from 'ant-design-vue';
import Icon from '@/components/Icon/Icon.vue'; import Icon from '@/components/Icon/Icon.vue';
import { omit } from 'lodash-es'; import { omit } from 'lodash-es';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
const ADropdown = Dropdown; const ADropdown = Dropdown;
const AMenu = Menu; const AMenu = Menu;

View File

@ -41,7 +41,7 @@
import type { FormActionType, FormProps, FormSchema } from './types/form'; import type { FormActionType, FormProps, FormSchema } from './types/form';
import type { AdvanceState } from './types/hooks'; import type { AdvanceState } from './types/hooks';
import type { Ref } from 'vue'; import type { Ref } from 'vue';
import { isArray } from '@vben/shared';
import { defineComponent, reactive, ref, computed, unref, onMounted, watch, nextTick } from 'vue'; import { defineComponent, reactive, ref, computed, unref, onMounted, watch, nextTick } from 'vue';
import { Form, Row } from 'ant-design-vue'; import { Form, Row } from 'ant-design-vue';
import FormItem from './components/FormItem.vue'; import FormItem from './components/FormItem.vue';
@ -120,7 +120,7 @@
const { defaultValue, component, isHandleDateDefaultValue = true } = schema; const { defaultValue, component, isHandleDateDefaultValue = true } = schema;
// handle date type // handle date type
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) { if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
if (!Array.isArray(defaultValue)) { if (!isArray(defaultValue)) {
schema.defaultValue = dateUtil(defaultValue); schema.defaultValue = dateUtil(defaultValue);
} else { } else {
const def: any[] = []; const def: any[] = [];

View File

@ -23,7 +23,7 @@
import { defineComponent, PropType, ref, unref, watch, watchEffect } from 'vue'; import { defineComponent, PropType, ref, unref, watch, watchEffect } from 'vue';
import { Cascader } from 'ant-design-vue'; import { Cascader } from 'ant-design-vue';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { isFunction } from '/@/utils/is'; import { isFunction, isArray } from '@vben/shared';
import { get, omit } from 'lodash-es'; import { get, omit } from 'lodash-es';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { LoadingOutlined } from '@ant-design/icons-vue'; import { LoadingOutlined } from '@ant-design/icons-vue';
@ -119,7 +119,7 @@
loading.value = true; loading.value = true;
try { try {
const res = await api(props.initFetchParams); const res = await api(props.initFetchParams);
if (Array.isArray(res)) { if (isArray(res)) {
apiData.value = res; apiData.value = res;
return; return;
} }
@ -143,7 +143,7 @@
const res = await api({ const res = await api({
[props.asyncFetchParamKey]: Reflect.get(targetOption, 'value'), [props.asyncFetchParamKey]: Reflect.get(targetOption, 'value'),
}); });
if (Array.isArray(res)) { if (isArray(res)) {
const children = generatorOptions(res); const children = generatorOptions(res);
targetOption.children = children; targetOption.children = children;
return; return;

View File

@ -21,7 +21,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, type PropType, ref, watchEffect, computed, unref, watch } from 'vue'; import { defineComponent, type PropType, ref, watchEffect, computed, unref, watch } from 'vue';
import { Radio } from 'ant-design-vue'; import { Radio } from 'ant-design-vue';
import { isFunction } from '/@/utils/is'; import { isFunction, isArray } from '@vben/shared';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '@vben/hooks'; import { useAttrs } from '@vben/hooks';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
@ -106,7 +106,7 @@
try { try {
loading.value = true; loading.value = true;
const res = await api(props.params); const res = await api(props.params);
if (Array.isArray(res)) { if (isArray(res)) {
options.value = res; options.value = res;
emitChange(); emitChange();
return; return;

View File

@ -23,7 +23,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType, ref, watchEffect, computed, unref, watch } from 'vue'; import { defineComponent, PropType, ref, watchEffect, computed, unref, watch } from 'vue';
import { Select } from 'ant-design-vue'; import { Select } from 'ant-design-vue';
import { isFunction } from '/@/utils/is'; import { isFunction, isArray } from '@vben/shared';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '@vben/hooks'; import { useAttrs } from '@vben/hooks';
import { get, omit } from 'lodash-es'; import { get, omit } from 'lodash-es';
@ -110,7 +110,7 @@
try { try {
loading.value = true; loading.value = true;
const res = await api(props.params); const res = await api(props.params);
if (Array.isArray(res)) { if (isArray(res)) {
options.value = res; options.value = res;
emitChange(); emitChange();
return; return;

View File

@ -14,7 +14,7 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, watch, ref, unref, watchEffect, PropType } from 'vue'; import { computed, defineComponent, watch, ref, unref, watchEffect, PropType } from 'vue';
import { Transfer } from 'ant-design-vue'; import { Transfer } from 'ant-design-vue';
import { isFunction } from '/@/utils/is'; import { isArray, isFunction } from '@vben/shared';
import { get, omit } from 'lodash-es'; import { get, omit } from 'lodash-es';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
@ -76,10 +76,10 @@
if (unref(_targetKeys).length > 0) { if (unref(_targetKeys).length > 0) {
return unref(_targetKeys); return unref(_targetKeys);
} }
if (Array.isArray(props.value)) { if (isArray(props.value)) {
return props.value; return props.value;
} }
if (Array.isArray(props.targetKeys)) { if (isArray(props.targetKeys)) {
return props.targetKeys; return props.targetKeys;
} }
return []; return [];
@ -107,7 +107,7 @@
async function fetch() { async function fetch() {
const api = props.api; const api = props.api;
if (!api || !isFunction(api)) { if (!api || !isFunction(api)) {
if (Array.isArray(props.dataSource)) { if (isArray(props.dataSource)) {
_dataSource.value = props.dataSource; _dataSource.value = props.dataSource;
} }
return; return;
@ -115,7 +115,7 @@
_dataSource.value = []; _dataSource.value = [];
try { try {
const res = await api(props.params); const res = await api(props.params);
if (Array.isArray(res)) { if (isArray(res)) {
_dataSource.value = res; _dataSource.value = res;
emitChange(); emitChange();
return; return;

View File

@ -13,7 +13,7 @@
import { type Recordable, type AnyFunction } from '@vben/types'; import { type Recordable, type AnyFunction } from '@vben/types';
import { type PropType, computed, defineComponent, watch, ref, onMounted, unref } from 'vue'; import { type PropType, computed, defineComponent, watch, ref, onMounted, unref } from 'vue';
import { Tree } from 'ant-design-vue'; import { Tree } from 'ant-design-vue';
import { isArray, isFunction } from '/@/utils/is'; import { isArray, isFunction } from '@vben/shared';
import { get } from 'lodash-es'; import { get } from 'lodash-es';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { LoadingOutlined } from '@ant-design/icons-vue'; import { LoadingOutlined } from '@ant-design/icons-vue';

View File

@ -13,7 +13,7 @@
import { type Recordable } from '@vben/types'; import { type Recordable } from '@vben/types';
import { type PropType, computed, defineComponent, watch, ref, onMounted, unref } from 'vue'; import { type PropType, computed, defineComponent, watch, ref, onMounted, unref } from 'vue';
import { TreeSelect } from 'ant-design-vue'; import { TreeSelect } from 'ant-design-vue';
import { isArray, isFunction } from '/@/utils/is'; import { isArray, isFunction } from '@vben/shared';
import { get } from 'lodash-es'; import { get } from 'lodash-es';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { LoadingOutlined } from '@ant-design/icons-vue'; import { LoadingOutlined } from '@ant-design/icons-vue';

View File

@ -8,7 +8,8 @@
import { Col, Divider, Form } from 'ant-design-vue'; import { Col, Divider, Form } from 'ant-design-vue';
import { componentMap } from '../componentMap'; import { componentMap } from '../componentMap';
import { BasicHelp } from '/@/components/Basic'; import { BasicHelp } from '/@/components/Basic';
import { isBoolean, isFunction, isNull } from '/@/utils/is'; import { isBoolean, isFunction, isArray } from '@vben/shared';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
import { import {
createPlaceholderMessage, createPlaceholderMessage,
@ -163,10 +164,10 @@
function validator(rule: any, value: any) { function validator(rule: any, value: any) {
const msg = rule.message || defaultMsg; const msg = rule.message || defaultMsg;
if (value === undefined || isNull(value)) { if (value === undefined || value === null) {
// //
return Promise.reject(msg); return Promise.reject(msg);
} else if (Array.isArray(value) && value.length === 0) { } else if (isArray(value) && value.length === 0) {
// //
return Promise.reject(msg); return Promise.reject(msg);
} else if (typeof value === 'string' && value.trim() === '') { } else if (typeof value === 'string' && value.trim() === '') {
@ -176,8 +177,8 @@
typeof value === 'object' && typeof value === 'object' &&
Reflect.has(value, 'checked') && Reflect.has(value, 'checked') &&
Reflect.has(value, 'halfChecked') && Reflect.has(value, 'halfChecked') &&
Array.isArray(value.checked) && isArray(value.checked) &&
Array.isArray(value.halfChecked) && isArray(value.halfChecked) &&
value.checked.length === 0 && value.checked.length === 0 &&
value.halfChecked.length === 0 value.halfChecked.length === 0
) { ) {
@ -318,7 +319,7 @@
const getHelpMessage = isFunction(helpMessage) const getHelpMessage = isFunction(helpMessage)
? helpMessage(unref(getValues)) ? helpMessage(unref(getValues))
: helpMessage; : helpMessage;
if (!getHelpMessage || (Array.isArray(getHelpMessage) && getHelpMessage.length === 0)) { if (!getHelpMessage || (isArray(getHelpMessage) && getHelpMessage.length === 0)) {
return renderLabel; return renderLabel;
} }
return ( return (

View File

@ -13,7 +13,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType, computed, ref } from 'vue'; import { defineComponent, PropType, computed, ref } from 'vue';
import { Radio } from 'ant-design-vue'; import { Radio } from 'ant-design-vue';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '@vben/hooks'; import { useAttrs } from '@vben/hooks';

View File

@ -2,7 +2,7 @@ import type { ValidationRule } from 'ant-design-vue/lib/form/Form';
import type { ComponentType } from './types/index'; import type { ComponentType } from './types/index';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { dateUtil } from '/@/utils/dateUtil'; import { dateUtil } from '/@/utils/dateUtil';
import { isNumber, isObject } from '/@/utils/is'; import { isNumber, isObject } from '@vben/shared';
const { t } = useI18n(); const { t } = useI18n();

View File

@ -2,7 +2,7 @@ import type { ColEx } from '../types';
import type { AdvanceState } from '../types/hooks'; import type { AdvanceState } from '../types/hooks';
import { ComputedRef, getCurrentInstance, Ref, shallowReactive, computed, unref, watch } from 'vue'; import { ComputedRef, getCurrentInstance, Ref, shallowReactive, computed, unref, watch } from 'vue';
import type { FormProps, FormSchema } from '../types/form'; import type { FormProps, FormSchema } from '../types/form';
import { isBoolean, isFunction, isNumber, isObject } from '/@/utils/is'; import { isBoolean, isFunction, isNumber, isObject } from '@vben/shared';
import { useBreakpoint } from '/@/hooks/event/useBreakpoint'; import { useBreakpoint } from '/@/hooks/event/useBreakpoint';
import { useDebounceFn } from '@vueuse/core'; import { useDebounceFn } from '@vueuse/core';

View File

@ -3,14 +3,14 @@ import type { FormProps, FormSchema, FormActionType } from '../types/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface'; import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue'; import { unref, toRaw, nextTick } from 'vue';
import { import {
isArray, isNullOrUndefined,
isFunction, isFunction,
isObject, isArray,
isString, isString,
isDef, isUndefined,
isNullOrUnDef,
isEmpty, isEmpty,
} from '/@/utils/is'; isObject,
} from '@vben/shared';
import { deepMerge } from '/@/utils'; import { deepMerge } from '/@/utils';
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper'; import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
import { dateUtil } from '/@/utils/dateUtil'; import { dateUtil } from '/@/utils/dateUtil';
@ -153,13 +153,13 @@ export function useFormEvents({
nestKeyArray.forEach((nestKey: string) => { nestKeyArray.forEach((nestKey: string) => {
try { try {
const value = nestKey.split('.').reduce((out, item) => out[item], values); const value = nestKey.split('.').reduce((out, item) => out[item], values);
if (isDef(value)) { if (!isUndefined(value)) {
unref(formModel)[nestKey] = unref(value); unref(formModel)[nestKey] = unref(value);
validKeys.push(nestKey); validKeys.push(nestKey);
} }
} catch (e) { } catch (e) {
// key not exist // key not exist
if (isDef(defaultValueRef.value[nestKey])) { if (!isUndefined(defaultValueRef.value[nestKey])) {
unref(formModel)[nestKey] = cloneDeep(unref(defaultValueRef.value[nestKey])); unref(formModel)[nestKey] = cloneDeep(unref(defaultValueRef.value[nestKey]));
} }
} }
@ -304,9 +304,9 @@ export function useFormEvents({
item.component != 'Divider' && item.component != 'Divider' &&
Reflect.has(item, 'field') && Reflect.has(item, 'field') &&
item.field && item.field &&
!isNullOrUnDef(item.defaultValue) && !isNullOrUndefined(item.defaultValue) &&
(!(item.field in currentFieldsValue) || (!(item.field in currentFieldsValue) ||
isNullOrUnDef(currentFieldsValue[item.field]) || isNullOrUndefined(currentFieldsValue[item.field]) ||
isEmpty(currentFieldsValue[item.field])) isEmpty(currentFieldsValue[item.field]))
) { ) {
obj[item.field] = item.defaultValue; obj[item.field] = item.defaultValue;

View File

@ -1,4 +1,4 @@
import { isArray, isFunction, isObject, isString, isNullOrUnDef } from '/@/utils/is'; import { isFunction, isArray, isString, isNullOrUndefined, isObject } from '@vben/shared';
import { dateUtil } from '/@/utils/dateUtil'; import { dateUtil } from '/@/utils/dateUtil';
import { unref } from 'vue'; import { unref } from 'vue';
import type { Ref, ComputedRef } from 'vue'; import type { Ref, ComputedRef } from 'vue';
@ -97,7 +97,7 @@ export function useFormValues({
function handleRangeTimeValue(values: Recordable) { function handleRangeTimeValue(values: Recordable) {
const fieldMapToTime = unref(getProps).fieldMapToTime; const fieldMapToTime = unref(getProps).fieldMapToTime;
if (!fieldMapToTime || !Array.isArray(fieldMapToTime)) { if (!fieldMapToTime || !isArray(fieldMapToTime)) {
return values; return values;
} }
@ -128,7 +128,7 @@ export function useFormValues({
const obj: Recordable = {}; const obj: Recordable = {};
schemas.forEach((item) => { schemas.forEach((item) => {
const { defaultValue } = item; const { defaultValue } = item;
if (!isNullOrUnDef(defaultValue)) { if (!isNullOrUndefined(defaultValue)) {
obj[item.field] = defaultValue; obj[item.field] = defaultValue;
if (formModel[item.field] === undefined) { if (formModel[item.field] === undefined) {

View File

@ -1,7 +1,7 @@
import type { Ref } from 'vue'; import type { Ref } from 'vue';
import { computed, unref } from 'vue'; import { computed, unref } from 'vue';
import type { FormProps, FormSchema } from '../types/form'; import type { FormProps, FormSchema } from '../types/form';
import { isNumber } from '/@/utils/is'; import { isNumber } from '@vben/shared';
export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) { export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) {
return computed(() => { return computed(() => {

View File

@ -27,7 +27,7 @@
} from 'vue'; } from 'vue';
import SvgIcon from './src/SvgIcon.vue'; import SvgIcon from './src/SvgIcon.vue';
import Iconify from '@purge-icons/generated'; import Iconify from '@purge-icons/generated';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
const SVG_END_WITH_FLAG = '|svg'; const SVG_END_WITH_FLAG = '|svg';

View File

@ -71,6 +71,7 @@
import { Input, Popover, Pagination, Empty } from 'ant-design-vue'; import { Input, Popover, Pagination, Empty } from 'ant-design-vue';
import Icon from '../Icon.vue'; import Icon from '../Icon.vue';
import SvgIcon from './SvgIcon.vue'; import SvgIcon from './SvgIcon.vue';
import { isArray } from '@vben/shared';
import iconsData from '../data/icons.data'; import iconsData from '../data/icons.data';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
@ -93,7 +94,7 @@
let result: string[] = []; let result: string[] = [];
if (prefix) { if (prefix) {
result = (data?.icons ?? []).map((item) => `${prefix}:${item}`); result = (data?.icons ?? []).map((item) => `${prefix}:${item}`);
} else if (Array.isArray(iconsData)) { } else if (isArray(iconsData)) {
result = iconsData as string[]; result = iconsData as string[];
} }
return result; return result;

View File

@ -25,7 +25,7 @@
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum'; import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
import { useOpenKeys } from './useOpenKeys'; import { useOpenKeys } from './useOpenKeys';
import { RouteLocationNormalizedLoaded, useRouter } from 'vue-router'; import { RouteLocationNormalizedLoaded, useRouter } from 'vue-router';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { basicProps } from './props'; import { basicProps } from './props';
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting'; import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
import { REDIRECT_NAME } from '/@/router/constant'; import { REDIRECT_NAME } from '/@/router/constant';

View File

@ -67,7 +67,8 @@
import ModalClose from './components/ModalClose.vue'; import ModalClose from './components/ModalClose.vue';
import ModalFooter from './components/ModalFooter.vue'; import ModalFooter from './components/ModalFooter.vue';
import ModalHeader from './components/ModalHeader.vue'; import ModalHeader from './components/ModalHeader.vue';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { type Recordable } from '@vben/types';
import { deepMerge } from '/@/utils'; import { deepMerge } from '/@/utils';
import { basicProps } from './props'; import { basicProps } from './props';
import { useFullScreen } from './hooks/useModalFullScreen'; import { useFullScreen } from './hooks/useModalFullScreen';
@ -106,7 +107,7 @@
} }
// Custom title component: get title // Custom title component: get title
const getMergeProps = computed((): Recordable => { const getMergeProps = computed((): Recordable<any> => {
return { return {
...props, ...props,
...(unref(propsRef) as any), ...(unref(propsRef) as any),
@ -120,7 +121,7 @@
}); });
// modal component does not need title and origin buttons // modal component does not need title and origin buttons
const getProps = computed((): Recordable => { const getProps = computed((): Recordable<any> => {
const opt = { const opt = {
...unref(getMergeProps), ...unref(getMergeProps),
visible: unref(visibleRef), visible: unref(visibleRef),
@ -134,7 +135,7 @@
}; };
}); });
const getBindValue = computed((): Recordable => { const getBindValue = computed((): Recordable<any> => {
const attr = { const attr = {
...attrs, ...attrs,
...unref(getMergeProps), ...unref(getMergeProps),

View File

@ -17,7 +17,7 @@ import {
computed, computed,
} from 'vue'; } from 'vue';
import { isProdMode } from '/@/utils/env'; import { isProdMode } from '/@/utils/env';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
import { tryOnUnmounted } from '@vueuse/core'; import { tryOnUnmounted } from '@vueuse/core';
import { error } from '/@/utils/log'; import { error } from '/@/utils/log';

View File

@ -21,7 +21,7 @@
import { Image } from 'ant-design-vue'; import { Image } from 'ant-design-vue';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
interface ImageProps { interface ImageProps {
alt?: string; alt?: string;

View File

@ -1,11 +1,9 @@
import type { Options, Props } from './typing'; import type { Options, Props } from './typing';
import ImgPreview from './Functional.vue'; import ImgPreview from './Functional.vue';
import { isClient } from '/@/utils/is';
import { createVNode, render } from 'vue'; import { createVNode, render } from 'vue';
let instance: ReturnType<typeof createVNode> | null = null; let instance: ReturnType<typeof createVNode> | null = null;
export function createImgPreview(options: Options) { export function createImgPreview(options: Options) {
if (!isClient) return;
const propsData: Partial<Props> = {}; const propsData: Partial<Props> = {};
const container = document.createElement('div'); const container = document.createElement('div');
Object.assign(propsData, { show: true, index: 0, scaleStep: 100 }, options); Object.assign(propsData, { show: true, index: 0, scaleStep: 100 }, options);

View File

@ -1,4 +1,4 @@
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { RenderQrCodeParams, LogoType } from './typing'; import { RenderQrCodeParams, LogoType } from './typing';
export const drawLogo = ({ canvas, logo }: RenderQrCodeParams) => { export const drawLogo = ({ canvas, logo }: RenderQrCodeParams) => {

View File

@ -20,6 +20,7 @@
import { addResizeListener, removeResizeListener } from '/@/utils/event'; import { addResizeListener, removeResizeListener } from '/@/utils/event';
import componentSetting from '/@/settings/componentSetting'; import componentSetting from '/@/settings/componentSetting';
import { toObject } from './util'; import { toObject } from './util';
import { isArray } from '@vben/shared';
import { import {
defineComponent, defineComponent,
ref, ref,
@ -76,7 +77,7 @@
provide('scroll-bar-wrap', wrap); provide('scroll-bar-wrap', wrap);
const style = computed(() => { const style = computed(() => {
if (Array.isArray(props.wrapStyle)) { if (isArray(props.wrapStyle)) {
return toObject(props.wrapStyle); return toObject(props.wrapStyle);
} }
return props.wrapStyle; return props.wrapStyle;

View File

@ -29,9 +29,8 @@
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { REDIRECT_NAME } from '/@/router/constant'; import { REDIRECT_NAME } from '/@/router/constant';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { isFunction, isUrl } from '/@/utils/is'; import { isFunction, isHttpUrl } from '@vben/shared';
import { openWindow } from '/@/utils'; import { openWindow } from '/@/utils';
import { useOpenKeys } from './useOpenKeys'; import { useOpenKeys } from './useOpenKeys';
export default defineComponent({ export default defineComponent({
@ -129,7 +128,7 @@
} }
async function handleSelect(key: string) { async function handleSelect(key: string) {
if (isUrl(key)) { if (isHttpUrl(key)) {
openWindow(key); openWindow(key);
return; return;
} }

View File

@ -77,7 +77,7 @@
import { CollapseTransition } from '/@/components/Transition'; import { CollapseTransition } from '/@/components/Transition';
import Icon from '@/components/Icon/Icon.vue'; import Icon from '@/components/Icon/Icon.vue';
import { Popover } from 'ant-design-vue'; import { Popover } from 'ant-design-vue';
import { isBoolean, isObject } from '/@/utils/is'; import { isObject, isBoolean, isArray } from '@vben/shared';
import { mitt } from '/@/utils/mitt'; import { mitt } from '/@/utils/mitt';
const DELAY = 200; const DELAY = 200;
@ -284,7 +284,7 @@
return; return;
} }
if (props.name && Array.isArray(data)) { if (props.name && isArray(data)) {
state.opened = (data as (string | number)[]).includes(props.name); state.opened = (data as (string | number)[]).includes(props.name);
} }
}, },

View File

@ -71,7 +71,7 @@
import { omit } from 'lodash-es'; import { omit } from 'lodash-es';
import { basicProps } from './props'; import { basicProps } from './props';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { warn } from '/@/utils/log'; import { warn } from '/@/utils/log';
export default defineComponent({ export default defineComponent({

View File

@ -41,7 +41,7 @@
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { useTableContext } from '../hooks/useTableContext'; import { useTableContext } from '../hooks/useTableContext';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { isBoolean, isFunction, isString } from '/@/utils/is'; import { isBoolean, isFunction, isString } from '@vben/shared';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { ACTION_COLUMN_FLAG } from '../const'; import { ACTION_COLUMN_FLAG } from '../const';

View File

@ -16,7 +16,8 @@
import { defineComponent, unref, computed, toRaw } from 'vue'; import { defineComponent, unref, computed, toRaw } from 'vue';
import { Table } from 'ant-design-vue'; import { Table } from 'ant-design-vue';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { type AnyFunction, Recordable } from '@vben/types';
import type { BasicColumn } from '../types/table'; import type { BasicColumn } from '../types/table';
import { INDEX_COLUMN_FLAG } from '../const'; import { INDEX_COLUMN_FLAG } from '../const';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
@ -29,20 +30,20 @@
components: { Table }, components: { Table },
props: { props: {
summaryFunc: { summaryFunc: {
type: Function as PropType<Fn>, type: Function as PropType<AnyFunction>,
}, },
summaryData: { summaryData: {
type: Array as PropType<Recordable[]>, type: Array as PropType<Recordable<any>[]>,
}, },
scroll: { scroll: {
type: Object as PropType<Recordable>, type: Object as PropType<Recordable<any>>,
}, },
rowKey: propTypes.string.def('key'), rowKey: propTypes.string.def('key'),
}, },
setup(props) { setup(props) {
const table = useTableContext(); const table = useTableContext();
const getDataSource = computed((): Recordable[] => { const getDataSource = computed((): Recordable<any>[] => {
const { summaryFunc, summaryData } = props; const { summaryFunc, summaryData } = props;
if (summaryData?.length) { if (summaryData?.length) {
summaryData.forEach((item, i) => (item[props.rowKey] = `${i}`)); summaryData.forEach((item, i) => (item[props.rowKey] = `${i}`));
@ -52,7 +53,7 @@
return []; return [];
} }
let dataSource = toRaw(unref(table.getDataSource())); let dataSource = toRaw(unref(table.getDataSource()));
dataSource = summaryFunc(dataSource); dataSource = summaryFunc(dataSource) as any;
dataSource.forEach((item, i) => { dataSource.forEach((item, i) => {
item[props.rowKey] = `${i}`; item[props.rowKey] = `${i}`;
}); });

View File

@ -7,7 +7,7 @@
import { computed, defineComponent, PropType } from 'vue'; import { computed, defineComponent, PropType } from 'vue';
import { BasicTitle } from '/@/components/Basic/index'; import { BasicTitle } from '/@/components/Basic/index';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
export default defineComponent({ export default defineComponent({
name: 'BasicTableTitle', name: 'BasicTableTitle',

View File

@ -11,7 +11,7 @@
import clickOutside from '/@/directives/clickOutside'; import clickOutside from '/@/directives/clickOutside';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { isArray, isBoolean, isFunction, isNumber, isString } from '/@/utils/is'; import { isArray, isBoolean, isFunction, isNumber, isString } from '@vben/shared';
import { createPlaceholderMessage } from './helper'; import { createPlaceholderMessage } from './helper';
import { pick, set } from 'lodash-es'; import { pick, set } from 'lodash-es';
import { treeToList } from '/@/utils/helper/treeHelper'; import { treeToList } from '/@/utils/helper/treeHelper';

View File

@ -3,7 +3,7 @@ import type { BasicColumn } from '/@/components/Table/src/types/table';
import { h, Ref } from 'vue'; import { h, Ref } from 'vue';
import EditableCell from './EditableCell.vue'; import EditableCell from './EditableCell.vue';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
interface Params { interface Params {
text: string; text: string;

View File

@ -119,7 +119,7 @@
import { useTableContext } from '../../hooks/useTableContext'; import { useTableContext } from '../../hooks/useTableContext';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
// import { useSortable } from '/@/hooks/web/useSortable'; // import { useSortable } from '/@/hooks/web/useSortable';
import { isFunction, isNullAndUnDef } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { getPopupContainer as getParentContainer } from '/@/utils'; import { getPopupContainer as getParentContainer } from '/@/utils';
import { cloneDeep, omit } from 'lodash-es'; import { cloneDeep, omit } from 'lodash-es';
import Sortablejs from 'sortablejs'; import Sortablejs from 'sortablejs';
@ -301,7 +301,7 @@
handle: '.table-column-drag-icon ', handle: '.table-column-drag-icon ',
onEnd: (evt) => { onEnd: (evt) => {
const { oldIndex, newIndex } = evt; const { oldIndex, newIndex } = evt;
if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { if (oldIndex === newIndex) {
return; return;
} }
// Sort column // Sort column

View File

@ -5,7 +5,7 @@ import { computed, Ref, ref, reactive, toRaw, unref, watch } from 'vue';
import { renderEditCell } from '../components/editable'; import { renderEditCell } from '../components/editable';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { isArray, isBoolean, isFunction, isMap, isString } from '/@/utils/is'; import { isMap, isArray, isBoolean, isFunction, isString } from '@vben/shared';
import { cloneDeep, isEqual } from 'lodash-es'; import { cloneDeep, isEqual } from 'lodash-es';
import { formatToDate } from '/@/utils/dateUtil'; import { formatToDate } from '/@/utils/dateUtil';
import { ACTION_COLUMN_FLAG, DEFAULT_ALIGN, INDEX_COLUMN_FLAG, PAGE_SIZE } from '../const'; import { ACTION_COLUMN_FLAG, DEFAULT_ALIGN, INDEX_COLUMN_FLAG, PAGE_SIZE } from '../const';

View File

@ -2,7 +2,7 @@ import type { ComputedRef } from 'vue';
import type { BasicTableProps } from '../types/table'; import type { BasicTableProps } from '../types/table';
import { unref } from 'vue'; import { unref } from 'vue';
import { ROW_KEY } from '../const'; import { ROW_KEY } from '../const';
import { isString, isFunction } from '/@/utils/is'; import { isString, isFunction } from '@vben/shared';
interface Options { interface Options {
setSelectedRowKeys: (keys: string[]) => void; setSelectedRowKeys: (keys: string[]) => void;

View File

@ -13,9 +13,9 @@ import {
} from 'vue'; } from 'vue';
import { useTimeoutFn } from '@vben/hooks'; import { useTimeoutFn } from '@vben/hooks';
import { buildUUID } from '/@/utils/uuid'; import { buildUUID } from '/@/utils/uuid';
import { isFunction, isBoolean, isObject } from '/@/utils/is';
import { get, cloneDeep, merge } from 'lodash-es'; import { get, cloneDeep, merge } from 'lodash-es';
import { FETCH_SETTING, ROW_KEY, PAGE_SIZE } from '../const'; import { FETCH_SETTING, ROW_KEY, PAGE_SIZE } from '../const';
import { isArray, isFunction, isBoolean, isObject } from '@vben/shared';
interface ActionType { interface ActionType {
getPaginationInfo: ComputedRef<boolean | PaginationProps>; getPaginationInfo: ComputedRef<boolean | PaginationProps>;
@ -91,7 +91,7 @@ export function useDataSource(
} }
function setTableKey(items: any[]) { function setTableKey(items: any[]) {
if (!items || !Array.isArray(items)) return; if (!items || !isArray(items)) return;
items.forEach((item) => { items.forEach((item) => {
if (!item[ROW_KEY]) { if (!item[ROW_KEY]) {
item[ROW_KEY] = buildUUID(); item[ROW_KEY] = buildUUID();
@ -164,7 +164,7 @@ export function useDataSource(
if (!dataSourceRef.value || dataSourceRef.value.length == 0) return; if (!dataSourceRef.value || dataSourceRef.value.length == 0) return;
const rowKeyName = unref(getRowKey); const rowKeyName = unref(getRowKey);
if (!rowKeyName) return; if (!rowKeyName) return;
const rowKeys = !Array.isArray(rowKey) ? [rowKey] : rowKey; const rowKeys = !isArray(rowKey) ? [rowKey] : rowKey;
function deleteRow(data, key) { function deleteRow(data, key) {
const row: { index: number; data: [] } = findRow(data, key); const row: { index: number; data: [] } = findRow(data, key);
@ -304,7 +304,7 @@ export function useDataSource(
const res = await api(params); const res = await api(params);
rawDataSourceRef.value = res; rawDataSourceRef.value = res;
const isArrayResult = Array.isArray(res); const isArrayResult = isArray(res);
let resultItems: Recordable[] = isArrayResult ? res : get(res, listField); let resultItems: Recordable[] = isArrayResult ? res : get(res, listField);
const resultTotal: number = isArrayResult ? res.length : get(res, totalField); const resultTotal: number = isArrayResult ? res.length : get(res, totalField);

View File

@ -2,7 +2,7 @@ import type { PaginationProps } from '../types/pagination';
import type { BasicTableProps } from '../types/table'; import type { BasicTableProps } from '../types/table';
import { computed, unref, ref, ComputedRef, watch } from 'vue'; import { computed, unref, ref, ComputedRef, watch } from 'vue';
import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue'; import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue';
import { isBoolean } from '/@/utils/is'; import { isBoolean } from '@vben/shared';
import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../const'; import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../const';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';

View File

@ -1,4 +1,4 @@
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import type { BasicTableProps, TableRowSelection } from '../types/table'; import type { BasicTableProps, TableRowSelection } from '../types/table';
import { computed, ComputedRef, nextTick, Ref, ref, toRaw, unref, watch } from 'vue'; import { computed, ComputedRef, nextTick, Ref, ref, toRaw, unref, watch } from 'vue';
import { ROW_KEY } from '../const'; import { ROW_KEY } from '../const';

View File

@ -2,7 +2,7 @@ import type { ComputedRef, Slots } from 'vue';
import type { BasicTableProps, FetchParams } from '../types/table'; import type { BasicTableProps, FetchParams } from '../types/table';
import { unref, computed } from 'vue'; import { unref, computed } from 'vue';
import type { FormProps } from '/@/components/Form'; import type { FormProps } from '/@/components/Form';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
export function useTableForm( export function useTableForm(
propsRef: ComputedRef<BasicTableProps>, propsRef: ComputedRef<BasicTableProps>,

View File

@ -2,7 +2,7 @@ import type { ComputedRef, Slots } from 'vue';
import type { BasicTableProps, InnerHandlers } from '../types/table'; import type { BasicTableProps, InnerHandlers } from '../types/table';
import { unref, computed, h } from 'vue'; import { unref, computed, h } from 'vue';
import TableHeader from '../components/TableHeader.vue'; import TableHeader from '../components/TableHeader.vue';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
export function useTableHeader( export function useTableHeader(

View File

@ -1,7 +1,7 @@
import type { BasicTableProps, TableRowSelection, BasicColumn } from '../types/table'; import type { BasicTableProps, TableRowSelection, BasicColumn } from '../types/table';
import { Ref, ComputedRef, ref, computed, unref, nextTick, watch } from 'vue'; import { Ref, ComputedRef, ref, computed, unref, nextTick, watch } from 'vue';
import { getViewportOffset } from '/@/utils/domUtils'; import { getViewportOffset } from '/@/utils/domUtils';
import { isBoolean } from '/@/utils/is'; import { isBoolean } from '@vben/shared';
import { useWindowSizeFn, onMountedOrActivated } from '@vben/hooks'; import { useWindowSizeFn, onMountedOrActivated } from '@vben/hooks';
import { useModalContext } from '/@/components/Modal'; import { useModalContext } from '/@/components/Modal';
import { useDebounceFn } from '@vueuse/core'; import { useDebounceFn } from '@vueuse/core';

View File

@ -1,7 +1,7 @@
import type { ComputedRef } from 'vue'; import type { ComputedRef } from 'vue';
import type { BasicTableProps, TableCustomRecord } from '../types/table'; import type { BasicTableProps, TableCustomRecord } from '../types/table';
import { unref } from 'vue'; import { unref } from 'vue';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) { export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) {
function getRowClassName(record: TableCustomRecord, index: number) { function getRowClassName(record: TableCustomRecord, index: number) {

View File

@ -6,7 +6,7 @@
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { useIntervalFn } from '@vueuse/core'; import { useIntervalFn } from '@vueuse/core';
import { formatToDateTime, formatToDate, dateUtil } from '/@/utils/dateUtil'; import { formatToDateTime, formatToDate, dateUtil } from '/@/utils/dateUtil';
import { isNumber, isObject, isString } from '/@/utils/is'; import { isNumber, isObject, isString } from '@vben/shared';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
const ONE_SECONDS = 1000; const ONE_SECONDS = 1000;

View File

@ -52,6 +52,7 @@
import 'tinymce/plugins/visualblocks'; import 'tinymce/plugins/visualblocks';
import 'tinymce/plugins/visualchars'; import 'tinymce/plugins/visualchars';
import 'tinymce/plugins/wordcount'; import 'tinymce/plugins/wordcount';
import { isArray, isNumber } from '@vben/shared';
import { import {
defineComponent, defineComponent,
@ -70,7 +71,6 @@
import { bindHandlers } from './helper'; import { bindHandlers } from './helper';
import { onMountedOrActivated } from '@vben/hooks'; import { onMountedOrActivated } from '@vben/hooks';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { isNumber } from '/@/utils/is';
import { useLocale } from '/@/locales/useLocale'; import { useLocale } from '/@/locales/useLocale';
import { useAppStore } from '/@/store/modules/app'; import { useAppStore } from '/@/store/modules/app';
@ -259,7 +259,7 @@
function bindModelHandlers(editor: any) { function bindModelHandlers(editor: any) {
const modelEvents = attrs.modelEvents ? attrs.modelEvents : null; const modelEvents = attrs.modelEvents ? attrs.modelEvents : null;
const normalizedEvents = Array.isArray(modelEvents) ? modelEvents.join(' ') : modelEvents; const normalizedEvents = isArray(modelEvents) ? modelEvents.join(' ') : modelEvents;
watch( watch(
() => props.modelValue, () => props.modelValue,

View File

@ -25,7 +25,8 @@
import { TreeIcon } from './TreeIcon'; import { TreeIcon } from './TreeIcon';
import { ScrollContainer } from '/@/components/Container'; import { ScrollContainer } from '/@/components/Container';
import { omit, get, difference, cloneDeep } from 'lodash-es'; import { omit, get, difference, cloneDeep } from 'lodash-es';
import { isArray, isBoolean, isEmpty, isFunction } from '/@/utils/is'; import { isArray, isBoolean, isEmpty, isFunction } from '@vben/shared';
import { type Recordable } from '@vben/types';
import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper'; import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper';
import { filter, treeToList, eachTree } from '/@/utils/helper/treeHelper'; import { filter, treeToList, eachTree } from '/@/utils/helper/treeHelper';
import { useTree } from './hooks/useTree'; import { useTree } from './hooks/useTree';
@ -129,7 +130,7 @@
getSelectedNode, getSelectedNode,
} = useTree(treeDataRef, getFieldNames); } = useTree(treeDataRef, getFieldNames);
function getIcon(params: Recordable, icon?: string) { function getIcon(params: Recordable<any>, icon?: string) {
if (!icon) { if (!icon) {
if (props.renderIcon && isFunction(props.renderIcon)) { if (props.renderIcon && isFunction(props.renderIcon)) {
return props.renderIcon(params); return props.renderIcon(params);
@ -138,13 +139,13 @@
return icon; return icon;
} }
async function handleRightClick({ event, node }: Recordable) { async function handleRightClick({ event, node }: Recordable<any>) {
const { rightMenuList: menuList = [], beforeRightClick } = props; const { rightMenuList: menuList = [], beforeRightClick } = props;
let contextMenuOptions: CreateContextOptions = { event, items: [] }; let contextMenuOptions: CreateContextOptions = { event, items: [] };
if (beforeRightClick && isFunction(beforeRightClick)) { if (beforeRightClick && isFunction(beforeRightClick)) {
let result = await beforeRightClick(node, event); let result = await beforeRightClick(node, event);
if (Array.isArray(result)) { if (isArray(result)) {
contextMenuOptions.items = result; contextMenuOptions.items = result;
} else { } else {
Object.assign(contextMenuOptions, result); Object.assign(contextMenuOptions, result);

View File

@ -1,6 +1,6 @@
import type { VNode, FunctionalComponent } from 'vue'; import type { VNode, FunctionalComponent } from 'vue';
import { h } from 'vue'; import { h } from 'vue';
import { isString } from 'lodash-es'; import { isString } from '@vben/shared';
import Icon from '@/components/Icon/Icon.vue'; import Icon from '@/components/Icon/Icon.vue';
export const TreeIcon: FunctionalComponent = ({ icon }: { icon: VNode | string }) => { export const TreeIcon: FunctionalComponent = ({ icon }: { icon: VNode | string }) => {

View File

@ -44,7 +44,7 @@
import { uploadContainerProps } from './props'; import { uploadContainerProps } from './props';
import { omit } from 'lodash-es'; import { omit } from 'lodash-es';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
import UploadModal from './UploadModal.vue'; import UploadModal from './UploadModal.vue';
import UploadPreviewModal from './UploadPreviewModal.vue'; import UploadPreviewModal from './UploadPreviewModal.vue';

View File

@ -1,7 +1,7 @@
<script lang="tsx"> <script lang="tsx">
import { defineComponent, CSSProperties, watch, nextTick } from 'vue'; import { defineComponent, CSSProperties, watch, nextTick } from 'vue';
import { fileListProps } from './props'; import { fileListProps } from './props';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { useModalContext } from '/@/components/Modal/src/hooks/useModalContext'; import { useModalContext } from '/@/components/Modal/src/hooks/useModalContext';
export default defineComponent({ export default defineComponent({

View File

@ -57,7 +57,7 @@
// utils // utils
import { checkImgType, getBase64WithFile } from './helper'; import { checkImgType, getBase64WithFile } from './helper';
import { buildUUID } from '/@/utils/uuid'; import { buildUUID } from '/@/utils/uuid';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
import { warn } from '/@/utils/log'; import { warn } from '/@/utils/log';
import FileList from './FileList.vue'; import FileList from './FileList.vue';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';

View File

@ -20,7 +20,7 @@
import { downloadByUrl } from '/@/utils/file/download'; import { downloadByUrl } from '/@/utils/file/download';
import { createPreviewColumns, createPreviewActionColumn } from './data'; import { createPreviewColumns, createPreviewActionColumn } from './data';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
export default defineComponent({ export default defineComponent({
components: { BasicModal, FileList }, components: { BasicModal, FileList },

View File

@ -1,6 +1,6 @@
import { on } from '/@/utils/domUtils'; import { on } from '/@/utils/domUtils';
import { isServer } from '/@/utils/is';
import type { ComponentPublicInstance, DirectiveBinding, ObjectDirective } from 'vue'; import type { ComponentPublicInstance, DirectiveBinding, ObjectDirective } from 'vue';
import { isArray } from '@vben/shared';
type DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void; type DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void;
@ -16,18 +16,16 @@ const nodeList: FlushList = new Map();
let startClick: MouseEvent; let startClick: MouseEvent;
if (!isServer) { on(document, 'mousedown', (e: MouseEvent) => (startClick = e));
on(document, 'mousedown', (e: MouseEvent) => (startClick = e)); on(document, 'mouseup', (e: MouseEvent) => {
on(document, 'mouseup', (e: MouseEvent) => { for (const { documentHandler } of nodeList.values()) {
for (const { documentHandler } of nodeList.values()) { documentHandler(e, startClick);
documentHandler(e, startClick); }
} });
});
}
function createDocumentHandler(el: HTMLElement, binding: DirectiveBinding): DocumentHandler { function createDocumentHandler(el: HTMLElement, binding: DirectiveBinding): DocumentHandler {
let excludes: HTMLElement[] = []; let excludes: HTMLElement[] = [];
if (Array.isArray(binding.arg)) { if (isArray(binding.arg)) {
excludes = binding.arg; excludes = binding.arg;
} else { } else {
// due to current implementation on binding type is wrong the type casting is necessary here // due to current implementation on binding type is wrong the type casting is necessary here

View File

@ -1,7 +1,7 @@
import type { Ref } from 'vue'; import type { Ref } from 'vue';
import { ref, onMounted, watch, onUnmounted } from 'vue'; import { ref, onMounted, watch, onUnmounted } from 'vue';
import { isWindow, isObject } from '/@/utils/is'; import { isWindow, isObject } from '@vben/shared';
import { useThrottleFn } from '@vueuse/core'; import { useThrottleFn } from '@vueuse/core';
export function useScroll( export function useScroll(

View File

@ -2,7 +2,7 @@ import { ComputedRef, isRef, nextTick, Ref, ref, unref, watch } from 'vue';
import { onMountedOrActivated, useWindowSizeFn } from '@vben/hooks'; import { onMountedOrActivated, useWindowSizeFn } from '@vben/hooks';
import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight'; import { useLayoutHeight } from '/@/layouts/default/content/useContentViewHeight';
import { getViewportOffset } from '/@/utils/domUtils'; import { getViewportOffset } from '/@/utils/domUtils';
import { isNumber, isString } from '/@/utils/is'; import { isNumber, isString } from '@vben/shared';
export interface CompensationHeight { export interface CompensationHeight {
// 使用 layout Footer 高度作为判断补偿高度的条件 // 使用 layout Footer 高度作为判断补偿高度的条件

View File

@ -1,6 +1,5 @@
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import { isUndefined } from '@vben/shared';
import { isDef } from '/@/utils/is';
interface Options { interface Options {
target?: HTMLElement; target?: HTMLElement;
@ -13,7 +12,7 @@ export function useCopyToClipboard(initial?: string) {
watch( watch(
clipboardRef, clipboardRef,
(str?: string) => { (str?: string) => {
if (isDef(str)) { if (!isUndefined(str)) {
copiedRef.value = true; copiedRef.value = true;
isSuccessRef.value = copyTextToClipboard(str); isSuccessRef.value = copyTextToClipboard(str);
} }

View File

@ -3,7 +3,7 @@ import { Modal, message as Message, notification } from 'ant-design-vue';
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue'; import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
import { NotificationArgsProps, ConfigProps } from 'ant-design-vue/lib/notification'; import { NotificationArgsProps, ConfigProps } from 'ant-design-vue/lib/notification';
import { useI18n } from './useI18n'; import { useI18n } from './useI18n';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
export interface NotifyApi { export interface NotifyApi {
info(config: NotificationArgsProps): void; info(config: NotificationArgsProps): void;

View File

@ -14,7 +14,7 @@ import { PermissionModeEnum } from '/@/enums/appEnum';
import { RoleEnum } from '/@/enums/roleEnum'; import { RoleEnum } from '/@/enums/roleEnum';
import { intersection } from 'lodash-es'; import { intersection } from 'lodash-es';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
import { useMultipleTabStore } from '/@/store/modules/multipleTab'; import { useMultipleTabStore } from '/@/store/modules/multipleTab';
// User permissions related operations // User permissions related operations

View File

@ -1,7 +1,7 @@
import { getCurrentInstance, onBeforeUnmount, ref, Ref, shallowRef, unref } from 'vue'; import { getCurrentInstance, onBeforeUnmount, ref, Ref, shallowRef, unref } from 'vue';
import { useRafThrottle } from '/@/utils/domUtils'; import { useRafThrottle } from '/@/utils/domUtils';
import { addResizeListener, removeResizeListener } from '/@/utils/event'; import { addResizeListener, removeResizeListener } from '/@/utils/event';
import { isDef } from '/@/utils/is'; import { isUndefined } from '@vben/shared';
const domSymbol = Symbol('watermark-dom'); const domSymbol = Symbol('watermark-dom');
const sourceMap = new WeakMap<HTMLElement, {}>(); const sourceMap = new WeakMap<HTMLElement, {}>();
@ -58,13 +58,13 @@ export function useWatermark(
) { ) {
const el = unref(watermarkEl); const el = unref(watermarkEl);
if (!el) return; if (!el) return;
if (isDef(options.width)) { if (!isUndefined(options.width)) {
el.style.width = `${options.width}px`; el.style.width = `${options.width}px`;
} }
if (isDef(options.height)) { if (!isUndefined(options.height)) {
el.style.height = `${options.height}px`; el.style.height = `${options.height}px`;
} }
if (isDef(options.str)) { if (!isUndefined(options.str)) {
el.style.background = `url(${createBase64(options.str)}) left top repeat`; el.style.background = `url(${createBase64(options.str)}) left top repeat`;
} }
} }

View File

@ -29,7 +29,7 @@
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { isString } from '/@/utils/is'; import { isString } from '@vben/shared';
import { filter } from '/@/utils/helper/treeHelper'; import { filter } from '/@/utils/helper/treeHelper';
import { getMenus } from '/@/router/menus'; import { getMenus } from '/@/router/menus';

View File

@ -58,7 +58,8 @@
import { ListItem } from './data'; import { ListItem } from './data';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { List, Avatar, Tag, Typography } from 'ant-design-vue'; import { List, Avatar, Tag, Typography } from 'ant-design-vue';
import { isNumber } from '/@/utils/is'; import { isNumber } from '@vben/shared';
export default defineComponent({ export default defineComponent({
components: { components: {
[Avatar.name]: Avatar, [Avatar.name]: Avatar,

View File

@ -15,7 +15,7 @@
import { useSplitMenu } from './useLayoutMenu'; import { useSplitMenu } from './useLayoutMenu';
import { openWindow } from '/@/utils'; import { openWindow } from '/@/utils';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import { isUrl } from '/@/utils/is'; import { isHttpUrl } from '@vben/shared';
import { useRootSetting } from '/@/hooks/setting/useRootSetting'; import { useRootSetting } from '/@/hooks/setting/useRootSetting';
import { useAppInject } from '/@/hooks/web/useAppInject'; import { useAppInject } from '/@/hooks/web/useAppInject';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
@ -119,7 +119,7 @@
* @param menu * @param menu
*/ */
async function beforeMenuClickFn(path: string) { async function beforeMenuClickFn(path: string) {
if (!isUrl(path)) { if (!isHttpUrl(path)) {
return true; return true;
} }
openWindow(path); openWindow(path);

View File

@ -3,7 +3,6 @@ import type { RouteLocationNormalized } from 'vue-router';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { useSortable } from '/@/hooks/web/useSortable'; import { useSortable } from '/@/hooks/web/useSortable';
import { useMultipleTabStore } from '/@/store/modules/multipleTab'; import { useMultipleTabStore } from '/@/store/modules/multipleTab';
import { isNullAndUnDef } from '/@/utils/is';
import projectSetting from '/@/settings/projectSetting'; import projectSetting from '/@/settings/projectSetting';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -68,7 +67,7 @@ export function useTabsDrag(affixTextList: string[]) {
onEnd: (evt) => { onEnd: (evt) => {
const { oldIndex, newIndex } = evt; const { oldIndex, newIndex } = evt;
if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) { if (oldIndex === newIndex) {
return; return;
} }

View File

@ -2,7 +2,7 @@ import { AppRouteModule } from '/@/router/types';
import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types'; import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
import { findPath, treeMap } from '/@/utils/helper/treeHelper'; import { findPath, treeMap } from '/@/utils/helper/treeHelper';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { isUrl } from '/@/utils/is'; import { isHttpUrl } from '@vben/shared';
import { RouteParams } from 'vue-router'; import { RouteParams } from 'vue-router';
import { toRaw } from 'vue'; import { toRaw } from 'vue';
@ -20,7 +20,7 @@ function joinParentPath(menus: Menu[], parentPath = '') {
// 请注意,以 / 开头的嵌套路径将被视为根路径。 // 请注意,以 / 开头的嵌套路径将被视为根路径。
// This allows you to leverage the component nesting without having to use a nested URL. // This allows you to leverage the component nesting without having to use a nested URL.
// 这允许你利用组件嵌套,而无需使用嵌套 URL。 // 这允许你利用组件嵌套,而无需使用嵌套 URL。
if (!(menu.path.startsWith('/') || isUrl(menu.path))) { if (!(menu.path.startsWith('/') || isHttpUrl(menu.path))) {
// path doesn't start with /, nor is it a url, join parent path // path doesn't start with /, nor is it a url, join parent path
// 路径不以 / 开头,也不是 url加入父路径 // 路径不以 / 开头,也不是 url加入父路径
menu.path = `${parentPath}/${menu.path}`; menu.path = `${parentPath}/${menu.path}`;

View File

@ -5,7 +5,7 @@ import { useAppStoreWithOut } from '/@/store/modules/app';
import { usePermissionStore } from '/@/store/modules/permission'; import { usePermissionStore } from '/@/store/modules/permission';
import { transformMenuModule, getAllParentPath } from '/@/router/helper/menuHelper'; import { transformMenuModule, getAllParentPath } from '/@/router/helper/menuHelper';
import { filter } from '/@/utils/helper/treeHelper'; import { filter } from '/@/utils/helper/treeHelper';
import { isUrl } from '/@/utils/is'; import { isHttpUrl, isArray } from '@vben/shared';
import { router } from '/@/router'; import { router } from '/@/router';
import { PermissionModeEnum } from '/@/enums/appEnum'; import { PermissionModeEnum } from '/@/enums/appEnum';
import { pathToRegexp } from 'path-to-regexp'; import { pathToRegexp } from 'path-to-regexp';
@ -16,7 +16,7 @@ const menuModules: MenuModule[] = [];
Object.keys(modules).forEach((key) => { Object.keys(modules).forEach((key) => {
const mod = modules[key].default || {}; const mod = modules[key].default || {};
const modList = Array.isArray(mod) ? [...mod] : [mod]; const modList = isArray(mod) ? [...mod] : [mod];
menuModules.push(...modList); menuModules.push(...modList);
}); });
@ -115,7 +115,7 @@ export async function getChildrenMenus(parentPath: string) {
function basicFilter(routes: RouteRecordNormalized[]) { function basicFilter(routes: RouteRecordNormalized[]) {
return (menu: Menu) => { return (menu: Menu) => {
const matchRoute = routes.find((route) => { const matchRoute = routes.find((route) => {
if (isUrl(menu.path)) return true; if (isHttpUrl(menu.path)) return true;
if (route.meta?.carryParam) { if (route.meta?.carryParam) {
return pathToRegexp(route.path).test(menu.path); return pathToRegexp(route.path).test(menu.path);

View File

@ -5,6 +5,7 @@ import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic';
import { mainOutRoutes } from './mainOut'; import { mainOutRoutes } from './mainOut';
import { PageEnum } from '/@/enums/pageEnum'; import { PageEnum } from '/@/enums/pageEnum';
import { t } from '/@/hooks/web/useI18n'; import { t } from '/@/hooks/web/useI18n';
import { isArray } from '@vben/shared';
// import.meta.globEager() 直接引入所有的模块 Vite 独有的功能 // import.meta.globEager() 直接引入所有的模块 Vite 独有的功能
const modules = import.meta.globEager('./modules/**/*.ts'); const modules = import.meta.globEager('./modules/**/*.ts');
@ -13,7 +14,7 @@ const routeModuleList: AppRouteModule[] = [];
// 加入到路由集合中 // 加入到路由集合中
Object.keys(modules).forEach((key) => { Object.keys(modules).forEach((key) => {
const mod = modules[key].default || {}; const mod = modules[key].default || {};
const modList = Array.isArray(mod) ? [...mod] : [mod]; const modList = isArray(mod) ? [...mod] : [mod];
routeModuleList.push(...modList); routeModuleList.push(...modList);
}); });

View File

@ -14,7 +14,7 @@ import { router } from '/@/router';
import { usePermissionStore } from '/@/store/modules/permission'; import { usePermissionStore } from '/@/store/modules/permission';
import { RouteRecordRaw } from 'vue-router'; import { RouteRecordRaw } from 'vue-router';
import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic'; import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
import { h } from 'vue'; import { h } from 'vue';
interface UserState { interface UserState {

View File

@ -1,4 +1,5 @@
import { prefixCls } from '/@/settings/designSetting'; import { prefixCls } from '/@/settings/designSetting';
import { isArray } from '@vben/shared';
type Mod = string | { [key: string]: any }; type Mod = string | { [key: string]: any };
type Mods = Mod | Mod[]; type Mods = Mod | Mod[];
@ -14,7 +15,7 @@ function genBem(name: string, mods?: Mods): string {
return ` ${name}--${mods}`; return ` ${name}--${mods}`;
} }
if (Array.isArray(mods)) { if (isArray(mods)) {
return mods.reduce<string>((ret, item) => ret + genBem(name, item), ''); return mods.reduce<string>((ret, item) => ret + genBem(name, item), '');
} }

View File

@ -1,7 +1,7 @@
import { cacheCipher } from '/@/settings/encryptionSetting'; import { cacheCipher } from '/@/settings/encryptionSetting';
import type { EncryptionParams } from '/@/utils/cipher'; import type { EncryptionParams } from '/@/utils/cipher';
import { AesEncryption } from '/@/utils/cipher'; import { AesEncryption } from '/@/utils/cipher';
import { isNullOrUnDef } from '/@/utils/is'; import { isNullOrUndefined } from '@vben/shared';
export interface CreateStorageParams extends EncryptionParams { export interface CreateStorageParams extends EncryptionParams {
prefixKey: string; prefixKey: string;
@ -60,7 +60,7 @@ export const createStorage = ({
const stringData = JSON.stringify({ const stringData = JSON.stringify({
value, value,
time: Date.now(), time: Date.now(),
expire: !isNullOrUnDef(expire) ? new Date().getTime() + expire * 1000 : null, expire: !isNullOrUndefined(expire) ? new Date().getTime() + expire * 1000 : null,
}); });
const stringifyValue = this.hasEncrypt const stringifyValue = this.hasEncrypt
? this.encryption.encryptByAES(stringData) ? this.encryption.encryptByAES(stringData)
@ -82,7 +82,7 @@ export const createStorage = ({
const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val; const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val;
const data = JSON.parse(decVal); const data = JSON.parse(decVal);
const { value, expire } = data; const { value, expire } = data;
if (isNullOrUnDef(expire) || expire >= new Date().getTime()) { if (isNullOrUndefined(expire) || expire >= new Date().getTime()) {
return value; return value;
} }
this.remove(key); this.remove(key);

View File

@ -1,7 +1,5 @@
import ResizeObserver from 'resize-observer-polyfill'; import ResizeObserver from 'resize-observer-polyfill';
const isServer = typeof window === 'undefined';
/* istanbul ignore next */ /* istanbul ignore next */
function resizeHandler(entries: any[]) { function resizeHandler(entries: any[]) {
for (const entry of entries) { for (const entry of entries) {
@ -16,7 +14,6 @@ function resizeHandler(entries: any[]) {
/* istanbul ignore next */ /* istanbul ignore next */
export function addResizeListener(element: any, fn: () => any) { export function addResizeListener(element: any, fn: () => any) {
if (isServer) return;
if (!element.__resizeListeners__) { if (!element.__resizeListeners__) {
element.__resizeListeners__ = []; element.__resizeListeners__ = [];
element.__ro__ = new ResizeObserver(resizeHandler); element.__ro__ = new ResizeObserver(resizeHandler);

View File

@ -1,3 +1,5 @@
import { isArray } from '@vben/shared';
interface TreeHelperConfig { interface TreeHelperConfig {
id: string; id: string;
children: string; children: string;
@ -181,7 +183,7 @@ export function treeMapEach(
data: any, data: any,
{ children = 'children', conversion }: { children?: string; conversion: Fn }, { children = 'children', conversion }: { children?: string; conversion: Fn },
) { ) {
const haveChildren = Array.isArray(data[children]) && data[children].length > 0; const haveChildren = isArray(data[children]) && data[children].length > 0;
const conversionData = conversion(data) || {}; const conversionData = conversion(data) || {};
if (haveChildren) { if (haveChildren) {
return { return {

View File

@ -1,5 +1,5 @@
import { Slots } from 'vue'; import { Slots } from 'vue';
import { isFunction } from '/@/utils/is'; import { isFunction } from '@vben/shared';
/** /**
* @description: Get slot to prevent empty error * @description: Get slot to prevent empty error

View File

@ -10,7 +10,7 @@ import type { CreateAxiosOptions } from './axiosTransform';
import axios from 'axios'; import axios from 'axios';
import qs from 'qs'; import qs from 'qs';
import { AxiosCanceler } from './axiosCancel'; import { AxiosCanceler } from './axiosCancel';
import { isFunction } from '/@/utils/is'; import { isFunction, isArray } from '@vben/shared';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { ContentTypeEnum, RequestEnum } from '/@/enums/httpEnum'; import { ContentTypeEnum, RequestEnum } from '/@/enums/httpEnum';
@ -138,7 +138,7 @@ export class VAxios {
if (params.data) { if (params.data) {
Object.keys(params.data).forEach((key) => { Object.keys(params.data).forEach((key) => {
const value = params.data![key]; const value = params.data![key];
if (Array.isArray(value)) { if (isArray(value)) {
value.forEach((item) => { value.forEach((item) => {
formData.append(`${key}[]`, item); formData.append(`${key}[]`, item);
}); });

View File

@ -1,4 +1,4 @@
import { isObject, isString } from '/@/utils/is'; import { isString, isObject } from '@vben/shared';
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'; const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';

View File

@ -10,7 +10,7 @@ import { checkStatus } from './checkStatus';
import { useGlobSetting } from '/@/hooks/setting'; import { useGlobSetting } from '/@/hooks/setting';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { RequestEnum, ResultEnum, ContentTypeEnum } from '/@/enums/httpEnum'; import { RequestEnum, ResultEnum, ContentTypeEnum } from '/@/enums/httpEnum';
import { isString, isUnDef, isNull, isEmpty } from '/@/utils/is'; import { isString, isUndefined, isEmpty } from '@vben/shared';
import { getToken } from '/@/utils/auth'; import { getToken } from '/@/utils/auth';
import { setObjToUrlParams, deepMerge } from '/@/utils'; import { setObjToUrlParams, deepMerge } from '/@/utils';
import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog'; import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog';
@ -58,7 +58,7 @@ const transform: AxiosTransform = {
if (hasSuccess) { if (hasSuccess) {
let successMsg = message; let successMsg = message;
if (isNull(successMsg) || isUnDef(successMsg) || isEmpty(successMsg)) { if (successMsg === null || isUndefined(successMsg) || isEmpty(successMsg)) {
successMsg = t(`sys.api.operationSuccess`); successMsg = t(`sys.api.operationSuccess`);
} }

View File

@ -2,7 +2,7 @@ import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router'
import type { App, Component } from 'vue'; import type { App, Component } from 'vue';
import { unref } from 'vue'; import { unref } from 'vue';
import { isArray, isObject } from '/@/utils/is'; import { isArray, isObject } from '@vben/shared';
import { cloneDeep, isEqual, mergeWith, unionWith } from 'lodash-es'; import { cloneDeep, isEqual, mergeWith, unionWith } from 'lodash-es';
export const noop = () => {}; export const noop = () => {};

View File

@ -1,98 +0,0 @@
const toString = Object.prototype.toString;
export function is(val: unknown, type: string) {
return toString.call(val) === `[object ${type}]`;
}
export function isDef<T = unknown>(val?: T): val is T {
return typeof val !== 'undefined';
}
export function isUnDef<T = unknown>(val?: T): val is T {
return !isDef(val);
}
export function isObject(val: any): val is Record<any, any> {
return val !== null && is(val, 'Object');
}
export function isEmpty<T = unknown>(val: T): val is T {
if (isArray(val) || isString(val)) {
return val.length === 0;
}
if (val instanceof Map || val instanceof Set) {
return val.size === 0;
}
if (isObject(val)) {
return Object.keys(val).length === 0;
}
return false;
}
export function isDate(val: unknown): val is Date {
return is(val, 'Date');
}
export function isNull(val: unknown): val is null {
return val === null;
}
export function isNullAndUnDef(val: unknown): val is null | undefined {
return isUnDef(val) && isNull(val);
}
export function isNullOrUnDef(val: unknown): val is null | undefined {
return isUnDef(val) || isNull(val);
}
export function isNumber(val: unknown): val is number {
return is(val, 'Number');
}
export function isPromise<T = any>(val: unknown): val is Promise<T> {
return is(val, 'Promise') && isObject(val) && isFunction(val.then) && isFunction(val.catch);
}
export function isString(val: unknown): val is string {
return is(val, 'String');
}
export function isFunction(val: unknown): val is Function {
return typeof val === 'function';
}
export function isBoolean(val: unknown): val is boolean {
return is(val, 'Boolean');
}
export function isRegExp(val: unknown): val is RegExp {
return is(val, 'RegExp');
}
export function isArray(val: any): val is Array<any> {
return val && Array.isArray(val);
}
export function isWindow(val: any): val is Window {
return typeof window !== 'undefined' && is(val, 'Window');
}
export function isElement(val: unknown): val is Element {
return isObject(val) && !!val.tagName;
}
export function isMap(val: unknown): val is Map<any, any> {
return is(val, 'Map');
}
export const isServer = typeof window === 'undefined';
export const isClient = !isServer;
export function isUrl(path: string): boolean {
const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/;
return reg.test(path);
}

View File

@ -1,7 +1,8 @@
// copy from element-plus // copy from element-plus
import { warn } from 'vue'; import { warn } from 'vue';
import { fromPairs, isObject } from 'lodash-es'; import { fromPairs } from 'lodash-es';
import { isObject } from '@vben/shared';
import type { ExtractPropTypes, PropType } from 'vue'; import type { ExtractPropTypes, PropType } from 'vue';
import type { Mutable } from './types'; import type { Mutable } from './types';

View File

@ -60,7 +60,8 @@
import { PageWrapper } from '/@/components/Page'; import { PageWrapper } from '/@/components/Page';
import { Card, Row, Col, Spin } from 'ant-design-vue'; import { Card, Row, Col, Spin } from 'ant-design-vue';
import { cloneDeep, uniq } from 'lodash-es'; import { cloneDeep, uniq } from 'lodash-es';
import { isArray } from '/@/utils/is'; import { isArray } from '@vben/shared';
import { type Nullable } from '@vben/types';
export default defineComponent({ export default defineComponent({
components: { BasicTree, PageWrapper, Card, Row, Col, Spin }, components: { BasicTree, PageWrapper, Card, Row, Col, Spin },

View File

@ -28,7 +28,7 @@
import { Empty, Input, Form, FormItem, Switch, Checkbox, Select, Slider } from 'ant-design-vue'; import { Empty, Input, Form, FormItem, Switch, Checkbox, Select, Slider } from 'ant-design-vue';
import RuleProps from './RuleProps.vue'; import RuleProps from './RuleProps.vue';
import { useFormDesignState } from '../../../hooks/useFormDesignState'; import { useFormDesignState } from '../../../hooks/useFormDesignState';
import { isArray } from 'lodash-es'; import { isArray } from '@vben/shared';
export default defineComponent({ export default defineComponent({
name: 'FormItemProps', name: 'FormItemProps',

Some files were not shown because too many files have changed in this diff Show More