generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
5,341 additions
and
126 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Wed May 10 13:57:01 CST 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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 |
---|---|---|
@@ -1,89 +1,89 @@ | ||
@rem | ||
@rem Copyright 2015 the original author or authors. | ||
@rem | ||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
@rem you may not use this file except in compliance with the License. | ||
@rem You may obtain a copy of the License at | ||
@rem | ||
@rem https://www.apache.org/licenses/LICENSE-2.0 | ||
@rem | ||
@rem Unless required by applicable law or agreed to in writing, software | ||
@rem distributed under the License is distributed on an "AS IS" BASIS, | ||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@rem See the License for the specific language governing permissions and | ||
@rem limitations under the License. | ||
@rem | ||
|
||
@if "%DEBUG%" == "" @echo off | ||
@rem ########################################################################## | ||
@rem | ||
@rem Gradle startup script for Windows | ||
@rem | ||
@rem ########################################################################## | ||
|
||
@rem Set local scope for the variables with windows NT shell | ||
if "%OS%"=="Windows_NT" setlocal | ||
|
||
set DIRNAME=%~dp0 | ||
if "%DIRNAME%" == "" set DIRNAME=. | ||
set APP_BASE_NAME=%~n0 | ||
set APP_HOME=%DIRNAME% | ||
set JAVA_HOME=E:\jdk\jdk-17 | ||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
|
||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
|
||
@rem Find java.exe | ||
if defined JAVA_HOME goto findJavaFromJavaHome | ||
|
||
set JAVA_EXE=java.exe | ||
%JAVA_EXE% -version >NUL 2>&1 | ||
if "%ERRORLEVEL%" == "0" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:findJavaFromJavaHome | ||
set JAVA_HOME=%JAVA_HOME:"=% | ||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
|
||
if exist "%JAVA_EXE%" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:execute | ||
@rem Setup the command line | ||
|
||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
|
||
|
||
@rem Execute Gradle | ||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
|
||
:end | ||
@rem End local scope for the variables with windows NT shell | ||
if "%ERRORLEVEL%"=="0" goto mainEnd | ||
|
||
:fail | ||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
rem the _cmd.exe /c_ return code! | ||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
exit /b 1 | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega | ||
@rem | ||
@rem Copyright 2015 the original author or authors. | ||
@rem | ||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
@rem you may not use this file except in compliance with the License. | ||
@rem You may obtain a copy of the License at | ||
@rem | ||
@rem https://www.apache.org/licenses/LICENSE-2.0 | ||
@rem | ||
@rem Unless required by applicable law or agreed to in writing, software | ||
@rem distributed under the License is distributed on an "AS IS" BASIS, | ||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@rem See the License for the specific language governing permissions and | ||
@rem limitations under the License. | ||
@rem | ||
|
||
@if "%DEBUG%" == "" @echo off | ||
@rem ########################################################################## | ||
@rem | ||
@rem Gradle startup script for Windows | ||
@rem | ||
@rem ########################################################################## | ||
|
||
@rem Set local scope for the variables with windows NT shell | ||
if "%OS%"=="Windows_NT" setlocal | ||
|
||
set DIRNAME=%~dp0 | ||
if "%DIRNAME%" == "" set DIRNAME=. | ||
set APP_BASE_NAME=%~n0 | ||
set APP_HOME=%DIRNAME% | ||
set JAVA_HOME=E:\jdk\jdk-17 | ||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
|
||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
|
||
@rem Find java.exe | ||
if defined JAVA_HOME goto findJavaFromJavaHome | ||
|
||
set JAVA_EXE=java.exe | ||
%JAVA_EXE% -version >NUL 2>&1 | ||
if "%ERRORLEVEL%" == "0" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:findJavaFromJavaHome | ||
set JAVA_HOME=%JAVA_HOME:"=% | ||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
|
||
if exist "%JAVA_EXE%" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:execute | ||
@rem Setup the command line | ||
|
||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
|
||
|
||
@rem Execute Gradle | ||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
|
||
:end | ||
@rem End local scope for the variables with windows NT shell | ||
if "%ERRORLEVEL%"=="0" goto mainEnd | ||
|
||
:fail | ||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
rem the _cmd.exe /c_ return code! | ||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
exit /b 1 | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,81 @@ | ||
!function(){const t="githuboss_githubFastHttps",e=/(http.*jsdelivr.net)/g,n=["https://gcore.jsdelivr.net","https://cdn.jsdelivr.net","https://fastly.jsdelivr.net","https://originfastly.jsdelivr.net","https://quantil.jsdelivr.net"],a=(t,e,n)=>{const a=((t,e)=>t.getAttribute(e))(t,e);a&&a.match(/^http.*jsdelivr\.net/i)&&t.setAttribute(e,s(a,n))},r=async t=>{const e=await Promise.all(t.map((t=>(async t=>{const e=performance.now(),n=`${t}/gh/guicaiyue/FigureBed/Pwa/favicon.ico`;return await fetch(n,{mode:"no-cors"}),performance.now()-e})(t)))),n=Math.min(...e);return t[e.indexOf(n)]},s=(t,n)=>t.replace(e,n),i=()=>{let e=localStorage.getItem(t),s=-1!==n.indexOf(e)?e:/\s*zh-(CN|cn)\s*/g.test(navigator.language||navigator.browserLanguage||navigator.userLanguage)?"https://gcore.jsdelivr.net":"https://cdn.jsdelivr.net",i=document.getElementsByTagName("img");for(let t=0;t<i.length;t++)a(i[t],"src",s),a(i[t],"data-src",s);r(n).then((e=>{return n=e,localStorage.setItem(t,n);var n}))};document.addEventListener("DOMContentLoaded",(function(){i()}))}(); | ||
(function () { | ||
// 立即执行函数开始 | ||
const githubFastHttpsKey = "githuboss_githubFastHttps"; | ||
const imgRegex = /(http.*jsdelivr.net)/g; | ||
const testFilePath = "/gh/guicaiyue/FigureBed/Pwa/favicon.ico"; | ||
const domains = [ | ||
"https://gcore.jsdelivr.net", | ||
"https://cdn.jsdelivr.net", | ||
"https://fastly.jsdelivr.net", | ||
"https://originfastly.jsdelivr.net", | ||
"https://quantil.jsdelivr.net", | ||
]; | ||
|
||
// 获取本地缓存的值 | ||
const getLocalValue = () => localStorage.getItem(githubFastHttpsKey); | ||
|
||
// 设置本地缓存的值 | ||
const setLocalValue = (value) => localStorage.setItem(githubFastHttpsKey, value); | ||
|
||
// 根据浏览器设置的语言判断用户是否在中国 | ||
const isInChina = () => { | ||
const chinaRegexp = /\s*zh-(CN|cn)\s*/g; | ||
return chinaRegexp.test(navigator.language || navigator.browserLanguage || navigator.userLanguage); | ||
}; | ||
|
||
// 获取图片的指定属性地址 | ||
const getImageSrc = (imgElement,attribute) => imgElement.getAttribute(attribute); | ||
|
||
// 替换图片的指定属性地址 | ||
const replaceImageSrc = (imgElement,attribute, domain) => { | ||
const src = getImageSrc(imgElement,attribute); | ||
if (src && src.match(/^http.*jsdelivr\.net/i)) { | ||
imgElement.setAttribute(attribute, replaceImageProtocolAndDomain(src, domain)); | ||
} | ||
} | ||
|
||
// 测试哪个域名速度最快 | ||
const testDomainSpeed = async (domain) => { | ||
try { | ||
const startTime = performance.now(); | ||
const url = `${domain}${testFilePath}`; | ||
const response = await fetch(url, {mode: "no-cors"}); | ||
const endTime = performance.now(); | ||
return endTime - startTime; | ||
}catch (e) { | ||
return 9999999; | ||
} | ||
}; | ||
|
||
// 获取最快的域名 | ||
const getFastestDomain = async (domains) => { | ||
const domainSpeeds = await Promise.all(domains.map((domain) => testDomainSpeed(domain))); | ||
const minSpeed = Math.min(...domainSpeeds); | ||
const index = domainSpeeds.indexOf(minSpeed); | ||
return domains[index]; | ||
}; | ||
|
||
// 替换图片地址的协议和域名 | ||
const replaceImageProtocolAndDomain = (imgSrc, domain) => { | ||
return imgSrc.replace(imgRegex, domain); | ||
}; | ||
|
||
// 初始化操作 | ||
const init = () => { | ||
// 第一步,从本地缓存中获取 githubFastHttps 的值,如果不存在,则根据用户所在地区设置不同的值,并将其设置到本地缓存中 | ||
let githubFastHttps = getLocalValue(); | ||
let domain = domains.indexOf(githubFastHttps) !== -1 ? githubFastHttps : isInChina()? "https://gcore.jsdelivr.net":"https://cdn.jsdelivr.net"; | ||
|
||
// 第二步,替换页面中所有http.*jsdelivr.net的图片路径 | ||
let imgList = document.getElementsByTagName('img'); | ||
for (let i = 0; i < imgList.length; i++) { | ||
replaceImageSrc(imgList[i],"src",domain); | ||
replaceImageSrc(imgList[i],"data-src",domain); | ||
} | ||
// 第三步 异步更新最快的访问地址 | ||
getFastestDomain(domains).then(r => setLocalValue(r)); | ||
}; | ||
document.addEventListener("DOMContentLoaded", function () { | ||
init(); | ||
}); | ||
})(); |
Oops, something went wrong.