mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: store local data to local db (#2037)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
rootCurrentWorkspaceIdAtom,
|
||||
rootWorkspacesMetadataAtom,
|
||||
} from '@affine/workspace/atom';
|
||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import { atom } from 'jotai';
|
||||
|
||||
@@ -46,6 +47,21 @@ rootWorkspacesMetadataAtom.onMount = setAtom => {
|
||||
}
|
||||
return metadata;
|
||||
});
|
||||
|
||||
if (environment.isDesktop) {
|
||||
window.apis.workspace.list().then(workspaceIDs => {
|
||||
const newMetadata = workspaceIDs.map(w => ({
|
||||
id: w,
|
||||
flavour: WorkspaceFlavour.LOCAL,
|
||||
}));
|
||||
setAtom(metadata => {
|
||||
return [
|
||||
...metadata,
|
||||
...newMetadata.filter(m => !metadata.find(m2 => m2.id === m.id)),
|
||||
];
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,14 @@ export const ExportPanel = () => {
|
||||
return (
|
||||
<>
|
||||
<Wrapper marginBottom="42px"> {t('Export Description')}</Wrapper>
|
||||
<Button type="light" shape="circle" disabled>
|
||||
<Button
|
||||
type="light"
|
||||
shape="circle"
|
||||
disabled={!environment.isDesktop}
|
||||
onClick={() => {
|
||||
window.apis.openSaveDBFileDialog();
|
||||
}}
|
||||
>
|
||||
{t('Export AFFiNE backup file')}
|
||||
</Button>
|
||||
</>
|
||||
|
||||
@@ -158,7 +158,13 @@ export const GeneralPanel: React.FC<PanelProps> = ({
|
||||
{/* </StyledRow>*/}
|
||||
{/*)}*/}
|
||||
|
||||
<StyledRow>
|
||||
<StyledRow
|
||||
onClick={() => {
|
||||
if (environment.isDesktop) {
|
||||
window.apis.openDBFolder();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<StyledSettingKey>{t('Workspace Type')}</StyledSettingKey>
|
||||
{isOwner ? (
|
||||
workspace.flavour === WorkspaceFlavour.LOCAL ? (
|
||||
|
||||
@@ -7,7 +7,9 @@ export const ThemeModeSwitch = () => {
|
||||
const { setTheme, resolvedTheme } = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
window.apis?.onThemeChange(resolvedTheme === 'dark' ? 'dark' : 'light');
|
||||
if (environment.isDesktop) {
|
||||
window.apis?.onThemeChange(resolvedTheme === 'dark' ? 'dark' : 'light');
|
||||
}
|
||||
}, [resolvedTheme]);
|
||||
|
||||
const [isHover, setIsHover] = useState(false);
|
||||
|
||||
@@ -95,7 +95,9 @@ export const WorkSpaceSliderBar: React.FC<WorkSpaceSliderBarProps> = ({
|
||||
const show = isPublicWorkspace ? false : sidebarOpen;
|
||||
const actualWidth = floatingSlider ? 'calc(10vw + 400px)' : sliderWidth;
|
||||
useEffect(() => {
|
||||
window.apis?.onSidebarVisibilityChange(sidebarOpen);
|
||||
if (environment.isDesktop) {
|
||||
window.apis?.onSidebarVisibilityChange(sidebarOpen);
|
||||
}
|
||||
}, [sidebarOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -28,6 +28,9 @@ export function useSyncRouterWithCurrentWorkspaceId(router: NextRouter) {
|
||||
if (targetWorkspace) {
|
||||
console.log('set workspace id', workspaceId);
|
||||
setCurrentWorkspaceId(targetWorkspace.id);
|
||||
if (environment.isDesktop) {
|
||||
window.apis?.onWorkspaceChange(targetWorkspace.id);
|
||||
}
|
||||
void router.push({
|
||||
pathname: '/workspace/[workspaceId]/all',
|
||||
query: {
|
||||
|
||||
Reference in New Issue
Block a user