diff --git a/src/tree/configs.ts b/src/tree/fancy-tab-master-tree/configs.ts similarity index 99% rename from src/tree/configs.ts rename to src/tree/fancy-tab-master-tree/configs.ts index cc9c7be..19669a2 100644 --- a/src/tree/configs.ts +++ b/src/tree/fancy-tab-master-tree/configs.ts @@ -1,6 +1,6 @@ import { tabs } from 'webextension-polyfill'; -import { BrowserExtensionUtils, FancyTreeUtils, logLazy } from './utils'; +import { BrowserExtensionUtils, FancyTreeUtils, logLazy } from '../utils'; interface DND5Data { dataTransfer: { diff --git a/src/tree/fancy-tab-master-tree.ts b/src/tree/fancy-tab-master-tree/fancy-tab-master-tree.ts similarity index 97% rename from src/tree/fancy-tab-master-tree.ts rename to src/tree/fancy-tab-master-tree/fancy-tab-master-tree.ts index 191b7e1..f979eec 100644 --- a/src/tree/fancy-tab-master-tree.ts +++ b/src/tree/fancy-tab-master-tree/fancy-tab-master-tree.ts @@ -1,13 +1,13 @@ import type { Tabs, Windows } from 'webextension-polyfill'; import browser from 'webextension-polyfill'; -import TreeNodeTpl, { TPL_CONSTANTS } from '../templates/tree-node-tpl'; +import TreeNodeTpl, { TPL_CONSTANTS } from '../../templates/tree-node-tpl'; +import * as TabNodes from '../node-builders'; +import { createWindowNode } from '../node-builders'; +import type { NodeType, TreeData, TreeNode } from '../nodes'; +import { NodeUtils } from '../utils'; import { DND5_CONFIG } from './configs'; -import * as TabNodes from './node-builders'; -import { createWindowNode } from './node-builders'; -import type { NodeType, TreeData, TreeNode } from './nodes'; import { ViewTabIndexUtils } from './tab-index-utils'; -import { NodeUtils } from './utils'; type Tab = Tabs.Tab; diff --git a/src/tree/tab-index-utils.ts b/src/tree/fancy-tab-master-tree/tab-index-utils.ts similarity index 86% rename from src/tree/tab-index-utils.ts rename to src/tree/fancy-tab-master-tree/tab-index-utils.ts index f82e322..bbee1c0 100644 --- a/src/tree/tab-index-utils.ts +++ b/src/tree/fancy-tab-master-tree/tab-index-utils.ts @@ -1,17 +1,4 @@ export const ViewTabIndexUtils = { - // 添加tab - // 1. 根据index找到元素 - // 2. 选择适合的方式添加元素 - // 3. 后面元素的index + 1 - - // 删除tab - // 1. 删除元素 - // 2. 后面元素的index - 1 - - // 移动tab - // 1. 根据index找到元素 - // 2. 和目标元素交换index - increaseIndex: (tree: Fancytree.Fancytree, windowId: number, index: number) => { const parentNode = tree.getNodeByKey(`${windowId}`); parentNode.visit((node) => { diff --git a/src/tree/main.ts b/src/tree/main.ts index 03d6404..aa41365 100644 --- a/src/tree/main.ts +++ b/src/tree/main.ts @@ -1,6 +1,6 @@ import { onMessage } from '@garinz/webext-bridge'; -import { FancyTabMasterTree } from './fancy-tab-master-tree'; +import { FancyTabMasterTree } from './fancy-tab-master-tree/fancy-tab-master-tree'; const tree = new FancyTabMasterTree('#tree'); tree.initTree(); diff --git a/src/tsconfig.json b/src/tsconfig.json index 55f3cdc..2d881f6 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -31,7 +31,8 @@ "module": "ESNext", "baseUrl": "./", "paths": { - "@/*": ["src/*"] + "@/*": ["src/*"], + "?/*": ["test/*"] }, "typeRoots": ["../node_modules/@types", "./typings"], "types": ["jquery", "webext-bridge", "jquery.fancytree"] diff --git a/test/tree/fancy-tab-master-tree.spec.ts b/test/tree/fancy-tab-master-tree/fancy-tab-master-tree.spec.ts similarity index 98% rename from test/tree/fancy-tab-master-tree.spec.ts rename to test/tree/fancy-tab-master-tree/fancy-tab-master-tree.spec.ts index 255e066..04a3a2a 100644 --- a/test/tree/fancy-tab-master-tree.spec.ts +++ b/test/tree/fancy-tab-master-tree/fancy-tab-master-tree.spec.ts @@ -5,9 +5,10 @@ import type { Tabs } from 'webextension-polyfill'; -import type { TabData } from '../../src/tree/nodes'; -import { createTab, initFancytree } from '../utils/gen-utils'; -import { toAsciiTree } from '../utils/print-utils'; +import type { TabData } from '@/tree/nodes'; + +import { createTab, initFancytree } from '../../utils/gen-utils'; +import { toAsciiTree } from '../../utils/print-utils'; import { SINGLE_TAB_WINDOW } from './mock-data'; type FancytreeNode = Fancytree.FancytreeNode; diff --git a/test/tree/mock-data.ts b/test/tree/fancy-tab-master-tree/mock-data.ts similarity index 98% rename from test/tree/mock-data.ts rename to test/tree/fancy-tab-master-tree/mock-data.ts index 3515128..a7668eb 100644 --- a/test/tree/mock-data.ts +++ b/test/tree/fancy-tab-master-tree/mock-data.ts @@ -1,4 +1,4 @@ -import type { TabData, TreeData, TreeNode, WindowData } from '../../src/tree/nodes'; +import type { TabData, TreeData, TreeNode, WindowData } from '../../../src/tree/nodes'; export const SINGLE_TAB_WINDOW = [ { diff --git a/test/utils/gen-utils.ts b/test/utils/gen-utils.ts index 91e5209..36544fb 100644 --- a/test/utils/gen-utils.ts +++ b/test/utils/gen-utils.ts @@ -4,14 +4,14 @@ import type { Tabs } from 'webextension-polyfill'; -import { FancyTabMasterTree } from '../../src/tree/fancy-tab-master-tree'; +import { FancyTabMasterTree } from '../../src/tree/fancy-tab-master-tree/fancy-tab-master-tree'; import type { TreeData, TreeNode } from '../../src/tree/nodes'; import 'jquery.fancytree'; import 'jquery.fancytree/dist/modules/jquery.fancytree.dnd5'; import 'jquery.fancytree/dist/modules/jquery.fancytree.childcounter'; -export function initFancytree(source: TreeNode[]) { +export function initFancytree(source: TreeNode[]): FancyTabMasterTree { document.body.innerHTML = '
'; const tree = new FancyTabMasterTree('#tree'); tree.initTree(source); diff --git a/tsconfig.json b/tsconfig.json index 39a42d2..52a4707 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,7 +24,10 @@ "module": "ESNext", "baseUrl": "./", "types": ["jquery", "webext-bridge", "jquery.fancytree", "jest"], - "typeRoots": ["node_modules/@types", "src/typings"] + "typeRoots": ["node_modules/@types", "src/typings"], + "paths": { + "@/*": ["src/*"] + } }, "exclude": ["manifest.ts"] }