admin-layout.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Component } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { RouterModule, RouterOutlet } from '@angular/router';
  4. import { WxworkAuth } from "fmode-ng/core";
  5. @Component({
  6. selector: 'app-admin-layout',
  7. standalone: true,
  8. imports: [CommonModule, RouterModule, RouterOutlet],
  9. templateUrl: './admin-layout.html',
  10. styleUrl: './admin-layout.scss'
  11. })
  12. export class AdminLayout {
  13. sidebarOpen = true;
  14. currentUser = { name: '超级管理员', avatar: "data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' fill='%23CCFFCC'/%3E%3Ctext x='50%25' y='50%25' font-family='Arial' font-size='13.333333333333334' font-weight='bold' text-anchor='middle' fill='%23555555' dy='0.3em'%3EADMIN%3C/text%3E%3C/svg%3E" };
  15. currentDate = new Date();
  16. constructor(){
  17. this.loadProfile()
  18. }
  19. async loadProfile(){
  20. let cid = localStorage.getItem("company");
  21. if(cid){
  22. let wwAuth = new WxworkAuth({cid:cid})
  23. let profile = await wwAuth.currentProfile();
  24. this.currentUser = {
  25. name: profile?.get("name") || profile?.get("mobile"),
  26. avatar: profile?.get("avatar")
  27. }
  28. }
  29. }
  30. toggleSidebar() {
  31. this.sidebarOpen = !this.sidebarOpen;
  32. }
  33. }