liyongli 1 year ago
parent
commit
bb15a16919
9 changed files with 277 additions and 120 deletions
  1. 3 0
      package.json
  2. 72 2
      pnpm-lock.yaml
  3. 31 0
      src/api/index.js
  4. 81 0
      src/config/index.js
  5. 3 3
      src/style.css
  6. 53 0
      src/utils/request_axios.js
  7. 23 113
      src/view/home/index.vue
  8. 8 2
      src/view/login/index.vue
  9. 3 0
      vite.config.js

+ 3 - 0
package.json

@@ -9,8 +9,11 @@
     "preview": "vite preview"
   },
   "dependencies": {
+    "axios": "^1.6.2",
+    "js-sha256": "^0.10.1",
     "view-ui-plus": "^1.3.14",
     "vue": "^3.3.4",
+    "vue-axios": "^3.5.2",
     "vue-router": "4"
   },
   "devDependencies": {

+ 72 - 2
pnpm-lock.yaml

@@ -5,12 +5,21 @@ settings:
   excludeLinksFromLockfile: false
 
 dependencies:
+  axios:
+    specifier: ^1.6.2
+    version: 1.6.2
+  js-sha256:
+    specifier: ^0.10.1
+    version: 0.10.1
   view-ui-plus:
     specifier: ^1.3.14
     version: 1.3.14
   vue:
     specifier: ^3.3.4
     version: 3.3.4
+  vue-axios:
+    specifier: ^3.5.2
+    version: 3.5.2(axios@1.6.2)(vue@3.3.4)
   vue-router:
     specifier: '4'
     version: 4.2.5(vue@3.3.4)
@@ -561,6 +570,20 @@ packages:
     resolution: {integrity: sha512-8eLCg00W9pIRZSB781UUX/H6Oskmm8xloZfr09lz5bikRpBVDlJ3hRVuxxP1SxcwsEYfJ4IU8Q19Y8/893r3rQ==}
     dev: false
 
+  /asynckit@0.4.0:
+    resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
+    dev: false
+
+  /axios@1.6.2:
+    resolution: {integrity: sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==}
+    dependencies:
+      follow-redirects: 1.15.3
+      form-data: 4.0.0
+      proxy-from-env: 1.1.0
+    transitivePeerDependencies:
+      - debug
+    dev: false
+
   /batch-processor@1.0.0:
     resolution: {integrity: sha512-xoLQD8gmmR32MeuBHgH0Tzd5PuSZx71ZsbhVxOCRbgktZEPe4SQy7s9Z50uPp0F/f7iw2XmkHN2xkgbMfckMDA==}
     dev: false
@@ -616,6 +639,13 @@ packages:
     engines: {node: '>=6.0'}
     dev: true
 
+  /combined-stream@1.0.8:
+    resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
+    engines: {node: '>= 0.8'}
+    dependencies:
+      delayed-stream: 1.0.0
+    dev: false
+
   /commander@2.20.3:
     resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
     dev: true
@@ -636,6 +666,11 @@ packages:
     engines: {node: '>=0.10.0'}
     dev: false
 
+  /delayed-stream@1.0.0:
+    resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
+    engines: {node: '>=0.4.0'}
+    dev: false
+
   /electron-to-chromium@1.4.583:
     resolution: {integrity: sha512-93y1gcONABZ7uqYe/JWDVQP/Pj/sQSunF0HVAPdlg/pfBnOyBMLlQUxWvkqcljJg1+W6cjvPuYD+r1Th9Tn8mA==}
     dev: true
@@ -741,6 +776,25 @@ packages:
       to-regex-range: 5.0.1
     dev: true
 
+  /follow-redirects@1.15.3:
+    resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==}
+    engines: {node: '>=4.0'}
+    peerDependencies:
+      debug: '*'
+    peerDependenciesMeta:
+      debug:
+        optional: true
+    dev: false
+
+  /form-data@4.0.0:
+    resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
+    engines: {node: '>= 6'}
+    dependencies:
+      asynckit: 0.4.0
+      combined-stream: 1.0.8
+      mime-types: 2.1.35
+    dev: false
+
   /fsevents@2.3.3:
     resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
     engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
@@ -810,6 +864,10 @@ packages:
     resolution: {integrity: sha512-dAA1/Zbp4+c5E+ARCVTIuKepXsNLzSYfzvOimiYD4S5eeP9QuplSHLcdhfqFSwyM1o1u6ku6RRRCyaZ0YAjiBw==}
     dev: false
 
+  /js-sha256@0.10.1:
+    resolution: {integrity: sha512-5obBtsz9301ULlsgggLg542s/jqtddfOpV5KJc4hajc9JV8GeY2gZHSVpYBn4nWqAUTJ9v+xwtbJ1mIBgIH5Vw==}
+    dev: false
+
   /json-parse-even-better-errors@2.3.1:
     resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
     dev: true
@@ -844,14 +902,12 @@ packages:
   /mime-db@1.52.0:
     resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
     engines: {node: '>= 0.6'}
-    dev: true
 
   /mime-types@2.1.35:
     resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
     engines: {node: '>= 0.6'}
     dependencies:
       mime-db: 1.52.0
-    dev: true
 
   /nanoid@3.3.7:
     resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
@@ -896,6 +952,10 @@ packages:
       picocolors: 1.0.0
       source-map-js: 1.0.2
 
+  /proxy-from-env@1.1.0:
+    resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
+    dev: false
+
   /punycode@2.3.1:
     resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
     engines: {node: '>=6'}
@@ -1137,6 +1197,16 @@ packages:
       fsevents: 2.3.3
     dev: true
 
+  /vue-axios@3.5.2(axios@1.6.2)(vue@3.3.4):
+    resolution: {integrity: sha512-GP+dct7UlAWkl1qoP3ppw0z6jcSua5/IrMpjB5O8bh089iIiJ+hdxPYH2NPEpajlYgkW5EVMP95ttXWdas1O0g==}
+    peerDependencies:
+      axios: '*'
+      vue: ^3.0.0 || ^2.0.0
+    dependencies:
+      axios: 1.6.2
+      vue: 3.3.4
+    dev: false
+
   /vue-router@4.2.5(vue@3.3.4):
     resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==}
     peerDependencies:

+ 31 - 0
src/api/index.js

@@ -0,0 +1,31 @@
+import service from '../utils/request_axios';
+function login_api(user_name, password) {
+  return service({
+    url: '/admin/users/login',
+    method: 'POST',
+    data: {
+      loginName: user_name,
+      loginPassword: password,
+    },
+  });
+}
+
+function menu_api(token) {
+  return service({
+    url: '/admin/module/list',
+    method: 'GET',
+  });
+}
+
+function login_out_api(token) {
+  return service({
+    url: '/admin/users/logout',
+    method: 'GET',
+  });
+}
+
+export default {
+  login_api,
+  menu_api,
+  login_out_api,
+};

+ 81 - 0
src/config/index.js

@@ -0,0 +1,81 @@
+export const base_url = 'http://47.109.139.179';
+export const request_retry = 4;
+export const request_retry_delay = 800;
+export const default_menu = [
+  {
+    name: 'home',
+    title: '人员管理',
+    icon: 'ios-person',
+    children: [
+      {
+        name: '/home/personnelMatters',
+        title: '管理员',
+      },
+      {
+        name: '/home/personnelMatters/user',
+        title: '用户',
+      },
+    ],
+  },
+  {
+    name: 'limitsAuthority',
+    title: '权限配置',
+    icon: 'ios-key',
+    children: [
+      {
+        name: '/home/limitsAuthority/role',
+        title: '角色管理',
+      },
+      {
+        name: '/home/limitsAuthority/permission',
+        title: '权限管理',
+      },
+    ],
+  },
+  {
+    name: 'belong',
+    title: '归属配置',
+    icon: 'ios-locate',
+    children: [
+      {
+        name: '/home/belong/organization',
+        title: '机构管理',
+      },
+      {
+        name: '/home/belong/area',
+        title: '地域管理',
+      },
+    ],
+  },
+  {
+    name: 'governmentAffairs',
+    title: '政务库管理',
+    icon: 'ios-cloud-download',
+    children: [
+      {
+        name: '/home/governmentAffairs/administration',
+        title: '行政领导配置',
+      },
+    ],
+  },
+  {
+    name: '/home/administration',
+    icon: 'ios-document',
+    title: '稿件管理',
+  },
+  {
+    name: '/home/medium',
+    icon: 'ios-film',
+    title: '媒体管理',
+  },
+  {
+    name: '/home/broadcast',
+    icon: 'ios-desktop',
+    title: '电视广播管理',
+  },
+  {
+    name: '/home/lifeService',
+    icon: 'ios-hammer',
+    title: '生活服务管理',
+  },
+];

+ 3 - 3
src/style.css

@@ -1,7 +1,7 @@
-@font-face {
+/* @font-face {
     font-family: puhui95;
     src: url(https://cxzx.smcic.net/topic/tool/font/alipuhui2.0.95.woff) format('woff');
-}
+} */
 
 
 
@@ -12,7 +12,7 @@
 }
 
 html,body,#app{
-    font-family: puhui95;
+    /* font-family: puhui95; */
     width: 100%;
     height: 100%;
 }

+ 53 - 0
src/utils/request_axios.js

@@ -0,0 +1,53 @@
+import Axios from 'axios';
+import { base_url, request_retry, request_retry_delay } from '../config/index';
+const service = Axios.create({
+  baseURL: base_url,
+  headers: {
+    Accept: '*/*',
+  },
+});
+
+service.defaults.retry = request_retry;
+service.defaults.retryDelay = request_retry_delay;
+// let LoadingInstance = null;
+
+service.interceptors.request.use(
+  config => {
+    config.headers['Authorization'] = localStorage.getItem('neican_token');
+    return config;
+  },
+  error => {
+    Promise.reject(error);
+  }
+);
+
+service.interceptors.response.use(
+  res => {
+    //if(LoadingInstance){LoadingInstance.clear();}
+    if (res.status !== 200) {
+      //Toast('数据返回出错');
+      return Promise.reject('响应非200!');
+    } else {
+      if (res.data.code != 0) {
+        if (res.config.closeInterceptors) {
+          return Promise.reject(res.data); //自己处理错误
+        }
+        //统一处理错误
+        return Promise.reject('error');
+      }
+      return res.data.data;
+    }
+  },
+  error => {
+    //if(LoadingInstance){LoadingInstance.clear();}
+    //Toast("网络错误");
+    if (/403/.test(error.toString()))
+      window.parent
+        ? (window.parent.location.href = '/')
+        : (location.href = '/');
+
+    return Promise.reject(error);
+  }
+);
+
+export default service;

+ 23 - 113
src/view/home/index.vue

@@ -2,25 +2,12 @@
 <template>
   <div class="layout">
     <Layout>
-      <Header>
-        <Menu mode="horizontal" theme="dark" active-name="1">
-          <div class="layout-logo"></div>
-          <div class="layout-nav">
-            <MenuItem name="1">
-              <Icon type="ios-navigate"></Icon>
-              Item 1
-            </MenuItem>
-            <MenuItem name="2">
-              <Icon type="ios-keypad"></Icon>
-              Item 2
-            </MenuItem>
-            <MenuItem name="3">
-              <Icon type="ios-analytics"></Icon>
-              Item 3
-            </MenuItem>
-          </div>
-        </Menu>
-      </Header>
+      <PageHeader title=" ">
+        <template #action>
+          <div class="login_out" @click="login_out">退出</div>
+        </template>
+        <template #content> </template>
+      </PageHeader>
       <Layout>
         <Sider hide-trigger :style="{ background: '#fff' }">
           <Menu
@@ -69,100 +56,37 @@
 </template>
 
 <script>
+import api from '../../api/index.js';
+import { default_menu } from '../../config/index';
+
 export default {
   data() {
     return {
       content_height: 0,
       active_name: '',
-      menu_list: [
-        {
-          name: 'home',
-          title: '人员管理',
-          icon: 'ios-person',
-          children: [
-            {
-              name: '/home/personnelMatters',
-              title: '管理员',
-            },
-            {
-              name: '/home/personnelMatters/user',
-              title: '用户',
-            },
-          ],
-        },
-        {
-          name: 'limitsAuthority',
-          title: '权限配置',
-          icon: 'ios-key',
-          children: [
-            {
-              name: '/home/limitsAuthority/role',
-              title: '角色管理',
-            },
-            {
-              name: '/home/limitsAuthority/permission',
-              title: '权限管理',
-            },
-          ],
-        },
-        {
-          name: 'belong',
-          title: '归属配置',
-          icon: 'ios-locate',
-          children: [
-            {
-              name: '/home/belong/organization',
-              title: '机构管理',
-            },
-            {
-              name: '/home/belong/area',
-              title: '地域管理',
-            },
-          ],
-        },
-        {
-          name: 'governmentAffairs',
-          title: '政务库管理',
-          icon: 'ios-cloud-download',
-          children: [
-            {
-              name: '/home/governmentAffairs/administration',
-              title: '行政领导配置',
-            },
-          ],
-        },
-        {
-          name: '/home/administration',
-          icon: 'ios-document',
-          title: '稿件管理',
-        },
-        {
-          name: '/home/medium',
-          icon: 'ios-film',
-          title: '媒体管理',
-        },
-        {
-          name: '/home/broadcast',
-          icon: 'ios-desktop',
-          title: '电视广播管理',
-        },
-        {
-          name: '/home/lifeService',
-          icon: 'ios-hammer',
-          title: '生活服务管理',
-        },
-      ],
+      menu_list: default_menu,
     };
   },
   mounted() {
     // 计算内容区域高度
     this.content_height = document.documentElement.clientHeight - 120;
     this.active_name = this.$route.path;
+    api.menu_api().then(r => {
+      console.log(r);
+      //   this.menu_list = (r || []);
+    });
   },
   methods: {
     changePage(p) {
       this.$router.replace(p);
     },
+    login_out() {
+      api.login_out_api().then(r => {
+        console.log(r);
+        localStorage.setItem('neican_token', '');
+        this.$router.replace('/');
+      });
+    },
   },
 };
 </script>
@@ -176,22 +100,8 @@ export default {
   overflow: hidden;
   width: 100%;
   height: 100%;
-
-  .layout-logo {
-    width: 100px;
-    height: 30px;
-    background: #5b6270;
-    border-radius: 3px;
-    float: left;
-    position: relative;
-    top: 15px;
-    left: 20px;
-  }
-
-  .layout-nav {
-    width: 420px;
-    margin: 0 auto;
-    margin-right: 20px;
+  .login_out {
+    cursor: pointer;
   }
 }
 </style>

+ 8 - 2
src/view/login/index.vue

@@ -10,6 +10,8 @@
 </template>
 
 <script>
+import api from '../../api/index.js';
+import { sha256 } from 'js-sha256';
 export default {
   data() {
     return {
@@ -19,8 +21,12 @@ export default {
   methods: {
     handleSubmit(valid, { username, password }) {
       if (!valid) return;
-      this.$Message.success('登录成功'+'username: ' + username + ' | password: ' + password);
-      this.$router.push('/home/personnelMatters')
+      const pws = sha256(password);
+      api.login_api(username, pws).then(res => {
+        localStorage.setItem('neican_token', res.token);
+        this.$Message.success('登录成功');
+        this.$router.replace('/home/personnelMatters');
+      });
     },
   },
 };

+ 3 - 0
vite.config.js

@@ -4,4 +4,7 @@ import vue from '@vitejs/plugin-vue'
 // https://vitejs.dev/config/
 export default defineConfig({
   plugins: [vue()],
+  server:{
+    host: '0.0.0.0'
+  }
 })