generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
078ac58
commit 3eb9376
Showing
7 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const addScript = (url: string, id: string): HTMLElement => { | ||
const headElement = document.getElementsByTagName("head")[0]; | ||
const scriptElement = document.createElement("script"); | ||
scriptElement.id = id; | ||
scriptElement.src = url; | ||
headElement.append(scriptElement); | ||
return scriptElement; | ||
}; | ||
|
||
export const addStyleSheet = (url: string, id: string): HTMLElement => { | ||
const headElement = document.getElementsByTagName("head")[0]; | ||
const linkElement = document.createElement("link"); | ||
linkElement.id = id; | ||
linkElement.rel = "stylesheet"; | ||
linkElement.href = url; | ||
headElement.append(linkElement); | ||
return linkElement; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Inject } from "@/type/editor"; | ||
import { addScript, addStyleSheet } from "@/utils/dom-utils"; | ||
|
||
export const quickInsertInject = (injectList: Inject[], id: string): void => { | ||
injectList.forEach((inject) => { | ||
const injectId = `${id}-${inject.id}`; | ||
switch (inject.type) { | ||
case "script": | ||
addScript(inject.url || "", injectId); | ||
break; | ||
case "style": | ||
addStyleSheet(inject.url || "", injectId); | ||
break; | ||
} | ||
}); | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
customElements.define( | ||
"joe-cloud", | ||
class JoeCloud extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.options = { | ||
type: this.getAttribute("type") || "default", | ||
title: this.getAttribute("title") || "默认标题", | ||
url: this.getAttribute("url"), | ||
password: this.getAttribute("password"), | ||
}; | ||
const type = { | ||
default: "默认网盘", | ||
360: "360网盘", | ||
bd: "百度网盘", | ||
ty: "天翼网盘", | ||
ct: "城通网盘", | ||
wy: "微云网盘", | ||
github: "Github仓库", | ||
gitee: "Gitee仓库", | ||
lz: "蓝奏云网盘", | ||
ad: "阿里云盘", | ||
}; | ||
this.innerHTML = ` | ||
<span class="joe_cloud"> | ||
<div class="joe_cloud__logo _${this.options.type}"></div> | ||
<div class="joe_cloud__describe"> | ||
<div class="joe_cloud__describe-title">${this.options.title}</div> | ||
<div class="joe_cloud__describe-type">来源:${ | ||
type[this.options.type] || "默认网盘" | ||
}${ | ||
this.options.password ? " | 提取码:" + this.options.password : "" | ||
}</div> | ||
</div> | ||
<a class="joe_cloud__btn" href="${ | ||
this.options.url | ||
}" target="_blank" rel="noopener noreferrer nofollow"> | ||
<i class="fa fa-download"></i> | ||
</a> | ||
</span> | ||
`; | ||
} | ||
} | ||
); |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"name": "Joe Theme", | ||
"tip": "Joe自定义模块", | ||
"provider": "halo-theme-joe-3.0", | ||
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\"><path d=\"M480-80q-26 0-47-12.5T400-126q-33 0-56.5-23.5T320-206v-142q-59-39-94.5-103T190-590q0-121 84.5-205.5T480-880q121 0 205.5 84.5T770-590q0 77-35.5 140T640-348v142q0 33-23.5 56.5T560-126q-12 21-33 33.5T480-80Zm-80-126h160v-36H400v36Zm0-76h160v-38H400v38Zm-8-118h58v-108l-88-88 42-42 76 76 76-76 42 42-88 88v108h58q54-26 88-76.5T690-590q0-88-61-149t-149-61q-88 0-149 61t-61 149q0 63 34 113.5t88 76.5Zm88-162Zm0-38Z\"/></svg>", | ||
"schema": [ | ||
{ | ||
"type": "template", | ||
"id": "joe-cloud", | ||
"icon": "", | ||
"name": "网盘资源", | ||
"formKit": [ | ||
{ | ||
"$formkit": "select", | ||
"name": "cloud-type", | ||
"label": "云盘类型", | ||
"help": "Choose the type of cloud service.", | ||
"value": "default", | ||
"options": [ | ||
{"label": "默认网盘", "value": "default"}, | ||
{"label": "百度网盘", "value": "bd"}, | ||
{"label": "阿里网盘", "value": "ad"}, | ||
{"label": "蓝奏云网盘", "value": "lz"}, | ||
{"label": "微云网盘", "value": "wy"}, | ||
{"label": "Github仓库", "value": "github"}, | ||
{"label": "Gitee仓库", "value": "gitee"} | ||
] | ||
}, | ||
{ | ||
"$formkit": "text", | ||
"name": "cloud-title", | ||
"label": "网盘名称", | ||
"help": "留空则显示默认标题" | ||
}, | ||
{ | ||
"$formkit": "url", | ||
"name": "cloud-url", | ||
"label": "跳转链接", | ||
"help": "网盘链接地址", | ||
"value": "" | ||
}, | ||
{ | ||
"$formkit": "text", | ||
"name": "cloud-password", | ||
"label": "密码", | ||
"help": "网盘的访问密码,无则留空", | ||
"value": "" | ||
} | ||
], | ||
"template": "<joe-cloud type=\"$cloud-type$\" url=\"$cloud-url$\" password=\"$cloud-password$\" title=\"$cloud-title$\"></joe-cloud>" | ||
} | ||
], | ||
"inject": [ | ||
{ | ||
"id": "inject-js", | ||
"type": "script", | ||
"url": "/plugins/vditor-mde/assets/static/inject-demo.js" | ||
}, | ||
{ | ||
"id": "inject-css", | ||
"type": "style", | ||
"url": "/plugins/vditor-mde/assets/static/inject-demo.css" | ||
}, | ||
{ | ||
"id": "inject-font", | ||
"type": "style", | ||
"url": "/themes/theme-Joe3/assets/lib/font-awesome/css/font-awesome.min.css" | ||
} | ||
] | ||
} |