generated from arvinxx/umi-chrome-extensions-template
-
Notifications
You must be signed in to change notification settings - Fork 7
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
8 changed files
with
167 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
console.log('This is background page!'); | ||
|
||
chrome.browserAction.onClicked.addListener((tab) => { | ||
console.log(tab); | ||
console.log('123'); | ||
chrome.browserAction.onClicked.addListener(() => { | ||
chrome.tabs.create({ url: 'https://yuque.com' }); | ||
}); | ||
|
||
export default null; | ||
chrome.runtime.onMessage.addListener((message) => { | ||
switch (message.action) { | ||
case 'openOptionsPage': | ||
chrome.runtime.openOptionsPage(); | ||
break; | ||
default: | ||
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
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
26 changes: 26 additions & 0 deletions
26
src/contentScripts/searchBar/app/useCheckTokenValidService.ts
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 @@ | ||
import { useContext, useEffect } from 'react'; | ||
|
||
import { SearchBarService } from './useSearchBarService'; | ||
import { YuqueTokenService } from '@/services'; | ||
|
||
/** | ||
* SearchInput 需要的状态 | ||
*/ | ||
export const useCheckTokenValidService = () => { | ||
const { visible } = useContext(SearchBarService); | ||
|
||
const { checkTokenValid, valid } = useContext(YuqueTokenService); | ||
|
||
useEffect(() => { | ||
// 可见且 token 无效时 检查 token | ||
if (visible && !valid) { | ||
checkTokenValid(); | ||
} | ||
}, [visible, checkTokenValid]); | ||
|
||
useEffect(() => { | ||
checkTokenValid(); | ||
}, []); | ||
|
||
return valid; | ||
}; |
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
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