-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { InjectionKey } from "vue"; | ||
|
||
/** | ||
* Creates an injection key for use with the provide/inject API. | ||
* 创建一个用于 provide/inject API 的注入键。 | ||
* | ||
* @template T - The type of value associated with the injection key. | ||
* 与注入键关联的值的类型。 | ||
* @param {string} key - The unique identifier for the injection key. | ||
* 用于标识注入键的唯一标识符。 | ||
* @returns {InjectionKey<T>} Returns the injection key. | ||
* 返回注入键。 | ||
*/ | ||
export function createInjectionKey<T>(key: string): InjectionKey<T> { | ||
return key as any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
Comment, | ||
Fragment, | ||
type VNode, | ||
type VNodeChild, | ||
createTextVNode, | ||
} from "vue"; | ||
|
||
/** | ||
* Flattens an array of VNode children. | ||
* 将 VNode 子数组展平。 | ||
* | ||
* @param {VNodeChild[]} vNodes - The array of VNode children to flatten. | ||
* 要展平的 VNode 子数组。 | ||
* @param {boolean} filterCommentNode - Whether to filter out comment nodes. Default is true. | ||
* 是否过滤掉注释节点。默认为 true。 | ||
* @param {VNode[]} result - The array to store the flattened VNodes. | ||
* 用于存储展平后的 VNodes 的数组。 | ||
* @returns {VNode[]} Returns an array of flattened VNodes. | ||
* 返回展平后的 VNode 数组。 | ||
*/ | ||
export function flattenVNodes( | ||
vNodes: VNodeChild[], | ||
filterCommentNode = true, | ||
result: VNode[] = [], | ||
): VNode[] { | ||
vNodes.forEach((vNode) => { | ||
if (vNode === null) { | ||
return; | ||
} | ||
if (typeof vNode !== "object") { | ||
if (typeof vNode === "string" || typeof vNode === "number") { | ||
result.push(createTextVNode(String(vNode))); | ||
} | ||
return; | ||
} | ||
if (Array.isArray(vNode)) { | ||
flattenVNodes(vNode, filterCommentNode, result); | ||
return; | ||
} | ||
if (vNode.type === Fragment) { | ||
if (vNode.children === null) { | ||
return; | ||
} | ||
if (Array.isArray(vNode.children)) { | ||
flattenVNodes(vNode.children, filterCommentNode, result); | ||
} | ||
// rawSlot | ||
} else if (vNode.type !== Comment) { | ||
result.push(vNode); | ||
} | ||
}); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from "./createInjectionKey"; | ||
export * from "./flattenVNodes"; | ||
export * from "./install"; |
e07ad7d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
celeris-web – ./apps/admin
celeris-web.vercel.app
celeris-web-git-master-kirklin.vercel.app
celeris-web-kirklin.vercel.app
e07ad7d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
celeris-web-api – ./services/admin
celeris-web-api.vercel.app
celeris-web-api-kirklin.vercel.app
celeris-web-api-git-master-kirklin.vercel.app