Skip to content

Commit

Permalink
feat: 新增在线用户管理
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Dec 18, 2021
1 parent c154d1e commit cff7647
Show file tree
Hide file tree
Showing 20 changed files with 781 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BASE_URL = /

# base api
VUE_APP_BASE_API = '/api/admin/'
VUE_APP_BASE_SOCKET_PATH = '/ws'
VUE_APP_BASE_SOCKET_PATH = '/ws-api'
VUE_APP_BASE_SOCKET_NSP = '/admin'

# mock api
Expand Down
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ ENV = 'production'

# base api
VUE_APP_BASE_API = 'http://buqiyuan.site:7001/admin/'
VUE_APP_BASE_SOCKET_PATH = '/ws'
VUE_APP_BASE_SOCKET_NSP = '/admin'
VUE_APP_BASE_SOCKET_PATH = '/ws-api'
VUE_APP_BASE_SOCKET_NSP = 'ws://buqiyuan.site:7002/admin'

# 网站前缀
BASE_URL = /vue3-antd-admin/
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"nprogress": "^1.0.0-1",
"pinia": "2.0.6",
"qs": "^6.10.2",
"socket.io-client": "4.4.0",
"sortablejs": "^1.14.0",
"vue": "^3.2.26",
"vue-router": "^4.0.12"
Expand All @@ -51,7 +52,7 @@
"babel-plugin-lodash": "^3.3.4",
"commitizen": "^4.2.4",
"compression-webpack-plugin": "^9.2.0",
"eslint": "^8.4.1",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/api/system/menu/model.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare namespace API {
type MenuListResultItem = {
createTime: string;
updateTime: string;
updatedAt: string;
id: number;
parentId: number;
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/api/system/role/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ declare namespace API {

/** 角色列表项 */
type RoleListResultItem = {
createTime: string;
updateTime: string;
createdAt: string;
updatedAt: string;
id: number;
userId: string;
name: string;
Expand Down
8 changes: 4 additions & 4 deletions src/components/dynamic-table/components/table-action.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
}
if (isString(auth)) {
const isValid = verifyAuth(auth);
item.disabled = !isValid;
if (item.disabled) {
item.disabled ??= !isValid;
if (item.disabled && !isValid) {
item.title = '对不起,您没有该操作权限!';
}
return isValid;
}
if (isObject(auth)) {
const isValid = verifyAuth(auth.perm);
const isDisable = auth.effect !== 'delete';
item.disabled = !isValid && isDisable;
if (item.disabled) {
item.disabled ??= !isValid && isDisable;
if (item.disabled && !isValid) {
item.title = '对不起,您没有该操作权限!';
}
return isValid || isDisable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
const table = useTableContext();
const selectedKeysRef = ref<SizeType[]>([table.getProps?.size || 'large']);
const selectedKeysRef = ref<SizeType[]>([table.getProps?.size || 'default']);
function handleMenuClick({ key }: { key: SizeType }) {
selectedKeysRef.value = [key];
Expand Down
16 changes: 14 additions & 2 deletions src/components/dynamic-table/dynamic-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
* @description 表格查询
*/
const queryTable = (params) => {
params.page = 1;
fetchTableData(params);
};
Expand All @@ -168,6 +169,7 @@
Object.assign(queryParams, {
page: _pagination.current,
limit: _pagination.pageSize,
...queryParams,
});
}
state.loading = true;
Expand All @@ -192,8 +194,13 @@
total: ~~total,
});
}
state.tableData = data?.list || [];
if (Array.isArray(data?.list)) {
state.tableData = data!.list;
} else if (Array.isArray(data)) {
state.tableData = data;
} else {
state.tableData = [];
}
}
};
Expand All @@ -220,6 +227,7 @@
title: '序号',
width: 60,
align: 'center',
fixed: 'left',
bodyCell: ({ index }) => {
const getPagination = unref(paginationRef);
if (isBoolean(getPagination)) {
Expand Down Expand Up @@ -291,6 +299,10 @@
display: flex;
}
.ant-image:hover {
cursor: zoom-in;
}
.ant-btn {
margin-right: 10px;
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/dynamic-table/typing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export type OnChangeCallbackParams = TableProps['onChange'];
/**
* 表格属性
*/
export interface TableColumn<T = any> extends TableColumnType {
export interface TableColumn<T = Indexable> extends Omit<TableColumnType, 'dataIndex' | 'key'> {
title: string;
dataIndex: string | '$action';
dataIndex: keyof T | '$action';
key?: keyof T | '$action';
width?: number;
/** 指定搜索的字段 */
searchField?: string;
Expand Down
6 changes: 6 additions & 0 deletions src/core/socket/event-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Socket事件名定义
*/

// 强制踢下线
export const EVENT_KICK = 'kick';
Loading

0 comments on commit cff7647

Please sign in to comment.