fix: 修复视图, 当日期没有数据时,前端显示Invalid Date (#767)

![image](/attachments/be7d49d9-2d06-4f06-8087-46be51add4cb)
![image](/attachments/f969e654-7d3f-4eef-8bea-21f8dcf3a909)

Co-authored-by: sealday <zhanglin@daoyoucloud.com>
Reviewed-on: daoyoucloud/tachybase#767
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-04-19 14:17:16 +08:00 committed by sealday
parent 95fc2c4e16
commit e9a090d674

View File

@ -36,6 +36,13 @@ export class LocalePlugin extends Plugin {
const dayjsLang = dayjsLocale[data?.data?.lang] || 'en';
await import(`dayjs/locale/${dayjsLang}`);
dayjs.locale(dayjsLang);
// 防止数据源没有日期值的时候, 界面显示 Invalid Date
const updateLocale = await import('dayjs/plugin/updateLocale');
dayjs.extend(updateLocale.default);
const localeSetting = { invalidDate: '-' };
dayjs.updateLocale(dayjsLang, localeSetting);
window['cronLocale'] = data?.data?.cron;
} catch (error) {
(() => {})();