Skip to content

Commit

Permalink
feat: set template on installed
Browse files Browse the repository at this point in the history
  • Loading branch information
siam-ese committed Dec 18, 2024
1 parent eab079a commit b14df84
Show file tree
Hide file tree
Showing 5 changed files with 2,257 additions and 65 deletions.
22 changes: 14 additions & 8 deletions chrome-extension/lib/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@

import { DrillDownService, IScraperDataSource, LocaleScraperDataSource, ScraperService } from '@univer-clipsheet-core/scraper';
import { getStorage, ISidePanelService, setAndPushStorage, SidePanelService, StorageService } from '@univer-clipsheet-core/shared';
import { getStorage, ISidePanelService, setAndPushStorage, SidePanelService, StorageService, WindowService } from '@univer-clipsheet-core/shared';
import type { IInitialSheet } from '@univer-clipsheet-core/table';
import { createEmptyInitialSheet, ITableDataSource, LocalTableDataSource, TableRecordTypeEnum, TableService, TableStorageKeyEnum } from '@univer-clipsheet-core/table';
import { IWorkflowDataSource, LocaleWorkflowDataSource, WorkflowService } from '@univer-clipsheet-core/workflow';
import { Injector } from '@wendellhu/redi';
import 'webextension-polyfill';
import { filterRowsByRemoveDuplicateRule } from './helper';

chrome.runtime.onInstalled.addListener((detail) => {
if (detail.reason === 'install') {
chrome.tabs.create({ url: 'https://univer.ai/clipsheet' });
}
});
import { setTemplate } from './set-templates';

const injector = new Injector([
[TableService],
[StorageService],
[ScraperService],
[DrillDownService],
[WorkflowService],
[WindowService],
[ISidePanelService, { useFactory: () => new SidePanelService('sidepanel/index.html') }],
[ITableDataSource, { useClass: LocalTableDataSource }],
[IScraperDataSource, { useClass: LocaleScraperDataSource }],
Expand All @@ -28,14 +24,16 @@ const injector = new Injector([

const tableService = injector.get(TableService);
const workflowService = injector.get(WorkflowService);
const windowService = injector.get(WindowService);

tableService.listenMessage();
workflowService.listenMessage();
windowService.listenMessage();
windowService.setWindowTemplatePath(chrome.runtime.getURL('/workflow-panel/workflow-window.html'));
injector.get(StorageService).listenMessage();
injector.get(DrillDownService).listenMessage();
injector.get(ScraperService).listenMessage();
injector.get(ISidePanelService).listenMessage();
injector.get(WorkflowService).setWorkflowWindowPath(chrome.runtime.getURL('/workflow-panel/workflow-window.html'));

workflowService.onWorkflowDone(async (ctx) => {
const { workflow, url, rows } = ctx;
Expand Down Expand Up @@ -81,3 +79,11 @@ workflowService.onWorkflowDone((ctx) => {
// You can do something after the workflow is done
});

chrome.runtime.onInstalled.addListener((detail) => {
if (detail.reason === 'install') {
chrome.tabs.create({ url: 'https://univer.ai/clipsheet' });

setTemplate(injector);
}
});

Loading

0 comments on commit b14df84

Please sign in to comment.