diff --git a/src/assets/imgs/avatar.jpg b/src/assets/imgs/avatar.jpg new file mode 100644 index 0000000..faeacd1 Binary files /dev/null and b/src/assets/imgs/avatar.jpg differ diff --git a/src/components/Highlight/index.ts b/src/components/Highlight/index.ts new file mode 100644 index 0000000..3e2d9ed --- /dev/null +++ b/src/components/Highlight/index.ts @@ -0,0 +1,3 @@ +import Highlight from './src/Highlight.vue' + +export { Highlight } diff --git a/src/components/Highlight/src/Highlight.vue b/src/components/Highlight/src/Highlight.vue new file mode 100644 index 0000000..0e820f3 --- /dev/null +++ b/src/components/Highlight/src/Highlight.vue @@ -0,0 +1,65 @@ + diff --git a/src/components/UserInfo/src/UserInfo.vue b/src/components/UserInfo/src/UserInfo.vue index a630fc1..791dfa8 100644 --- a/src/components/UserInfo/src/UserInfo.vue +++ b/src/components/UserInfo/src/UserInfo.vue @@ -38,7 +38,11 @@ const loginOut = () => { - + Archer diff --git a/src/hooks/web/useTimeAgo.ts b/src/hooks/web/useTimeAgo.ts new file mode 100644 index 0000000..6dc7123 --- /dev/null +++ b/src/hooks/web/useTimeAgo.ts @@ -0,0 +1,48 @@ +import { useTimeAgo as useTimeAgoCore, UseTimeAgoMessages } from '@vueuse/core' +import { computed, unref } from 'vue' +import { useLocaleStoreWithOut } from '@/store/modules/locale' + +const TIME_AGO_MESSAGE_MAP: { + 'zh-CN': UseTimeAgoMessages + en: UseTimeAgoMessages +} = { + 'zh-CN': { + justNow: '刚刚', + past: (n) => (n.match(/\d/) ? `${n}前` : n), + future: (n) => (n.match(/\d/) ? `${n}后` : n), + month: (n, past) => (n === 1 ? (past ? '上个月' : '下个月') : `${n} 个月`), + year: (n, past) => (n === 1 ? (past ? '去年' : '明年') : `${n} 年`), + day: (n, past) => (n === 1 ? (past ? '昨天' : '明天') : `${n} 天`), + week: (n, past) => (n === 1 ? (past ? '上周' : '下周') : `${n} 周`), + hour: (n) => `${n} 小时`, + minute: (n) => `${n} 分钟`, + second: (n) => `${n} 秒` + }, + en: { + justNow: '刚刚', + past: (n) => (n.match(/\d/) ? `${n} ago` : n), + future: (n) => (n.match(/\d/) ? `in ${n}` : n), + month: (n, past) => + n === 1 ? (past ? 'last month' : 'next month') : `${n} month${n > 1 ? 's' : ''}`, + year: (n, past) => + n === 1 ? (past ? 'last year' : 'next year') : `${n} year${n > 1 ? 's' : ''}`, + day: (n, past) => (n === 1 ? (past ? 'yesterday' : 'tomorrow') : `${n} day${n > 1 ? 's' : ''}`), + week: (n, past) => + n === 1 ? (past ? 'last week' : 'next week') : `${n} week${n > 1 ? 's' : ''}`, + hour: (n) => `${n} hour${n > 1 ? 's' : ''}`, + minute: (n) => `${n} minute${n > 1 ? 's' : ''}`, + second: (n) => `${n} second${n > 1 ? 's' : ''}` + } +} + +export const useTimeAgo = (time: Date | number | string) => { + const localeStore = useLocaleStoreWithOut() + + const currentLocale = computed(() => localeStore.getCurrentLocale) + + const timeAgo = useTimeAgoCore(time, { + messages: TIME_AGO_MESSAGE_MAP[unref(currentLocale).lang] + }) + + return timeAgo +} diff --git a/src/locales/en.ts b/src/locales/en.ts index 7d9d2af..4c60924 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -71,7 +71,8 @@ export default { menu12: 'Menu1-2', menu2: 'Menu2', dashboard: 'Dashboard', - analysis: 'Analysis' + analysis: 'Analysis', + workplace: 'Workplace' }, analysis: { newUser: 'New user', @@ -109,6 +110,28 @@ export default { saturday: 'Saturday', sunday: 'Sunday' }, + workplace: { + goodMorning: 'Good morning', + happyDay: 'Wish you happy every day!', + toady: `It's sunny today`, + project: 'Project', + access: 'Project access', + toDo: 'To do', + introduction: 'A serious introduction', + more: 'More', + shortcutOperation: 'Shortcut operation', + operation: 'Operation', + index: 'Index', + personal: 'Personal', + team: 'Team', + quote: 'Quote', + contribution: 'Contribution', + hot: 'Hot', + yield: 'Yield', + dynamic: 'Dynamic', + push: 'push', + pushCode: 'Archer push code to GitHub' + }, formDemo: { input: 'Input', inputNumber: 'InputNumber', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index f01b7a7..a2f3464 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -71,7 +71,8 @@ export default { menu12: '菜单1-2', menu2: '菜单2', dashboard: '首页', - analysis: '分析页' + analysis: '分析页', + workplace: '工作台' }, analysis: { newUser: '新增用户', @@ -109,6 +110,28 @@ export default { saturday: '周六', sunday: '周日' }, + workplace: { + goodMorning: '早安', + happyDay: '祝你开心每一天!', + toady: '今日晴', + project: '项目数', + access: '项目访问', + toDo: '待办', + introduction: '一个正经的简介', + more: '更多', + shortcutOperation: '快捷操作', + operation: '操作', + index: '指数', + personal: '个人', + team: '团队', + quote: '引用', + contribution: '贡献', + hot: '热度', + yield: '产量', + dynamic: '动态', + push: '推送', + pushCode: 'Archer 推送 代码到 Github' + }, formDemo: { input: '输入框', inputNumber: '数字输入框', diff --git a/src/plugins/echarts/index.ts b/src/plugins/echarts/index.ts index 54bc668..34f756f 100644 --- a/src/plugins/echarts/index.ts +++ b/src/plugins/echarts/index.ts @@ -1,6 +1,13 @@ import * as echarts from 'echarts/core' -import { BarChart, LineChart, PieChart, MapChart, PictorialBarChart } from 'echarts/charts' +import { + BarChart, + LineChart, + PieChart, + MapChart, + PictorialBarChart, + RadarChart +} from 'echarts/charts' import { TitleComponent, @@ -27,7 +34,8 @@ echarts.use([ PieChart, MapChart, CanvasRenderer, - PictorialBarChart + PictorialBarChart, + RadarChart ]) export default echarts diff --git a/src/router/index.ts b/src/router/index.ts index f814272..0f346bb 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -54,8 +54,16 @@ export const asyncRouterMap: AppRouteRecordRaw[] = [ name: 'Analysis', meta: { title: t('router.analysis'), - noCache: true, - affix: true + noCache: true + } + }, + { + path: 'workplace', + component: () => import('@/views/Dashboard/Workplace.vue'), + name: 'Workplace', + meta: { + title: t('router.workplace'), + noCache: true } } ] diff --git a/src/utils/index.ts b/src/utils/index.ts index aafe54d..11e1bbb 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -63,3 +63,35 @@ export const findIndex = (ary: Array, fn: Fn): number => { export const trim = (str: string) => { return str.replace(/(^\s*)|(\s*$)/g, '') } + +/** + * @param {Date | number | string} time 需要转换的时间 + * @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss + */ +export function formatTime(time: Date | number | string, fmt: string) { + if (!time) return '' + else { + const date = new Date(time) + const o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'H+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds(), + 'q+': Math.floor((date.getMonth() + 3) / 3), + S: date.getMilliseconds() + } + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) + } + for (const k in o) { + if (new RegExp('(' + k + ')').test(fmt)) { + fmt = fmt.replace( + RegExp.$1, + RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length) + ) + } + } + return fmt + } +} diff --git a/src/views/Dashboard/Analysis.vue b/src/views/Dashboard/Analysis.vue index 06118a5..a0f2eb8 100644 --- a/src/views/Dashboard/Analysis.vue +++ b/src/views/Dashboard/Analysis.vue @@ -32,7 +32,7 @@ setTimeout(() => { - + diff --git a/src/views/Dashboard/Workplace.vue b/src/views/Dashboard/Workplace.vue new file mode 100644 index 0000000..0d47968 --- /dev/null +++ b/src/views/Dashboard/Workplace.vue @@ -0,0 +1,299 @@ + + + + + + + + + + + + + {{ t('workplace.goodMorning') }},Archer,{{ t('workplace.happyDay') }} + + + {{ t('workplace.toady') }},20℃ - 32℃! + + + + + + + + {{ t('workplace.project') }} + + + + + {{ t('workplace.toDo') }} + + + + + {{ t('workplace.access') }} + + + + + + + + + + + + + + + + {{ t('workplace.project') }} + {{ t('workplace.more') }} + + + + + + + + {{ item.name }} + + {{ item.message }} + + {{ item.personal }} + {{ formatTime(item.time, 'yyyy-MM-dd') }} + + + + + + + + + + + + {{ t('workplace.dynamic') }} + {{ t('workplace.more') }} + + + + + + + + {{ t('workplace.pushCode') }} + + + {{ useTimeAgo(item.time) }} + + + + + + + + + + + + + {{ t('workplace.shortcutOperation') }} + + + + {{ t('workplace.operation') }}{{ item }} + + + + + + + + + xx{{ t('workplace.index') }} + + + + + + + + + {{ t('workplace.team') }} + + + + + + + {{ item.name }} + + + + + + + + + diff --git a/src/views/Dashboard/echarts-data.ts b/src/views/Dashboard/echarts-data.ts index a8a2e9d..42c7159 100644 --- a/src/views/Dashboard/echarts-data.ts +++ b/src/views/Dashboard/echarts-data.ts @@ -151,3 +151,34 @@ export const barOptions: EChartsOption = { } ] } + +export const radarOption: EChartsOption = { + legend: { + data: [t('workplace.personal'), t('workplace.team')] + }, + radar: { + // shape: 'circle', + indicator: [ + { name: t('workplace.quote'), max: 65 }, + { name: t('workplace.contribution'), max: 160 }, + { name: t('workplace.hot'), max: 300 }, + { name: t('workplace.yield'), max: 130 } + ] + }, + series: [ + { + name: `xxx${t('workplace.index')}`, + type: 'radar', + data: [ + { + value: [42, 30, 20, 35], + name: t('workplace.personal') + }, + { + value: [50, 140, 28, 35], + name: t('workplace.team') + } + ] + } + ] +}