diff --git a/src/renderer.js b/src/renderer.js
index c40c524..3339416 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -1,36 +1,16 @@
const { getConfig, setConfig, onClick, onChange, getStatus } = window.DemoMode
const { plugin: pluginPath, data: dataPath } = LiteLoader.plugins.DemoMode.path
-/**
- * 切换开关状态
- * @param {HTMLInputElement} el
- */
-const toggleSwitch = (el) => {
- if (el.hasAttribute('is-active')) el.removeAttribute('is-active')
- else el.setAttribute('is-active', '')
-}
-
-/**
- * 判断开关状态
- * @param {HTMLInputElement} el
- */
-const isSwitchChecked = (el) => el.hasAttribute('is-active')
-
const DEMO_MODE_BTN_HTML = `
`
-const DEMO_MODE_BTN_STYLE_HTML = ``
// 添加演示模式样式
const addDemoModeStyle = () => {
@@ -56,7 +36,7 @@ const addDemoModeStyle = () => {
const selectorsStr = selectors.join(',')
document.head.insertAdjacentHTML(
'beforeend',
- ``
+ ``
)
})
}
@@ -68,7 +48,10 @@ const addDemoModeBtn = () => {
// 插入演示模式按钮
funcMenu.insertAdjacentHTML('afterbegin', DEMO_MODE_BTN_HTML)
- document.head.insertAdjacentHTML('beforeend', DEMO_MODE_BTN_STYLE_HTML)
+ document.head.insertAdjacentHTML(
+ 'beforeend',
+ ''
+ )
// 监听演示模式按钮点击
const demoModeBtn = document.querySelector('#demoModeBtn')
@@ -124,6 +107,21 @@ setTimeout(() => {
clearInterval(addDemoModeStyleInterval)
}, 10000)
+/**
+ * 切换开关状态
+ * @param {HTMLInputElement} el
+ */
+const toggleSwitch = (el) => {
+ if (el.hasAttribute('is-active')) el.removeAttribute('is-active')
+ else el.setAttribute('is-active', '')
+}
+
+/**
+ * 判断开关状态
+ * @param {HTMLInputElement} el
+ */
+const isSwitchChecked = (el) => el.hasAttribute('is-active')
+
export const onSettingWindowCreated = async (view) => {
// 获取设置页文件路径
const htmlFilePath = `local:///${pluginPath}/src/setting/setting.html`