Skip to content

Commit ec98bbf

Browse files
committed
add: 支持自定义浏览器缓存字的键名
1 parent e6efaf5 commit ec98bbf

6 files changed

Lines changed: 25 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## 更新日志
22

3+
### 2.1.4
4+
5+
*2024-09-10*
6+
7+
#### Feat ✨
8+
9+
- 支持自定义浏览器缓存字的键名
10+
311
### 2.1.3
412

513
*2024-07-15*

README.en.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,9 @@ The solution is very simple. Add a script to the `head` in the `html`, which rea
143143
```html
144144
<script src="https://unpkg.com/element-theme-darkplus/utils/dark-mode.js"></script>
145145
```
146+
147+
Support custom browser cache word key name.
148+
149+
```html
150+
<script src="https://unpkg.com/element-theme-darkplus/utils/dark-mode.js" storage-key="custom-theme-appearance"></script>
151+
```

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,9 @@ Vue.component(Rate.name, Darken(Rate))
143143
```html
144144
<script src="https://unpkg.com/element-theme-darkplus/utils/dark-mode.js"></script>
145145
```
146+
147+
支持自定义浏览器缓存字的键名。
148+
149+
```html
150+
<script src="https://unpkg.com/element-theme-darkplus/utils/dark-mode.js" storage-key="custom-theme-appearance"></script>
151+
```

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "element-theme-darkplus",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"description": "Element component dark theme base on the latest version 2.15.14.",
55
"main": "lib/index.css",
66
"style": "lib/index.css",
@@ -10,6 +10,7 @@
1010
"EXAMPLE.md"
1111
],
1212
"scripts": {
13+
"dev": "live-server docs",
1314
"build:css": "gulp build",
1415
"build:scripts": "rollup -c scripts/rollup.config.js"
1516
},
@@ -45,6 +46,7 @@
4546
"gulp-rename": "^2.0.0",
4647
"gulp-sass": "^5.1.0",
4748
"gulp-util": "^3.0.8",
49+
"live-server": "^1.2.2",
4850
"prettier": "^2.8.8",
4951
"rollup": "^4.18.0",
5052
"sass": "1.32.13",

scripts/dark-mode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { scripts } from '../theme.config'
22

3-
const { storageKey } = scripts
3+
const storageKey = document.currentScript?.getAttribute('storage-key') || scripts.storageKey
44
const store = localStorage.getItem(`${storageKey}`)
55
const mediaQuery = window.matchMedia?.('(prefers-color-scheme: dark)')
66
const preferredDark = mediaQuery?.matches || false

utils/dark-mode.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)