From 000ef0b189975b8d513967fa5a31584138751c56 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 03 十二月 2024 17:47:30 +0800 Subject: [PATCH] loadAmisSource --- customer_list/ch/index.js | 74 ------------------------------------- 1 files changed, 0 insertions(+), 74 deletions(-) diff --git a/customer_list/ch/index.js b/customer_list/ch/index.js index 87269c0..1a9f36a 100644 --- a/customer_list/ch/index.js +++ b/customer_list/ch/index.js @@ -16,77 +16,3 @@ title.innerText = sysName; faviconIcon.href = icon + `?v=1`; -//#region ====================== LCP Promise ====================== -const loadBaseLCP = new Promise((resolve, reject) => { - try { - // 妫�鏌ユ槸鍚︽敮鎸� PerformanceObserver 鍜� LCP 鎸囨爣 - if ('PerformanceObserver' in window && PerformanceObserver.supportedEntryTypes.includes('largest-contentful-paint')) { - const observer = new PerformanceObserver((list) => { - window.list = list.getEntries(); - for (const entry of list.getEntries()) { - resolve(entry); - observer.disconnect(); // 瀹屾垚鍚庢柇寮�瑙傚療鑰� - } - }); - observer.observe({ type: 'largest-contentful-paint', buffered: true }); - } else { - // 涓嶆敮鎸佹椂 浣跨敤onLoad 鍔犺浇 - window.addEventListener('load', () => { - resolve(true); - }); - } - } catch (error) { - reject(error); - } -}); -//#endregion - -//#region ====================== 鍔犺浇script ====================== - -function loadScript(src, callback) { - const script = document.createElement('script'); - script.setAttribute('type', 'text/javascript'); - script.setAttribute('src', src); - script.async = true; - script.onload = () => callback(); - script.onerror = () => callback(new Error(`Failed to load ${src}`)); - document.head.appendChild(script); -} -window.eventList = {}; - -loadBaseLCP.then(() => { - window.eventList.amisSdkJsPromise = new Promise((resolve, reject) => { - loadScript('/static/amis/sdk/sdk.js', (error) => { - if (error) { - reject(error); - return; - } - resolve(); - }); - }); -}); - -//#endregion - -//#region ====================== 鍔犺浇鏍峰紡 ====================== -function loadStyles(styles) { - for (const path of styles) { - const style = document.createElement('link'); - style.setAttribute('rel', 'stylesheet'); - style.setAttribute('type', 'text/css'); - style.setAttribute('href', path); - // 璁剧疆 print 鍙互閬垮厤闃诲椤甸潰娓叉煋 - style.setAttribute('media', 'print'); - style.onload = () => { - style.setAttribute('media', 'all'); - }; - document.head.appendChild(style); - } -} - -loadBaseLCP.then(() => { - loadStyles(['/static/amis/sdk/sdk.css', '/static/amis/sdk/helper.css', '/static/amis/sdk/iconfont.css']); - -}); - -//#endregion -- Gitblit v1.9.3