Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
bs32g1038 committed Mar 29, 2023
1 parent aa416fd commit 357e842
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions client/libs/time/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
*/
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import utc from 'dayjs/plugin/utc';
import relativeTime from 'dayjs/plugin/relativeTime';
import timezone from 'dayjs/plugin/timezone'; // dependent on utc plugin
dayjs.locale('zh-cn');
dayjs.extend(relativeTime);
dayjs.extend(utc);
dayjs.extend(timezone);

export const timeAgo = (timestamp: string) => {
return dayjs(timestamp).fromNow();
return dayjs(timestamp).tz('Asia/Shanghai').fromNow();
};

export const parseTime = (timestamp: string, format = 'YYYY-MM-DD HH:mm') => {
return dayjs(timestamp).format(format);
return dayjs(timestamp).tz('Asia/Shanghai').format(format);
};
2 changes: 1 addition & 1 deletion client/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ export type AppStore = ReturnType<typeof makeStore>;
export type RootState = ReturnType<AppStore['getState']>;
export type AppDispatch = AppStore['dispatch'];

export const wrapper = createWrapper<AppStore>(makeStore, { debug: true });
export const wrapper = createWrapper<AppStore>(makeStore, { debug: process.env.NODE_ENV === 'development' });
1 change: 0 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const path = require('path');
const resolve = (dir) => path.resolve(__dirname, dir);

module.exports = {
experimental: { esmExternals: true },
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\.(txt|svg|ttf)$/,
Expand Down

0 comments on commit 357e842

Please sign in to comment.