Skip to content

Commit 85541c0

Browse files
committed
refactor: ♻️ adjusting mock settings configuration
1 parent 5800a9d commit 85541c0

9 files changed

+107
-35
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ dist-ssr
88
.cache
99

1010
# mock settings may contain sensitive tokens
11-
src/mock/settings.json
11+
mocks/settings.local.json

CONTRIBUTING.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Follow the steps below to run it locally for first time.
1010

1111
1. Copy `.env.example` to `.env`
12-
2. Turn on the HTTP APIs Server of Logseq
13-
3. Install dependencies: `pnpm install`
14-
4. Run `pnpm dev`
12+
2. Copy `mocks/settings.example.json` to `settings.local.json`
13+
3. Turn on the HTTP APIs Server of Logseq
14+
4. Install dependencies: `pnpm install`
15+
5. Run `pnpm dev`
File renamed without changes.

mocks/settings.example.json

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"disabled": true,
3+
"theme": "auto",
4+
"lightThemeType": "green",
5+
"homePage": "dashboard",
6+
"defaultView": "month",
7+
"weekStartDay": 0,
8+
"weekHourStart": 0,
9+
"weekHourEnd": 24,
10+
"defaultDuration": {
11+
"value": 0.5,
12+
"unit": "h"
13+
},
14+
"defaultDurationUnit": "h",
15+
"logKey": {
16+
"id": "Daily Log",
17+
"bgColor": "#047857",
18+
"textColor": "#fff",
19+
"borderColor": "#047857",
20+
"enabled": true
21+
},
22+
"journal": {
23+
"id": "Journal",
24+
"bgColor": "#047857",
25+
"textColor": "#fff",
26+
"borderColor": "#047857",
27+
"enabled": true
28+
},
29+
"projectList": [
30+
{
31+
"id": "logseq-plugin-agenda/2.15.0",
32+
"bgColor": "#b8e986",
33+
"textColor": "#4a4a4a",
34+
"borderColor": "#047857",
35+
"enabled": true
36+
}
37+
],
38+
"calendarList": [],
39+
"subscriptionList": [],
40+
"pomodoro": {
41+
"pomodoro": 25,
42+
"shortBreak": 5,
43+
"longBreak": 15,
44+
"autoStartBreaks": false,
45+
"autoStartPomodoros": false,
46+
"longBreakInterval": 4,
47+
"commonPomodoros": [
48+
10,
49+
15,
50+
20,
51+
25,
52+
40
53+
]
54+
},
55+
"initialized": true,
56+
"ignoreTag": null,
57+
"todoist": {},
58+
"language": "zh-hans"
59+
}

src/apps/PomodoroApp.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { genToolbarPomodoro, updatePomodoroInfo } from '@/helper/pomodoro'
2-
import { PomodoroConfig, usePomodoro } from '@haydenull/use-pomodoro'
1+
import { type PomodoroConfig, usePomodoro } from '@haydenull/use-pomodoro'
32
import { ConfigProvider, Tooltip } from 'antd'
43
import dayjs from 'dayjs'
54
import React, { useEffect, useMemo, useRef, useState } from 'react'
65
import { AiOutlinePoweroff, AiOutlineQuestionCircle } from 'react-icons/ai'
76
import { MdOutlineRunningWithErrors } from 'react-icons/md'
87
import { RiExternalLinkLine } from 'react-icons/ri'
8+
9+
import { genToolbarPomodoro, updatePomodoroInfo } from '@/helper/pomodoro'
10+
911
import InerruptionModal from '../components/InerruptionModal'
1012
import { transformBlockToEvent } from '../helper/transform'
1113
import useTheme from '../hooks/useTheme'
1214
import { getInitialSettings } from '../util/baseInfo'
1315
import { ANTD_THEME_CONFIG } from '../util/constants'
14-
import { IEvent } from '../util/events'
16+
import type { IEvent } from '../util/events'
1517
import { navToBlock } from '../util/logseq'
1618
import { notification } from '../util/util'
1719

src/main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if (isDevelopment) {
5050
apiServer: import.meta.env.VITE_LOGSEQ_API_SERVER,
5151
apiToken: import.meta.env.VITE_LOGSEQ_API_TOKEN,
5252
},
53-
settings: await import('@/mock/settings.json'),
53+
settings: window.mockSettings,
5454
})
5555
renderApp()
5656
// renderPomodoroApp('pomodoro')

src/vite-env.d.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/// <reference types="vite/client" />
22

3+
type IInterruption = import('./helper/pomodoro').IInterruption
34
interface Window {
4-
faizNavigate: (e: any) => void
5-
logseqAppUserConfigs: any
5+
faizNavigate: (e: unknown) => void
6+
logseqAppUserConfigs: unknown
67
currentApp: 'app' | 'pomodoro' | 'modal'
78
currentPomodoro: {
89
uuid?: string
@@ -11,7 +12,8 @@ interface Window {
1112
}
1213
}
1314
unmountPomodoroApp: () => void
14-
interruptionMap: Map<number, any>
15+
interruptionMap: Map<number, IInterruption[]>
16+
mockSettings: Record<string, unknown>
1517
}
1618

1719
interface ImportMetaEnv {

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
"@/*": ["./src/*"],
2121
}
2222
},
23-
"include": ["./src"]
23+
"include": ["./src", "./vite.config.ts"]
2424
}

vite.config.ts

+31-23
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,38 @@ import { resolve } from 'path'
33
import { defineConfig } from 'vite'
44

55
// https://vitejs.dev/config/
6-
export default defineConfig({
7-
plugins: [
8-
react(),
9-
// usePluginImport({
10-
// libraryName: "antd",
11-
// libraryDirectory: "es",
12-
// style: "css",
13-
// }),
14-
],
15-
resolve: {
16-
alias: {
17-
'@': resolve(__dirname, 'src'),
6+
export default defineConfig(async ({ command, mode }) => {
7+
return {
8+
plugins: [
9+
react(),
10+
// usePluginImport({
11+
// libraryName: "antd",
12+
// libraryDirectory: "es",
13+
// style: "css",
14+
// }),
15+
],
16+
resolve: {
17+
alias: {
18+
'@': resolve(__dirname, 'src'),
19+
},
20+
},
21+
base: './',
22+
build: {
23+
target: 'esnext',
24+
// minify: "esbuild",
1825
},
19-
},
20-
base: './',
21-
build: {
22-
target: 'esnext',
23-
// minify: "esbuild",
24-
},
25-
css: {
26-
preprocessorOptions: {
27-
less: {
28-
javascriptEnabled: true,
26+
css: {
27+
preprocessorOptions: {
28+
less: {
29+
javascriptEnabled: true,
30+
},
2931
},
3032
},
31-
},
33+
define: {
34+
mockSettings:
35+
mode === 'production'
36+
? await import('./mocks/settings.example.json')
37+
: await import('./mocks/settings.local.json'),
38+
},
39+
}
3240
})

0 commit comments

Comments
 (0)