chore(desktop): simplify code (#1146)

This commit is contained in:
Himself65 2023-02-20 23:15:40 -06:00 committed by GitHub
parent ed4d1e8bcd
commit edd8f347bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 30 additions and 191 deletions

View File

@ -7,9 +7,8 @@
"module": "true",
"scripts": {
"dev:app": "cross-env NODE_ENV=development tauri dev",
"dev:prerequisite": "cd ../../ && pnpm build && concurrently \"cd packages/data-center && pnpm dev\" \"cd apps/web && pnpm dev\"",
"dev:web": "pnpm --filter @affine/app dev",
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
"build:submodules": "zx scripts/buildSubModules.mjs",
"build:affine": "zx scripts/buildAffine.mjs",
"build:preload": "esbuild src/preload/index.ts --outdir=public/preload",
"build:app": "tauri build"

View File

@ -1,9 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const repoDirectory = path.join(__dirname, '..', '..', '..');
const clientAppDirectory = path.join(__dirname, '..');
const publicDistributionDirectory = path.join(clientAppDirectory, 'public');

View File

@ -1,18 +0,0 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const repoDirectory = path.join(__dirname, '..');
const publicDistributionDirectory = path.join(repoDirectory, 'public');
const octoBaseBranchName = 'master';
/**
* 1. Until OctoBase become public, we link it using submodule too.
*/
cd(`${path.join(repoDirectory, 'src-OctoBase')}`);
await $`git checkout ${octoBaseBranchName}`;
await $`git submodule update --recursive && git submodule update --remote`;
await $`git pull origin ${octoBaseBranchName}`;
await $`git reset --hard origin/${octoBaseBranchName}`;

View File

@ -1,9 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import fs from 'fs';
import path from 'path';
// TODO: use https://github.com/quicktype/quicktype#installation instead

View File

@ -1,6 +1,6 @@
{
"build": {
"beforeDevCommand": "pnpm build:preload && pnpm dev:prerequisite",
"beforeDevCommand": "pnpm dev:web",
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
"devPath": "http://localhost:8080",
"distDir": "../public",

View File

@ -1,80 +0,0 @@
import { Modal, ModalWrapper } from '@affine/component';
import { IconButton } from '@affine/component';
import { toast } from '@affine/component';
import { useTranslation } from '@affine/i18n';
import { useDataCenter } from '@affine/store';
import { useGlobalState } from '@affine/store';
import { CloseIcon } from '@blocksuite/icons';
import router from 'next/router';
import { useCallback, useState } from 'react';
import { Content, ContentTitle, Header, StyleButton, StyleTips } from './style';
interface EnableWorkspaceModalProps {
open: boolean;
onClose: () => void;
}
export const EnableWorkspaceModal = ({
open,
onClose,
}: EnableWorkspaceModalProps) => {
const { t } = useTranslation();
const login = useGlobalState(store => store.login);
const user = useGlobalState(store => store.user);
const dataCenter = useDataCenter();
const currentWorkspace = useGlobalState(
useCallback(store => store.currentDataCenterWorkspace, [])
);
const [loading, setLoading] = useState(false);
return (
<Modal open={open} onClose={onClose} data-testid="logout-modal">
<ModalWrapper width={560} height={292}>
<Header>
<IconButton
onClick={() => {
onClose();
}}
>
<CloseIcon />
</IconButton>
</Header>
<Content>
<ContentTitle>{t('Enable AFFiNE Cloud')}?</ContentTitle>
<StyleTips>{t('Enable AFFiNE Cloud Description')}</StyleTips>
{/* <StyleTips>{t('Retain local cached data')}</StyleTips> */}
<div>
<StyleButton
shape="round"
type="primary"
loading={loading}
onClick={async () => {
setLoading(true);
if (!user) {
await login();
}
if (currentWorkspace) {
const workspace = await dataCenter.enableWorkspaceCloud(
currentWorkspace
);
workspace &&
router.push(`/workspace/${workspace.id}/setting`);
toast(t('Enabled success'));
}
}}
>
{user ? t('Enable') : t('Sign in and Enable')}
</StyleButton>
<StyleButton
shape="round"
onClick={() => {
onClose();
}}
>
{t('Not now')}
</StyleButton>
</div>
</Content>
</ModalWrapper>
</Modal>
);
};

View File

@ -1,39 +0,0 @@
import { Button, styled } from '@affine/component';
export const Header = styled('div')({
height: '44px',
display: 'flex',
flexDirection: 'row-reverse',
paddingRight: '10px',
paddingTop: '10px',
});
export const Content = styled('div')({
textAlign: 'center',
});
export const ContentTitle = styled('h1')({
fontSize: '20px',
lineHeight: '28px',
fontWeight: 600,
textAlign: 'center',
});
export const StyleTips = styled('div')(() => {
return {
userSelect: 'none',
width: '400px',
margin: 'auto',
marginBottom: '32px',
marginTop: '12px',
};
});
export const StyleButton = styled(Button)(() => {
return {
width: '284px',
display: 'block',
margin: 'auto',
marginTop: '16px',
};
});

View File

@ -1,27 +0,0 @@
import {
CloudWorkspaceIcon as DefaultCloudWorkspaceIcon,
JoinedWorkspaceIcon as DefaultJoinedWorkspaceIcon,
LocalDataIcon as DefaultLocalDataIcon,
LocalWorkspaceIcon as DefaultLocalWorkspaceIcon,
PublishIcon as DefaultPublishIcon,
} from '@blocksuite/icons';
// Here are some icons with special color or size
export const JoinedWorkspaceIcon = () => {
return <DefaultJoinedWorkspaceIcon style={{ color: '#FF646B' }} />;
};
export const LocalWorkspaceIcon = () => {
return <DefaultLocalWorkspaceIcon style={{ color: '#FDBD32' }} />;
};
export const CloudWorkspaceIcon = () => {
return <DefaultCloudWorkspaceIcon style={{ color: '##60A5FA' }} />;
};
export const LocalDataIcon = () => {
return <DefaultLocalDataIcon style={{ color: '#62CD80' }} />;
};
export const PublishIcon = () => {
return <DefaultPublishIcon style={{ color: '##8699FF' }} />;
};

View File

@ -1,4 +1,8 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
declare global {
interface Window {
__TAURI_ISOLATION_HOOK_: (payload: any) => any;
}
}
// tauri preload script can't have `export {}`
// @ts-ignore 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.ts(1208)
@ -16,3 +20,5 @@ function setEnvironmentVariables() {
}
setEnvironmentVariables();
export {};

View File

@ -1,7 +1,9 @@
declare global {
// eslint-disable-next-line no-var
var __editoVersion: unknown;
interface Window {
CLIENT_APP?: boolean;
__editoVersion?: string;
}
}

View File

@ -1,7 +1,9 @@
declare global {
// eslint-disable-next-line no-var
var __editoVersion: unknown;
interface Window {
CLIENT_APP?: boolean;
__editoVersion?: string;
}
}

View File

@ -43,11 +43,18 @@ const printBuildInfo = () => {
};
function setWindowEditorVersion() {
// when it is not SSR
if (typeof window !== 'undefined') {
window.__editoVersion = publicRuntimeConfig.EDITOR_VERSION;
}
globalThis.__editoVersion = publicRuntimeConfig.EDITOR_VERSION;
}
printBuildInfo();
setWindowEditorVersion();
declare global {
// eslint-disable-next-line no-var
var __affineSetupEnv: boolean | undefined;
}
if (!globalThis.__affineSetupEnv) {
printBuildInfo();
setWindowEditorVersion();
globalThis.__affineSetupEnv = true;
}
export {};

View File

@ -11,9 +11,8 @@ const temp = JSON.parse(record);
loadPage();
declare global {
interface Window {
__editoVersion: unknown;
}
// eslint-disable-next-line no-var
var __editoVersion: unknown;
}
test.describe('web console', () => {