GitBucket
4.6.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull Requests
Labels
Milestones
Wiki
08335
/
hivui-platform-template
hivui平台项目模板
Browse code
add
master
1 parent
e3d067f
commit
b4e3ae44487e8fa96c4f4a051e00b5a65f35c50e
caibinghong
authored
on 29 Jul 2021
Showing
2 changed files
project/hivuiMain/index.html
project/hivuiMain/utils/request.js
Ignore Space
Show notes
View
project/hivuiMain/index.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>EAP5-Admin-Main</title> <link rel="stylesheet" href="/assets_platform/element-ui/index.css"> <script src="/assets_platform/vue/vue.min.js"></script> <script src="/assets_platform/element-ui/index.js"></script> <% if(!htmlWebpackPlugin.vite){%> <!--发布时 公共库--> <script src="/assets_platform/vendor_dll/vuelibs.dll.js"></script> <script src="/assets_platform/vendor_dll/vendor.dll.js"></script> <%}%> <script src="/assets_platform/eap/eap.umd.min.js"></script> <!-- <script src="/项目名/setting/desktop/appsetting/js/1.0.0/appsetting.js" type="text/javascript"></script> --> </head> <body> <div id="app"> <div style="padding:50px 0;text-align:center;"> <div> <img src="./assets/logo_max.png"/> </div> <div>系统正在预览初始化中...<a href="javascript:location.reload();">【点我刷新】</a></div> </div> </div> <script> function changeLayout(name) { window.localStorage.setItem('layout', name) window.location.reload(); } var Scp = { User: { id: "admin", name: "管理员", deptId: "", deptName: "", positionId: "GLY", postionName: "管理员", bzId: "admin_3", bzName: "管理员岗位3", bzDeptId: ".WLDJT.DGS", bzDeptName: "D公司", bzPositionId: "HQRY", bzPositionName: "后勤人员", orgId: "admin_3", defOrgId: "admin_3" } } var __guid = new Date().valueOf(); var __sysConfig = { events: { onLoad1: function () { } }, projectName: "eaptpl", sysProjectMange: { id: __guid++, name: '工程树', iconClass: 'icon-tree', uri: 'amreport/designer/tree/design.do', url: '/amrept-web/amreport/designer/tree/design.do' }, sysLoadLogo: { src: '', title: '中海创科技' }, sysLogo: { src: '', title: '中海创科技' }, //默认门户 对应自定义门户功能 sysSetTabs: [ { title: '首页', id: __guid++, close: false, type: 'home', actived: true //默认选中 } // ,{ // title:'工作台', // id: __guid++, // close:false, // type:'work' // } ], //默认 打开功能 sysDefTabs: [ // { // id: __guid++, // title:"设计", // url:'http://192.168.7.109:9090/#/design', // close:true, // }, // { // id: __guid++, // title:"百度功能测试", // url:'http://www.baidu.com', // close:true // }, // { // id: __guid++, // title:"bing", // url:'https://cn.bing.com/', // close:true // } ], sysList: [ ], sysFuncMenus: [ { id: __guid++, name: '<font color=red>邮件系统</font>', url: 'http://hcmail.histron.cn:8001/webmail/index.do?osName=windows', iconClass: 'icon-mail', target: '_blank', }, { type: 'split' }, { id: __guid++, name: '布局', type: 'layout', iconClass: 'icon-user', children: [ { id: 'vertical', name: '上下布局', handler: function () { changeLayout(this.id) } }, { id: 'level', name: '左右布局', handler: function () { changeLayout(this.id) } } ] }, { type: 'split' }, { id: __guid++, name: '用户信息', type: 'userInfo', iconClass: 'icon-user', children: [ { id: __guid++, name: '部门:AF10', iconClass: 'icon-user', actived: true }, { id: __guid++, html: '<font color=red>访问下属111</font>', name: '<font color=red>访问下属</font>', iconClass: 'icon-user', children: [ { name: "张三", id: __guid++ }, { name: "李四", id: __guid++ }, ] }, { id: __guid++, name: '修改密码', iconClass: '', handler: function () { alert('访问下属'); } } ] }, { type: 'split' } ], } </script> <% if(htmlWebpackPlugin.vite==true){%> <script type="module" src="./index.js"></script> <%}%> <!-- built files will be auto injected --> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>EAP5-Admin-Main</title> <link rel="stylesheet" href="/assets_platform/element-ui/index.css"> <script src="/assets_platform/vue/vue.min.js"></script> <script src="/assets_platform/element-ui/index.js"></script> <% if(!htmlWebpackPlugin.vite){%> <!--发布时 公共库--> <script src="/assets_platform/vendor_dll/vuelibs.dll.js"></script> <script src="/assets_platform/vendor_dll/vendor.dll.js"></script> <%}%> <script src="/assets_platform/eap/eap.umd.min.js"></script> <!-- <script src="/项目名/setting/desktop/appsetting/js/1.0.0/appsetting.js" type="text/javascript"></script> --> </head> <body> <div id="app"> 系统正在预览初始化中...<a href="javascript:location.reload();">【点我刷新】</a> </div> <script> function changeLayout(name) { window.localStorage.setItem('layout', name) window.location.reload(); } var Scp = { User: { id: "admin", name: "管理员", deptId: "", deptName: "", positionId: "GLY", postionName: "管理员", bzId: "admin_3", bzName: "管理员岗位3", bzDeptId: ".WLDJT.DGS", bzDeptName: "D公司", bzPositionId: "HQRY", bzPositionName: "后勤人员", orgId: "admin_3", defOrgId: "admin_3" } } var __guid = new Date().valueOf(); var __sysConfig = { events: { onLoad1: function () { } }, projectName: "eaptpl", sysProjectMange: { id: __guid++, name: '工程树', iconClass: 'icon-tree', uri: 'amreport/designer/tree/design.do', url: '/amrept-web/amreport/designer/tree/design.do' }, sysLoadLogo: { src: '', title: '中海创科技' }, sysLogo: { src: '', title: '中海创科技' }, //默认门户 对应自定义门户功能 sysSetTabs: [ { title: '首页', id: __guid++, close: false, type: 'home', actived: true //默认选中 } // ,{ // title:'工作台', // id: __guid++, // close:false, // type:'work' // } ], //默认 打开功能 sysDefTabs: [ // { // id: __guid++, // title:"设计", // url:'http://192.168.7.109:9090/#/design', // close:true, // }, // { // id: __guid++, // title:"百度功能测试", // url:'http://www.baidu.com', // close:true // }, // { // id: __guid++, // title:"bing", // url:'https://cn.bing.com/', // close:true // } ], sysList: [ ], sysFuncMenus: [ { id: __guid++, name: '<font color=red>邮件系统</font>', url: 'http://hcmail.histron.cn:8001/webmail/index.do?osName=windows', iconClass: 'icon-mail', target: '_blank', }, { type: 'split' }, { id: __guid++, name: '布局', type: 'layout', iconClass: 'icon-user', children: [ { id: 'vertical', name: '上下布局', handler: function () { changeLayout(this.id) } }, { id: 'level', name: '左右布局', handler: function () { changeLayout(this.id) } } ] }, { type: 'split' }, { id: __guid++, name: '用户信息', type: 'userInfo', iconClass: 'icon-user', children: [ { id: __guid++, name: '部门:AF10', iconClass: 'icon-user', actived: true }, { id: __guid++, html: '<font color=red>访问下属111</font>', name: '<font color=red>访问下属</font>', iconClass: 'icon-user', children: [ { name: "张三", id: __guid++ }, { name: "李四", id: __guid++ }, ] }, { id: __guid++, name: '修改密码', iconClass: '', handler: function () { alert('访问下属'); } } ] }, { type: 'split' } ], } </script> <% if(htmlWebpackPlugin.vite==true){%> <script type="module" src="./index.js"></script> <%}%> <!-- built files will be auto injected --> </body> </html>
Ignore Space
Show notes
View
project/hivuiMain/utils/request.js
import {baseURL,projectName} from '@main/config' // import { MessageBox, Message } from 'element-ui' import Message from '@main/components/vue-m-message' import store from '@main/store' import { getToken } from '@main/utils/auth' import axios from 'axios' // create an axios instance const service = axios.create({ // withCredentials: true, //加了这个 要明确那个地址跨域才行 baseURL: baseURL, // api的base_url timeout: 5000 // request timeout }) // request interceptor service.interceptors.request.use( 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['token'] = getToken() config.headers['Authorization'] = "Bearer " + getToken() }else{ //没有token,跳转登录页 location="/"+projectName+"/hivuiLogin/index.html#/"; } if (config.url.indexOf('?')==-1) config.url = config.url+"?pn="+projectName; else config.url = config.url+"&pn="+projectName; return config }, error => { // Do something with request error Promise.reject(error) } ) // respone interceptor service.interceptors.response.use( //response => response, /** * 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页 * 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中 (response) => { const res = response.data; if (res.code !== 0) { return Promise.reject('error'); } else { return res; } }, */ response => { const res = response.data if (res.type == "application/octet-stream") return res; // if the custom code is not 20000, it is judged as an error. if (!(response.status+"" == "200" || res.status+"" =="200")) { Message.error(res.msg || res.message || 'Error') /*Message({ message: res.msg || 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() }) })*/ if(confirm('You have been logged out, you can cancel to stay on this page, or log in again')){ store.dispatch('user/resetToken').then(() => { location.reload() }) } } //return Promise.reject(new Error(res.message || 'Error')) return Promise.reject(res) } else { if(res.status+"" =="200"){ res.dataPack = res.dataPack || res.data return res }else{ debugger; console.error(res.msg || res.message || 'Error'); Message.error(res.msg || res.message || 'Error') } } }, error => { console.log('err' + error) // for debug Message.error(error.msg||error.message) return Promise.reject(error) }) export default service
import {baseURL,projectName} from '@main/config' // import { MessageBox, Message } from 'element-ui' import store from '@main/store' import { getToken } from '@main/utils/auth' import axios from 'axios' // create an axios instance const service = axios.create({ // withCredentials: true, //加了这个 要明确那个地址跨域才行 baseURL: baseURL, // api的base_url timeout: 5000 // request timeout }) // request interceptor service.interceptors.request.use( 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['token'] = getToken() config.headers['Authorization'] = "Bearer " + getToken() }else{ //没有token,跳转登录页 location="/"+projectName+"/hivuiLogin/index.html#/"; } if (config.url.indexOf('?')==-1) config.url = config.url+"?pn="+projectName; else config.url = config.url+"&pn="+projectName; return config }, error => { // Do something with request error Promise.reject(error) } ) // respone interceptor service.interceptors.response.use( //response => response, /** * 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页 * 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中 (response) => { const res = response.data; if (res.code !== 0) { return Promise.reject('error'); } else { return res; } }, */ response => { const res = response.data if (res.type == "application/octet-stream") return res; // if the custom code is not 20000, it is judged as an error. if (!(response.status+"" == "200" || res.status+"" =="200")) { console.error(res.msg || res.message || 'Error'); /*Message({ message: res.msg || 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() }) })*/ if(confirm('You have been logged out, you can cancel to stay on this page, or log in again')){ store.dispatch('user/resetToken').then(() => { location.reload() }) } } //return Promise.reject(new Error(res.message || 'Error')) return Promise.reject(res) } else { if(res.status+"" =="200"){ res.dataPack = res.dataPack || res.data return res }else{ debugger;console.error(res.msg || res.message || 'Error'); alert(res.msg || res.message || 'Error'); } } }, error => { console.log('err' + error) // for debug /*Message({ message: error.msg||error.message, type: 'error', duration: 5 * 1000 })*/ console.error(error.msg||error.message); return Promise.reject(error) }) export default service
Show line notes below