35 lines
916 B
TypeScript
35 lines
916 B
TypeScript
export function renderMarketAuthGate(
|
|
document: Document,
|
|
currentWindow: Window,
|
|
message = "请先登录插件"
|
|
): HTMLElement {
|
|
const existingGate = document.querySelector(
|
|
'[data-market-auth-gate="root"]'
|
|
) as HTMLElement | null;
|
|
|
|
if (existingGate) {
|
|
return existingGate;
|
|
}
|
|
|
|
const root = document.createElement("section");
|
|
root.dataset.marketAuthGate = "root";
|
|
root.innerHTML = `
|
|
<strong></strong>
|
|
<p>打开扩展弹窗完成登录后刷新本页</p>
|
|
<button type="button" data-market-auth-help="button">去登录</button>
|
|
`;
|
|
const title = root.querySelector("strong");
|
|
if (title) {
|
|
title.textContent = message;
|
|
}
|
|
|
|
root
|
|
.querySelector('[data-market-auth-help="button"]')
|
|
?.addEventListener("click", () => {
|
|
currentWindow.alert("请点击浏览器工具栏中的扩展图标完成登录");
|
|
});
|
|
|
|
document.body.prepend(root);
|
|
return root;
|
|
}
|