mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
chore: use const replace var (#39632)
This commit is contained in:
parent
1b03cfdd29
commit
97cfc17278
@ -179,7 +179,7 @@ class Demo extends React.Component<DemoProps, DemoState> {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container" style="padding: 24px" />
|
<div id="container" style="padding: 24px" />
|
||||||
<script>var mountNode = document.getElementById('container');</script>
|
<script>const mountNode = document.getElementById('container');</script>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
|
|
||||||
|
14
.dumirc.ts
14
.dumirc.ts
@ -42,8 +42,8 @@ export default defineConfig({
|
|||||||
`
|
`
|
||||||
(function () {
|
(function () {
|
||||||
function isLocalStorageNameSupported() {
|
function isLocalStorageNameSupported() {
|
||||||
var testKey = 'test';
|
const testKey = 'test';
|
||||||
var storage = window.localStorage;
|
const storage = window.localStorage;
|
||||||
try {
|
try {
|
||||||
storage.setItem(testKey, '1');
|
storage.setItem(testKey, '1');
|
||||||
storage.removeItem(testKey);
|
storage.removeItem(testKey);
|
||||||
@ -53,13 +53,13 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 优先级提高到所有静态资源的前面,语言不对,加载其他静态资源没意义
|
// 优先级提高到所有静态资源的前面,语言不对,加载其他静态资源没意义
|
||||||
var pathname = location.pathname;
|
const pathname = location.pathname;
|
||||||
|
|
||||||
function isZhCN(pathname) {
|
function isZhCN(pathname) {
|
||||||
return /-cn\\/?$/.test(pathname);
|
return /-cn\\/?$/.test(pathname);
|
||||||
}
|
}
|
||||||
function getLocalizedPathname(path, zhCN) {
|
function getLocalizedPathname(path, zhCN) {
|
||||||
var pathname = path.indexOf('/') === 0 ? path : '/' + path;
|
const pathname = path.indexOf('/') === 0 ? path : '/' + path;
|
||||||
if (!zhCN) {
|
if (!zhCN) {
|
||||||
// to enUS
|
// to enUS
|
||||||
return /\\/?index(-cn)?/.test(pathname) ? '/' : pathname.replace('-cn', '');
|
return /\\/?index(-cn)?/.test(pathname) ? '/' : pathname.replace('-cn', '');
|
||||||
@ -72,9 +72,9 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 兼容旧的 URL, \`?locale=...\`
|
// 兼容旧的 URL, \`?locale=...\`
|
||||||
var queryString = location.search;
|
const queryString = location.search;
|
||||||
if (queryString) {
|
if (queryString) {
|
||||||
var isZhCNConfig = queryString.indexOf('zh-CN') > -1;
|
const isZhCNConfig = queryString.indexOf('zh-CN') > -1;
|
||||||
if (isZhCNConfig && !isZhCN(pathname)) {
|
if (isZhCNConfig && !isZhCN(pathname)) {
|
||||||
location.pathname = getLocalizedPathname(pathname, isZhCNConfig);
|
location.pathname = getLocalizedPathname(pathname, isZhCNConfig);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ export default defineConfig({
|
|||||||
|
|
||||||
// 首页无视链接里面的语言设置 https://github.com/ant-design/ant-design/issues/4552
|
// 首页无视链接里面的语言设置 https://github.com/ant-design/ant-design/issues/4552
|
||||||
if (isLocalStorageNameSupported() && (pathname === '/' || pathname === '/index-cn')) {
|
if (isLocalStorageNameSupported() && (pathname === '/' || pathname === '/index-cn')) {
|
||||||
var lang =
|
const lang =
|
||||||
(window.localStorage && localStorage.getItem('locale')) ||
|
(window.localStorage && localStorage.getItem('locale')) ||
|
||||||
((navigator.language || navigator.browserLanguage).toLowerCase() === 'zh-cn'
|
((navigator.language || navigator.browserLanguage).toLowerCase() === 'zh-cn'
|
||||||
? 'zh-CN'
|
? 'zh-CN'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
import { Col, Row } from '..';
|
import { Col, Row } from '..';
|
||||||
import { render } from '../../../tests/utils';
|
import { render } from '../../../tests/utils';
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { fireEvent, render } from '../../../tests/utils';
|
import { fireEvent, render } from '../../../tests/utils';
|
||||||
import Base from '../Base';
|
import Base from '../Base';
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
|
|
||||||
jest.mock('copy-to-clipboard');
|
jest.mock('copy-to-clipboard');
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import { act } from 'react-dom/test-utils';
|
|||||||
import { fireEvent, render, waitFakeTimer, triggerResize, waitFor } from '../../../tests/utils';
|
import { fireEvent, render, waitFakeTimer, triggerResize, waitFor } from '../../../tests/utils';
|
||||||
import type { EllipsisConfig } from '../Base';
|
import type { EllipsisConfig } from '../Base';
|
||||||
import Base from '../Base';
|
import Base from '../Base';
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
|
|
||||||
jest.mock('copy-to-clipboard');
|
jest.mock('copy-to-clipboard');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user