-
Notifications
You must be signed in to change notification settings - Fork 0
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
yong.teng
committed
Feb 3, 2023
1 parent
74a309a
commit 0069fad
Showing
5 changed files
with
21 additions
and
18 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
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
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 @@ | ||
export const ALL_PERMISSION = ':'; | ||
export const ALL_PERMISSION = '*:*'; |
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 @@ | ||
export type Un = undefined | null; |
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,21 +1,17 @@ | ||
export const hasAny = (data: string[] | null | undefined, value: any): boolean => { | ||
if (data === null || data === undefined) { | ||
return false; | ||
} | ||
import { Un } from "@/core/types"; | ||
|
||
return data.indexOf(value) >= 0; | ||
export const hasAny = (data: string[] | Un, value: any): boolean => { | ||
return Array.isArray(data) && data.indexOf(value) >= 0; | ||
} | ||
|
||
export const hasAll = (data: string[] | null | undefined, values: any[] | null | undefined): boolean => { | ||
if ((data === null || data === undefined) || (values === null || values === undefined || values.length === 0)) { | ||
return false; | ||
} | ||
|
||
for (let i = 0; i < values.length; i++) { | ||
if (data.indexOf(values[i]) < 0) { | ||
return false; | ||
export const hasAll = (data: string[] | Un, values: any[] | Un): boolean => { | ||
if (Array.isArray(data) && (Array.isArray(values) && values.length > 0)) { | ||
for (let i = 0; i < values.length; i++) { | ||
if (data.indexOf(values[i]) >= 0) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
return false; | ||
} |