-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
582 additions
and
215 deletions.
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
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 @@ | ||
import { GetItemOptions, Unwatch, WatchCallback } from "wxt/storage"; | ||
import { LemmaData } from "./define"; | ||
import { GlobalMode, SitMode } from "./messaging"; | ||
|
||
export interface Preference { | ||
highlight: string; | ||
} | ||
|
||
interface StorageMap { | ||
"local:percent": number; | ||
"local:rank": string[]; | ||
"local:lemma": LemmaData; | ||
"local:ignore-word": string[]; | ||
"local:site-mode": Record<string, SitMode>; | ||
"local:mode": GlobalMode; | ||
"local:preference": Preference; | ||
} | ||
|
||
export interface GenericStorage<TStorageMap extends Record<string, any>> { | ||
getItem<K extends Extract<keyof TStorageMap, string>>( | ||
key: K, | ||
opts?: GetItemOptions<TStorageMap[K]> | ||
): Promise<TStorageMap[K] | null>; | ||
setItem<K extends Extract<keyof TStorageMap, string>>( | ||
key: K, | ||
value: TStorageMap[K] | null | ||
): Promise<void>; | ||
watch<K extends Extract<keyof TStorageMap, string>>( | ||
key: K, | ||
cb: WatchCallback<TStorageMap[K] | null> | ||
): Unwatch; | ||
unwatch(): void; | ||
} | ||
|
||
declare type ExtensionMessenger<TStorageMap extends Record<string, any>> = | ||
GenericStorage<TStorageMap>; | ||
|
||
function defineExtensionStorage< | ||
TStorageMap extends Record<string, any> = Record<string, any> | ||
>(): ExtensionMessenger<TStorageMap> { | ||
return storage; | ||
} | ||
|
||
export const safeStorage = defineExtensionStorage<StorageMap>(); |
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,26 @@ | ||
const Template = (css: string) => | ||
`.insight-word-enable insight-word.insight-word-highlight { | ||
/* 修改下面样式 */ | ||
${css | ||
.split("\n") | ||
.filter((i) => i.trim() !== "") | ||
.map((i) => " " + i.trim()) | ||
.join("\n")} | ||
/* 结束 */ | ||
}`; | ||
|
||
export const PRESET_HIGHLIGHT_STYLE = [ | ||
Template(` | ||
text-shadow: 0 0 5px #ade30b, 0 0 5px #ade30b | ||
`), | ||
Template(` | ||
text-decoration: rgba(10, 163, 205, 0.491) wavy underline; | ||
`), | ||
Template(` | ||
background-color: rgba(10, 163, 205, 0.491); | ||
`), | ||
Template(` | ||
filter: drop-shadow(0 0 3px #ade30b) drop-shadow(0 0 3px #ade30b); | ||
`), | ||
]; | ||
export const DEFAULT_HIGHLIGHT_STYLE = PRESET_HIGHLIGHT_STYLE[0]; |
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,19 +1,7 @@ | ||
.insight-word-enable { | ||
insight-word.insight-word-highlight { | ||
display: inline; | ||
position: relative; | ||
text-decoration: rgba(10, 163, 205, 0.491) wavy underline; | ||
} | ||
|
||
code insight-word.insight-word-highlight { | ||
text-decoration: inherit; | ||
} | ||
|
||
pre insight-word.insight-word-highlight { | ||
text-decoration: inherit; | ||
} | ||
|
||
code insight-word.insight-word-highlight, | ||
pre insight-word.insight-word-highlight, | ||
insight-word.insight-word-ignore { | ||
text-decoration: inherit; | ||
all: inherit; | ||
} | ||
} |
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,8 +1,8 @@ | ||
#root { | ||
min-width: 300px; | ||
min-width: 320px; | ||
max-width: 1280px; | ||
max-height: 600px; | ||
margin: 0 auto; | ||
padding: 1rem; | ||
text-align: center; | ||
} | ||
|
Oops, something went wrong.