From 3a8266dae8675f71a5c8c2d6cf727d5084666521 Mon Sep 17 00:00:00 2001 From: moshangqi <2509678669@qq.com> Date: Wed, 25 Oct 2023 14:43:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20cr=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 8 +++++++ src/background/actionListener/tab.ts | 6 ++--- src/background/core/request.ts | 6 ++--- src/background/core/util.ts | 12 +++++----- src/components/AccountLayout/context.ts | 1 - src/components/ShortItem/index.module.less | 6 ++--- .../SuperSideBar/container/Header/index.tsx | 1 - .../SuperSideBar/core/BuiltinAssistant.tsx | 13 +--------- src/components/SuperSideBar/declare.ts | 24 ++++++++++--------- .../component/AddTagButton/index.tsx | 4 ++-- src/components/SuperSideBar/index.ts | 6 ++--- src/components/WordMarkLayout/context.ts | 2 +- src/components/WordMarkLayout/index.tsx | 2 +- src/components/lake-editor/editor-plugin.ts | 1 - src/components/lake-editor/editor.tsx | 2 +- src/core/bridge/background/index.ts | 4 ++-- src/core/bridge/background/stroge.ts | 2 +- src/core/bridge/background/tab.ts | 2 +- src/core/browser-system-link.ts | 6 ++--- src/hooks/useEnterShortCut.ts | 4 ++-- src/hooks/useMeasure.ts | 19 ++++++++------- src/isomorphic/background/index.ts | 1 - src/isomorphic/constant/wordMark.ts | 1 - src/isomorphic/constants.ts | 1 - src/isomorphic/event/contentScript.ts | 5 ++-- src/isomorphic/i18n.ts | 1 - src/isomorphic/util.ts | 1 - src/pages/inject/ScreenShot/app.tsx | 16 ++++++------- .../inject/WordMark/Inner/OperateMenu.tsx | 1 - src/pages/inject/WordMark/app.tsx | 6 ++--- src/pages/inject/action-listener.ts | 4 ++-- src/pages/inject/content-scripts.ts | 4 ++-- webpack.config.js | 1 - 33 files changed, 81 insertions(+), 92 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5cc195b1..574ae8e8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -80,6 +80,14 @@ const tslintConfig = { '@typescript-eslint/ban-ts-comment': [ 'warn' ], 'no-shadow': 'off', '@typescript-eslint/no-shadow': 'error', + 'no-multiple-empty-lines': [ + 'error', + { + max: 1, + maxEOF: 0, + maxBOF: 0, + }, + ], }, }; diff --git a/src/background/actionListener/tab.ts b/src/background/actionListener/tab.ts index 53086399..92239651 100644 --- a/src/background/actionListener/tab.ts +++ b/src/background/actionListener/tab.ts @@ -12,8 +12,8 @@ export async function createTabActionListener( const { type, url } = request.data; switch (type) { case OperateTabEnum.screenShot: { - const tabs = await Chrome.tabs.query({ lastFocusedWindow: true }) - const res = await Chrome.tabs.captureVisibleTab(tabs[0].windowId as number); + const tabs = await Chrome.tabs.query({ lastFocusedWindow: true }); + const res = await Chrome.tabs.captureVisibleTab(tabs[0].windowId as number); callback(res); break; } @@ -25,7 +25,7 @@ export async function createTabActionListener( case OperateTabEnum.create: { Chrome.tabs.create({ url }); callback(true); - break + break; } default: { break; diff --git a/src/background/core/request.ts b/src/background/core/request.ts index c5f88d59..a9fccf61 100644 --- a/src/background/core/request.ts +++ b/src/background/core/request.ts @@ -123,15 +123,15 @@ async function request( action: ContentScriptEvents.ForceUpgradeVersion, data: { html: responseJson?.html, - } - }) + }, + }); throw responseJson; } // 登录过期 if (response.status === 401 && responseJson.message === 'Unauthorized') { Chrome.sendMessageToAllTab({ action: ContentScriptEvents.LoginOut, - }) + }); throw responseJson; } if (!(response.status >= 200 && response.status < 300)) { diff --git a/src/background/core/util.ts b/src/background/core/util.ts index 2c1e9f0e..78ca989c 100644 --- a/src/background/core/util.ts +++ b/src/background/core/util.ts @@ -1,11 +1,11 @@ -import { IUser } from "@/isomorphic/interface"; -import Storage from "./storage"; -import { STORAGE_KEYS } from "@/config"; +import { IUser } from '@/isomorphic/interface'; +import Storage from './storage'; +import { STORAGE_KEYS } from '@/config'; export const getCurrentAccount = async () => { const account = await Storage.get(STORAGE_KEYS.CURRENT_ACCOUNT) as IUser; if (!account?.login_at) { - return {} - } + return {}; + } return account; -} +}; diff --git a/src/components/AccountLayout/context.ts b/src/components/AccountLayout/context.ts index 8ba09f37..c465c53b 100644 --- a/src/components/AccountLayout/context.ts +++ b/src/components/AccountLayout/context.ts @@ -12,4 +12,3 @@ export const AccountContext = createContext({ // }, }); - diff --git a/src/components/ShortItem/index.module.less b/src/components/ShortItem/index.module.less index 25851c40..56a70fc9 100644 --- a/src/components/ShortItem/index.module.less +++ b/src/components/ShortItem/index.module.less @@ -20,11 +20,11 @@ align-items: center; cursor: pointer; padding-left: 12px; - font-size: 14px; + font-size: @font-size; } .tooltip { - font-size: 14px; + font-size: @font-size; position: absolute; right: 16px; top: 50%; @@ -35,7 +35,7 @@ } .error { - font-size: 12px; + font-size: @font-size-sm; margin-top: 4px; color: @red-6; } diff --git a/src/components/SuperSideBar/container/Header/index.tsx b/src/components/SuperSideBar/container/Header/index.tsx index 79eb8b14..9034f7d6 100644 --- a/src/components/SuperSideBar/container/Header/index.tsx +++ b/src/components/SuperSideBar/container/Header/index.tsx @@ -10,7 +10,6 @@ import SettingSvg from '@/assets/svg/setting.svg'; import HomeSvg from '@/assets/svg/home.svg'; import styles from './index.module.less'; - function SuperSidebarHeader() { const openHome = () => { window.open(LinkHelper.dashboard); diff --git a/src/components/SuperSideBar/core/BuiltinAssistant.tsx b/src/components/SuperSideBar/core/BuiltinAssistant.tsx index b199fcb1..b56eb9d0 100644 --- a/src/components/SuperSideBar/core/BuiltinAssistant.tsx +++ b/src/components/SuperSideBar/core/BuiltinAssistant.tsx @@ -7,15 +7,6 @@ import { } from '@/components/SuperSideBar/declare'; import { IAssistantManifest } from './IAssistantManifest'; -function* builtinPriorityGenerator() { - let priority = 0; - while (true) { - yield `a${++priority}`; - } -} - -const builtinPriorityGeneratorInstance = builtinPriorityGenerator()!; - export class BuiltinAssistant implements IAssistant { id: number; @@ -29,15 +20,13 @@ export class BuiltinAssistant implements IAssistant { priority: string; - provider: ISideContentProvider; constructor(manifest: IAssistantManifest) { const builtinManifest = builtinManifests[manifest.type]; this.id = manifest.id; - this.priority = - manifest.priority || builtinPriorityGeneratorInstance.next().value!; + this.priority = manifest.priority; this.type = manifest.type; this.label = this.getLabel(manifest.label) || builtinManifest.label; this.description = manifest.description || builtinManifest.description; diff --git a/src/components/SuperSideBar/declare.ts b/src/components/SuperSideBar/declare.ts index ce9bce60..8116399c 100644 --- a/src/components/SuperSideBar/declare.ts +++ b/src/components/SuperSideBar/declare.ts @@ -3,10 +3,13 @@ import { IUser } from '@/isomorphic/interface'; import React, { MutableRefObject } from 'react'; export interface IRootDrawerRef { - render: (conf: RootRenderProps) => void, - onClose: () => void, + render: (conf: RootRenderProps) => void; + onClose: () => void; } -export type RootRenderProps = { title: React.ReactElement, content: React.ReactElement }; +export type RootRenderProps = { + title: React.ReactElement; + content: React.ReactElement; +}; export interface IScrollerRef { scrollToBottom(immediately?: boolean): void; @@ -14,7 +17,6 @@ export interface IScrollerRef { export type IListenerRemover = () => void; - export interface IMessageProgress { status?: number; icon?: IRenderResult; @@ -56,13 +58,12 @@ export interface IRenderTextOptions extends IBaseRenderOptions { typewriter?: boolean; } - export interface IRenderInputOptions extends IBaseRenderOptions { ref: React.MutableRefObject; placeholder?: string; disabled?: boolean; onEnter: (text: string) => void; - extra?: React.ReactNode + extra?: React.ReactNode; } export type IRenderResult = React.JSX.Element | React.ReactElement | null; @@ -121,7 +122,7 @@ export interface ISidebarRenderContext { scrollToBottom(immediately?: boolean): void; - renderDrawer: IRootDrawerRef['render'] + renderDrawer: IRootDrawerRef['render']; closeDrawer(): void; } @@ -256,7 +257,7 @@ export abstract class SideContentDatasource< } removeListener(listener: T) { - this._listeners = this._listeners.filter((it) => it !== listener); + this._listeners = this._listeners.filter(it => it !== listener); } protected notifyListener(invoker: (listener: T) => void) { @@ -264,7 +265,7 @@ export abstract class SideContentDatasource< } protected notifyDatasetUpdated(params?: IDatasetUpdatedParams) { - this.notifyListener((listener) => listener.onDatasetUpdated?.(params)); + this.notifyListener(listener => listener.onDatasetUpdated?.(params)); } } @@ -298,7 +299,9 @@ export enum AssistantType { ClipAssistant = 'ClipAssistant', } -export interface IAssistant { +export interface IAssistant< + T extends ISideContentProvider = ISideContentProvider, +> { id: number; type: AssistantType; label: string; @@ -308,4 +311,3 @@ export interface IAssistant