@ledvance/ui-biz-bundle 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/package.json +72 -72
- package/rn-cli.config.js +8 -8
- package/src/modules/history/HistoryPage.d.ts +2 -2
- package/src/modules/history/HistoryPage.tsx +254 -254
- package/src/modules/history/SwitchHistoryPageActions.d.ts +13 -13
- package/src/modules/history/SwitchHistoryPageActions.ts +53 -53
- package/src/modules/hooks/DeviceDpStateHooks.ts +27 -0
- package/src/modules/mood/MixLightActions.ts +82 -0
- package/src/modules/mood/MixLightSceneActions.ts +259 -0
- package/src/modules/mood/MixMoodItem.tsx +138 -0
- package/src/modules/mood/MixScene.tsx +131 -0
- package/src/modules/mood/MixSceneBeans.ts +62 -0
- package/src/modules/mood/MoodAction.ts +222 -0
- package/src/modules/mood/MoodItem.tsx +113 -0
- package/src/modules/mood/SceneInfo.ts +319 -0
- package/src/modules/timeSchedule/DeviceState.tsx +54 -0
- package/src/modules/timeSchedule/LdvScheduleItem.tsx +125 -0
- package/src/modules/timeSchedule/ManualSetting.tsx +69 -0
- package/src/modules/timeSchedule/MoodSetting.tsx +66 -0
- package/src/modules/timeSchedule/ScheduleScene.tsx +138 -0
- package/src/modules/timeSchedule/SingleLightView.tsx +254 -0
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +480 -0
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +323 -0
- package/src/modules/timeSchedule/mix/MixLightBean.ts +10 -0
- package/src/modules/timeSchedule/mix/MixLightView.tsx +221 -0
- package/src/modules/timeSchedule/utils.ts +7 -0
- package/src/modules/timer/TimerPage.tsx +409 -406
- package/src/modules/timer/{timerPageAction.ts → TimerPageAction.ts} +91 -91
- package/tsconfig.json +50 -50
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
2
|
-
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
3
|
-
import { dpItem } from "./TimerPage"
|
|
4
|
-
import { useCountDown as useCountDownAHook } from 'ahooks'
|
|
5
|
-
import dayjs from "dayjs"
|
|
6
|
-
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
7
|
-
import { useEffect, useState } from "react"
|
|
8
|
-
|
|
9
|
-
export const useCountdowns= (dps: dpItem[]) =>{
|
|
10
|
-
return dps.map(dp => {
|
|
11
|
-
return ({
|
|
12
|
-
countdown: useDp<number,(value:number)=>Promise<Result<any>>>(dp.dpId),
|
|
13
|
-
enable: useDp<boolean, (value:boolean)=>Promise<Result<any>>>(dp.enableDp),
|
|
14
|
-
...dp
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const useFormateProgress : (dp: dpItem, func: Function) => [number, (time: number, t: any) => void]= (dp, cancelTimer) =>{
|
|
21
|
-
const [progress, setProgress] = useCountDownAHook({
|
|
22
|
-
interval: 1000,
|
|
23
|
-
onEnd: () => cancelTimer(dp.dpId),
|
|
24
|
-
})
|
|
25
|
-
const [countdown] = useDp<number,(value:number)=>Promise<Result<any>>>(dp.dpId)
|
|
26
|
-
const devId = useDeviceId()
|
|
27
|
-
const [cloudProgressNumber, setCloudProgressNumber] = useState(0)
|
|
28
|
-
const [progressNumber, setProgressNumber] = useState(0)
|
|
29
|
-
const [cloudData, setCloudData] = useState<any>()
|
|
30
|
-
const getCloudJson = () =>{
|
|
31
|
-
NativeApi.getJson(devId, dp.cloudKey).then(res =>{
|
|
32
|
-
if(res.success && res.data){
|
|
33
|
-
const result = JSON.parse(res.data)
|
|
34
|
-
setCloudData(result)
|
|
35
|
-
setCloudProgressNumber(result.progressAllNumber)
|
|
36
|
-
if(countdown > 0) setProgress(Date.now() + countdown * 1000)
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
useEffect(() =>{
|
|
41
|
-
getCloudJson()
|
|
42
|
-
}, [])
|
|
43
|
-
|
|
44
|
-
useEffect(() =>{
|
|
45
|
-
if(cloudProgressNumber > 0){
|
|
46
|
-
const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
47
|
-
const remainingTime = Number(cloudData && dayjs(cloudData[getKey('StartTime', dp.dpId)] || 0).diff(currentTime))
|
|
48
|
-
const time = (cloudData && cloudData[getKey('Status', dp.dpId)] && remainingTime >= -1000) ? remainingTime : Number(progress.toString().slice(0, -3) + "000")
|
|
49
|
-
const conversion = (time / 1000) / cloudProgressNumber * 100
|
|
50
|
-
setProgressNumber(!isNaN(conversion) ? conversion : 0)
|
|
51
|
-
}
|
|
52
|
-
}, [progress])
|
|
53
|
-
|
|
54
|
-
useEffect(() =>{
|
|
55
|
-
if(countdown === 0 && cloudData){
|
|
56
|
-
setProgress(0)
|
|
57
|
-
setProgressNumber(0)
|
|
58
|
-
setCloudData('')
|
|
59
|
-
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 }))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if(countdown === 0 && !cloudData){
|
|
63
|
-
setProgress(0)
|
|
64
|
-
setProgressNumber(0)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if(countdown > 0 && !cloudData){
|
|
68
|
-
getCloudJson()
|
|
69
|
-
}
|
|
70
|
-
}, [countdown, cloudData])
|
|
71
|
-
|
|
72
|
-
const getKey = (suffix:string, dpId:string) =>{
|
|
73
|
-
const key = dpId + suffix
|
|
74
|
-
return key
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const startTimer = (time: number, t) => {
|
|
78
|
-
setCloudProgressNumber(time)
|
|
79
|
-
setProgress(Date.now() + time * 1000)
|
|
80
|
-
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: true, [getKey('StartTime', dp.dpId)]: t, progressAllNumber: time }));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return [progressNumber, startTimer]
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const useProgress = (dps: dpItem[], cancelTimer) =>{
|
|
87
|
-
return dps.map(dp => ({
|
|
88
|
-
progressHook: useFormateProgress(dp, cancelTimer),
|
|
89
|
-
...dp
|
|
90
|
-
}))
|
|
91
|
-
}
|
|
1
|
+
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
2
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
3
|
+
import { dpItem } from "./TimerPage"
|
|
4
|
+
import { useCountDown as useCountDownAHook } from 'ahooks'
|
|
5
|
+
import dayjs from "dayjs"
|
|
6
|
+
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
7
|
+
import { useEffect, useState } from "react"
|
|
8
|
+
|
|
9
|
+
export const useCountdowns= (dps: dpItem[]) =>{
|
|
10
|
+
return dps.map(dp => {
|
|
11
|
+
return ({
|
|
12
|
+
countdown: useDp<number,(value:number)=>Promise<Result<any>>>(dp.dpId),
|
|
13
|
+
enable: useDp<boolean, (value:boolean)=>Promise<Result<any>>>(dp.enableDp),
|
|
14
|
+
...dp
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const useFormateProgress : (dp: dpItem, func: Function) => [number, (time: number, t: any) => void]= (dp, cancelTimer) =>{
|
|
21
|
+
const [progress, setProgress] = useCountDownAHook({
|
|
22
|
+
interval: 1000,
|
|
23
|
+
onEnd: () => cancelTimer(dp.dpId),
|
|
24
|
+
})
|
|
25
|
+
const [countdown] = useDp<number,(value:number)=>Promise<Result<any>>>(dp.dpId)
|
|
26
|
+
const devId = useDeviceId()
|
|
27
|
+
const [cloudProgressNumber, setCloudProgressNumber] = useState(0)
|
|
28
|
+
const [progressNumber, setProgressNumber] = useState(0)
|
|
29
|
+
const [cloudData, setCloudData] = useState<any>()
|
|
30
|
+
const getCloudJson = () =>{
|
|
31
|
+
NativeApi.getJson(devId, dp.cloudKey).then(res =>{
|
|
32
|
+
if(res.success && res.data){
|
|
33
|
+
const result = JSON.parse(res.data)
|
|
34
|
+
setCloudData(result)
|
|
35
|
+
setCloudProgressNumber(result.progressAllNumber)
|
|
36
|
+
if(countdown > 0) setProgress(Date.now() + countdown * 1000)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
useEffect(() =>{
|
|
41
|
+
getCloudJson()
|
|
42
|
+
}, [])
|
|
43
|
+
|
|
44
|
+
useEffect(() =>{
|
|
45
|
+
if(cloudProgressNumber > 0){
|
|
46
|
+
const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
47
|
+
const remainingTime = Number(cloudData && dayjs(cloudData[getKey('StartTime', dp.dpId)] || 0).diff(currentTime))
|
|
48
|
+
const time = (cloudData && cloudData[getKey('Status', dp.dpId)] && remainingTime >= -1000) ? remainingTime : Number(progress.toString().slice(0, -3) + "000")
|
|
49
|
+
const conversion = (time / 1000) / cloudProgressNumber * 100
|
|
50
|
+
setProgressNumber(!isNaN(conversion) ? conversion : 0)
|
|
51
|
+
}
|
|
52
|
+
}, [progress])
|
|
53
|
+
|
|
54
|
+
useEffect(() =>{
|
|
55
|
+
if(countdown === 0 && cloudData){
|
|
56
|
+
setProgress(0)
|
|
57
|
+
setProgressNumber(0)
|
|
58
|
+
setCloudData('')
|
|
59
|
+
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 }))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if(countdown === 0 && !cloudData){
|
|
63
|
+
setProgress(0)
|
|
64
|
+
setProgressNumber(0)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if(countdown > 0 && !cloudData){
|
|
68
|
+
getCloudJson()
|
|
69
|
+
}
|
|
70
|
+
}, [countdown, cloudData])
|
|
71
|
+
|
|
72
|
+
const getKey = (suffix:string, dpId:string) =>{
|
|
73
|
+
const key = dpId + suffix
|
|
74
|
+
return key
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const startTimer = (time: number, t) => {
|
|
78
|
+
setCloudProgressNumber(time)
|
|
79
|
+
setProgress(Date.now() + time * 1000)
|
|
80
|
+
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: true, [getKey('StartTime', dp.dpId)]: t, progressAllNumber: time }));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return [progressNumber, startTimer]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const useProgress = (dps: dpItem[], cancelTimer) =>{
|
|
87
|
+
return dps.map(dp => ({
|
|
88
|
+
progressHook: useFormateProgress(dp, cancelTimer),
|
|
89
|
+
...dp
|
|
90
|
+
}))
|
|
91
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Basic Options */
|
|
4
|
-
"target": "ES2017",
|
|
5
|
-
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
8
|
-
"jsx": "react",
|
|
9
|
-
/* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
10
|
-
|
|
11
|
-
/* Strict Type-Checking Options */
|
|
12
|
-
/* "strict": true /* Enable all strict type-checking options. */
|
|
13
|
-
"noImplicitAny": false,
|
|
14
|
-
/* Raise error on expressions and declarations with an implied 'any' type. */
|
|
15
|
-
"strictNullChecks": true,
|
|
16
|
-
/* Enable strict null checks. */
|
|
17
|
-
|
|
18
|
-
/* Additional Checks */
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
/* Report errors on unused locals. */
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
/* Report errors on unused parameters. */
|
|
23
|
-
|
|
24
|
-
/* .d.ts config */
|
|
25
|
-
"declaration": true,
|
|
26
|
-
"emitDeclarationOnly": true,
|
|
27
|
-
|
|
28
|
-
/* Module Resolution Options */
|
|
29
|
-
"moduleResolution": "node",
|
|
30
|
-
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' */
|
|
31
|
-
"types": ["react", "react-native"],
|
|
32
|
-
/* Type declaration files to be included in compilation. */
|
|
33
|
-
"typeRoots": ["@types/*.d.ts"],
|
|
34
|
-
"allowSyntheticDefaultImports": true,
|
|
35
|
-
/* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
36
|
-
"esModuleInterop": true,
|
|
37
|
-
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
38
|
-
"baseUrl": "./src",
|
|
39
|
-
"paths": {
|
|
40
|
-
"@api": ["./api"],
|
|
41
|
-
"@components": ["./components"],
|
|
42
|
-
"@config": ["./config"],
|
|
43
|
-
"@i18n": ["./i18n"],
|
|
44
|
-
"@models": ["./models"],
|
|
45
|
-
"@res": ["./res"],
|
|
46
|
-
"@utils": ["./utils"]
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"include": ["src/**/*.ts","src/**/*.tsx"],
|
|
50
|
-
"exclude": ["node_modules",".yalc"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "ES2017",
|
|
5
|
+
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
8
|
+
"jsx": "react",
|
|
9
|
+
/* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
10
|
+
|
|
11
|
+
/* Strict Type-Checking Options */
|
|
12
|
+
/* "strict": true /* Enable all strict type-checking options. */
|
|
13
|
+
"noImplicitAny": false,
|
|
14
|
+
/* Raise error on expressions and declarations with an implied 'any' type. */
|
|
15
|
+
"strictNullChecks": true,
|
|
16
|
+
/* Enable strict null checks. */
|
|
17
|
+
|
|
18
|
+
/* Additional Checks */
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
/* Report errors on unused locals. */
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
/* Report errors on unused parameters. */
|
|
23
|
+
|
|
24
|
+
/* .d.ts config */
|
|
25
|
+
"declaration": true,
|
|
26
|
+
"emitDeclarationOnly": true,
|
|
27
|
+
|
|
28
|
+
/* Module Resolution Options */
|
|
29
|
+
"moduleResolution": "node",
|
|
30
|
+
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' */
|
|
31
|
+
"types": ["react", "react-native"],
|
|
32
|
+
/* Type declaration files to be included in compilation. */
|
|
33
|
+
"typeRoots": ["@types/*.d.ts"],
|
|
34
|
+
"allowSyntheticDefaultImports": true,
|
|
35
|
+
/* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
36
|
+
"esModuleInterop": true,
|
|
37
|
+
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
38
|
+
"baseUrl": "./src",
|
|
39
|
+
"paths": {
|
|
40
|
+
"@api": ["./api"],
|
|
41
|
+
"@components": ["./components"],
|
|
42
|
+
"@config": ["./config"],
|
|
43
|
+
"@i18n": ["./i18n"],
|
|
44
|
+
"@models": ["./models"],
|
|
45
|
+
"@res": ["./res"],
|
|
46
|
+
"@utils": ["./utils"]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"include": ["src/**/*.ts","src/**/*.tsx"],
|
|
50
|
+
"exclude": ["node_modules",".yalc"]
|
|
51
51
|
}
|