This commit is contained in:
孟帅
2023-12-29 20:08:00 +08:00
parent c68004b6da
commit b54055810b
52 changed files with 1468 additions and 1325 deletions

View File

@@ -9,8 +9,8 @@ import { PageEnum } from '@/enums/pageEnum';
import { useGlobSetting } from '@/hooks/setting';
import { isString } from '@/utils/is/';
import { deepMerge, isUrl } from '@/utils';
import { isString, isUrl } from '@/utils/is/';
import { deepMerge } from '@/utils';
import { setObjToUrlParams } from '@/utils/urlUtils';
import { CreateAxiosOptions, RequestOptions, Result } from './types';

View File

@@ -250,9 +250,35 @@ export function lighten(color: string, amount: number) {
)}${addLight(color.substring(4, 6), amount)}`;
}
/**
* 判断是否 url
* */
export function isUrl(url: string) {
return /^(http|https):\/\//g.test(url);
// 获取树的所有节点key
export function getAllExpandKeys(treeData: any): any[] {
let expandedKeys = [];
const expandKeys = (items: any[]) => {
items.forEach((item: any) => {
expandedKeys.push(item.key);
if (item.children && item.children.length > 0) {
expandKeys(item.children);
}
});
};
expandKeys(unref(treeData));
// 去重并转换为数组
expandedKeys = Array.from(new Set(expandedKeys));
return expandedKeys;
}
// 从树中查找指定ID
export function findTreeDataById(data: any[], id: number | string) {
for (const item of data) {
if (item.id === id) {
return item;
}
if (item.children) {
const found = findTreeDataById(item.children, id);
if (found) return found;
}
}
return null;
}

View File

@@ -1,33 +1,50 @@
import { CSSProperties, VNodeChild } from 'vue';
import { createTypes, VueTypeValidableDef, VueTypesInterface } from 'vue-types';
import {
createTypes,
VueTypeExtendCallback,
VueTypeValidableDef,
VueTypesInterface,
} from 'vue-types';
export type VueNode = VNodeChild | JSX.Element;
type PropTypes = VueTypesInterface & {
type ExtendedPropTypes = VueTypesInterface & {
readonly style: VueTypeValidableDef<CSSProperties>;
readonly VNodeChild: VueTypeValidableDef<VueNode>;
};
const propTypes = createTypes({
func: undefined,
bool: undefined,
string: undefined,
number: undefined,
object: undefined,
integer: undefined,
}) as PropTypes;
class CustomVueTypes
extends (createTypes({
func: undefined,
bool: undefined,
string: undefined,
number: undefined,
object: undefined,
integer: undefined,
}) as VueTypesInterface)
implements ExtendedPropTypes
{
static extend(types: VueTypeExtendCallback[]): CustomVueTypes {
return types.reduce((result, { name, ...callbacks }) => {
result[name] = { getter: true, ...callbacks };
return result;
}, this);
}
propTypes.extend([
readonly style!: VueTypeValidableDef<CSSProperties>;
readonly VNodeChild!: VueTypeValidableDef<VueNode>;
}
const propTypes = CustomVueTypes.extend([
{
name: 'style',
getter: true,
type: [String, Object],
default: undefined,
},
{
name: 'VNodeChild',
getter: true,
type: undefined,
},
]);
export { propTypes };