mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 10:45:57 +08:00
chore(desktop): simplify code (#1146)
This commit is contained in:
@@ -7,9 +7,8 @@
|
|||||||
"module": "true",
|
"module": "true",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:app": "cross-env NODE_ENV=development tauri dev",
|
"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:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
||||||
"build:submodules": "zx scripts/buildSubModules.mjs",
|
|
||||||
"build:affine": "zx scripts/buildAffine.mjs",
|
"build:affine": "zx scripts/buildAffine.mjs",
|
||||||
"build:preload": "esbuild src/preload/index.ts --outdir=public/preload",
|
"build:preload": "esbuild src/preload/index.ts --outdir=public/preload",
|
||||||
"build:app": "tauri build"
|
"build:app": "tauri build"
|
||||||
|
|||||||
@@ -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 repoDirectory = path.join(__dirname, '..', '..', '..');
|
||||||
const clientAppDirectory = path.join(__dirname, '..');
|
const clientAppDirectory = path.join(__dirname, '..');
|
||||||
const publicDistributionDirectory = path.join(clientAppDirectory, 'public');
|
const publicDistributionDirectory = path.join(clientAppDirectory, 'public');
|
||||||
|
|||||||
@@ -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}`;
|
|
||||||
@@ -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 fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
// TODO: use https://github.com/quicktype/quicktype#installation instead
|
// TODO: use https://github.com/quicktype/quicktype#installation instead
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm build:preload && pnpm dev:prerequisite",
|
"beforeDevCommand": "pnpm dev:web",
|
||||||
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
|
"beforeBuildCommand": "pnpm build:preload && pnpm build:affine",
|
||||||
"devPath": "http://localhost:8080",
|
"devPath": "http://localhost:8080",
|
||||||
"distDir": "../public",
|
"distDir": "../public",
|
||||||
|
|||||||
@@ -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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -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',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -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' }} />;
|
|
||||||
};
|
|
||||||
@@ -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 {}`
|
// 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)
|
// @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();
|
setEnvironmentVariables();
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
declare global {
|
declare global {
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var __editoVersion: unknown;
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
CLIENT_APP?: boolean;
|
CLIENT_APP?: boolean;
|
||||||
__editoVersion?: string;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
declare global {
|
declare global {
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var __editoVersion: unknown;
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
CLIENT_APP?: boolean;
|
CLIENT_APP?: boolean;
|
||||||
__editoVersion?: string;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,18 @@ const printBuildInfo = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function setWindowEditorVersion() {
|
function setWindowEditorVersion() {
|
||||||
// when it is not SSR
|
globalThis.__editoVersion = publicRuntimeConfig.EDITOR_VERSION;
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
window.__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 {};
|
export {};
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ const temp = JSON.parse(record);
|
|||||||
loadPage();
|
loadPage();
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
// eslint-disable-next-line no-var
|
||||||
__editoVersion: unknown;
|
var __editoVersion: unknown;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe('web console', () => {
|
test.describe('web console', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user