useSetTitle.js 822 B

1234567891011121314151617181920212223242526272829
  1. import { onLoad } from '@dcloudio/uni-app'
  2. import { get } from "@/http/http.js"
  3. import { useLoginUserStore } from '@/stores/loginUser'
  4. const loginUserStore = useLoginUserStore()
  5. export function useSetTitle() {
  6. /**
  7. * 设置标题
  8. */
  9. function setTitle(){
  10. console.log(loginUserStore.loginUser.sysName)
  11. if(loginUserStore.loginUser.sysName){
  12. uni.setNavigationBarTitle({
  13. title: loginUserStore.loginUser.sysName //页面标题为页面顶部显示的文字
  14. });
  15. }else{
  16. get("/auth/getSysNameAndLogo").then(res => {
  17. let sysName = res.sysName || '';
  18. loginUserStore.setLoginUserTitle(sysName)
  19. uni.setNavigationBarTitle({
  20. title: sysName //页面标题为页面顶部显示的文字
  21. });
  22. })
  23. }
  24. }
  25. onLoad(() => {
  26. setTitle();
  27. })
  28. }