ppoffice / hexo-theme-icarus

A simple, delicate, and modern theme for the static site generator Hexo.
https://ppoffice.github.io/hexo-theme-icarus/
MIT License
6.28k stars 1.54k forks source link

Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. #1161

Closed JIeJaitt closed 1 year ago

JIeJaitt commented 1 year ago

Bug描述 使用 hexo g 之后出现的

Deprecation warning: use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info.

系统与环境

node: 16.17.1 v8: 9.4.146.26-node.22 uv: 1.43.0 zlib: 1.2.11 brotli: 1.0.9 ares: 1.18.1 modules: 93 nghttp2: 1.47.0 napi: 8 llhttp: 6.0.9 openssl: 1.1.1q+quic cldr: 41.0 icu: 71.1 tz: 2022a unicode: 14.0 ngtcp2: 0.1.0-DEV nghttp3: 0.1.0-DEV


- 站点配置文件`_config.yml`
```yml
title: 未来可妻
subtitle: ''
description: ''
keywords: null
author: JIeJaitt
language: zh-CN
timezone: ''
url: https://jiejaitt.github.io
root: /
#permalink: ':year/:month/:day/:title/'
# permalink_defaults: null
permalink: posts/:abbrlink.html
abbrlink:
  alg: crc32  # 算法:crc16(default) and crc32
  rep: hex    # 进制:dec(default) and hex

pretty_urls:
  trailing_index: true
  trailing_html: true
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: ':lang'
skip_render: null
new_post_name: ':title.md'
default_layout: post
titlecase: false
external_link:
  enable: true
  field: site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''
index_generator:
  path: ''
  per_page: 10
  order_by: '-date'
default_category: uncategorized
category_map: null
tag_map: null
meta_generator: true
date_format: YYYY-MM-DD
time_format: HH:mm:ss
updated_option: mtime
per_page: 10
pagination_dir: page
include: null
exclude: null
ignore: null
theme: icarus
deploy:
  type: git
  repo: git@github.com:JIeJaitt/jiejaitt.github.io.git
  branch: main

widgets:

    position: left
    type: profile
    author: JIeJaitt
    author_title: 有趣的技术实践分享
    location: Your location
    # avatar: https://pic1.imgdb.cn/item/633988e016f2c2beb149e475.jpg
    avatar: /img/avatar.png
    avatar_rounded: true
    gravatar: 
    follow_link: https://github.com/jiejaitt
    social_links:
        Github:
            icon: fab fa-github
            url: https://github.com/jiejaitt
        Facebook:
            icon: fab fa-facebook
            url: https://facebook.com/jiejaitt
        Twitter:
            icon: fab fa-twitter
            url: https://twitter.com/jiejaitt
        Dribbble:
            icon: fab fa-dribbble
            url: https://dribbble.com/jiejaitt
        RSS:
            icon: fas fa-rss
            url: /
-
    position: right
    type: toc
    index: true
    collapsed: true
    depth: 3
-
    position: left
    type: links
    links:
        Icarus: https://jiejaitt.github.io
        Notion: https://jiejaitt.notion.site
-
    position: left
    type: categories
-
    position: right
    type: recent_posts
-
    position: left
    type: archives
-
    position: left
    type: tags
    order_by: name
    amount: 
    show_count: true
-
    position: left
    type: subscribe_email
    description: 
    feedburner_id: ''
-
    position: left
    type: adsense
    client_id: ''
    slot_id: ''
-
    position: left
    type: followit
    description: 
    action_url: ''
    verification_code: ''

plugins: animejs: true back_to_top: true baidu_analytics: tracking_id: bing_webmaster: tracking_id: busuanzi: false cnzz: id: web_id: cookie_consent: type: info theme: edgeless static: false position: bottom-left policyLink: https://www.cookiesandyou.com/ gallery: true google_analytics: tracking_id: hotjar: site_id: katex: false mathjax: false outdated_browser: false progressbar: true statcounter: project: security: twitter_conversion_tracking: pixel_id:

providers: cdn: jsdelivr fontcdn: google iconcdn: fontawesome

- front-matter

title: 标题 excerpt: 摘要 toc: true



**复现方式**
命令行使用 `hexo g`之后就出现了,试过了网上很多方法和报错里面的把`locale`改成`updateLocale` 也没什么效果,之前该主题的issue在2019年也提过这个问题,但是好像因为issue不符合规范就被作者直接关闭了,所以我这次提一个更加规范的issue。

**期望行为**
正常`hexo g`构建,不会出现该警告或者是报错
**截图**
<img width="1390" alt="image" src="https://user-images.githubusercontent.com/77219045/207503324-3ab73650-274e-4948-9158-8038bbf30218.png">
ppoffice commented 1 year ago

Related to https://github.com/ppoffice/hexo-theme-icarus/issues/1031 https://github.com/ppoffice/hexo-theme-icarus/issues/809.

导致此问题的原因为Icarus中的某些组件在设置日期的语言时,语言的名称与moment.js内置的语言名称不一致。例如_config.yml中设置的语言为zh-CN而moment.js内置的语言名为zh-cn。从而moment.js在加载的过程中会重复加载同一个语言文件,引发Deprecation warning。

有趣的是,在大小写敏感的文件系统上(如NTFS与ext4),重复加载并不会导致warning。因为moment.js在大小写敏感的文件系统上加载zh-CN时会找不到语言文件zh-CN.js(因为moment.js只有zh-cn.js)。而macOS的文件系统APFS对文件的大小写不敏感,所以会触发bug。

此问题已在最新版本的Icarus中修复。

JIeJaitt commented 1 year ago

Related to #1031 #809.

导致此问题的原因为Icarus中的某些组件在设置日期的语言时,语言的名称与moment.js内置的语言名称不一致。例如_config.yml中设置的语言为zh-CN而moment.js内置的语言名为zh-cn。从而moment.js在加载的过程中会重复加载同一个语言文件,引发Deprecation warning。

有趣的是,在大小写敏感的文件系统上(如NTFS与ext4),重复加载并不会导致warning。因为moment.js在大小写敏感的文件系统上加载zh-CN时会找不到语言文件zh-CN.js(因为moment.js只有zh-cn.js)。而macOS的文件系统APFS对文件的大小写不敏感,所以会触发bug。

此问题已在最新版本的Icarus中修复。

感谢解答,我在升级版本之后就没有再出现过该错误了