Skip to content

Commit 2a13c50

Browse files
Zzzz-zmyZzm0809
andauthored
[Fix] Fix the jumping and internationalization issues in the workbench (#3677)
Signed-off-by: Zzm0809 <934230207@qq.com> Co-authored-by: Zzm0809 <Zzm0809@users.noreply.github.com>
1 parent 6fc9e81 commit 2a13c50

File tree

5 files changed

+152
-57
lines changed

5 files changed

+152
-57
lines changed

dinky-web/src/locales/en-US/pages.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,80 @@ export default {
270270
'home.mywork': 'My Task',
271271
'home.allwork': 'All Task',
272272
'home.task.not.desc': 'No mission statement at this time',
273+
'home.task.update.at': 'Updated At: {time}',
274+
'home.job.stream': 'Stream Job',
275+
'home.job.batch': 'Batch Job',
276+
'home.header.tips.morning.1': 'Good morning, {user}, A new day, new code, new challenges',
277+
'home.header.tips.morning.2':
278+
'good morning, {user}, The morning sunshine brings a new beginning, come on!',
279+
'home.header.tips.morning.3':
280+
'Good morning, {user}, programmer! May your bugs dissipate like morning mist.',
281+
'home.header.tips.morning.4':
282+
'Good morning, {user}, a new day, new ideas, looking forward to your burst of inspiration.',
283+
'home.header.tips.morning.5':
284+
'Good morning, {user}, The morning coffee is ready and it`s time to start working.',
285+
'home.header.tips.morning.6':
286+
'Good morning, {user}, may your morning be like a cup of hot tea, warm and comfortable.',
287+
'home.header.tips.morning.7':
288+
'Good morning, {user}, remember to smile, it will make your day even better.',
289+
'home.header.tips.morning.8':
290+
'Good morning, {user}, stay positive, something wonderful is about to happen.',
291+
'home.header.tips.morning.9':
292+
'Good morning, {user}, May your programming journey be filled with discovery and innovation.',
293+
'home.header.tips.morning.10': 'Good morning, {user}, may your code be as fresh as morning dew.',
294+
'home.header.tips.forenoon.1':
295+
'Good morning, {user}, may your code be as bright as the morning sun.',
296+
'home.header.tips.forenoon.2':
297+
'Good morning, {user}, are you tired from coding this morning? Take a break and continue to work hard.',
298+
'home.header.tips.forenoon.3':
299+
'Good morning, {user}, the sunshine this morning is just right, illuminating your workbench.',
300+
'home.header.tips.forenoon.4':
301+
'Good morning, {user}, enjoy your morning work. Every task is worth giving your all.',
302+
'home.header.tips.forenoon.5':
303+
'Good morning, {user}, May your code be as refreshing as morning coffee.',
304+
'home.header.tips.forenoon.6':
305+
'Good morning, {user}, may your code be as vast as the morning sky.',
306+
'home.header.tips.noon.1':
307+
'Good afternoon, {user}, Lunch time, give yourself a chance to rest and recharge.',
308+
'home.header.tips.noon.2':
309+
'Good afternoon, {user}, The sunshine at noon reminds us that it`s time to slow down and enjoy a moment of tranquility.',
310+
'home.header.tips.noon.3':
311+
'Good afternoon, {user}, A brief break at noon can make your afternoon more energetic',
312+
'home.header.tips.noon.4':
313+
'Good afternoon, {user}, The sunshine at noon is a warm embrace throughout the day.',
314+
'home.header.tips.noon.5':
315+
'Good afternoon, {user}, A sumptuous lunch is the best reward for your hard work.',
316+
'home.header.tips.afternoon.1':
317+
'Good afternoon, {user}, The afternoon work has begun. Stay enthusiastic and focused.',
318+
'home.header.tips.afternoon.2':
319+
'Good afternoon, {user}, The gentle sunshine in the afternoon is suitable for thinking or meditation, to find inner peace.',
320+
'home.header.tips.afternoon.3':
321+
'Good afternoon, {user}, The gentle breeze of the afternoon brings fresh air. May your mood be so fresh as well.',
322+
'home.header.tips.afternoon.4':
323+
'Good afternoon, {user}, don`t forget to give yourself some sweet treats during this busy afternoon! (✿✪‿✪。)',
324+
'home.header.tips.afternoon.5':
325+
'Good afternoon, {user}, the gentle breeze of the afternoon, may your mood be as relaxed as it is. (✧∀✧)',
326+
'home.header.tips.evening.1':
327+
'Good evening, {user}, the busy day is over, let`s relax and unwind! (✿✪‿✪。)',
328+
'home.header.tips.evening.2':
329+
'Good evening, {user}, the evening glow. May your mood be as brilliant as it is. (✧∇✧)',
330+
'home.header.tips.evening.3':
331+
'Good evening, {user}, enjoy the tranquility of the evening and let the busyness of the day slowly settle. (✧◡◡✧)',
332+
'home.header.tips.evening.4':
333+
'Good evening, {user}, In the evening sky, stars are starting to twinkle. May your dreams also light up with them. (✧✧✧)',
334+
'home.header.tips.evening.5':
335+
'Good evening, {user}, may your code shine like the stars in the evening.',
336+
'home.header.tips.lateNight.1':
337+
'Good night, {user}, The tranquility of late night, may you have a peaceful and beautiful night. (✿ ✉ ✿)',
338+
'home.header.tips.lateNight.2':
339+
'Good night, {user}, The starry sky at night brings infinite inspiration to your thinking.',
340+
'home.header.tips.lateNight.3':
341+
'Good night, {user}, The starry sky at night reminds us of the vastness of the universe and the possibilities of thinking.',
342+
'home.header.tips.lateNight.4':
343+
'Good night, {user}, late night work. May your focus and persistence bring results.',
344+
'home.header.tips.lateNight.5':
345+
'Good night, {user}, May your code be as profound as the thoughts of late night.',
346+
273347
/**
274348
*
275349
* layouts

dinky-web/src/locales/zh-CN/pages.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,48 @@ export default {
255255
'home.mywork': '我负责的任务',
256256
'home.allwork': '全部任务',
257257
'home.task.not.desc': '暂无任务说明',
258+
'home.task.update.at': '更新于: {time}',
258259
'home.job.stream': '流作业',
259260
'home.job.batch': '批作业',
261+
'home.header.tips.morning.1': '早上好, {user}!新的一天,新的代码,新的挑战.',
262+
'home.header.tips.morning.2': '早安!{user}!早晨的阳光带来了新的开始,加油!',
263+
'home.header.tips.morning.3': '早上好, {user},程序员!愿你的bug像早晨的雾气一样消散。',
264+
'home.header.tips.morning.4': '早安,{user},新的一天,新的创意,期待你的灵感爆发。',
265+
'home.header.tips.morning.5': '早上好, {user},早晨的咖啡已经准备好,是时候开始工作了。',
266+
'home.header.tips.morning.6': '早安,{user},愿你的早晨像一杯热茶,温暖而舒适。',
267+
'home.header.tips.morning.7': '早上好, {user},记得微笑,它会让你的一天更加美好。',
268+
'home.header.tips.morning.8': '早上好, {user},保持积极,美好的事情即将发生。',
269+
'home.header.tips.morning.9': '早上好, {user},愿你的编程之旅充满发现和创新。',
270+
'home.header.tips.morning.10': '早安, {user},愿你的代码像早晨的露水一样清新。',
271+
'home.header.tips.forenoon.1': '上午好, {user},愿你的代码像上午的阳光一样明亮。',
272+
'home.header.tips.forenoon.2': '上午好, {user},早上的代码写累了吗?休息一下,再继续加油。',
273+
'home.header.tips.forenoon.3': '上午好, {user},上午的阳光正好,照亮你的工作台。',
274+
'home.header.tips.forenoon.4': '上午好, {user},享受上午的工作,每项任务都值得全力以赴。',
275+
'home.header.tips.forenoon.5': '上午好, {user},愿你的代码像上午的咖啡一样提神。',
276+
'home.header.tips.forenoon.6': '上午好, {user},愿你的代码像上午的天空一样广阔。',
277+
'home.header.tips.noon.1': '中午好, {user},午餐时间,给自己一个休息和充电的机会。',
278+
'home.header.tips.noon.2': '中午好, {user},中午的阳光提醒我们,是时候放慢脚步,享受片刻宁静。',
279+
'home.header.tips.noon.3': '中午好, {user},中午的短暂休息,可以让你的下午更加精力充沛.',
280+
'home.header.tips.noon.4': '中午好, {user},中午的阳光,是一天中温暖的拥抱。',
281+
'home.header.tips.noon.5': '中午好, {user},一顿丰盛的午餐,是对自己辛勤工作的最好奖赏。',
282+
'home.header.tips.afternoon.1': '下午好, {user},下午的工作开始了,保持热情和专注。',
283+
'home.header.tips.afternoon.2':
284+
'下午好, {user},下午的阳光温柔,适合思考或冥想,找到内心的平静。',
285+
'home.header.tips.afternoon.3':
286+
'下午好, {user},下午的微风,带来清新的空气,愿你的心情也如此清新。',
287+
'home.header.tips.afternoon.4': '下午好, {user},忙碌的下午,也别忘了给自己一点甜头哦!(✿✪‿✪。)',
288+
'home.header.tips.afternoon.5': '下午好, {user},下午的微风,愿你的心情像它一样轻松。(✧∀✧)',
289+
'home.header.tips.evening.1': '傍晚好, {user},一天的忙碌结束了,好好放松一下吧!(✿✪‿✪。)',
290+
'home.header.tips.evening.2': '傍晚好, {user},傍晚的晚霞,愿你的心情像它一样绚烂。(✧∇✧)',
291+
'home.header.tips.evening.3': '傍晚好, {user},享受傍晚的宁静,让一天的忙碌慢慢沉淀。(✧◡◡✧)',
292+
'home.header.tips.evening.4':
293+
'傍晚好, {user},傍晚的天空,星星开始闪烁,愿你的梦想也随之点亮。(✧✧✧)',
294+
'home.header.tips.evening.5': '傍晚好, {user},愿你的代码像傍晚的星光一样璀璨。',
295+
'home.header.tips.lateNight.1': '深夜好, {user},深夜的宁静,愿你有一个平静美好的夜晚。(✿✉✿)',
296+
'home.header.tips.lateNight.2': '深夜好, {user},深夜的星空,为你的思考带来无限灵感。',
297+
'home.header.tips.lateNight.3': '深夜好, {user},深夜的星空,提醒我们宇宙的广阔和思维的可能性。',
298+
'home.header.tips.lateNight.4': '深夜好, {user},深夜的工作,愿你的专注和坚持带来成果。',
299+
'home.header.tips.lateNight.5': '深夜好, {user},愿你的代码像深夜的思考一样深邃。',
260300

261301
/**
262302
*

dinky-web/src/pages/Home/components/MyWorker/MyWorker.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
import { Card, Space, Tag, Typography } from 'antd';
20+
import { Button, Card, Space, Tag, Typography } from 'antd';
2121
import useHookRequest from '@/hooks/useHookRequest';
2222
import { getData } from '@/services/api';
2323
import { API_CONSTANTS } from '@/services/endpoints';
@@ -29,6 +29,7 @@ import StatusTag from '@/components/JobTags/StatusTag';
2929
import EllipsisMiddle from '@/components/Typography/EllipsisMiddle';
3030
import { l } from '@/utils/intl';
3131
import { history } from 'umi';
32+
import { formatDateToYYYYMMDDHHMMSS } from '@/utils/function';
3233

3334
const MyWorker = () => {
3435
const { loading, data } = useHookRequest<any, any>(getData, {
@@ -53,10 +54,16 @@ const MyWorker = () => {
5354
}}
5455
title={l('home.mywork')}
5556
bordered={false}
56-
extra={<a href='/'>{l('home.allwork')}</a>}
57+
extra={
58+
<Button type='link' onClick={() => history.push('/devops')}>
59+
{l('home.allwork')}
60+
</Button>
61+
}
5762
loading={loading}
58-
bodyStyle={{
59-
padding: 0
63+
styles={{
64+
body: {
65+
padding: 0
66+
}
6067
}}
6168
>
6269
<Card
@@ -79,7 +86,11 @@ const MyWorker = () => {
7986
>
8087
<div style={{ marginBottom: 10 }}>{item.note ?? l('home.task.not.desc')}</div>
8188
<Space style={{ fontSize: 10 }}>
82-
<Typography.Text type='secondary'>{item.updateTime.toString()}</Typography.Text>
89+
<Typography.Text type='secondary'>
90+
{l('home.task.update.at', '', {
91+
time: formatDateToYYYYMMDDHHMMSS(item.updateTime)
92+
})}
93+
</Typography.Text>
8394
<StatusTag animation={false} bordered={false} status={item.status} />
8495
</Space>
8596
</ProCard>

dinky-web/src/pages/Home/components/WorkerHeader/WorkHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const WorkHeader = () => {
7777
{dayTip}
7878
</Space>
7979
<div>
80-
<Tag color='magenta'>{user.worknum}</Tag>
80+
{user.worknum && <Tag color='magenta'>{user.worknum}</Tag>}
8181
{renderRoleTagList(roleList || [])}
8282
{renderTenantTagList(tenantList || [])}
8383
</div>

dinky-web/src/pages/Home/util.ts

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,26 @@
1717
*
1818
*/
1919

20-
const greetings = {
21-
morning: [
22-
'早上好,{user}!新的一天,新的代码,新的挑战。',
23-
'早安!{user}!早晨的阳光带来了新的开始,加油!。',
24-
'早上好,{user},程序员!愿你的bug像早晨的雾气一样消散。',
25-
'早安,{user},新的一天,新的创意,期待你的灵感爆发。',
26-
'早上好,{user},早晨的咖啡已经准备好,是时候开始工作了。',
27-
'早安,{user},愿你的早晨像一杯热茶,温暖而舒适。',
28-
'早上好,{user},愿你的代码像早晨的露水一样清新。',
29-
'早安,{user},记得微笑,它会让你的一天更加美好。',
30-
'早上好,{user},保持积极,美好的事情即将发生。',
31-
'早安,{user},愿你的编程之旅充满发现和创新。'
32-
],
33-
forenoon: [
34-
'上午好,{user},愿你的代码像上午的阳光一样明亮。',
35-
'上午好,{user},早上的代码写累了吗?休息一下,再继续加油。',
36-
'上午好,{user},上午的阳光正好,照亮你的工作台。',
37-
'上午好,{user},享受上午的工作,每项任务都值得全力以赴。',
38-
'上午好,{user},愿你的代码像上午的咖啡一样提神。',
39-
'上午好,{user},愿你的代码像上午的天空一样广阔。'
40-
],
41-
noon: [
42-
'中午好,{user},午餐时间,给自己一个休息和充电的机会。',
43-
'中午好,{user},中午的阳光提醒我们,是时候放慢脚步,享受片刻宁静。',
44-
'中午好,{user},中午的短暂休息,可以让你的下午更加精力充沛.',
45-
'中午好,{user},中午的阳光,是一天中温暖的拥抱。',
46-
'中午好,{user},一顿丰盛的午餐,是对自己辛勤工作的最好奖赏。'
47-
],
48-
afternoon: [
49-
'下午好,{user},下午的工作开始了,保持热情和专注。',
50-
'下午好,{user},下午的阳光温柔,适合思考或冥想,找到内心的平静。',
51-
'下午好,{user},下午的微风,带来清新的空气,愿你的心情也如此清新。',
52-
'下午好,{user},忙碌的下午,也别忘了给自己一点甜头哦!(✿✪‿✪。)',
53-
'下午好,{user},下午的微风,愿你的心情像它一样轻松。(✧∀✧)'
54-
],
55-
evening: [
56-
'傍晚好,{user},傍晚好,一天的忙碌结束了,好好放松一下吧!(✿✪‿✪。)',
57-
'傍晚好,{user},傍晚的晚霞,愿你的心情像它一样绚烂。(✧∇✧)',
58-
'傍晚好,{user},享受傍晚的宁静,让一天的忙碌慢慢沉淀。(✧◡◡✧)',
59-
'傍晚好,{user},傍晚的天空,星星开始闪烁,愿你的梦想也随之点亮。(✧✧✧)',
60-
'傍晚好,{user},愿你的代码像傍晚的星光一样璀璨。'
61-
],
62-
lateNight: [
63-
'深夜好,{user},深夜的宁静,愿你有一个平静美好的夜晚。(✿✉✿)',
64-
'深夜好,{user},深夜的星空,为你的思考带来无限灵感。',
65-
'深夜好,{user},深夜的星空,提醒我们宇宙的广阔和思维的可能性。',
66-
'深夜好,{user},深夜的工作,愿你的专注和坚持带来成果。',
67-
'深夜好,{user},愿你的代码像深夜的思考一样深邃。'
68-
]
20+
import { l } from '@/utils/intl';
21+
22+
/**
23+
* 根据前缀和个数获取国际化提示语 | Get internationalization tips based on prefix and count
24+
*/
25+
function getTips(prefix: string, count: number): string[] {
26+
const tips: string[] = [];
27+
for (let i = 1; i <= count; i++) {
28+
tips.push(l(`${prefix}.${i}`));
29+
}
30+
return tips;
31+
}
32+
33+
const greetings: Record<string, string[]> = {
34+
morning: getTips('home.header.tips.morning', 10),
35+
forenoon: getTips('home.header.tips.forenoon', 6),
36+
noon: getTips('home.header.tips.noon', 5),
37+
afternoon: getTips('home.header.tips.afternoon', 5),
38+
evening: getTips('home.header.tips.evening', 5),
39+
lateNight: getTips('home.header.tips.lateNight', 5)
6940
};
7041
// 获取当前时间并判断时间段
7142
const getTimeSegment = () => {
@@ -82,8 +53,7 @@ const getTimeSegment = () => {
8253

8354
// 随机选择一条关怀话语
8455
export const getRandomGreeting = (user: string) => {
85-
let greetingsArray: string[];
86-
greetingsArray = greetings[getTimeSegment()];
56+
let greetingsArray: string[] = greetings[getTimeSegment()] ?? [];
8757
const randomIndex = Math.floor(Math.random() * greetingsArray.length);
8858
const txt = greetingsArray[randomIndex];
8959
return txt.replace('{user}', user);

0 commit comments

Comments
 (0)