增加ai办公,考勤管理
This commit is contained in:
1 parent
eb9b7beff5
commit
31ae07175d
46 files changed
+9250
-296
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 浏览器标签页图标(favicon)。
|
||||
*
|
||||
* 图标来源:平台「系统设置 - 平台设置 - 平台信息」的「站点图标」(标签 ico)。
|
||||
* 未配置时保留 index.html 里的默认图标,不做任何改写。
|
||||
*/
|
||||
|
||||
const API_BASE_URL = String(import.meta.env.VITE_API_BASE_URL || "").replace(/\/+$/, "");
|
||||
|
||||
/** 相对路径(/uploads/x.ico)补上接口基址,完整 URL 原样使用 */
|
||||
function resolveIconUrl(url) {
|
||||
const value = String(url || "").trim().replace(/\\/g, "/");
|
||||
if (!value) return "";
|
||||
if (/^(https?:)?\/\//i.test(value) || /^(data|blob):/i.test(value)) return value;
|
||||
return `${API_BASE_URL}/${value.replace(/^\/+/, "")}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定地址应用为页面 favicon。
|
||||
* @param {string} url 图片地址(可相对)
|
||||
* @returns {boolean} 是否已应用
|
||||
*/
|
||||
export function applyFavicon(url) {
|
||||
const href = resolveIconUrl(url);
|
||||
if (!href) return false;
|
||||
|
||||
let link = document.querySelector('link[rel="icon"]');
|
||||
if (!link) {
|
||||
link = document.createElement("link");
|
||||
link.setAttribute("rel", "icon");
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
// .ico 显式声明 MIME,其余交给浏览器按扩展名/内容识别
|
||||
if (/\.ico(\?|#|$)/i.test(href)) {
|
||||
link.setAttribute("type", "image/x-icon");
|
||||
} else {
|
||||
link.removeAttribute("type");
|
||||
}
|
||||
link.setAttribute("href", href);
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user