mirror of
https://github.com/bufanyun/hotgo.git
synced 2026-01-22 07:06:02 +08:00
发布v2.12.1版本,更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user