feat:请求方法全部换成新的request类,并且引入useEcharts hook
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import request from '@/utils/request'
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
// 触发访问
|
||||
export function access() {
|
||||
return request({
|
||||
url: '/access-log',
|
||||
method: 'post'
|
||||
})
|
||||
url: "/access-log",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 获取本周数据
|
||||
export function getWeek() {
|
||||
return request({
|
||||
url: '/access-log/week',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
url: "/access-log/week",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,79 +1,78 @@
|
||||
import request from '@/utils/request'
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
// 登录方法
|
||||
export function login(username, password, code, uuid) {
|
||||
const data = {
|
||||
username,
|
||||
password,
|
||||
code,
|
||||
uuid
|
||||
}
|
||||
return request({
|
||||
url: '/account/login',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 注册方法
|
||||
export function register(userName,password,phone,code,uuid) {
|
||||
const data = {
|
||||
userName,
|
||||
password,
|
||||
phone,
|
||||
code,
|
||||
uuid
|
||||
}
|
||||
return request({
|
||||
url: '/account/register',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
return request({
|
||||
url: '/account',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
const data = {
|
||||
username,
|
||||
password,
|
||||
code,
|
||||
uuid,
|
||||
};
|
||||
return request({
|
||||
url: "/account/login",
|
||||
headers: {
|
||||
isToken: false,
|
||||
},
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 注册方法
|
||||
export function register(userName, password, phone, code, uuid) {
|
||||
const data = {
|
||||
userName,
|
||||
password,
|
||||
phone,
|
||||
code,
|
||||
uuid,
|
||||
};
|
||||
return request({
|
||||
url: "/account/register",
|
||||
headers: {
|
||||
isToken: false,
|
||||
},
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
return request({
|
||||
url: "/account",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 退出方法
|
||||
export function logout() {
|
||||
return request({
|
||||
url: '/account/logout',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
export function getCodeImg() {
|
||||
return request({
|
||||
url: '/account/captcha-image',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'get',
|
||||
timeout: 20000
|
||||
})
|
||||
}
|
||||
// 获取短信验证码
|
||||
export function getCodePhone(phone) {
|
||||
return request({
|
||||
url: '/account/captcha-phone',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'post',
|
||||
timeout: 20000,
|
||||
data:{phone}
|
||||
})
|
||||
}
|
||||
return request({
|
||||
url: "/account/logout",
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
export function getCodeImg() {
|
||||
return request({
|
||||
url: "/account/captcha-image",
|
||||
headers: {
|
||||
isToken: false,
|
||||
},
|
||||
method: "get",
|
||||
timeout: 20000,
|
||||
});
|
||||
}
|
||||
// 获取短信验证码
|
||||
export function getCodePhone(phone) {
|
||||
return request({
|
||||
url: "/account/captcha-phone",
|
||||
headers: {
|
||||
isToken: false,
|
||||
},
|
||||
method: "post",
|
||||
timeout: 20000,
|
||||
data: { phone },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function operate(discussId){
|
||||
if(discussId==undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return myaxios({
|
||||
url: `/agree/operate/${discussId}`,
|
||||
method: 'post'
|
||||
})
|
||||
};
|
||||
import request from "@/config/axios/service";
|
||||
export function operate(discussId) {
|
||||
if (discussId == undefined) {
|
||||
return;
|
||||
}
|
||||
return request({
|
||||
url: `/agree/operate/${discussId}`,
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,41 +1,40 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getList(data){
|
||||
return myaxios({
|
||||
url: '/article',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
export function get(id){
|
||||
return myaxios({
|
||||
url: `/article/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
};
|
||||
export function add(data){
|
||||
return myaxios({
|
||||
url: `/article`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function update(id,data){
|
||||
return myaxios({
|
||||
url: `/article/${id}`,
|
||||
method: 'put',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function del(ids){
|
||||
return myaxios({
|
||||
url: `/article/${ids}`,
|
||||
method: 'delete'
|
||||
})
|
||||
};
|
||||
export function all(discussId)
|
||||
{
|
||||
return myaxios({
|
||||
url: `/article/all/discuss-id/${discussId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
import request from "@/config/axios/service";
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: "/article",
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
export function get(id) {
|
||||
return request({
|
||||
url: `/article/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: `/article`,
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
export function update(id, data) {
|
||||
return request({
|
||||
url: `/article/${id}`,
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: `/article/${ids}`,
|
||||
method: "delete",
|
||||
});
|
||||
}
|
||||
export function all(discussId) {
|
||||
return request({
|
||||
url: `/article/all/discuss-id/${discussId}`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getList(data){
|
||||
return myaxios({
|
||||
url: '/banner',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: "/banner",
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getListByDiscussId(discussId,data){
|
||||
return myaxios({
|
||||
url: `/comment/discuss-id/${discussId}`,
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
export function add(data){
|
||||
return myaxios({
|
||||
url: `/comment`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
export function del(ids){
|
||||
return myaxios({
|
||||
url: `/comment/${ids}`,
|
||||
method: 'delete'
|
||||
})
|
||||
};
|
||||
export function getListByDiscussId(discussId, data) {
|
||||
return request({
|
||||
url: `/comment/discuss-id/${discussId}`,
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: `/comment`,
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: `/comment/${ids}`,
|
||||
method: "delete",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getList(data){
|
||||
return myaxios({
|
||||
url: '/discuss',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
export function getTopList(data){
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
if(data==undefined)
|
||||
{
|
||||
data={isTop:true}
|
||||
}
|
||||
else
|
||||
{
|
||||
data["isTop"]=true;
|
||||
}
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: "/discuss",
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
export function getTopList(data) {
|
||||
if (data == undefined) {
|
||||
data = { isTop: true };
|
||||
} else {
|
||||
data["isTop"] = true;
|
||||
}
|
||||
|
||||
return myaxios({
|
||||
url: '/discuss',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
export function get(id){
|
||||
return myaxios({
|
||||
url: `/discuss/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
};
|
||||
export function add(data){
|
||||
return myaxios({
|
||||
url: `/discuss`,
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function update(id,data){
|
||||
return myaxios({
|
||||
url: `/discuss/${id}`,
|
||||
method: 'put',
|
||||
data:data
|
||||
})
|
||||
};
|
||||
export function del(ids){
|
||||
return myaxios({
|
||||
url: `/discuss/${ids}`,
|
||||
method: 'delete'
|
||||
})
|
||||
};
|
||||
return request({
|
||||
url: "/discuss",
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
export function get(id) {
|
||||
return request({
|
||||
url: `/discuss/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: `/discuss`,
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
export function update(id, data) {
|
||||
return request({
|
||||
url: `/discuss/${id}`,
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: `/discuss/${ids}`,
|
||||
method: "delete",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function upload(data){
|
||||
return myaxios({
|
||||
url: '/file',
|
||||
method: 'post',
|
||||
data:data,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
};
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
export function upload(data) {
|
||||
return request({
|
||||
url: "/file",
|
||||
method: "post",
|
||||
data: data,
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import myaxios from '@/utils/request'
|
||||
export function getList(data){
|
||||
return myaxios({
|
||||
url: '/plate',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
};
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: "/plate",
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,133 +1,131 @@
|
||||
import myaxios from '@/utils/request'
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
// 查询用户列表
|
||||
export function listUser(query) {
|
||||
return myaxios({
|
||||
url: '/user',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/user",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户详细
|
||||
export function getUser(userId) {
|
||||
return myaxios({
|
||||
url: '/user/' + parseStrEmpty(userId),
|
||||
method: 'get'
|
||||
})
|
||||
return request({
|
||||
url: "/user/" + parseStrEmpty(userId),
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
export function addUser(data) {
|
||||
return myaxios({
|
||||
url: '/user',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
return request({
|
||||
url: "/user",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 修改用户
|
||||
export function updateUser(id, data) {
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/user/${id}`,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
export function delUser(userId) {
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/user/${userId}`,
|
||||
method: 'delete',
|
||||
})
|
||||
method: "delete",
|
||||
});
|
||||
}
|
||||
|
||||
// 用户密码重置
|
||||
export function resetUserPwd(id, password) {
|
||||
const data = {
|
||||
password
|
||||
}
|
||||
password,
|
||||
};
|
||||
|
||||
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/account/rest-password/${id}`,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 用户状态修改
|
||||
export function changeUserStatus(userId, isDel) {
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/user/${userId}/${isDel}`,
|
||||
method: 'put'
|
||||
})
|
||||
method: "put",
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户个人信息
|
||||
export function getUserProfile() {
|
||||
return myaxios({
|
||||
url: '/account',
|
||||
method: 'get'
|
||||
})
|
||||
return request({
|
||||
url: "/account",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 修改用户个人信息
|
||||
export function updateUserProfile(data) {
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/user/profile`,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
// 只修改用户头像
|
||||
export function updateUserIcon(data) {
|
||||
return myaxios({
|
||||
return request({
|
||||
url: `/account/icon`,
|
||||
method: 'put',
|
||||
data:{icon:data}
|
||||
})
|
||||
method: "put",
|
||||
data: { icon: data },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 用户密码重置
|
||||
export function updateUserPwd(oldPassword, newPassword) {
|
||||
const data = {
|
||||
oldPassword,
|
||||
newPassword
|
||||
}
|
||||
return myaxios({
|
||||
url: '/account/password',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
newPassword,
|
||||
};
|
||||
return request({
|
||||
url: "/account/password",
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 用户头像上传
|
||||
export function uploadAvatar(data) {
|
||||
return request({
|
||||
url: '/system/user/profile/avatar',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
url: "/system/user/profile/avatar",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询授权角色
|
||||
export function getAuthRole(userId) {
|
||||
return request({
|
||||
url: '/system/user/authRole/' + userId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/system/user/authRole/" + userId,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 保存授权角色
|
||||
export function updateAuthRole(data) {
|
||||
return request({
|
||||
url: '/system/user/authRole',
|
||||
method: 'put',
|
||||
params: data
|
||||
})
|
||||
url: "/system/user/authRole",
|
||||
method: "put",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
// // 查询部门下拉树结构
|
||||
|
||||
@@ -1,55 +1,51 @@
|
||||
<template>
|
||||
<div ref="VisitsLineChart"></div>
|
||||
<div ref="VisitsLineChart"></div>
|
||||
</template>
|
||||
<script setup>
|
||||
import * as echarts from 'echarts/core';
|
||||
import { GridComponent } from 'echarts/components';
|
||||
import { LineChart } from 'echarts/charts';
|
||||
import { UniversalTransition } from 'echarts/features';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { ref ,onMounted} from 'vue';
|
||||
import { getWeek } from '@/apis/accessApi.js'
|
||||
import * as echarts from "echarts/core";
|
||||
import { GridComponent } from "echarts/components";
|
||||
import { LineChart } from "echarts/charts";
|
||||
import { UniversalTransition } from "echarts/features";
|
||||
import { CanvasRenderer } from "echarts/renderers";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { getWeek } from "@/apis/accessApi.js";
|
||||
echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition]);
|
||||
|
||||
const VisitsLineChart=ref(null);
|
||||
const VisitsLineChart = ref(null);
|
||||
|
||||
onMounted(async()=>{
|
||||
onMounted(async () => {
|
||||
var myChart = echarts.init(VisitsLineChart.value, null, {
|
||||
width: 320,
|
||||
height: 230
|
||||
height: 230,
|
||||
});
|
||||
var option;
|
||||
var option;
|
||||
|
||||
const response=await getWeek();
|
||||
const response = await getWeek();
|
||||
|
||||
var numberData=response.data.map(x=>x.number);
|
||||
var numberData = response.data.map((x) => x.number);
|
||||
|
||||
option = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: numberData,
|
||||
type: 'line',
|
||||
areaStyle: {}
|
||||
}
|
||||
]
|
||||
};
|
||||
option = {
|
||||
xAxis: {
|
||||
type: "category",
|
||||
boundaryGap: false,
|
||||
data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: numberData,
|
||||
type: "line",
|
||||
areaStyle: {},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
option && myChart.setOption(option);
|
||||
option && myChart.setOption(option);
|
||||
|
||||
window.addEventListener('resize', function() {
|
||||
window.addEventListener("resize", function () {
|
||||
myChart.resize();
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
});
|
||||
</script>
|
||||
|
||||
50
Yi.BBS.Vue3/src/hooks/useEcharts.js
Normal file
50
Yi.BBS.Vue3/src/hooks/useEcharts.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import * as echarts from "echarts";
|
||||
import { onMounted, onUnmounted, watch } from "vue";
|
||||
import { debounce } from "@/utils/index";
|
||||
import _ from "lodash";
|
||||
|
||||
// containerRef echarts实例 props 传入的值 baseOptions 图表初始化渲染
|
||||
export default function useEcharts(containerRef, emits, props, baseOptions) {
|
||||
let chart = null;
|
||||
|
||||
onMounted(() => {
|
||||
chart = echarts.init(containerRef.value);
|
||||
init();
|
||||
chart.on("click", function (param) {
|
||||
emits("chart-click", param);
|
||||
});
|
||||
//自适应不同屏幕时改变图表尺寸
|
||||
window.addEventListener("resize", cancalDebounce);
|
||||
});
|
||||
// 用于将echarts实例暴露出去使用
|
||||
const getChart = () => chart;
|
||||
onUnmounted(() => {
|
||||
chart && chart.dispose();
|
||||
window.removeEventListener("resize", cancalDebounce);
|
||||
});
|
||||
|
||||
function init() {
|
||||
let option = _.cloneDeep(baseOptions);
|
||||
chart.setOption(option);
|
||||
chart.setOption(props.option);
|
||||
}
|
||||
|
||||
function resize() {
|
||||
chart && chart.resize();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.option,
|
||||
(val) => {
|
||||
chart && chart.setOption(val);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
const cancalDebounce = debounce(resize, 500);
|
||||
|
||||
return {
|
||||
getChart,
|
||||
resize,
|
||||
};
|
||||
}
|
||||
12
Yi.BBS.Vue3/src/utils/index.js
Normal file
12
Yi.BBS.Vue3/src/utils/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
//设置防抖,保证无论拖动窗口大小,只执行一次获取浏览器宽高的方法
|
||||
export const debounce = (fun, delay) => {
|
||||
let timer;
|
||||
return function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
fun();
|
||||
}, delay);
|
||||
};
|
||||
};
|
||||
@@ -131,8 +131,8 @@ onMounted(async () => {
|
||||
plateList.value = plateData.items;
|
||||
const { data: discussData } = await discussGetList(query);
|
||||
discussList.value = discussData.items;
|
||||
const { data: bannerData } = await bannerGetList();
|
||||
bannerList.value = bannerData.items;
|
||||
// const { data: bannerData } = await bannerGetList();
|
||||
// bannerList.value = bannerData.items;
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user