1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| export const revisePath = (path: string) => {
| if (!path) {
| return "";
| }
|
| if (path[0] == "/") {
| return path;
| } else {
| return `/${path}`;
| }
| };
|
| export function firstMenu(list: Array<any>) {
| let path = "";
|
| const fn = (arr: Array<any>) => {
| arr.forEach((e: any) => {
| if (e.type == 1) {
| if (!path) {
| path = e.path;
| }
| } else {
| fn(e.children);
| }
| });
| };
|
| fn(list);
|
| return path || "/404";
| }
|
| export function createLink(url: string, id?: string) {
| const link = document.createElement("link");
| link.href = url;
| link.type = "text/css";
| link.rel = "stylesheet";
| if (id) {
| link.id = id;
| }
|
| setTimeout(() => {
| document.getElementsByTagName("head").item(0)?.appendChild(link);
| }, 0);
| }
|
|