index.ts 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { watch } from "vue";
  2. import { scroller } from "./scroller";
  3. import { initTheme, setH5 } from "./theme";
  4. import { initLocale, locale, updateTitle } from "@/locale";
  5. import "@/uni_modules/cool-ui";
  6. export function cool(app: VueApp) {
  7. app.mixin({
  8. onPageScroll(e) {
  9. scroller.emit(e.scrollTop);
  10. },
  11. onShow() {
  12. // 更新标题
  13. updateTitle();
  14. // #ifdef H5
  15. setTimeout(() => {
  16. setH5();
  17. }, 0);
  18. // #endif
  19. },
  20. onLoad() {
  21. // 监听语言切换,更新标题
  22. watch(locale, () => {
  23. updateTitle();
  24. });
  25. }
  26. });
  27. initTheme();
  28. initLocale();
  29. console.log(app);
  30. }
  31. export * from "./animation";
  32. export * from "./ctx";
  33. export * from "./hooks";
  34. export * from "./router";
  35. export * from "./scroller";
  36. export * from "./service";
  37. export * from "./store";
  38. export * from "./theme";
  39. export * from "./upload";
  40. export * from "./utils";
  41. export * from "./types";