mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
feat(system): 优化删除操作并添加清除在线用户功能
- 重构了多个模块的删除操作,支持批量删除 - 在线监控模块增加了清除所有在线用户的功能 - 优化了前端API接口,提高了可维护性
This commit is contained in:
@@ -11,11 +11,19 @@ const OnlineAPI = {
|
||||
},
|
||||
|
||||
// 强退用户
|
||||
deleteOnline(body: any) {
|
||||
deleteOnline(session_id: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `/monitor/online/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
data: session_id,
|
||||
});
|
||||
},
|
||||
|
||||
// 强退用户
|
||||
clearOnline() {
|
||||
return request<ApiResponse>({
|
||||
url: `/monitor/online/clear`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ const AuthAPI = {
|
||||
getCaptcha() {
|
||||
return request<ApiResponse<CaptchaInfo>>({
|
||||
url: `/system/auth/captcha/get`,
|
||||
method: "post",
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ const ConfigAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getConfigDetail(query: any) {
|
||||
getConfigDetail(id: number) {
|
||||
return request<ApiResponse<ConfigTable>>({
|
||||
url: `/system/config/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -49,15 +49,15 @@ const ConfigAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteConfig(query: any) {
|
||||
deleteConfig(body: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/config/delete`,
|
||||
method: "delete",
|
||||
params: query,
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportConfig(body: any) {
|
||||
exportConfig(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/config/export`,
|
||||
method: "post",
|
||||
|
||||
@@ -9,11 +9,11 @@ const DeptAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getDeptDetail(query: any) {
|
||||
getDeptDetail(id: number) {
|
||||
return request<ApiResponse<DeptTable>>({
|
||||
url: `/system/dept/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ const DeptAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteDept(query: any) {
|
||||
deleteDept(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dept/delete`,
|
||||
method: "delete",
|
||||
@@ -41,7 +41,7 @@ const DeptAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailableDept(body: any) {
|
||||
batchAvailableDept(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dept/available/setting`,
|
||||
method: "patch",
|
||||
|
||||
@@ -16,11 +16,11 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getDictTypeDetail(query: any) {
|
||||
getDictTypeDetail(id: number) {
|
||||
return request<ApiResponse<DictTable>>({
|
||||
url: `/system/dict/type/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteDictType(query: any) {
|
||||
deleteDictType(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dict/type/delete`,
|
||||
method: "delete",
|
||||
@@ -65,11 +65,11 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getDictDataDetail(query: any) {
|
||||
getDictDataDetail(id: number) {
|
||||
return request<ApiResponse<DictDataTable>>({
|
||||
url: `/system/dict/data/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteDictData(query: any) {
|
||||
deleteDictData(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dict/data/delete`,
|
||||
method: "delete",
|
||||
@@ -97,7 +97,7 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportDictData(body: any) {
|
||||
exportDictData(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dict/data/export`,
|
||||
method: "post",
|
||||
@@ -106,9 +106,9 @@ const DictAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getInitDict(query: any) {
|
||||
getInitDict(dict_type: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/dict/data/info/${query}`,
|
||||
url: `/system/dict/data/info/${dict_type}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
const JobAPI = {
|
||||
getJobList(query: any) {
|
||||
return request<ApiResponse>({
|
||||
getJobList(query: JobPageQuery) {
|
||||
return request<ApiResponse<PageResult<JobTable>>>({
|
||||
url: `/system/job/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getJobDetail(query: any) {
|
||||
return request<ApiResponse>({
|
||||
getJobDetail(id: number) {
|
||||
return request<ApiResponse<JobTable>>({
|
||||
url: `/system/job/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
createJob(body: any) {
|
||||
createJob(body: JobForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/job/create`,
|
||||
method: "post",
|
||||
@@ -25,7 +25,7 @@ const JobAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
updateJob(body: any) {
|
||||
updateJob(body: JobForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/job/update`,
|
||||
method: "put",
|
||||
@@ -33,7 +33,7 @@ const JobAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteJob(query: any) {
|
||||
deleteJob(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/job/delete`,
|
||||
method: "delete",
|
||||
@@ -41,7 +41,7 @@ const JobAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportJob(body: any) {
|
||||
exportJob(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/job/export`,
|
||||
method: "post",
|
||||
@@ -57,7 +57,7 @@ const JobAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
OptionJob(params: any) {
|
||||
OptionJob(params: JobPageQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/job/option`,
|
||||
method: "put",
|
||||
@@ -77,6 +77,11 @@ export interface JobPageQuery extends PageQuery {
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
export interface JobPageQuery extends PageQuery {
|
||||
id?: number;
|
||||
option?: number; //操作类型 1: 暂停 2: 恢复 3: 重启
|
||||
}
|
||||
|
||||
export interface JobTable {
|
||||
index?: number;
|
||||
id?: number;
|
||||
|
||||
@@ -9,15 +9,15 @@ const LogAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getLogDetail(query: any) {
|
||||
getLogDetail(id: number) {
|
||||
return request<ApiResponse<LogTable>>({
|
||||
url: `/system/log/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
deleteLog(query: any) {
|
||||
deleteLog(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/log/delete`,
|
||||
method: "delete",
|
||||
@@ -25,7 +25,7 @@ const LogAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportLog(query: any) {
|
||||
exportLog(query: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/log/export`,
|
||||
method: "post",
|
||||
|
||||
@@ -9,11 +9,11 @@ const MenuAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getMenuDetail(query: any) {
|
||||
getMenuDetail(id: number) {
|
||||
return request<ApiResponse<MenuTable>>({
|
||||
url: `/system/menu/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ const MenuAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteMenu(query: any) {
|
||||
deleteMenu(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/menu/delete`,
|
||||
method: "delete",
|
||||
@@ -41,7 +41,7 @@ const MenuAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailableMenu(body: any) {
|
||||
batchAvailableMenu(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/menu/available/setting`,
|
||||
method: "patch",
|
||||
|
||||
@@ -16,11 +16,11 @@ const NoticeAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getNoticeDetail(query: any) {
|
||||
getNoticeDetail(id: number) {
|
||||
return request<ApiResponse<NoticeTable>>({
|
||||
url: `/system/notice/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -40,7 +40,7 @@ const NoticeAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteNotice(query: any) {
|
||||
deleteNotice(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/notice/delete`,
|
||||
method: "delete",
|
||||
@@ -48,7 +48,7 @@ const NoticeAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailableNotice(body: any) {
|
||||
batchAvailableNotice(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/notice/available/setting`,
|
||||
method: "patch",
|
||||
@@ -56,7 +56,7 @@ const NoticeAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportNotice(body: any) {
|
||||
exportNotice(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/notice/export`,
|
||||
method: "post",
|
||||
|
||||
@@ -9,11 +9,11 @@ const PositionAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getPositionDetail(query: any) {
|
||||
getPositionDetail(id: number) {
|
||||
return request<ApiResponse<PositionTable>>({
|
||||
url: `/system/position/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ const PositionAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deletePosition(query: any) {
|
||||
deletePosition(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/position/delete`,
|
||||
method: "delete",
|
||||
@@ -41,7 +41,7 @@ const PositionAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailablePosition(body: any) {
|
||||
batchAvailablePosition(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/position/available/setting`,
|
||||
method: "patch",
|
||||
@@ -49,7 +49,7 @@ const PositionAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportPosition(body: any) {
|
||||
exportPosition(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/position/export`,
|
||||
method: "post",
|
||||
|
||||
@@ -9,11 +9,11 @@ const RoleAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getRoleDetail(query: any) {
|
||||
getRoleDetail(id: number) {
|
||||
return request<ApiResponse<RoleTable>>({
|
||||
url: `/system/role/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ const RoleAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteRole(query: any) {
|
||||
deleteRole(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/role/delete`,
|
||||
method: "delete",
|
||||
@@ -41,7 +41,7 @@ const RoleAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailableRole(body: any) {
|
||||
batchAvailableRole(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/role/available/setting`,
|
||||
method: "patch",
|
||||
@@ -57,7 +57,7 @@ const RoleAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportRole(body: any) {
|
||||
exportRole(body: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/role/export`,
|
||||
method: "post",
|
||||
|
||||
@@ -18,7 +18,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
updateCurrentUserInfo(body: any) {
|
||||
updateCurrentUserInfo(body: InfoFormState) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/current/info/update`,
|
||||
method: "put",
|
||||
@@ -26,7 +26,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
changeCurrentUserPassword(body: any) {
|
||||
changeCurrentUserPassword(body: PasswordFormState) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/current/password/change`,
|
||||
method: "put",
|
||||
@@ -50,23 +50,23 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
getUserList(query: any) {
|
||||
return request<ApiResponse>({
|
||||
getUserList(query: UserPageQuery) {
|
||||
return request<ApiResponse<PageResult<UserInfo[]>>>({
|
||||
url: `/system/user/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getUserDetail(query: any) {
|
||||
getUserDetail(id: number) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/detail`,
|
||||
method: "get",
|
||||
params: query,
|
||||
params: id,
|
||||
});
|
||||
},
|
||||
|
||||
createUser(body: any) {
|
||||
createUser(body: InfoFormState) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/create`,
|
||||
method: "post",
|
||||
@@ -74,7 +74,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
updateUser(body: any) {
|
||||
updateUser(body: InfoFormState) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/update`,
|
||||
method: "put",
|
||||
@@ -82,7 +82,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
deleteUser(query: any) {
|
||||
deleteUser(query: DeleteType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/delete`,
|
||||
method: "delete",
|
||||
@@ -90,7 +90,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
batchAvailableUser(body: any) {
|
||||
batchAvailableUser(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/available/setting`,
|
||||
method: "patch",
|
||||
@@ -98,7 +98,7 @@ export const UserAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
exportUser(query: any) {
|
||||
exportUser(query: any[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `/system/user/export`,
|
||||
method: "post",
|
||||
@@ -208,6 +208,7 @@ export interface positionSelectorType {
|
||||
}
|
||||
|
||||
export interface InfoFormState {
|
||||
id?: number;
|
||||
name: string;
|
||||
gender: number;
|
||||
mobile: string;
|
||||
|
||||
@@ -6,7 +6,6 @@ import { setupStore } from "@/store";
|
||||
import { setupElIcons } from "./icons";
|
||||
import { setupPermission } from "./permission";
|
||||
import { InstallCodeMirror } from "codemirror-editor-vue3";
|
||||
import { setupVxeTable } from "./vxeTable";
|
||||
|
||||
export default {
|
||||
install(app: App<Element>) {
|
||||
@@ -20,8 +19,6 @@ export default {
|
||||
setupElIcons(app);
|
||||
// 路由守卫
|
||||
setupPermission();
|
||||
// vxe-table
|
||||
setupVxeTable(app);
|
||||
// 注册 CodeMirror
|
||||
app.use(InstallCodeMirror);
|
||||
},
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import type { App } from "vue";
|
||||
import VXETable from "vxe-table"; // https://vxetable.cn/v4.6/#/table/start/install
|
||||
|
||||
// 全局默认参数
|
||||
VXETable.setConfig({
|
||||
// 全局尺寸
|
||||
size: "medium",
|
||||
// 全局 zIndex 起始值,如果项目的的 z-index 样式值过大时就需要跟随设置更大,避免被遮挡
|
||||
zIndex: 9999,
|
||||
// 版本号,对于某些带数据缓存的功能有用到,上升版本号可以用于重置数据
|
||||
version: 0,
|
||||
// 全局 loading 提示内容,如果为 null 则不显示文本
|
||||
loadingText: null,
|
||||
table: {
|
||||
showHeader: true,
|
||||
showOverflow: "tooltip",
|
||||
showHeaderOverflow: "tooltip",
|
||||
autoResize: true,
|
||||
// stripe: false,
|
||||
border: "inner",
|
||||
// round: false,
|
||||
emptyText: "暂无数据",
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
isCurrent: true,
|
||||
// 行数据的唯一主键字段名
|
||||
keyField: "_VXE_ID",
|
||||
},
|
||||
columnConfig: {
|
||||
resizable: false,
|
||||
},
|
||||
align: "center",
|
||||
headerAlign: "center",
|
||||
},
|
||||
pager: {
|
||||
// size: "medium",
|
||||
// 配套的样式
|
||||
perfect: false,
|
||||
pageSize: 10,
|
||||
pagerCount: 7,
|
||||
pageSizes: [10, 20, 50],
|
||||
layouts: [
|
||||
"Total",
|
||||
"PrevJump",
|
||||
"PrevPage",
|
||||
"Number",
|
||||
"NextPage",
|
||||
"NextJump",
|
||||
"Sizes",
|
||||
"FullJump",
|
||||
],
|
||||
},
|
||||
modal: {
|
||||
minWidth: 500,
|
||||
minHeight: 400,
|
||||
lockView: true,
|
||||
mask: true,
|
||||
// duration: 3000,
|
||||
// marginSize: 20,
|
||||
dblclickZoom: false,
|
||||
showTitleOverflow: true,
|
||||
transfer: true,
|
||||
draggable: false,
|
||||
},
|
||||
});
|
||||
|
||||
export function setupVxeTable(app: App) {
|
||||
// Vxe Table 组件完整引入
|
||||
app.use(VXETable);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// tags缓存
|
||||
export const useTagsViewStore = defineStore("tagsView", () => {
|
||||
|
||||
const visitedViews = ref<TagView[]>([]);
|
||||
const cachedViews = ref<string[]>([]);
|
||||
const router = useRouter();
|
||||
|
||||
@@ -98,9 +98,9 @@ export const useUserStore = defineStore("user", {
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
AuthAPI.refreshToken({refresh_token: refreshToken})
|
||||
.then((data) => {
|
||||
.then((response) => {
|
||||
// 更新令牌,保持当前记住我状态
|
||||
Auth.setTokens(data.access_token, data.refresh_token, Auth.getRememberMe());
|
||||
Auth.setTokens(response.data.data.access_token, response.data.data.refresh_token, Auth.getRememberMe());
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
Vendored
+15
@@ -130,5 +130,20 @@ declare global {
|
||||
origin_name: string;
|
||||
file_url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
export interface DeleteType {
|
||||
ids?: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量启用、停用
|
||||
*/
|
||||
export interface BatchType {
|
||||
ids?: number[];
|
||||
status?: boolean;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
<!-- 功能区域 -->
|
||||
<div class="data-table__toolbar">
|
||||
<div class="data-table__toolbar--actions">
|
||||
<el-button :disabled="selectIds.length === 0" type="danger" icon="delete"
|
||||
@click="handleSubmit()">批量强退</el-button>
|
||||
<el-button type="danger" icon="delete" @click="handleClear()">强退所有</el-button>
|
||||
</div>
|
||||
<div class="data-table__toolbar--tools">
|
||||
<el-tooltip content="刷新">
|
||||
@@ -209,6 +208,22 @@ async function handleSubmit(id?: number) {
|
||||
}
|
||||
}
|
||||
|
||||
// 强退所有
|
||||
async function handleClear() {
|
||||
ElMessageBox.confirm("确认强制退出所有用户?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await OnlineAPI.clearOnline();
|
||||
handleResetQuery();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
loadingData();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user