Skip to content

Commit

Permalink
fix: 修复 cr 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moshangqi committed Oct 25, 2023
1 parent c840c53 commit 3a8266d
Show file tree
Hide file tree
Showing 33 changed files with 81 additions and 92 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
},
};

Expand Down
6 changes: 3 additions & 3 deletions src/background/actionListener/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -25,7 +25,7 @@ export async function createTabActionListener(
case OperateTabEnum.create: {
Chrome.tabs.create({ url });
callback(true);
break
break;
}
default: {
break;
Expand Down
6 changes: 3 additions & 3 deletions src/background/core/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ async function request<T>(
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)) {
Expand Down
12 changes: 6 additions & 6 deletions src/background/core/util.ts
Original file line number Diff line number Diff line change
@@ -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;
}
};
1 change: 0 additions & 1 deletion src/components/AccountLayout/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ export const AccountContext = createContext<IAccountContext>({
//
},
});

6 changes: 3 additions & 3 deletions src/components/ShortItem/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand All @@ -35,7 +35,7 @@
}

.error {
font-size: 12px;
font-size: @font-size-sm;
margin-top: 4px;
color: @red-6;
}
1 change: 0 additions & 1 deletion src/components/SuperSideBar/container/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 1 addition & 12 deletions src/components/SuperSideBar/core/BuiltinAssistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
24 changes: 13 additions & 11 deletions src/components/SuperSideBar/declare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ 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;
}

export type IListenerRemover = () => void;


export interface IMessageProgress {
status?: number;
icon?: IRenderResult;
Expand Down Expand Up @@ -56,13 +58,12 @@ export interface IRenderTextOptions extends IBaseRenderOptions {
typewriter?: boolean;
}


export interface IRenderInputOptions extends IBaseRenderOptions {
ref: React.MutableRefObject<any | undefined>;
placeholder?: string;
disabled?: boolean;
onEnter: (text: string) => void;
extra?: React.ReactNode
extra?: React.ReactNode;
}

export type IRenderResult = React.JSX.Element | React.ReactElement | null;
Expand Down Expand Up @@ -121,7 +122,7 @@ export interface ISidebarRenderContext {

scrollToBottom(immediately?: boolean): void;

renderDrawer: IRootDrawerRef['render']
renderDrawer: IRootDrawerRef['render'];
closeDrawer(): void;
}

Expand Down Expand Up @@ -256,15 +257,15 @@ 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) {
this._listeners.forEach(invoker);
}

protected notifyDatasetUpdated(params?: IDatasetUpdatedParams) {
this.notifyListener((listener) => listener.onDatasetUpdated?.(params));
this.notifyListener(listener => listener.onDatasetUpdated?.(params));
}
}

Expand Down Expand Up @@ -298,7 +299,9 @@ export enum AssistantType {
ClipAssistant = 'ClipAssistant',
}

export interface IAssistant<T extends ISideContentProvider = ISideContentProvider> {
export interface IAssistant<
T extends ISideContentProvider = ISideContentProvider,
> {
id: number;
type: AssistantType;
label: string;
Expand All @@ -308,4 +311,3 @@ export interface IAssistant<T extends ISideContentProvider = ISideContentProvide
hasWatermark?: boolean;
provider: T;
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { __i18n } from '@/isomorphic/i18n';
import TagMenu, { ITagMenuProps } from './TagMenu';
import styles from './index.module.less';

interface IAddTagButtonProps extends ITagMenuProps {}
type IAddTagButtonProps = ITagMenuProps;

function AddTagButton(props: IAddTagButtonProps) {
const { tags, selectTags, updateSelectTags, updateTags } = props;
Expand Down Expand Up @@ -50,7 +50,7 @@ function AddTagButton(props: IAddTagButtonProps) {
arrow={false}
>
<Button
className={classnames("add-tag-button", styles.button)}
className={classnames('add-tag-button', styles.button)}
onClick={() => {
setOpen(!open);
}}
Expand Down
6 changes: 3 additions & 3 deletions src/components/SuperSideBar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SuperSidebarContainer {
get first() {
return this.rightBarAssistants?.[0];
}

initCurrentAssistant() {
if (this._assistants.length === 0) {
return;
Expand Down Expand Up @@ -159,8 +159,8 @@ class SuperSidebarContainer {

addAssistant(assistant: IAssistant) {
this._assistants.push(assistant);
this.notifyListener((listener) => listener.onAssistantsChanged?.());
this.notifyListener((listener) => listener.onManifestsChanged?.());
this.notifyListener(listener => listener.onAssistantsChanged?.());
this.notifyListener(listener => listener.onManifestsChanged?.());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/WordMarkLayout/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from 'react';
import { IWordMarkConfig } from '@/isomorphic/constant/wordMark';

export interface IWordMarkContext extends IWordMarkConfig {}
export type IWordMarkContext = IWordMarkConfig;
export const WordMarkContext = createContext<IWordMarkContext>({} as IWordMarkContext);
2 changes: 1 addition & 1 deletion src/components/WordMarkLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function WordMarkLayout(props: IWordMarkLayoutProps) {
}
return true;
};

useEffect(() => {
backgroundBridge.wordMarkConfig.get().then(res => {
setWordMarkConfig(res);
Expand Down
1 change: 0 additions & 1 deletion src/components/lake-editor/editor-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export function InjectEditorPlugin({ EditorPlugin, KernelPlugin, PositionUtil, O
}
}


class CustomKernelPlugin extends KernelPlugin {
static PluginName = 'CustomEditorPlugin';

Expand Down
2 changes: 1 addition & 1 deletion src/components/lake-editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default forwardRef<IEditorRef, EditorProps>((props, ref) => {
typeof widget.enable === 'function'
? () => (widget.enable as (ui: any) => boolean)(cardUI)
: () => !!widget.enable,
}))
})),
});
});
return cardUI.cardData.getOcrLocations()?.length > 0;
Expand Down
4 changes: 2 additions & 2 deletions src/core/bridge/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function callBackgroundBridge(
data?: MapT<any>,
callback?: OneArgFunctionT<any>,
) {
callback = callback || function () {
callback = callback || function() {
// ignore
};
Chrome.runtime.sendMessage(
{
action: bridgeName,
data: data,
data,
},
res => {
callback?.(res);
Expand Down
2 changes: 1 addition & 1 deletion src/core/bridge/background/stroge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function createStorageBridge(impl: ICallBridgeImpl) {
impl(
BackgroundEvents.OperateStorage,
{ key, type: OperateStorageEnum.get },
(res) => {
res => {
resolve(res);
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/bridge/background/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function createTabBridge(impl: ICallBridgeImpl) {
},
);
});
}
},
},
};
}
6 changes: 3 additions & 3 deletions src/core/browser-system-link.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import bowser from 'bowser';

const name = bowser.getParser(navigator.userAgent).getBrowserName();
const name = bowser.getParser(navigator.userAgent).getBrowserName();
const isEdge = name === 'Microsoft Edge';

const ChromeSystemLink = {
cookieSetting: 'chrome://settings/cookies',
shortCut: 'chrome://extensions/shortcuts',
}
};

const EdgeSystemLink = {
cookieSetting: 'edge://settings/content',
shortCut: 'edge://extensions/shortcuts',
}
};

function findSystemLink() {
if (isEdge) {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useEnterShortCut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useEnterShortcut(props: IUseShortcutProps) {
const onOk = (e: KeyboardEvent) => {
e.preventDefault();
props.onOk();
}
};
keymaster(okKey, onOk);
return () => keymaster.unbind(okKey);
}, [props.onOk, okKey]);
Expand All @@ -24,7 +24,7 @@ export function useEnterShortcut(props: IUseShortcutProps) {
const onCancel = (e: KeyboardEvent) => {
e.preventDefault();
props.onCancel();
}
};
keymaster(cancelKey, onCancel);
return () => keymaster.unbind(cancelKey);
}, [props.onCancel, cancelKey]);
Expand Down
Loading

0 comments on commit 3a8266d

Please sign in to comment.