Skip to content

Commit

Permalink
feat: try sync instead of local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Apr 4, 2024
1 parent 141803d commit 776dd44
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion entrypoints/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default defineBackground(() => {
const { menuItemId } = info;
switch (menuItemId as MenuIds) {
case 'usewiki2-open':
chrome.storage.local.get('port', function (result) {
chrome.storage.sync.get('port', function (result) {
if (result.port) {
chrome.tabs.create({
url: 'http://localhost:' + result.port,
Expand Down
12 changes: 6 additions & 6 deletions entrypoints/sidepanel/Sidepanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ const port = ref<number | undefined>();
const aihtml = ref('');
// TODO: use sync instead of local
chrome.storage.local.get('port', function (result) {
chrome.storage.sync.get('port', function (result) {
port.value = result.port || constant.default_port;
});
chrome.storage.local.get('isCheckTw5', function (result) {
chrome.storage.sync.get('isCheckTw5', function (result) {
isCheckTw5.value = result.isCheckTw5;
});
chrome.storage.local.get(['tags'], function (result) {
chrome.storage.sync.get(['tags'], function (result) {
if (result.tags) {
dynamicTags.value = Object.values(result.tags);
} else {
Expand Down Expand Up @@ -152,7 +152,7 @@ const showInput = () => {
const handleInputConfirm = () => {
if (inputValue.value) {
dynamicTags.value.push(inputValue.value.trim());
chrome.storage.local.set({ tags: toRaw(dynamicTags.value) });
chrome.storage.sync.set({ tags: toRaw(dynamicTags.value) });
}
inputVisible.value = false;
inputValue.value = '';
Expand All @@ -172,7 +172,7 @@ const vanillaStatus: IStatus = {
const status = ref<IStatus>(vanillaStatus);
watch(isCheckTw5, async (newValue) => {
chrome.storage.local.set({ isCheckTw5: newValue });
chrome.storage.sync.set({ isCheckTw5: newValue });
if (newValue) {
await checkStatus(port.value!, status, isChecking);
} else {
Expand Down Expand Up @@ -212,7 +212,7 @@ async function ai2md() {
}
function savePort(port: number) {
chrome.storage.local.set({ port });
chrome.storage.sync.set({ port });
if (isCheckTw5.value) {
checkStatus(port, status, isChecking);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "usewiki2",
"description": "Convert HTML to Markdown, and save to your computer, support nodejs tiddlywiki",
"private": true,
"version": "2.6.1",
"version": "2.7.0",
"type": "module",
"scripts": {
"dev": "wxt",
Expand Down
2 changes: 1 addition & 1 deletion utils/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ai = async (question: string, options?: ClientOptions) => {
cancelButtonText: '取消',
}).then(({ value }) => {
apiKey = value;
chrome.storage.local.set({ GROQ_APIKEY: apiKey });
chrome.storage.sync.set({ GROQ_APIKEY: apiKey });
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function saveGROQAPIKEY(GROQ_APIKEY: string) {
});
return;
}
chrome.storage.local.set({ GROQ_APIKEY });
chrome.storage.sync.set({ GROQ_APIKEY });
notify({
type: 'success',
message: '保存成功',
Expand Down

0 comments on commit 776dd44

Please sign in to comment.