Skip to content

Commit

Permalink
Merge pull request #25 from GarinZ/v1.0.10
Browse files Browse the repository at this point in the history
V1.0.10
  • Loading branch information
GarinZ authored Apr 11, 2023
2 parents 4e0bf2e + e495bbc commit 3405bf0
Show file tree
Hide file tree
Showing 32 changed files with 492 additions and 250 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "link-map",
"displayName": "Link Map",
"version": "1.0.9",
"version": "1.0.10",
"browserslist": "Chrome >= 96",
"description": "Vertical Tabs Sidebar, But In Tree Structure",
"author": "Garin",
Expand Down
85 changes: 53 additions & 32 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,55 +168,49 @@
"message": "Link Map feels stronger!"
},
"updateNoteContent": {
"message": "That's right Link Map has been updated again, this time with some additional features and optimizations based on your feedback, check it out (yes, the details are still in the top node)"
"message": "In the v1.0.0, there is some little improvements to give your more detail control of Link Map’s behavior. If you are interested, just checkout the top node in the tree."
},
"updateTutorialNode": {
"message": "New features in v1.0.7"
"message": "New features in v1.0.10"
},
"updateTutorialFeature1": {
"message": "Save: keep the node in the tree at all times"
"message": "Options: Just besides the “Expand All“ button"
},
"updateTutorialFeature1Desc1": {
"message": "Save ensures that tags are not deleted in the tree when it is closed"
"message": "Auto Scroll to Active Tab"
},
"updateTutorialFeature1Desc2": {
"message": "Save can be used using the right-click drop-down menu or shortcut keys"
},
"updateTutorialFeature1Desc3": {
"message": "To Save a batch of nodes, collapse first and then Save"
"updateTutorialFeature1Desc11": {
"message": "Enable: When switch tab, tree will autoscroll to active tab, and make it visible"
},
"updateTutorialFeature2": {
"message": "Notes shortcut: use LinkMap like RoamResearch"
},
"updateTutorialFeature2Desc1": {
"message": "Notes nodes can now be created via shortcuts"
"updateTutorialFeature1Desc12": {
"message": "Disable: Tree won’t draw attention"
},
"updateTutorialFeature2Desc2": {
"message": "Quickly record ideas while browsing the web, like RoamResearch"
"updateTutorialFeature1Desc2": {
"message": "Create New Tab by Level"
},
"updateTutorialFeature3": {
"message": "Show the number of open tabs next to the LinkMap extension icon"
"updateTutorialFeature1Desc21": {
"message": "Enable: When create new empty tab, new tab created as the child of the opener(if opener is the last node)"
},
"updateTutorialFeature4": {
"message": "Expand/Collapse All: Make LinkMap more tidy"
"updateTutorialFeature1Desc22": {
"message": "Disable: New tab will always create flatten as the last child of Window"
},
"updateTutorialFeature4Desc1": {
"message": "Below the search box you can find use them"
"updateTutorialFeature1Desc23": {
"message": "May confusing, try it"
},
"updateTutorialFeature4Desc2": {
"message": "In the right-click menu you can expand/collapse all for the current node only"
"updateTutorialFeature2": {
"message": "Copy All Subtree as TXT/Markdown: added in the context-menu"
},
"updateTutorialFeature5": {
"message": "Some minor optimizations"
"updateTutorialFeature2Desc1": {
"message": "It’s useful when putting your links to note-taking app"
},
"updateTutorialFeature5Desc1": {
"message": "'New tabs' will now be created in the same level in the tree"
"updateTutorialFeature3": {
"message": "Optimization for 'Locate'"
},
"updateTutorialFeature5Desc2": {
"message": "Some options have been added to the 'Delete/Close' in the right-click menu"
"updateTutorialFeature3Desc1": {
"message": "Now it will only locate the active tab of the top window"
},
"updateTutorialFeature5Desc3": {
"message": "The theme has the 'auto' option to automatically switch between light/dark modes"
"updateTutorialFeature3Desc2": {
"message": "It still doesn't perform perfectly sometime, I will continue optimizing"
},
"reviewLinkMap": {
"message": "Do you like Link Map or have any suggestions?"
Expand All @@ -241,5 +235,32 @@
},
"save": {
"message": "Save"
},
"copySubtreeAsText": {
"message": "Copy Subtree as Text"
},
"copySubtreeAsMarkdown": {
"message": "Copy Subtree as Markdown"
},
"options": {
"message": "Options"
},
"autoScrollToActiveTab": {
"message": "Auto Scroll to Active Tab"
},
"createNewTabByLevel": {
"message": "Create New Tab by Level"
},
"deleteNode": {
"message": "Delete Node"
},
"deleteSubtree": {
"message": "Delete Subtree"
},
"closeNode": {
"message": "Close Node"
},
"closeSubtree": {
"message": "Close Subtree"
}
}
85 changes: 53 additions & 32 deletions public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,55 +168,49 @@
"message": "Link Map感觉自己更强大了!"
},
"updateNoteContent": {
"message": "没错Link Map又更新了,这次根据大家的反馈增加了一些功能和优化,快看看吧(对,细节还是在最顶部的节点)"
"message": "在v1.0.0版本中,增加了一些小的改进,可以更细粒度的控制Link Map的行为。如果你感兴趣,只需查看树中的第一个节点来获取细节"
},
"updateTutorialNode": {
"message": "新功能!(v1.0.7)"
"message": "v1.0.10中的新功能"
},
"updateTutorialFeature1": {
"message": "保存:让节点一直保留在树中"
"message": "选项:就在'展开全部'按钮旁边"
},
"updateTutorialFeature1Desc1": {
"message": "保存可以保证标签不会在关闭时在树中被删除"
"message": "自动滚动到激活的标签"
},
"updateTutorialFeature1Desc2": {
"message": "可以使用右键下拉菜单或快捷键使用保存"
},
"updateTutorialFeature1Desc3": {
"message": "收起节点时保存,就可以批量保存一批节点"
"updateTutorialFeature1Desc11": {
"message": "启用:切换标签时,树将自动滚动到激活的标签节点,并使其可见"
},
"updateTutorialFeature2": {
"message": "笔记快捷键:像RoamResearch一样使用LinkMap"
},
"updateTutorialFeature2Desc1": {
"message": "现在可以通过快捷键创建笔记节点"
"updateTutorialFeature1Desc12": {
"message": "禁用:树啥也不做,就那么呆着"
},
"updateTutorialFeature2Desc2": {
"message": "在浏览网页时可以快速记录想法,就像RoamResearch"
"updateTutorialFeature1Desc2": {
"message": "根据层级创建新标签"
},
"updateTutorialFeature3": {
"message": "LinkMap扩展图标旁展示已打开标签数量"
"updateTutorialFeature1Desc21": {
"message": "启用:如果从最后一个标签创建的空标签页,新标签页会作为子节点创建"
},
"updateTutorialFeature4": {
"message": "展开/收起全部:让LinkMap更加整洁"
"updateTutorialFeature1Desc22": {
"message": "禁用:新标签将始终作为窗口的最后一个子节点创建"
},
"updateTutorialFeature4Desc1": {
"message": "在搜索框的下方你可以发现使用它们"
"updateTutorialFeature1Desc23": {
"message": "我的描述可能会让你感到困惑,请尝试一下"
},
"updateTutorialFeature4Desc2": {
"message": "在右键菜单中可以只对当前节点展开/收起全部"
"updateTutorialFeature2": {
"message": "将子树复制为TXT/Markdown:功能在右键下拉菜单中"
},
"updateTutorialFeature5": {
"message": "一些小优化"
"updateTutorialFeature2Desc1": {
"message": "将链接复制到笔记应用程序中时很有用"
},
"updateTutorialFeature5Desc1": {
"message": "“新标签”现在会在树中平级创建"
"updateTutorialFeature3": {
"message": "'定位标签节点'优化"
},
"updateTutorialFeature5Desc2": {
"message": "右键菜单中的“删除/关闭”增加了一些选项"
"updateTutorialFeature3Desc1": {
"message": "现在它只会定位顶级窗口中处于激活状态的标签"
},
"updateTutorialFeature5Desc3": {
"message": "主题中可以选择“跟随系统”自动切换亮/暗模式"
"updateTutorialFeature3Desc2": {
"message": "它仍然不完美,有时会有问题,我将继续优化"
},
"reviewLinkMap": {
"message": "Link Map有没有帮到你或者有什么想吐槽的?"
Expand All @@ -241,5 +235,32 @@
},
"save": {
"message": "保存"
},
"copySubtreeAsText": {
"message": "复制全部为txt"
},
"copySubtreeAsMarkdown": {
"message": "复制全部为Markdown"
},
"options": {
"message": "选项"
},
"autoScrollToActiveTab": {
"message": "自动滚动到激活的标签"
},
"createNewTabByLevel": {
"message": "根据层级创建新标签"
},
"deleteNode": {
"message": "删除节点"
},
"deleteSubtree": {
"message": "删除子树"
},
"closeNode": {
"message": "关闭节点"
},
"closeSubtree": {
"message": "关闭子树"
}
}
2 changes: 1 addition & 1 deletion src/background/event-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sendMessage } from '@garinz/webext-bridge';
import type { JsonValue } from 'type-fest';
import browser from 'webextension-polyfill';

import { getExtPageInfo } from '../storage/ext-page-info';
import { getExtPageInfo } from '../storage/basic';

const EXT_HOME_PAGE_PATH = 'tree.html';

Expand Down
25 changes: 18 additions & 7 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ import { onMessage } from '@garinz/webext-bridge';
import log from 'loglevel';
import browser from 'webextension-polyfill';

import { setLogLevel } from '../config/log-config';
import type { LocalStorageImportData } from '../import/App';
import { getExtPageInfo, removeExtPageInfo, setExtPageInfo } from '../storage/ext-page-info';
import {
getExtPageInfo,
removeExtPageInfo,
setExtPageInfo,
setPrevFocusWindowId,
} from '../storage/basic';
import { TabMasterDB } from '../storage/idb';
import { setIsNewUser, setIsUpdate } from '../storage/user-journey';
import type { ExportJsonData } from '../tree/features/settings/Settings';
import { isContentScriptPage, sendMessageToExt } from './event-bus';

try {
log.setLevel(__ENV__ === 'development' ? 'debug' : 'silent');
setLogLevel();

async function syncTabsCountInBadge() {
const allTabs = await browser.tabs.query({});
Expand All @@ -28,9 +34,10 @@ try {
await setIsNewUser(true);
}
if (
details.reason === 'update' &&
details.previousVersion !== '1.0.7' &&
browser.runtime.getManifest().version === '1.0.7'
details.reason === 'update'
// &&
// details.previousVersion !== '1.0.10' &&
// browser.runtime.getManifest().version === '1.0.10'
) {
// chrome.runtime.getManifest().version
await setIsUpdate(true);
Expand Down Expand Up @@ -88,7 +95,10 @@ try {
* 将extIdPair更新到localStorage中
* This Method Wouldn't Fire if popup has benn set
*/
browser.action.onClicked.addListener(focusOrCreateExtWindow);
browser.action.onClicked.addListener((tab) => {
setPrevFocusWindowId(tab.windowId!);
focusOrCreateExtWindow();
});

// #### 浏览器Fire的事件
browser.tabs.onCreated.addListener(async (tab) => {
Expand Down Expand Up @@ -150,7 +160,8 @@ try {
});

browser.tabs.onReplaced.addListener((addedTabId, removedTabId) => {
log.debug(`Tab replaced, added tabId: ${addedTabId}`, `removed tabId: ${removedTabId}`);
log.debug('[bg]: replaced, tabId:', addedTabId);
sendMessageToExt('replace-tab', { addedTabId, removedTabId });
});
/**
* detach tab的时候会触发这个事件
Expand Down
5 changes: 5 additions & 0 deletions src/config/log-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import log from 'loglevel';

export const setLogLevel = () => {
log.setLevel(__ENV__ === 'development' ? 'debug' : 'error');
};
4 changes: 2 additions & 2 deletions src/import/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import log from 'loglevel';
import { createRoot } from 'react-dom/client';
import { HashRouter } from 'react-router-dom';

import { setLogLevel } from '../config/log-config';
import App from './App';

const container = document.querySelector('#root');
const root = createRoot(container!);
log.setLevel(__ENV__ === 'development' ? 'debug' : 'silent');
setLogLevel();
root.render(
<HashRouter>
<App />
Expand Down
46 changes: 46 additions & 0 deletions src/storage/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { isEmpty } from 'lodash';
import { storage } from 'webextension-polyfill';

const EXT_PAGE_INFO = 'extPageInfo';

export interface Basic {
windowId: number;
tabId: number;
ready: boolean;
}

export const getExtPageInfo = async (): Promise<Basic | null> => {
const extPageInfo = await storage.local.get(EXT_PAGE_INFO);
// 如果key不存在,返回的localStorage为空对象
return isEmpty(extPageInfo) ? null : JSON.parse(extPageInfo[EXT_PAGE_INFO]);
};

export const setExtPageInfo = async (extPageInfo: Partial<Basic>): Promise<void> => {
const oldData = (await getExtPageInfo()) ?? {};
return await storage.local.set({
[EXT_PAGE_INFO]: JSON.stringify({
...oldData,
...extPageInfo,
}),
});
};

export const removeExtPageInfo = () => {
return storage.local.remove(EXT_PAGE_INFO);
};

const PREV_FOCUS_WINDOW_ID = 'prevFocusWindowId';
export const getPrevFocusWindowId = async (): Promise<number | null> => {
const prevFocusWindowId = await storage.local.get(PREV_FOCUS_WINDOW_ID);
return isEmpty(prevFocusWindowId) ? null : prevFocusWindowId[PREV_FOCUS_WINDOW_ID];
};

export const setPrevFocusWindowId = async (prevFocusWindowId: number): Promise<void> => {
return await storage.local.set({
[PREV_FOCUS_WINDOW_ID]: prevFocusWindowId,
});
};

export const removePrevFocusWindowId = () => {
return storage.local.remove(PREV_FOCUS_WINDOW_ID);
};
Loading

0 comments on commit 3405bf0

Please sign in to comment.