admin base

This commit is contained in:
xiaomlove
2021-04-22 03:24:59 +08:00
parent b822536283
commit 92f22c9560
26 changed files with 891 additions and 75 deletions
+47
View File
@@ -0,0 +1,47 @@
import axios from "./axios";
const api = {
listAllowAgent: (params = {}) => {
return axios.get('agent-allow', {params: params});
},
storeAllowAgent: (params = {}) => {
return axios.post('agent-allow', params);
},
updateAllowAgent: (id, params = {}) => {
return axios.put('agent-allow/' + id, params);
},
getAllowAgent: (id) => {
return axios.get('agent-allow/' + id);
},
deleteAllowAgent: (id) => {
return axios.delete('agent-allow/' + id);
},
listUser: (params = {}) => {
return axios.get('user', {params: params});
},
storeUser: (params = {}) => {
return axios.post('user', params);
},
listExam: (params = {}) => {
return axios.get('exam', {params: params});
},
storeExam: (params = {}) => {
return axios.post('exam', params);
},
updateExam: (id, params = {}) => {
return axios.put('exam/' + id, params);
},
getExam: (id) => {
return axios.get('exam/' + id);
},
deleteExam: (id) => {
return axios.delete('exam/' + id);
},
listClass: (params = {}) => {
return axios.get('class', {params: params});
},
}
export default api
+28
View File
@@ -0,0 +1,28 @@
import axios from 'axios'
import { ElMessage } from 'element-plus'
axios.defaults.baseURL = 'http://nexus-php8.tinyhd.net'
axios.defaults.withCredentials = true
axios.defaults.headers['X-Requested-With'] = 'XMLHttpRequest'
axios.defaults.headers['Content-Type'] = 'application/json'
axios.defaults.headers['Accept'] = 'application/json'
// 请求拦截器,内部根据返回值,重新组装,统一管理。
axios.interceptors.response.use(res => {
console.log(res)
if (typeof res.data !== 'object') {
ElMessage.error('Server Error 1')
return Promise.reject(res)
}
if (res.data.ret && res.data.ret != 0) {
ElMessage.error(res.data.msg)
return Promise.reject(res.data)
}
return res.data
}, error => {
console.log(error.response)
ElMessage.error(error.response.data.msg || 'Server Error 2')
return Promise.reject(error)
})
export default axios
+50
View File
@@ -0,0 +1,50 @@
export function localGet (key) {
const value = window.localStorage.getItem(key)
try {
return JSON.parse(window.localStorage.getItem(key))
} catch (error) {
return value
}
}
export function localSet (key, value) {
window.localStorage.setItem(key, JSON.stringify(value))
}
export function localRemove (key) {
window.localStorage.removeItem(key)
}
// 判断内容是否含有表情字符,现有数据库不支持。
export function hasEmoji (str = '') {
const reg = /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g;
return str.match(reg) && str.match(reg).length
}
// 单张图片上传
export const uploadImgServer = 'http://backend-api-02.newbee.ltd/manage-api/v1/upload/file'
// 多张图片上传
export const uploadImgsServer = 'http://backend-api-02.newbee.ltd/manage-api/v1/upload/files'
export const pathMap = {
login: '登录',
introduce: '系统介绍',
dashboard: 'Dashboard',
add: '添加商品',
swiper: '轮播图配置',
hot: '热销商品配置',
new: '新品上线配置',
recommend: '为你推荐配置',
category: '分类管理',
level2: '分类二级管理',
level3: '分类三级管理',
good: '商品管理',
guest: '会员管理',
order: '订单管理',
order_detail: '订单详情',
account: '修改账户',
'agent-allow': 'Agent allow',
'agent-allow-form': 'Agent allow form',
'user': 'User',
'user-form': 'User form',
}