Skip to content

Commit 68cbd64

Browse files
committed
feat(storage): migrating data for Android (#613)
1 parent d87602d commit 68cbd64

File tree

7 files changed

+53
-49
lines changed

7 files changed

+53
-49
lines changed

src/pages/app/Layout/menu/item.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export const MENU_GROUPS: MenuGroup[] = [{
6161
}, {
6262
title: msg => msg.menu.dataClear,
6363
route: '/data/manage',
64-
icon: Database
64+
icon: Database,
65+
mobile: true,
6566
}]
6667
}, {
6768
title: msg => msg.menu.behavior,

src/pages/app/components/DataManage/ClearPanel/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import { t } from "@app/locale"
99
import db, { type StatCondition } from "@db/stat-database"
1010
import { MILL_PER_DAY, MILL_PER_SECOND } from "@util/time"
11-
import { ElAlert, ElCard, ElMessage, ElMessageBox } from "element-plus"
11+
import { ElCard, ElMessage, ElMessageBox } from "element-plus"
1212
import { defineComponent, type StyleValue } from "vue"
13-
import { alertProps } from "../common"
1413
import { useDataMemory } from "../context"
14+
import DataManageAlert from '../DataManageAlert'
1515
import ClearFilter from "./ClearFilter"
1616

1717
type FilterOption = {
@@ -102,7 +102,7 @@ const _default = defineComponent(() => {
102102

103103
return () => (
104104
<ElCard style={{ width: '100%' } satisfies StyleValue}>
105-
<ElAlert {...alertProps} title={t(msg => msg.dataManage.operationAlert)} />
105+
<DataManageAlert text={msg => msg.dataManage.operationAlert} />
106106
<ClearFilter onDelete={(date, focus, time) => handleClick({ date, focus, time })} />
107107
</ElCard>
108108
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { t, type I18nKey } from '@app/locale'
2+
import { ElAlert, type AlertProps } from 'element-plus'
3+
import { computed, defineComponent } from 'vue'
4+
5+
type Props = {
6+
type?: AlertProps['type']
7+
text: I18nKey | string
8+
}
9+
10+
const DataManageAlert = defineComponent<Props>(props => {
11+
const text = computed(() => {
12+
const text = props.text
13+
return typeof text === 'string' ? text : t(text)
14+
})
15+
16+
return () => (
17+
<ElAlert type={props.type ?? 'info'} closable={false} center>
18+
{text.value}
19+
</ElAlert>
20+
)
21+
}, { props: ['text', 'type'] })
22+
23+
export default DataManageAlert

src/pages/app/components/DataManage/MemoryInfo.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import { t } from "@app/locale"
99
import Flex from "@pages/components/Flex"
10-
import { ElAlert, ElCard, ElProgress } from "element-plus"
10+
import { ElCard, ElProgress } from "element-plus"
1111
import { computed, defineComponent, type StyleValue } from "vue"
12-
import { alertProps } from "./common"
1312
import { useDataMemory } from "./context"
13+
import DataManageAlert from './DataManageAlert'
1414

1515
const byte2Mb = (size: number) => Math.round((size || 0) / 1024.0 / 1024.0 * 1000) / 1000
1616

@@ -44,15 +44,13 @@ const _default = defineComponent(() => {
4444
bodyStyle={{ height: '100%', boxSizing: 'border-box' }}
4545
>
4646
<Flex column height='100%' align="center">
47-
<ElAlert
48-
{...alertProps}
47+
<DataManageAlert
4948
type={totalMb.value ? "info" : "warning"}
50-
title={totalTitle(totalMb.value)}
49+
text={totalTitle(totalMb.value)}
5150
/>
5251
<Flex flex={1} height={0}>
5352
<ElProgress
54-
width={260}
55-
strokeWidth={30}
53+
strokeWidth={10}
5654
percentage={percentage.value}
5755
type="circle"
5856
color={color.value}

src/pages/app/components/DataManage/Migration/index.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import Flex from "@pages/components/Flex"
1111
import Immigration from "@service/components/immigration"
1212
import { exportJson } from "@util/file"
1313
import { formatTime } from "@util/time"
14-
import { ElAlert, ElButton, ElCard } from "element-plus"
14+
import { ElButton, ElCard } from "element-plus"
1515
import { type FunctionalComponent, type StyleValue } from "vue"
16-
import { alertProps } from "../common"
16+
import DataManageAlert from '../DataManageAlert'
1717
import ImportButton from "./ImportButton"
1818
import ImportOtherButton from "./ImportOtherButton"
1919

@@ -26,15 +26,10 @@ async function handleExport() {
2626
}
2727

2828
const Migration: FunctionalComponent = () => (
29-
<ElCard
30-
style={{ width: '100%' } satisfies StyleValue}
31-
bodyStyle={{ height: '100%', boxSizing: 'border-box' } as StyleValue}
32-
>
33-
<Flex justify="center" height="100%" align="center">
34-
<Flex column gap={20} height="100%" maxWidth={190} flex={3}>
35-
<ElAlert style={{ flex: 1 }} {...alertProps} >
36-
{t(msg => msg.dataManage.migrationAlert)}
37-
</ElAlert>
29+
<ElCard style={{ width: '100%' } satisfies StyleValue}>
30+
<Flex column gap={20} justify="center" height="100%" align="center">
31+
<DataManageAlert text={msg => msg.dataManage.migrationAlert} />
32+
<Flex column gap={20} maxWidth={350} flex={1}>
3833
<ElButton
3934
size="large"
4035
type="success"

src/pages/app/components/DataManage/common.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/pages/app/components/DataManage/index.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,34 @@
55
* https://opensource.org/licenses/MIT
66
*/
77

8+
import { MediaSize, useMediaSize } from '@hooks/useMediaSize'
89
import Flex from "@pages/components/Flex"
910
import { ElScrollbar } from 'element-plus'
10-
import { defineComponent, type StyleValue } from "vue"
11+
import { computed, defineComponent, type StyleValue } from "vue"
1112
import ContentContainer from "../common/ContentContainer"
12-
import ClearPanel from "./ClearPanel"
13+
import ClearPanel from './ClearPanel'
1314
import MemoryInfo from "./MemoryInfo"
1415
import Migration from "./Migration"
1516
import { initDataManage } from "./context"
1617

1718
export default defineComponent(() => {
1819
initDataManage()
20+
const mediaSize = useMediaSize()
21+
const ltSm = computed(() => mediaSize.value < MediaSize.sm)
1922

2023
return () => (
2124
<ElScrollbar height="100%" style={{ width: '100%' } satisfies StyleValue}>
2225
<ContentContainer>
23-
<Flex gap={22} height={490}>
24-
<Flex height='100%' flex={8}>
25-
<MemoryInfo />
26-
</Flex>
27-
<Flex height='100%' flex={11}>
28-
<ClearPanel />
29-
</Flex>
30-
<Flex height='100%' flex={5}>
31-
<Migration />
26+
<Flex column gap={22}>
27+
<Flex gap={22} height={ltSm.value ? undefined : 300} column={ltSm.value}>
28+
<Flex height='100%' flex={5}>
29+
<MemoryInfo />
30+
</Flex>
31+
<Flex height='100%' flex={5}>
32+
<Migration />
33+
</Flex>
3234
</Flex>
35+
<ClearPanel />
3336
</Flex>
3437
</ContentContainer >
3538
</ElScrollbar>

0 commit comments

Comments
 (0)