Skip to content

Commit

Permalink
[Fix] Fix the jumping and internationalization issues in the workbench (
Browse files Browse the repository at this point in the history
#3677)

Signed-off-by: Zzm0809 <[email protected]>
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Jul 29, 2024
1 parent 6fc9e81 commit 2a13c50
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 57 deletions.
74 changes: 74 additions & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,80 @@ export default {
'home.mywork': 'My Task',
'home.allwork': 'All Task',
'home.task.not.desc': 'No mission statement at this time',
'home.task.update.at': 'Updated At: {time}',
'home.job.stream': 'Stream Job',
'home.job.batch': 'Batch Job',
'home.header.tips.morning.1': 'Good morning, {user}, A new day, new code, new challenges',
'home.header.tips.morning.2':
'good morning, {user}, The morning sunshine brings a new beginning, come on!',
'home.header.tips.morning.3':
'Good morning, {user}, programmer! May your bugs dissipate like morning mist.',
'home.header.tips.morning.4':
'Good morning, {user}, a new day, new ideas, looking forward to your burst of inspiration.',
'home.header.tips.morning.5':
'Good morning, {user}, The morning coffee is ready and it`s time to start working.',
'home.header.tips.morning.6':
'Good morning, {user}, may your morning be like a cup of hot tea, warm and comfortable.',
'home.header.tips.morning.7':
'Good morning, {user}, remember to smile, it will make your day even better.',
'home.header.tips.morning.8':
'Good morning, {user}, stay positive, something wonderful is about to happen.',
'home.header.tips.morning.9':
'Good morning, {user}, May your programming journey be filled with discovery and innovation.',
'home.header.tips.morning.10': 'Good morning, {user}, may your code be as fresh as morning dew.',
'home.header.tips.forenoon.1':
'Good morning, {user}, may your code be as bright as the morning sun.',
'home.header.tips.forenoon.2':
'Good morning, {user}, are you tired from coding this morning? Take a break and continue to work hard.',
'home.header.tips.forenoon.3':
'Good morning, {user}, the sunshine this morning is just right, illuminating your workbench.',
'home.header.tips.forenoon.4':
'Good morning, {user}, enjoy your morning work. Every task is worth giving your all.',
'home.header.tips.forenoon.5':
'Good morning, {user}, May your code be as refreshing as morning coffee.',
'home.header.tips.forenoon.6':
'Good morning, {user}, may your code be as vast as the morning sky.',
'home.header.tips.noon.1':
'Good afternoon, {user}, Lunch time, give yourself a chance to rest and recharge.',
'home.header.tips.noon.2':
'Good afternoon, {user}, The sunshine at noon reminds us that it`s time to slow down and enjoy a moment of tranquility.',
'home.header.tips.noon.3':
'Good afternoon, {user}, A brief break at noon can make your afternoon more energetic',
'home.header.tips.noon.4':
'Good afternoon, {user}, The sunshine at noon is a warm embrace throughout the day.',
'home.header.tips.noon.5':
'Good afternoon, {user}, A sumptuous lunch is the best reward for your hard work.',
'home.header.tips.afternoon.1':
'Good afternoon, {user}, The afternoon work has begun. Stay enthusiastic and focused.',
'home.header.tips.afternoon.2':
'Good afternoon, {user}, The gentle sunshine in the afternoon is suitable for thinking or meditation, to find inner peace.',
'home.header.tips.afternoon.3':
'Good afternoon, {user}, The gentle breeze of the afternoon brings fresh air. May your mood be so fresh as well.',
'home.header.tips.afternoon.4':
'Good afternoon, {user}, don`t forget to give yourself some sweet treats during this busy afternoon! (✿✪‿✪。)',
'home.header.tips.afternoon.5':
'Good afternoon, {user}, the gentle breeze of the afternoon, may your mood be as relaxed as it is. (✧∀✧)',
'home.header.tips.evening.1':
'Good evening, {user}, the busy day is over, let`s relax and unwind! (✿✪‿✪。)',
'home.header.tips.evening.2':
'Good evening, {user}, the evening glow. May your mood be as brilliant as it is. (✧∇✧)',
'home.header.tips.evening.3':
'Good evening, {user}, enjoy the tranquility of the evening and let the busyness of the day slowly settle. (✧◡◡✧)',
'home.header.tips.evening.4':
'Good evening, {user}, In the evening sky, stars are starting to twinkle. May your dreams also light up with them. (✧✧✧)',
'home.header.tips.evening.5':
'Good evening, {user}, may your code shine like the stars in the evening.',
'home.header.tips.lateNight.1':
'Good night, {user}, The tranquility of late night, may you have a peaceful and beautiful night. (✿ ✉ ✿)',
'home.header.tips.lateNight.2':
'Good night, {user}, The starry sky at night brings infinite inspiration to your thinking.',
'home.header.tips.lateNight.3':
'Good night, {user}, The starry sky at night reminds us of the vastness of the universe and the possibilities of thinking.',
'home.header.tips.lateNight.4':
'Good night, {user}, late night work. May your focus and persistence bring results.',
'home.header.tips.lateNight.5':
'Good night, {user}, May your code be as profound as the thoughts of late night.',

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

/**
*
Expand Down
21 changes: 16 additions & 5 deletions dinky-web/src/pages/Home/components/MyWorker/MyWorker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import { Card, Space, Tag, Typography } from 'antd';
import { Button, Card, Space, Tag, Typography } from 'antd';
import useHookRequest from '@/hooks/useHookRequest';
import { getData } from '@/services/api';
import { API_CONSTANTS } from '@/services/endpoints';
Expand All @@ -29,6 +29,7 @@ import StatusTag from '@/components/JobTags/StatusTag';
import EllipsisMiddle from '@/components/Typography/EllipsisMiddle';
import { l } from '@/utils/intl';
import { history } from 'umi';
import { formatDateToYYYYMMDDHHMMSS } from '@/utils/function';

const MyWorker = () => {
const { loading, data } = useHookRequest<any, any>(getData, {
Expand All @@ -53,10 +54,16 @@ const MyWorker = () => {
}}
title={l('home.mywork')}
bordered={false}
extra={<a href='/'>{l('home.allwork')}</a>}
extra={
<Button type='link' onClick={() => history.push('/devops')}>
{l('home.allwork')}
</Button>
}
loading={loading}
bodyStyle={{
padding: 0
styles={{
body: {
padding: 0
}
}}
>
<Card
Expand All @@ -79,7 +86,11 @@ const MyWorker = () => {
>
<div style={{ marginBottom: 10 }}>{item.note ?? l('home.task.not.desc')}</div>
<Space style={{ fontSize: 10 }}>
<Typography.Text type='secondary'>{item.updateTime.toString()}</Typography.Text>
<Typography.Text type='secondary'>
{l('home.task.update.at', '', {
time: formatDateToYYYYMMDDHHMMSS(item.updateTime)
})}
</Typography.Text>
<StatusTag animation={false} bordered={false} status={item.status} />
</Space>
</ProCard>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const WorkHeader = () => {
{dayTip}
</Space>
<div>
<Tag color='magenta'>{user.worknum}</Tag>
{user.worknum && <Tag color='magenta'>{user.worknum}</Tag>}
{renderRoleTagList(roleList || [])}
{renderTenantTagList(tenantList || [])}
</div>
Expand Down
72 changes: 21 additions & 51 deletions dinky-web/src/pages/Home/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,26 @@
*
*/

const greetings = {
morning: [
'早上好,{user}!新的一天,新的代码,新的挑战。',
'早安!{user}!早晨的阳光带来了新的开始,加油!。',
'早上好,{user},程序员!愿你的bug像早晨的雾气一样消散。',
'早安,{user},新的一天,新的创意,期待你的灵感爆发。',
'早上好,{user},早晨的咖啡已经准备好,是时候开始工作了。',
'早安,{user},愿你的早晨像一杯热茶,温暖而舒适。',
'早上好,{user},愿你的代码像早晨的露水一样清新。',
'早安,{user},记得微笑,它会让你的一天更加美好。',
'早上好,{user},保持积极,美好的事情即将发生。',
'早安,{user},愿你的编程之旅充满发现和创新。'
],
forenoon: [
'上午好,{user},愿你的代码像上午的阳光一样明亮。',
'上午好,{user},早上的代码写累了吗?休息一下,再继续加油。',
'上午好,{user},上午的阳光正好,照亮你的工作台。',
'上午好,{user},享受上午的工作,每项任务都值得全力以赴。',
'上午好,{user},愿你的代码像上午的咖啡一样提神。',
'上午好,{user},愿你的代码像上午的天空一样广阔。'
],
noon: [
'中午好,{user},午餐时间,给自己一个休息和充电的机会。',
'中午好,{user},中午的阳光提醒我们,是时候放慢脚步,享受片刻宁静。',
'中午好,{user},中午的短暂休息,可以让你的下午更加精力充沛.',
'中午好,{user},中午的阳光,是一天中温暖的拥抱。',
'中午好,{user},一顿丰盛的午餐,是对自己辛勤工作的最好奖赏。'
],
afternoon: [
'下午好,{user},下午的工作开始了,保持热情和专注。',
'下午好,{user},下午的阳光温柔,适合思考或冥想,找到内心的平静。',
'下午好,{user},下午的微风,带来清新的空气,愿你的心情也如此清新。',
'下午好,{user},忙碌的下午,也别忘了给自己一点甜头哦!(✿✪‿✪。)',
'下午好,{user},下午的微风,愿你的心情像它一样轻松。(✧∀✧)'
],
evening: [
'傍晚好,{user},傍晚好,一天的忙碌结束了,好好放松一下吧!(✿✪‿✪。)',
'傍晚好,{user},傍晚的晚霞,愿你的心情像它一样绚烂。(✧∇✧)',
'傍晚好,{user},享受傍晚的宁静,让一天的忙碌慢慢沉淀。(✧◡◡✧)',
'傍晚好,{user},傍晚的天空,星星开始闪烁,愿你的梦想也随之点亮。(✧✧✧)',
'傍晚好,{user},愿你的代码像傍晚的星光一样璀璨。'
],
lateNight: [
'深夜好,{user},深夜的宁静,愿你有一个平静美好的夜晚。(✿✉✿)',
'深夜好,{user},深夜的星空,为你的思考带来无限灵感。',
'深夜好,{user},深夜的星空,提醒我们宇宙的广阔和思维的可能性。',
'深夜好,{user},深夜的工作,愿你的专注和坚持带来成果。',
'深夜好,{user},愿你的代码像深夜的思考一样深邃。'
]
import { l } from '@/utils/intl';

/**
* 根据前缀和个数获取国际化提示语 | Get internationalization tips based on prefix and count
*/
function getTips(prefix: string, count: number): string[] {
const tips: string[] = [];
for (let i = 1; i <= count; i++) {
tips.push(l(`${prefix}.${i}`));
}
return tips;
}

const greetings: Record<string, string[]> = {
morning: getTips('home.header.tips.morning', 10),
forenoon: getTips('home.header.tips.forenoon', 6),
noon: getTips('home.header.tips.noon', 5),
afternoon: getTips('home.header.tips.afternoon', 5),
evening: getTips('home.header.tips.evening', 5),
lateNight: getTips('home.header.tips.lateNight', 5)
};
// 获取当前时间并判断时间段
const getTimeSegment = () => {
Expand All @@ -82,8 +53,7 @@ const getTimeSegment = () => {

// 随机选择一条关怀话语
export const getRandomGreeting = (user: string) => {
let greetingsArray: string[];
greetingsArray = greetings[getTimeSegment()];
let greetingsArray: string[] = greetings[getTimeSegment()] ?? [];
const randomIndex = Math.floor(Math.random() * greetingsArray.length);
const txt = greetingsArray[randomIndex];
return txt.replace('{user}', user);
Expand Down

0 comments on commit 2a13c50

Please sign in to comment.