Explorar el Código

权限管理优化

wangkang3 %!s(int64=2) %!d(string=hace) años
padre
commit
800a3d40e6

+ 1 - 1
dmp-edge-ai/.env.development

@ -4,4 +4,4 @@ NODE_ENV = 'development'
4 4
VUE_APP_MODE = 'development'
5 5
6 6
# 接口服务器配置
7
VUE_APP_REQUEST_BASE_URL = 'http://47.105.130.83:8011'
7
VUE_APP_REQUEST_BASE_URL = 'http://8.130.50.1:8011'

+ 2 - 2
dmp-edge-ai/public/index.html

@ -5,7 +5,7 @@
5 5
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 6
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
7 7
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
    <title><%= htmlWebpackPlugin.options.title %></title>
8
    <title>用户中心</title>
9 9
    <style media="screen" type="text/css">
10 10
      #appLoading { position: fixed; top: 0; bottom: 0; left: 0; right: 0; background-color: #020232; }
11 11
      #appLoading img {
@ -22,7 +22,7 @@
22 22
  </head>
23 23
  <body>
24 24
    <noscript>
25
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
25
      <strong>We're sorry but 用户中心 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
26 26
    </noscript>
27 27
    <div id="appLoading">
28 28
      <img src="<%= BASE_URL %>iot-loading.gif" alt="loading" />

BIN
dmp-edge-ai/src/assets/image/iotsigle2.png


BIN
dmp-edge-ai/src/assets/image/login-bg.png


BIN
dmp-edge-ai/src/assets/image/login-logo-new.png


BIN
dmp-edge-ai/src/assets/image/subject.png


+ 20 - 15
dmp-edge-ai/src/router/index.js

@ -24,8 +24,8 @@ Vue.use(VueRouter)
24 24
// }
25 25
26 26
const router = new VueRouter({
27
  mode: 'history',
28
  base: process.env.BASE_URL,
27
  mode: 'hash',
28
  base: window.__MICRO_APP_BASE_ROUTE__ || process.env.BASE_URL,
29 29
  routes,
30 30
  scrollBehavior(to, from, savedPosition) {
31 31
    if (savedPosition) {
@ -39,26 +39,31 @@ router.beforeEach((to, from, next) => {
39 39
  if (to.meta.title) {
40 40
    document.title = to.meta.title
41 41
  }
42
  const token = localStorage.getItem(TOKEN)
42
  const token = to.query.token||localStorage.getItem(TOKEN)
43 43
  const menuList = localStorage.getItem(actionType.SET_MENU)
44 44
  const userInfo = store.getters.userInfo
45
  console.log(token)
45 46
  console.log(menuList)
46 47
  console.log(to, 2, from)
47 48
  if (from.name === 'Login' || (to.name !== 'Login' && token && isEmpty(userInfo))) {
49
    console.log(1)
50
    localStorage.setItem(TOKEN,token)
48 51
    // 如果来自登录页面 或者 跳转至非登录页token存在且无用户信息
49
    store.commit(actionType.SET_TOKEN, token)
50
    store.dispatch(actionType.SET_USER).then(
51
      () => {
52
        if (to.name === 'NotFound') {
53
          store.commit(actionType.SET_MENU, formatMenu(JSON.parse(menuList)))
54
          router.replace({ path: to.path, query: to.query })
52
    store.dispatch(actionType.SET_TOKEN, token).then( ()=>{
53
      store.dispatch(actionType.SET_USER).then(
54
        () => {
55
          if (to.name === 'NotFound') {
56
            store.commit(actionType.SET_MENU, formatMenu(JSON.parse(menuList)))
57
            router.replace({ path: to.path, query: to.query })
58
          }
59
          console.log(2)
60
          next()
61
        },
62
        () => {
63
          next(false)
55 64
        }
56
        next()
57
      },
58
      () => {
59
        next(false)
60
      }
61
    )
65
      )
66
    })
62 67
  } else if (!token && to.name !== 'Login') {
63 68
    const query = {}
64 69
    if (to.name !== 'NotFound') {

+ 11 - 7
dmp-edge-ai/src/router/routes.js

@ -11,6 +11,10 @@ export default [
11 11
  },
12 12
  {
13 13
    path: '/',
14
    redirect: '/login'
15
  },
16
  {
17
    path: '/system',
14 18
    component: Layout,
15 19
    name: 'Layout',
16 20
    children: [
@ -23,7 +27,7 @@ export default [
23 27
        }
24 28
      },
25 29
      {
26
        path: 'system/user',
30
        path: 'user',
27 31
        name: 'User',
28 32
        component: () => import(/* webpackChunkName: "User" */ '@/views/system/user'),
29 33
        meta: {
@ -31,7 +35,7 @@ export default [
31 35
        }
32 36
      },
33 37
      {
34
        path: 'system/role',
38
        path: 'role',
35 39
        name: 'Role',
36 40
        component: () => import(/* webpackChunkName: "Role" */ '@/views/system/role'),
37 41
        meta: {
@ -39,7 +43,7 @@ export default [
39 43
        }
40 44
      },
41 45
      {
42
        path: 'system/menu',
46
        path: 'menu',
43 47
        name: 'Menu',
44 48
        component: () => import(/* webpackChunkName: "Menu" */ '@/views/system/menu'),
45 49
        meta: {
@ -47,7 +51,7 @@ export default [
47 51
        }
48 52
      },
49 53
      {
50
        path: 'system/organize',
54
        path: 'organize',
51 55
        name: 'Organize',
52 56
        component: () => import(/* webpackChunkName: "Organize" */ '@/views/system/organize'),
53 57
        meta: {
@ -55,7 +59,7 @@ export default [
55 59
        }
56 60
      },
57 61
      {
58
        path: 'system/post',
62
        path: 'post',
59 63
        name: 'Post',
60 64
        component: () => import(/* webpackChunkName: "Post" */ '@/views/system/post'),
61 65
        meta: {
@ -63,7 +67,7 @@ export default [
63 67
        }
64 68
      },
65 69
      {
66
        path: 'system/authority',
70
        path: 'authority',
67 71
        name: 'Authority',
68 72
        component: () => import(/* webpackChunkName: "Authority" */ '@/views/system/authority'),
69 73
        meta: {
@ -71,7 +75,7 @@ export default [
71 75
        }
72 76
      },
73 77
      {
74
        path: 'system/dictionary',
78
        path: 'dictionary',
75 79
        name: 'Dictionary',
76 80
        component: () => import(/* webpackChunkName: "Dictionary" */ '@/views/system/dictionary'),
77 81
        meta: {

+ 2 - 1
dmp-edge-ai/src/utils/constant.js

@ -34,7 +34,8 @@ export const MenuType = createEnum({
34 34
 */
35 35
export const IframeFlag = createEnum({
36 36
  IN: [0, '内链'],
37
  OUT: [1, '外链']
37
  OUT: [1, '外链'],
38
  NEW: [2, '新窗口']
38 39
})
39 40
40 41
/**

+ 1 - 1
dmp-edge-ai/src/utils/menu.js

@ -10,7 +10,7 @@ export function formatMenu(menuList) {
10 10
  let counter = 0
11 11
  const formatMenuList = []
12 12
  for (let i = 0; i < menuList.length; i++) {
13
    if (menuList[i].hiddenFlag === VisibleStatus.NO) {
13
    if (menuList[i].hiddenFlag === VisibleStatus.NO || menuList[i].showType != 1) {
14 14
      // 如果根节点不可见
15 15
      continue
16 16
    }

+ 1 - 0
dmp-edge-ai/src/utils/request.js

@ -21,6 +21,7 @@ service.interceptors.request.use(
21 21
  (config) => {
22 22
    // do something before request is sent
23 23
    const token = localStorage.getItem(TOKEN)
24
    console.log(token)
24 25
    // 如果请求地址需要携带token,且token存在,携带token进行请求
25 26
    if (!EXCLUDE_URL.includes(config.url) && token) {
26 27
      config.headers[ACCESS_TOKEN] = token

+ 5 - 2
dmp-edge-ai/src/views/home/index.vue

@ -1,12 +1,15 @@
1 1
<template>
2 2
  <div class="pages-common bg-login bg-cover">
3
    <div class="mt-8 text-2xl text-white text-center tracking-wider">欢迎进入物联网设备管理平台!</div>
3
    <div class="mt-8 text-2xl text-white text-center tracking-wider">欢迎进入亚信物联网智能边缘产品!</div>
4 4
  </div>
5 5
</template>
6 6
7 7
<script>
8 8
export default {
9
  name: 'Home'
9
  name: 'Home',
10
  created() {
11
    console.log(this.$router)
12
  }
10 13
}
11 14
</script>
12 15

+ 2 - 1
dmp-edge-ai/src/views/layout/index.vue

@ -3,7 +3,7 @@
3 3
    <el-header class="flex justify-between p-0 bg-headPrimary">
4 4
      <div class="w-150 h-15 flex items-center bg-brand-bg bg-cover">
5 5
        <div class="w-8 h-8 ml-4 bg-brand-logo bg-cover"></div>
6
        <span class="ml-3.5 text-xl text-white font-medium">物联网设备管理平台</span>
6
        <span class="ml-3.5 text-xl text-white font-medium">亚信物联网智能边缘产品</span>
7 7
        <div class="cursor-pointer ml-5 w-7 h-7 bg-view-module bg-cover"></div>
8 8
      </div>
9 9
      <div class="flex items-center px-4">
@ -105,6 +105,7 @@ export default {
105 105
    }
106 106
  },
107 107
  async mounted() {
108
    console.log(this.$router)
108 109
    if (screenfull.enabled) {
109 110
      screenfull.on('change', this.onFullscreenChange)
110 111
    }

+ 99 - 27
dmp-edge-ai/src/views/login/index.vue

@ -1,29 +1,58 @@
1 1
<template>
2
  <div class="pages-common bg-login bg-cover">
3
    <div class="absolute-center w-100 h-88 bg-white bg-opacity-60 rounded-md px-5 p-9">
4
      <h1 class="flex justify-center items-center h-12.5 text-title font-bold text-loginPrimary">物联网管理平台</h1>
5
      <el-form ref="form" class="mt-7" :model="form" :rules="rules" label-width="0">
6
        <el-form-item label="" prop="username">
7
          <el-input v-model.trim="form.username" placeholder="请输入用户名"></el-input>
8
        </el-form-item>
9
        <el-form-item label="" prop="password">
10
          <el-input v-model.trim="form.password" type="password" placeholder="请输入密码"></el-input>
11
        </el-form-item>
12
        <el-form-item label="" prop="code" class="overflow-auto">
13
          <el-input v-model.trim="form.code" class="identify float-left w-3/5" placeholder="请输入验证码"></el-input>
14
          <img
15
            :src="identifyingCodeImg"
16
            class="float-right w-2/5 h-10 rounded-r cursor-pointer border-0"
17
            alt="验证码"
18
            @click="changeImg"
19
          />
20
        </el-form-item>
21
        <div class="flex justify-end">
22
          <el-button v-if="!submitLoading" type="primary" @click="onSubmit">登录</el-button>
23
          <el-button v-else type="primary" :loading="submitLoading">登录中</el-button>
24
        </div>
25
      </el-form>
26
    </div>
2
  <div class="login">
3
    <el-container>
4
      <el-header>
5
        <el-row>
6
          <el-col :span="4">
7
            <div class="logo"></div>
8
          </el-col>
9
          <el-col :span="8">
10
            <h4 class="title">亚信物联网智能边缘产品</h4>
11
          </el-col>
12
        </el-row>
13
      </el-header>
14
      <el-main>
15
        <el-row type="flex" align="middle">
16
          <el-col :span="12">
17
            <img class="subject" src="../../assets/image/subject.png" />
18
          </el-col>
19
          <el-col :span="12" class="login-form">
20
            <el-row>
21
              <el-col>
22
                <h2>您好!</h2>
23
                <h3>欢迎使用亚信物联网智能边缘产品</h3>
24
              </el-col>
25
            </el-row>
26
            <el-form ref="form" :model="form" :rules="rules" label-width="0px">
27
              <el-form-item prop="username">
28
                <el-input v-model="form.username" placeholder="请输入用户名">
29
                  <i slot="prefix" class="el-input__icon el-icon-user"></i>
30
                </el-input>
31
              </el-form-item>
32
              <el-form-item prop="password">
33
                <el-input v-model="form.password" type="password" placeholder="请输入密码">
34
                  <i slot="prefix" class="el-input__icon el-icon-lock"></i>
35
                </el-input>
36
              </el-form-item>
37
              <el-form-item prop="identifyingCode">
38
                <el-input v-model="form.code" type="identifyingCode" placeholder="请输入验证码">
39
                  <img
40
                    slot="suffix"
41
                    :src="identifyingCodeImg"
42
                    alt="验证码"
43
                    class="identifying-img"
44
                    @click="changeImg"
45
                  />
46
                </el-input>
47
              </el-form-item>
48
              <el-form-item>
49
                <el-button type="primary" @click="onSubmit">登录</el-button>
50
              </el-form-item>
51
            </el-form>
52
          </el-col>
53
        </el-row>
54
      </el-main>
55
    </el-container>
27 56
  </div>
28 57
</template>
29 58
@ -105,7 +134,50 @@ export default {
105 134
</script>
106 135
107 136
<style scoped>
108
.identify ::v-deep input {
109
  border-radius: 0.25rem 0 0 0.25rem;
137
.login {
138
  height: 100%;
139
  background: url(../../assets/image/login-bg.png) no-repeat;
140
  background-size: 100% 100%;
141
}
142
.login .el-container {
143
  height: 100%;
144
}
145
.login .logo {
146
  width: 260px;
147
  height: 100px;
148
  background: url(../../assets/image/login-logo-new.png) no-repeat;
149
  background-size: 100% 100%;
150
}
151
.login .title {
152
  line-height: 100px;
153
  margin: 0 20px;
154
  color: #ffffff;
155
}
156
.login .el-main {
157
  align-items: center;
158
  display: flex;
159
  /* min-width: 1500px; */
160
}
161
.login .el-main .el-row {
162
  width: 100%;
163
}
164
.login .el-main .login-form {
165
  width: 300px;
166
  margin: 0 auto;
167
}
168
.login .el-main .login-form .el-button {
169
  width: 100%;
170
}
171
.login .el-main .login-form .el-form {
172
  width: 300px;
173
}
174
.login .el-main .subject {
175
  border: 0;
176
  width: 90%;
177
  height: auto;
178
}
179
.login .el-main .identifying-img {
180
  border: 0;
181
  cursor: pointer;
110 182
}
111 183
</style>

+ 35 - 0
dmp-edge-ai/src/views/system/iframe/index.vue

@ -0,0 +1,35 @@
1
<template>
2
  <div>
3
    <iframe
4
      id="external-frame"
5
      :src="url"
6
      importance="high"
7
      width="100%"
8
      frameborder="0"
9
      scrolling="auto"
10
      @load="setIframeHeight"
11
    ></iframe>
12
  </div>
13
</template>
14
<script>
15
export default {
16
  data() {
17
    return {
18
      url: ''
19
    }
20
  },
21
  mounted() {
22
    console.log('iframe')
23
    this.url = this.$route.query.path
24
  },
25
  methods: {
26
    setIframeHeight() {
27
      console.log('loadiframe')
28
      document.getElementById('external-frame').height = document.documentElement.clientHeight - 150
29
      let iframe = document.getElementById('external-frame')
30
      console.log(localStorage.getItem('token'))
31
      iframe.contentWindow.postMessage({ token: localStorage.getItem('token') }, '*')
32
    }
33
  }
34
}
35
</script>

+ 20 - 3
dmp-edge-ai/src/views/system/menu/components/BaseDialog.vue

@ -15,11 +15,17 @@
15 15
                  </el-radio>
16 16
                </el-radio-group>
17 17
              </el-form-item>
18
              <el-form-item label="菜单归属" prop="showType">
19
                <el-select v-model="form.showType" style="width: 100%">
20
                  <el-option v-for="item in showTypeList" :key="item.id" :label="item.name" :value="item.id">
21
                  </el-option>
22
                </el-select>
23
              </el-form-item>
18 24
              <el-form-item label="内外链地址" prop="linkUrl" v-if="form.menuType === MenuType.MENU">
19 25
                <el-input v-model.trim="form.linkUrl" placeholder="请输入内外链地址"></el-input>
20 26
              </el-form-item>
21 27
              <el-form-item label="排序" prop="menuSort">
22
                <el-input-number v-model="form.menuSort" :min="1"></el-input-number>
28
                <el-input-number v-model="form.menuSort" :min="0"></el-input-number>
23 29
              </el-form-item>
24 30
            </el-col>
25 31
          </el-row>
@ -45,7 +51,7 @@
45 51
                  </el-radio>
46 52
                </el-radio-group>
47 53
              </el-form-item>
48
              <el-form-item label="图标" prop="menuIcon" v-if="form.menuType === MenuType.CONTENT">
54
              <el-form-item label="图标" prop="menuIcon" v-if="form.menuType === MenuType.CONTENT || MenuType.MENU">
49 55
                <el-input v-model.trim="form.menuIcon" placeholder="请选择或输入图标">
50 56
                  <el-button slot="append" icon="el-icon-setting" @click="menuIconSelect"></el-button>
51 57
                </el-input>
@ -118,8 +124,19 @@ export default {
118 124
        menuType: [{ required: true, message: '请选择菜单类型', trigger: 'change' }],
119 125
        iframeFlag: [{ required: true, message: '请选择打开方式', trigger: 'change' }],
120 126
        linkUrl: [{ required: true, message: '请输入内外链地址', trigger: 'change' }],
121
        menuIcon: [{ required: true, message: '请选择或输入图标', trigger: 'blur' }]
127
        // menuIcon: [{ required: true, message: '请选择或输入图标', trigger: 'blur' }],
128
        showType: [{ required: true, message: '请选择菜单归属', trigger: 'blur' }]
122 129
      },
130
      showTypeList: [
131
        {
132
          id: '1',
133
          name: '门户管理'
134
        },
135
        {
136
          id: '2',
137
          name: 'aiot'
138
        }
139
      ],
123 140
      modalType: ModalType.ADD,
124 141
      submitLoading: false
125 142
    }

+ 19 - 1
dmp-edge-ai/src/views/system/menu/index.vue

@ -31,6 +31,11 @@
31 31
            {{ MenuType.getDescFromValue(row.menuType) }}
32 32
          </template>
33 33
        </el-table-column>
34
        <el-table-column label="菜单归属" prop="hiddenFlag" width="80">
35
          <template slot-scope="{ row }">
36
            {{ getShowType(row.showType) }}
37
          </template>
38
        </el-table-column>
34 39
        <el-table-column label="图标" prop="menuIcon" width="120"></el-table-column>
35 40
        <el-table-column label="路由地址" prop="linkUrl" show-overflow-tooltip></el-table-column>
36 41
        <el-table-column label="打开方式" prop="linkUrl" width="80">
@ -86,6 +91,16 @@ export default {
86 91
    this.MenuType = MenuType
87 92
    this.IframeFlag = IframeFlag
88 93
    return {
94
      showTypeList: [
95
        {
96
          id: '1',
97
          name: '门户管理'
98
        },
99
        {
100
          id: '2',
101
          name: 'aiot'
102
        }
103
      ],
89 104
      headerStyle: {
90 105
        width: '100%',
91 106
        'background-color': 'rgba(237, 239, 242, 0.5)',
@ -103,6 +118,9 @@ export default {
103 118
    }
104 119
  },
105 120
  methods: {
121
    getShowType(shoType) {
122
      return this.showTypeList.filter((item) => item.id === shoType)[0].name
123
    },
106 124
    addMenu() {
107 125
      this.menuId = ''
108 126
      this.baseVisible = true
@ -124,7 +142,7 @@ export default {
124 142
            }
125 143
            MenuService.changeStatus(params)
126 144
              .then(() => {
127
                this.tableData[index].hiddenFlag = params.hiddenFlag
145
                row.hiddenFlag = params.hiddenFlag
128 146
                done()
129 147
              })
130 148
              .finally(() => {

+ 1 - 1
dmp-edge-ai/tailwind.config.js

@ -37,7 +37,7 @@ module.exports = {
37 37
      },
38 38
      backgroundImage: {
39 39
        'brand-bg': "url('~@/assets/image/bg_u7.png')",
40
        'brand-logo': "url('~@/assets/image/iotsigle.png')",
40
        'brand-logo': "url('~@/assets/image/iotsigle2.png')",
41 41
        'view-module': "url('~@/assets/svg/view-module.svg')",
42 42
        settings: "url('~@/assets/svg/settings.svg')",
43 43
        fullscreen: "url('~@/assets/svg/fullscreen.svg')",