@umijs/plugin-docs 4.0.0-rc.5 → 4.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,17 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import useLanguage from './useLanguage';
3
3
 
4
4
  export default () => {
5
- const { currentLanguage, languages, switchLanguage } = useLanguage();
5
+ const { currentLanguage, languages, switchLanguage, isFromPath } =
6
+ useLanguage();
6
7
  const [isExpanded, setExpanded] = useState(false);
7
8
 
9
+ // 首次加载时,根据 localstorage 记录的上次语言自动切换
10
+ useEffect(() => {
11
+ const locale = window.localStorage.getItem('umi_locale');
12
+ if (locale && !isFromPath) switchLanguage(locale);
13
+ }, []);
14
+
8
15
  if (!currentLanguage) {
9
16
  return null;
10
17
  }
@@ -65,7 +65,7 @@ export default () => {
65
65
  <div
66
66
  className="rounded-lg w-40 lg:w-64 flex items-center pr-2 flex-row hover:bg-gray-50
67
67
  transition duration-300 bg-gray-100 border border-white focus-within:border-gray-100
68
- focus-within:bg-white dark:bg-gray-700 dark:border-gray-700
68
+ focus-within:bg-white dark:bg-gray-700 dark:border-gray-700 relative
69
69
  dark:focus-within:border-gray-700 dark:focus-within:bg-gray-800 dark:text-gray-100"
70
70
  >
71
71
  <input
@@ -74,7 +74,7 @@ export default () => {
74
74
  value={keyword}
75
75
  onChange={(e) => setKeyword(e.target.value)}
76
76
  id="search-input"
77
- className="w-full bg-transparent outline-0 text-sm px-4 py-2 "
77
+ className="w-full bg-transparent outline-none text-sm px-4 py-2 "
78
78
  placeholder={render('Search anything ...')}
79
79
  />
80
80
  <div
@@ -85,7 +85,7 @@ export default () => {
85
85
  </div>
86
86
  <div
87
87
  className={cx(
88
- 'absolute transition-all duration-500 top-16 w-96 rounded-lg',
88
+ 'absolute transition-all duration-500 top-12 w-96 rounded-lg',
89
89
  'cursor-pointer shadow overflow-hidden',
90
90
  result.length > 0 && isFocused ? 'max-h-80' : 'max-h-0',
91
91
  )}
@@ -660,10 +660,6 @@ Ensure the default browser behavior of the `hidden` attribute.
660
660
  top: 3rem;
661
661
  }
662
662
 
663
- .top-16 {
664
- top: 4rem;
665
- }
666
-
667
663
  .right-2 {
668
664
  right: 0.5rem;
669
665
  }
@@ -1326,10 +1322,6 @@ Ensure the default browser behavior of the `hidden` attribute.
1326
1322
  outline-offset: 2px;
1327
1323
  }
1328
1324
 
1329
- .outline-0 {
1330
- outline-width: 0px;
1331
- }
1332
-
1333
1325
  .blur {
1334
1326
  --tw-blur: blur(8px);
1335
1327
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
@@ -35,6 +35,7 @@ function useLanguage(): useLanguageResult {
35
35
 
36
36
  // 切换到默认语言
37
37
  if (locale === languages[0].locale && isFromPath) {
38
+ window.localStorage.removeItem('umi_locale');
38
39
  let p = location.pathname.split('/');
39
40
  p.shift();
40
41
  p.shift();
@@ -42,6 +43,8 @@ function useLanguage(): useLanguageResult {
42
43
  return;
43
44
  }
44
45
 
46
+ window.localStorage.setItem('umi_locale', locale);
47
+
45
48
  // 当前在默认语言,切换到其他语言
46
49
  if (!isFromPath) {
47
50
  history.push('/' + locale + location.pathname);
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Compositor, Inc. and Vercel, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.