feat: task log show username
This commit is contained in:
parent
2432181ca0
commit
68c9890bb8
@ -57,6 +57,7 @@ type Task struct {
|
|||||||
FinishTime int64 `json:"finish_time" gorm:"index"`
|
FinishTime int64 `json:"finish_time" gorm:"index"`
|
||||||
Progress string `json:"progress" gorm:"type:varchar(20);index"`
|
Progress string `json:"progress" gorm:"type:varchar(20);index"`
|
||||||
Properties Properties `json:"properties" gorm:"type:json"`
|
Properties Properties `json:"properties" gorm:"type:json"`
|
||||||
|
Username string `json:"username,omitempty" gorm:"-"`
|
||||||
// 禁止返回给用户,内部可能包含key等隐私信息
|
// 禁止返回给用户,内部可能包含key等隐私信息
|
||||||
PrivateData TaskPrivateData `json:"-" gorm:"column:private_data;type:json"`
|
PrivateData TaskPrivateData `json:"-" gorm:"column:private_data;type:json"`
|
||||||
Data json.RawMessage `json:"data" gorm:"type:json"`
|
Data json.RawMessage `json:"data" gorm:"type:json"`
|
||||||
@ -233,6 +234,12 @@ func TaskGetAllTasks(startIdx int, num int, queryParams SyncTaskQueryParams) []*
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, task := range tasks {
|
||||||
|
if cache, err := GetUserCache(task.UserId); err == nil {
|
||||||
|
task.Username = cache.Username
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return tasks
|
return tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ import {
|
|||||||
TASK_ACTION_REMIX_GENERATE,
|
TASK_ACTION_REMIX_GENERATE,
|
||||||
} from '../../../constants/common.constant';
|
} from '../../../constants/common.constant';
|
||||||
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
|
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
|
||||||
|
import { stringToColor } from '../../../helpers/render';
|
||||||
|
import { Avatar, Space } from '@douyinfe/semi-ui';
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
'amber',
|
'amber',
|
||||||
@ -288,6 +290,39 @@ export const getTaskLogsColumns = ({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: COLUMN_KEYS.USERNAME,
|
||||||
|
title: t('用户'),
|
||||||
|
dataIndex: 'username',
|
||||||
|
render: (text, record, index) => {
|
||||||
|
if (!isAdminUser) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
const displayName = record.display_name;
|
||||||
|
const label = displayName || text || t('未知');
|
||||||
|
const avatarText =
|
||||||
|
typeof displayName === 'string' && displayName.length > 0
|
||||||
|
? displayName[0]
|
||||||
|
: typeof text === 'string' && text.length > 0
|
||||||
|
? text[0]
|
||||||
|
: '?';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Space>
|
||||||
|
<Avatar
|
||||||
|
size='extra-small'
|
||||||
|
color={stringToColor(label)}
|
||||||
|
style={{ cursor: 'default' }}
|
||||||
|
>
|
||||||
|
{avatarText}
|
||||||
|
</Avatar>
|
||||||
|
<Typography.Text ellipsis={{ showTooltip: true }}>
|
||||||
|
{label}
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: COLUMN_KEYS.PLATFORM,
|
key: COLUMN_KEYS.PLATFORM,
|
||||||
title: t('平台'),
|
title: t('平台'),
|
||||||
|
|||||||
@ -40,6 +40,7 @@ export const useTaskLogsData = () => {
|
|||||||
FINISH_TIME: 'finish_time',
|
FINISH_TIME: 'finish_time',
|
||||||
DURATION: 'duration',
|
DURATION: 'duration',
|
||||||
CHANNEL: 'channel',
|
CHANNEL: 'channel',
|
||||||
|
USERNAME: 'username',
|
||||||
PLATFORM: 'platform',
|
PLATFORM: 'platform',
|
||||||
TYPE: 'type',
|
TYPE: 'type',
|
||||||
TASK_ID: 'task_id',
|
TASK_ID: 'task_id',
|
||||||
@ -104,6 +105,7 @@ export const useTaskLogsData = () => {
|
|||||||
// For non-admin users, force-hide admin-only columns (does not touch admin settings)
|
// For non-admin users, force-hide admin-only columns (does not touch admin settings)
|
||||||
if (!isAdminUser) {
|
if (!isAdminUser) {
|
||||||
merged[COLUMN_KEYS.CHANNEL] = false;
|
merged[COLUMN_KEYS.CHANNEL] = false;
|
||||||
|
merged[COLUMN_KEYS.USERNAME] = false;
|
||||||
}
|
}
|
||||||
setVisibleColumns(merged);
|
setVisibleColumns(merged);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -122,6 +124,7 @@ export const useTaskLogsData = () => {
|
|||||||
[COLUMN_KEYS.FINISH_TIME]: true,
|
[COLUMN_KEYS.FINISH_TIME]: true,
|
||||||
[COLUMN_KEYS.DURATION]: true,
|
[COLUMN_KEYS.DURATION]: true,
|
||||||
[COLUMN_KEYS.CHANNEL]: isAdminUser,
|
[COLUMN_KEYS.CHANNEL]: isAdminUser,
|
||||||
|
[COLUMN_KEYS.USERNAME]: isAdminUser,
|
||||||
[COLUMN_KEYS.PLATFORM]: true,
|
[COLUMN_KEYS.PLATFORM]: true,
|
||||||
[COLUMN_KEYS.TYPE]: true,
|
[COLUMN_KEYS.TYPE]: true,
|
||||||
[COLUMN_KEYS.TASK_ID]: true,
|
[COLUMN_KEYS.TASK_ID]: true,
|
||||||
@ -151,7 +154,10 @@ export const useTaskLogsData = () => {
|
|||||||
const updatedColumns = {};
|
const updatedColumns = {};
|
||||||
|
|
||||||
allKeys.forEach((key) => {
|
allKeys.forEach((key) => {
|
||||||
if (key === COLUMN_KEYS.CHANNEL && !isAdminUser) {
|
if (
|
||||||
|
(key === COLUMN_KEYS.CHANNEL || key === COLUMN_KEYS.USERNAME) &&
|
||||||
|
!isAdminUser
|
||||||
|
) {
|
||||||
updatedColumns[key] = false;
|
updatedColumns[key] = false;
|
||||||
} else {
|
} else {
|
||||||
updatedColumns[key] = checked;
|
updatedColumns[key] = checked;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user