bzkf3 3 vuotta sitten
vanhempi
commit
12fe7bf2cb

+ 4 - 0
.env.development

@@ -0,0 +1,4 @@
+# .env.development
+VITE_APP_TITLE=活动评比后台管理
+VITE_APP_BASE_API=https://hdpb.dev.bozedu.net/
+

+ 3 - 0
.env.production

@@ -0,0 +1,3 @@
+# .env.production
+VITE_APP_TITLE=活动评比后台管理
+VITE_APP_BASE_API=https://hdpb.bozedu.net/

+ 5 - 1
.gitignore

@@ -1 +1,5 @@
-/.idea/
+node_modules
+.DS_Store
+dist
+dist-ssr
+*.local

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Vite App</title>
+    <title></title>
   </head>
   <body>
     <div id="app"></div>

+ 41 - 0
package-lock.json

@@ -9,6 +9,7 @@
       "version": "0.0.0",
       "dependencies": {
         "@vue/composition-api": "^1.4.9",
+        "axios": "^0.26.1",
         "element-ui": "^2.15.6",
         "normalize.css": "^8.0.1",
         "path-browserify": "^1.0.1",
@@ -814,6 +815,14 @@
         "node": ">= 4.0.0"
       }
     },
+    "node_modules/axios": {
+      "version": "0.26.1",
+      "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
+      "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
+      "dependencies": {
+        "follow-redirects": "^1.14.8"
+      }
+    },
     "node_modules/babel-helper-vue-jsx-merge-props": {
       "version": "2.0.3",
       "resolved": "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
@@ -1447,6 +1456,25 @@
         "node": ">=8"
       }
     },
+    "node_modules/follow-redirects": {
+      "version": "1.14.9",
+      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
+      "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==",
+      "funding": [
+        {
+          "type": "individual",
+          "url": "https://github.com/sponsors/RubenVerborgh"
+        }
+      ],
+      "engines": {
+        "node": ">=4.0"
+      },
+      "peerDependenciesMeta": {
+        "debug": {
+          "optional": true
+        }
+      }
+    },
     "node_modules/fs-extra": {
       "version": "9.1.0",
       "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
@@ -2797,6 +2825,14 @@
       "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
       "dev": true
     },
+    "axios": {
+      "version": "0.26.1",
+      "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz",
+      "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==",
+      "requires": {
+        "follow-redirects": "^1.14.8"
+      }
+    },
     "babel-helper-vue-jsx-merge-props": {
       "version": "2.0.3",
       "resolved": "https://registry.npmjs.org/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
@@ -3169,6 +3205,11 @@
         "to-regex-range": "^5.0.1"
       }
     },
+    "follow-redirects": {
+      "version": "1.14.9",
+      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
+      "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w=="
+    },
     "fs-extra": {
       "version": "9.1.0",
       "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",

+ 4 - 1
package.json

@@ -4,7 +4,9 @@
   "version": "0.0.0",
   "scripts": {
     "dev": "vite",
-    "build": "vite build",
+    "build": "vite build --mode development",
+    "build:dev": "vite build --mode development",
+    "build:prod": "vite build",
     "preview": "vite preview"
   },
   "devDependencies": {
@@ -15,6 +17,7 @@
   },
   "dependencies": {
     "@vue/composition-api": "^1.4.9",
+    "axios": "^0.26.1",
     "element-ui": "^2.15.6",
     "normalize.css": "^8.0.1",
     "path-browserify": "^1.0.1",

+ 11 - 1
src/layout/app/index.vue

@@ -10,7 +10,9 @@
             <main class="main">
                 <Navbar></Navbar>
                 <div class="main-wrapper">
-                    <router-view></router-view>
+                    <div class="main-content">
+                        <router-view></router-view>
+                    </div>
                 </div>
             </main>
         </section>
@@ -92,6 +94,14 @@ export default defineComponent({
                 align-items: stretch;
                 padding: 6px;
                 box-sizing: border-box;
+                .main-content {
+                    background-color: #fff;
+                    border-radius: 4px;
+                    height: 100%;
+                    width: 100%;
+                    box-sizing: border-box;
+                    padding: 10px;
+                }
             }
         }
     }

+ 1 - 13
src/layout/main/default/index.vue

@@ -1,16 +1,4 @@
 <template>
-    <div class="main-content">
-        <router-view></router-view>
-    </div>
+    <router-view></router-view>
 </template>
 
-<style scoped lang="scss">
-.main-content {
-    background-color: #fff;
-    border-radius: 4px;
-    height: 100%;
-    width: 100%;
-    box-sizing: border-box;
-    padding: 10px;
-}
-</style>

+ 6 - 160
src/router/index.js

@@ -39,12 +39,6 @@ import MainDefaultLayout from '@/layout/main/default/index.vue'
  * all roles can be accessed
  */
 export const constantRoutes = [
-  // {
-  //   path: '/login',
-  //   component: () => import('@/views/login/index.vue'),
-  //   hidden: true,
-  // },
-
   {
     path: '/404',
     component: () => import('@/views/404.vue'),
@@ -197,160 +191,7 @@ export const constantRoutes = [
       },
     ],
   },
-  // {
-  //   path: '/mhgl1',
-  //   component: AppLayout,
-  //   redirect: '/mhgl/tzgg/index.html',
-  //   name: 'mhgl',
-  //   meta: {
-  //     title: '门户管理',
-  //     icon: 'el-icon-document-copy',
-  //   },
-  //   children: [
-  //     {
-  //       path: 'tzgg',
-  //       name: 'tzgg',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'tzgg_index',
-  //           component: () => import('@/views/mhgl/tzgg/index.vue'),
-  //           meta: { title: '通知公告' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'hdgg',
-  //       name: 'hdgg',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'hdgg_index',
-  //           component: () => import('@/views/mhgl/hdgg/index.vue'),
-  //           meta: { title: '活动公告' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'yxzp',
-  //       name: 'yxzp',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'yxzp_index',
-  //           component: () => import('@/views/mhgl/yxzp/index.vue'),
-  //           meta: { title: '优秀作品' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'wjdc',
-  //       name: 'wjdc',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'wjdc_index',
-  //           component: () => import('@/views/mhgl/wjdc/index.vue'),
-  //           meta: { title: '问卷调查' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'tplb',
-  //       name: 'tplb',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'tplb_index',
-  //           component: () => import('@/views/mhgl/tplb/index.vue'),
-  //           meta: { title: '投票列表' },
-  //         },
-  //       ],
-  //     },
-  //   ],
-  // },
-  // {
-  //   path: '/mhgl2',
-  //   component: AppLayout,
-  //   redirect: '/mhgl/tzgg/index.html',
-  //   name: 'mhgl',
-  //   meta: {
-  //     title: '门户管理',
-  //     icon: 'el-icon-document-copy',
-  //   },
-  //   children: [
-  //     {
-  //       path: 'tzgg',
-  //       name: 'tzgg',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'tzgg_index',
-  //           component: () => import('@/views/mhgl/tzgg/index.vue'),
-  //           meta: { title: '通知公告' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'hdgg',
-  //       name: 'hdgg',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'hdgg_index',
-  //           component: () => import('@/views/mhgl/hdgg/index.vue'),
-  //           meta: { title: '活动公告' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'yxzp',
-  //       name: 'yxzp',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'yxzp_index',
-  //           component: () => import('@/views/mhgl/yxzp/index.vue'),
-  //           meta: { title: '优秀作品' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'wjdc',
-  //       name: 'wjdc',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'wjdc_index',
-  //           component: () => import('@/views/mhgl/wjdc/index.vue'),
-  //           meta: { title: '问卷调查' },
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       path: 'tplb',
-  //       name: 'tplb',
-  //       component: MainDefaultLayout,
-  //       children: [
-  //         {
-  //           path: 'index.html',
-  //           name: 'tplb_index',
-  //           component: () => import('@/views/mhgl/tplb/index.vue'),
-  //           meta: { title: '投票列表' },
-  //         },
-  //       ],
-  //     },
-  //   ],
-  // },
+
   // 404 page must be placed at the end !!!
   { path: '*', redirect: '/404', hidden: true },
 ]
@@ -376,3 +217,8 @@ export default router
 =====================================================================================
 =====================================================================================
 */
+import getPageTitle from '@/utils/get-page-title'
+router.beforeEach(async (to, from, next) => {
+  document.title = getPageTitle(to.meta.title)
+  next()
+})

+ 40 - 0
src/stores/user.js

@@ -0,0 +1,40 @@
+import { defineStore } from 'pinia'
+
+localStorage.setItem('userInfo', JSON.stringify({
+  user_id: '4',
+  user_name: 'l1',
+  user_realname: '教师1',
+  lastlogintime: '0',
+  user_role_id: '75',
+  user_role_name: '学校教师',
+  user_avatar: {
+    big: 'http://127.0.0.1template/default/static/img/user_avatar.png',
+    middle: 'http://127.0.0.1template/default/static/img/user_avatar.png',
+    small: 'http://127.0.0.1template/default/static/img/user_avatar.png',
+  },
+  token:
+    'f6ed7S2Eier_bikVCpBK5uB9DAwUWd9zbwc06RGes8o93x8TUGC3GhMogy6JfcY6x_bSUVA4RiPnUi_b_am2NDK63O1eOekZBvA',
+  user_phone: '13744444444',
+  idcard: '',
+  org_info: {
+    dept_id: '5',
+    dept_name: '教务处',
+    dept_full: [
+      { dept_id: '1', dept_name: '教育和体育局' },
+      { dept_id: '3', dept_name: '测试第一中学' },
+      { dept_id: '5', dept_name: '教务处' },
+    ],
+  },
+}))
+
+const { token } = JSON.parse(localStorage.getItem('userInfo'))
+export const useUserStore = defineStore('user', {
+  state: () => ({
+    token,
+  }),
+  actions: {
+    // toggleIsCollapse() {
+    //   this.isCollapse = !this.isCollapse
+    // },
+  },
+})

+ 0 - 15
src/utils/auth.js

@@ -1,15 +0,0 @@
-import Cookies from 'js-cookie'
-
-const TokenKey = 'vue_admin_template_token'
-
-export function getToken() {
-  return Cookies.get(TokenKey)
-}
-
-export function setToken(token) {
-  return Cookies.set(TokenKey, token)
-}
-
-export function removeToken() {
-  return Cookies.remove(TokenKey)
-}

+ 2 - 4
src/utils/get-page-title.js

@@ -1,7 +1,5 @@
-import defaultSettings from '@/settings'
-
-const title = defaultSettings.title || 'Vue Admin Template'
-
+const title = import.meta.env.VITE_APP_TITLE  
+console.log('import.meta.env :>> ', import.meta.env);
 export default function getPageTitle(pageTitle) {
   if (pageTitle) {
     return `${pageTitle} - ${title}`

+ 20 - 63
src/utils/request.js

@@ -1,29 +1,28 @@
 import axios from 'axios'
-import { MessageBox, Message } from 'element-ui'
-import store from '@/store'
-import { getToken } from '@/utils/auth'
-
-// create an axios instance
+import { useUserStore } from '@/stores/user'
+const { token } = useUserStore()
+console.log('token :>> ', token)
 const service = axios.create({
-  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
-  // withCredentials: true, // send cookies when cross-domain requests
-  timeout: 5000 // request timeout
+  baseURL: import.meta.env.VITE_APP_BASE_API,
+  method: 'post',
+  timeout: 5000,
+  headers: {
+    'Content-Type': 'application/x-www-form-urlencoded',
+  },
 })
 
-// request interceptor
 service.interceptors.request.use(
-  config => {
+  (config) => {
     // do something before request is sent
-
-    if (store.getters.token) {
-      // let each request carry token
-      // ['X-Token'] is a custom headers key
-      // please modify it according to the actual situation
-      config.headers['X-Token'] = getToken()
-    }
+    config.data = Object.assign(config.data, {
+      token,
+      site: 'qqyxt',
+      client: 'web',
+      api: 'json',
+    })
     return config
   },
-  error => {
+  (error) => {
     // do something with request error
     console.log(error) // for debug
     return Promise.reject(error)
@@ -32,54 +31,12 @@ service.interceptors.request.use(
 
 // response interceptor
 service.interceptors.response.use(
-  /**
-   * If you want to get http information such as headers or status
-   * Please return  response => response
-  */
-
-  /**
-   * Determine the request status by custom code
-   * Here is just an example
-   * You can also judge the status by HTTP Status Code
-   */
-  response => {
-    const res = response.data
-
-    // if the custom code is not 20000, it is judged as an error.
-    if (res.code !== 20000) {
-      Message({
-        message: res.message || 'Error',
-        type: 'error',
-        duration: 5 * 1000
-      })
-
-      // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
-      if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
-        // to re-login
-        MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
-          confirmButtonText: 'Re-Login',
-          cancelButtonText: 'Cancel',
-          type: 'warning'
-        }).then(() => {
-          store.dispatch('user/resetToken').then(() => {
-            location.reload()
-          })
-        })
-      }
-      return Promise.reject(new Error(res.message || 'Error'))
-    } else {
-      return res
-    }
+  (response) => {
+    return response.data
   },
-  error => {
+  (error) => {
     console.log('err' + error) // for debug
-    Message({
-      message: error.message,
-      type: 'error',
-      duration: 5 * 1000
-    })
     return Promise.reject(error)
   }
 )
-
 export default service

+ 1 - 12
src/utils/validate.js

@@ -1,8 +1,4 @@
 /**
- * Created by PanJiaChen on 16/11/18.
- */
-
-/**
  * @param {string} path
  * @returns {Boolean}
  */
@@ -10,11 +6,4 @@ export function isExternal(path) {
   return /^(https?:|mailto:|tel:)/.test(path)
 }
 
-/**
- * @param {string} str
- * @returns {Boolean}
- */
-export function validUsername(str) {
-  const valid_map = ['admin', 'editor']
-  return valid_map.indexOf(str.trim()) >= 0
-}
+

+ 5 - 1
src/views/mhgl/tzgg/api.js

@@ -1,5 +1,9 @@
 import request from '@/utils/request'
-export const queryApi = () => request({})
+export const queryApi = (data) =>
+  request({
+    url: 'hdpb/hdgl/index',
+    data,
+  })
 export const addApi = () => request({})
 export const deleteApi = () => request({})
 export const editApi = () => request({})

+ 27 - 3
src/views/hdlb/index.vue

@@ -1,12 +1,36 @@
 <template>
-    <div>hdlb</div>
+    <div>
+        <div>
+            <!-- <el-table
+                :data="tableData"
+                tooltip-effect="dark"
+                style="width: 100%"
+            >
+                <el-table-column type="selection" width="55"></el-table-column>
+                <el-table-column label="日期" width="120">
+                    <template slot-scope="scope">{{ scope.row.date }}</template>
+                </el-table-column>
+                <el-table-column prop="name" label="姓名" width="120"></el-table-column>
+                <el-table-column prop="address" label="地址" show-overflow-tooltip></el-table-column>
+            </el-table>-->
+        </div>
+        <div>
+            <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
+        </div>
+    </div>
 </template>
 
 <script>
 
-export default {
+import { defineComponent, ref } from "@vue/composition-api";
+import { queryApi } from './api';
 
-}
+export default defineComponent({
+    async setup() {
+        const { data } = await queryApi()
+        console.log('data :>> ', data);
+    }
+})
 </script>
 
 <style lang="scss" scoped>

+ 3 - 28
src/views/mhgl/tzgg/index.vue

@@ -1,37 +1,12 @@
 <template>
-    <div>
-        <el-button>新建活动公告</el-button>
-        <el-input></el-input>
-        <el-button>搜索</el-button>
-    </div>
-    <div>
-        <el-table
-            ref="multipleTable"
-            :data="tableData"
-            tooltip-effect="dark"
-            style="width: 100%"
-            @selection-change="handleSelectionChange"
-        >
-            <el-table-column type="selection" width="55"></el-table-column>
-            <el-table-column label="日期" width="120">
-                <template slot-scope="scope">{{ scope.row.date }}</template>
-            </el-table-column>
-            <el-table-column prop="name" label="姓名" width="120"></el-table-column>
-            <el-table-column prop="address" label="地址" show-overflow-tooltip></el-table-column>
-        </el-table>
-    </div>
-    <div>
-        <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination>
-    </div>
+    <div>tzgg</div>
 </template>
 
 <script>
-import { defineComponent } from "@vue/composition-api";
-// import {}
 
-export default defineComponent({
+export default {
 
-})
+}
 </script>
 
 <style lang="scss" scoped>