summaryrefslogtreecommitdiffstats
path: root/libs/Utils.php
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-07-10 22:58:49 +0800
committerBigCoke233 <hi@guhub.cn>2020-07-10 22:58:49 +0800
commit4901b642cd90a9124a4ca5732210707caa030290 (patch)
tree5bb5954a5b306e88e5125d4b44a80710c1f146c0 /libs/Utils.php
parent39b4e65156bb35e5a23ef1904d16716cd9562ab1 (diff)
:zap: Perf: 兼容 typecho 自带反垃圾功能,并优化代码结构
Diffstat (limited to 'libs/Utils.php')
-rw-r--r--libs/Utils.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/libs/Utils.php b/libs/Utils.php
index ab3cb9a..69ebe60 100644
--- a/libs/Utils.php
+++ b/libs/Utils.php
@@ -109,4 +109,35 @@ class Utils
}
}</style>';
}
+
+ /**
+ * 自动生成引用
+ */
+ function addRequires($files,$type,$cdn,$custom) {
+ if ($cdn=='1'){
+ $path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/assets/";
+ }
+ elseif ($cdn=='2'){
+ $path = 'https://raw.githack.com/BigCoke233/miracles/master/assets/';
+ }
+ elseif ($cdn=='4'){
+ $path = 'https://rawcdn.githack.com/BigCoke233/miracles/master/assets/';
+ }
+ elseif ($cdn=='5'){
+ $path = 'https://cdn.9jojo.cn/Miracles/'.themeVersion().'/';
+ }
+ elseif ($cdn=='3'){
+ $path = $custom;
+ }else{
+ $path = Helper::options()->themeUrl("","Miracles/assets");
+ }
+ foreach ($files as $file) {
+ if ($type == "js"){
+ echo "<script src=".$path. $type."/".$file.".".$type."></script>";
+ }
+ elseif ($type == "css"){
+ echo "<link rel=\"stylesheet\" href=".$path. $type."/".$file.".".$type." />";
+ }
+ }
+ }
} \ No newline at end of file