-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
文档:https://pkuhpc.github.io/SCOW/pr-preview/pr-1311/docs/integration/ui-extension/develop#%E5%A2%9E%E5%8A%A0%E5%AF%BC%E8%88%AA%E6%A0%8F%E9%93%BE%E6%8E%A5post-apiportalmisnavbarlinks 开发示例:PKUHPC/scow-ui-extension-demo#1 --------- Co-authored-by: 何童崇 <[email protected]>
- Loading branch information
Showing
14 changed files
with
373 additions
and
132 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,8 @@ | ||
--- | ||
"@scow/portal-web": patch | ||
"@scow/mis-web": patch | ||
"@scow/lib-web": patch | ||
"@scow/docs": patch | ||
--- | ||
|
||
UI 扩展增加导航栏链接自定义 |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy | ||
* SCOW is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
import { z } from "zod"; | ||
|
||
export const ScowExtensionRouteContext = z.object({ | ||
scowUserToken: z.string().optional(), | ||
scowDark: z.enum(["true", "false"]), | ||
scowLangId: z.string(), | ||
}); | ||
|
||
export type ScowExtensionRouteContext = z.infer<typeof ScowExtensionRouteContext>; | ||
|
||
export function isUrl(input: string): boolean { | ||
try { | ||
new URL(input); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2022 Peking University and Peking University Institute for Computing and Digital Economy | ||
* SCOW is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
import { ScowExtensionRouteContext } from "src/extensions/common"; | ||
import { defineExtensionRoute } from "src/extensions/routes"; | ||
import { z } from "zod"; | ||
|
||
export const NavbarLink = z.object({ | ||
href: z.string({ description: "链接的目标路径,将会被直接填入<a>标签的href" }), | ||
text: z.string(), | ||
icon: z.optional(z.object({ | ||
src: z.string(), | ||
alt: z.string().optional(), | ||
})), | ||
openInNewPage: z.boolean().default(true), | ||
priority: z.number().default(0), | ||
}); | ||
|
||
export type NavbarLink = z.infer<typeof NavbarLink>; | ||
|
||
export const navbarLinksRoute = (from: "portal" | "mis") => defineExtensionRoute({ | ||
path: `/${from}/navbarLinks`, | ||
method: "POST" as const, | ||
query: ScowExtensionRouteContext, | ||
responses: { | ||
200: z.object({ | ||
navbarLinks: z.optional(z.array(NavbarLink)), | ||
}), | ||
}, | ||
}); | ||
|
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
Oops, something went wrong.