onThemeChange 
- Category: 
Events - Relate: 
onThemeChange - Dependencies: 
@lark-base-open/js-sdk - Last Changed: yesterday
 
Notice
This function needs to use in Base, please use this website as a plugin in a Base to see the demo.
Demo 
Show demo code
vue
<script setup lang="ts">
import { onThemeChange } from "@qww0302/use-bitable";
import { bitable } from "@lark-base-open/js-sdk";
import { ref, onMounted } from "vue";
const theme = ref("LIGHT");
onThemeChange({
  callback: (t) => {
    theme.value = t;
  }
});
onMounted(() => {
  bitable.bridge.getTheme().then((t) => {
    theme.value = t;
  });
});
</script>
<template>
  <div>Current theme: {{ theme }}</div>
</template>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Usage 
Type Declarations 
ts
import type {
  ThemeModeType,
  IDashboard,
  IBridge,
  IDashboardTheme,
} from "@lark-base-open/js-sdk"
export interface OnThemeChangeOption<T extends IBridge | IDashboard> {
  /**
   * The target object(bridge or dashboard) to get the theme
   *
   * 获取主题的目标对象( bridge 或 dashboard )
   *
   * @default bridge
   * @type {IBridge | IDashboard}
   */
  target?: T
  callback: (theme: T extends IBridge ? ThemeModeType : IDashboardTheme) => void
}
export declare function onThemeChange(
  callback: (theme: ThemeModeType) => void,
): () => void
export declare function onThemeChange(
  option: OnThemeChangeOption<IBridge>,
): () => void
export declare function onThemeChange(
  option: OnThemeChangeOption<IDashboard>,
): void
export declare function onThemeChange<T extends IDashboard | IBridge>(
  option: OnThemeChangeOption<T>,
): void | (() => void)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30