1 Star 0 Fork 3

sahara/test-lib-front

forked from anolis/test-lib-front 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
customPlugins.ts 1.82 KB
一键复制 编辑 原始数据 按行查看 历史
import { IApi } from '@umijs/max'
import { publicPath, isPro, replaceStr } from "./config/utils"
const attrReplaceString = ($: any, ele: any) => {
const { name } = $(ele)[0]
if (name === "link") {
const str = $(ele).attr("href")
$(ele).attr("href", str.substr(1, str.length - 1))
}
if (name === "meta") {
const content = $(ele).attr("content")
if (content && ~content.indexOf(replaceStr)) {
$(ele).attr("content", content.replace(`/${replaceStr}/`, `${replaceStr}/`));
}
}
if (name === "script") {
const str = $(ele).attr("src")
$(ele).attr("src", str.substr(1, str.length - 1))
}
}
export default (api: IApi) => {
api.addHTMLMetas(() => [
{
name: "keywords",
content: "OpenAnolis 龙蜥操作系统开源社区 TestLib"
},
{
name: "description",
content: "Test library is a test management system"
},
{
property: "og:description",
content: "Test library is a test management system"
},
{
property: "og:image",
content: publicPath + "logo.png"
},
])
api.addHTMLLinks(() => [
{
rel: "icon",
href: publicPath + "favicon.ico",
type: "image/x-icon"
},
{
type: "image/png",
href: publicPath + "logo.png",
rel: "shortcut icon"
}
])
api.modifyHTML(($) => {
if (isPro) {
$("head").children().each((i, ele) => attrReplaceString($, ele))
$("body").children().each((i, ele) => attrReplaceString($, ele))
const js = $(`<script>window.publicPath = "${replaceStr}/";</script>`)
$("head").append(js)
}
return $;
})
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/wb-jwk/test-lib-front.git
git@gitee.com:wb-jwk/test-lib-front.git
wb-jwk
test-lib-front
test-lib-front
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385