Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动态菜单怎么在用户登录之后刷新菜单? #1

Open
Dreampie opened this issue Apr 9, 2015 · 0 comments
Open

动态菜单怎么在用户登录之后刷新菜单? #1

Dreampie opened this issue Apr 9, 2015 · 0 comments

Comments

@Dreampie
Copy link

Dreampie commented Apr 9, 2015

//登录
$http.post('/api/v1.0/sessions', {username: username, password: password, rememberMe: rememberMe}, (rep)->
          data.ferror = false
          data.loading = false
          #返回的user数据
          $state.user = rep
          try
            localStorage.setItem('username', username)
          //把菜单权限存到localStorage
            localStorage.setItem("permissions", stateman.user.permissions)
          catch e

          data.password = null
          component.$update()

          #跳转
          $state.go("app.order");
)
//app模块的菜单数据 菜单组件 <app-menu ref="appMenu" menus={menus} state={@(this.$state)}></app-menu>
config: (data)->
      data.menus = [
        {url: '/', name: '首页', icon: 'home', state: 'app.index'}
      ]

      try
        permissions = localStorage.getItem("permissions")
      catch e

      if permissions
        permissions=permissions.split(",")
        for permission in permissions
          switch permission
            when 'P_ORDER' then data.menus.push({url: '/order', name: '订单', icon: 'table', state: 'app.order'})
            when 'P_SALE' then data.menus.push({url: '/sale', name: '销售', icon: 'strikethrough', state: 'app.sale'})
            when 'P_FINANCE' then data.menus.push({url: '/finance', name: '财务', icon: 'yen', state: 'app.finance'})
            when 'P_SETTING' then data.menus.push({url: '/setting', name: '设置', icon: 'configure', state: 'app.setting'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant