Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineConfig } from 'dumi';
import path from 'path';

const isProdSite =
// 不是预览模式 同时是生产环境
process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production';
// const isProdSite =
// // 不是预览模式 同时是生产环境
// process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production';

const name = 'tooltip';
// const name = 'tooltip';

export default defineConfig({
alias: {
Expand All @@ -18,6 +18,6 @@ export default defineConfig({
name: 'Tooltip',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
base: isProdSite ? `/${name}/` : '/',
publicPath: isProdSite ? `/${name}/` : '/',
// base: isProdSite ? `/${name}/` : '/',
// publicPath: isProdSite ? `/${name}/` : '/',
Comment on lines +21 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

base/publicPath 被注释可能导致 gh-pages 子路径部署 404

如果文档站点仍通过 gh-pages 挂载在 /tooltip/,当前配置会以根路径输出,生产访问将异常。建议按环境恢复条件配置。

-  // base: isProdSite ? `/${name}/` : '/',
-  // publicPath: isProdSite ? `/${name}/` : '/',
+  base: isProdSite ? `/${name}/` : '/',
+  publicPath: isProdSite ? `/${name}/` : '/',

请确认当前文档发布目标(例如 Vercel/Netlify 根域名 vs GitHub Pages 子路径)。若已迁移到根域名,可在 PR 描述注明,以免后续误回滚。


🏁 Script executed:

#!/bin/bash
set -euo pipefail
printf "Searching for dumi/umi config files (.dumirc.ts, dumirc.ts, .umirc.ts, umirc.ts)...\n\n"
files=()
while IFS= read -r -d '' f; do files+=("$f"); done < <(find . -type f \( -name ".dumirc.ts" -o -name "dumirc.ts" -o -name ".umirc.ts" -o -name "umirc.ts" \) -print0)
if [ ${#files[@]} -eq 0 ]; then
  printf "No dumi/umi config file found\n\n"
else
  for f in "${files[@]}"; do
    printf "== FILE: %s ==\n" "$f"
    nl -ba -w3 -s': ' "$f" | sed -n '1,200p'
    printf "\n-- Matches for base/publicPath/isProdSite/name in this file --\n"
    rg -n --hidden --no-ignore -S '\b(base|publicPath|isProdSite|name)\b' "$f" || true
    printf "\n\n"
  done
fi

printf "Searching for package.json files and printing key fields (homepage / scripts)...\n\n"
while IFS= read -r -d '' pj; do
  printf "== %s ==\n" "$pj"
  rg -n --hidden --no-ignore -n '"homepage"\s*:' "$pj" || true
  rg -n --hidden --no-ignore -n '"scripts"\s*:' "$pj" || true
  sed -n '1,200p' "$pj"
  printf "\n"
done < <(find . -type f -name package.json -print0)

printf "Searching repo for gh-pages / github.io / vercel / netlify / CNAME references...\n\n"
rg -n --hidden --no-ignore -S 'gh-pages|github\.io|vercel|netlify|CNAME' || true

printf "\nSearching .github/workflows for pages/deploy steps...\n\n"
if [ -d .github/workflows ]; then
  rg -n --hidden --no-ignore -S 'pages|gh-pages|deploy|vercel|netlify|publish' .github/workflows || true
else
  printf "No .github/workflows directory\n"
fi

printf "\nDONE\n"

Length of output: 141


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
# 重试:运行下列脚本以查找相关配置文件并验证 base/publicPath 配置。

echo "1) 查找 dumi/umi 配置文件 (.dumirc.ts, dumirc.ts, .umirc.ts, umirc.ts)..."
if find . -type f \( -name ".dumirc.ts" -o -name "dumirc.ts" -o -name ".umirc.ts" -o -name "umirc.ts" \) -print -quit | grep -q .; then
  find . -type f \( -name ".dumirc.ts" -o -name "dumirc.ts" -o -name ".umirc.ts" -o -name "umirc.ts" \) -print0 | \
  while IFS= read -r -d '' f; do
    echo "== FILE: $f =="
    nl -ba -w3 -s': ' "$f" | sed -n '1,200p'
    echo "-- 匹配 base/publicPath/isProdSite/name --"
    if command -v rg >/dev/null 2>&1; then
      rg -n --hidden --no-ignore -S '\b(base|publicPath|isProdSite|name)\b' "$f" || true
    else
      grep -nE '\b(base|publicPath|isProdSite|name)\b' "$f" || true
    fi
    echo
  done
else
  echo "未找到 dumi/umi 配置文件(.dumirc.ts/dumirc.ts/.umirc.ts/umirc.ts)"
fi

echo
echo "2) 查找 package.json 并显示 homepage / scripts 字段(若存在)..."
if find . -type f -name package.json -print -quit | grep -q .; then
  find . -type f -name package.json -print0 | \
  while IFS= read -r -d '' pj; do
    echo "== $pj =="
    if command -v rg >/dev/null 2>&1; then
      rg -n '"homepage"\s*:' "$pj" || true
      rg -n '"scripts"\s*:' "$pj" || true
    else
      grep -nE '"homepage"\s*:' "$pj" || true
      grep -nE '"scripts"\s*:' "$pj" || true
    fi
    sed -n '1,200p' "$pj" || true
    echo
  done
else
  echo "未找到 package.json 文件"
fi

echo
echo "3) 全仓库关键词搜索:gh-pages / github.io / vercel / netlify / CNAME ..."
if command -v rg >/dev/null 2>&1; then
  rg -n --hidden --no-ignore -S 'gh-pages|github\.io|vercel|netlify|CNAME' || true
else
  grep -RIn --binary-files=without-match -E 'gh-pages|github\.io|vercel|netlify|CNAME' . || true
fi

echo
echo "4) 检查 .github/workflows 中是否有 pages/gh-pages/部署步骤..."
if [ -d .github/workflows ]; then
  if command -v rg >/dev/null 2>&1; then
    rg -n --hidden --no-ignore -S 'pages|gh-pages|deploy|vercel|netlify|publish' .github/workflows || true
  else
    grep -RIn --binary-files=without-match -E 'pages|gh-pages|deploy|vercel|netlify|publish' .github/workflows || true
  fi
else
  echo "未找到 .github/workflows 目录"
fi

echo
echo "完成"

Length of output: 134


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
f="./.dumirc.ts"
if [ -f "$f" ]; then
  echo "找到文件:$f,显示前 200 行并带行号:"
  awk 'NR>=1 && NR<=200 {printf("%4d: %s\n", NR,$0)}' "$f" || true
  echo
  echo "-- 匹配(注释的 base/publicPath & 任何 base/publicPath/isProdSite/name 出现) --"
  grep -nE '^\s*//\s*(base|publicPath)' "$f" || true
  grep -nE '\b(base|publicPath|isProdSite|name)\b' "$f" || true
else
  echo "未找到文件:$f"
fi

Length of output: 1159


修复 .dumirc.ts 的 base/publicPath 环境配置(避免 gh-pages 子路径 404)

验证:./.dumirc.ts 中 isProdSite/name(第 4–9 行)与 base/publicPath(第 21–22 行)均被注释,当前构建会以根路径输出;若站点通过 GitHub Pages 子路径(例如 /tooltip/)发布,将导致 404。

操作建议:

  • 在 ./ .dumirc.ts 恢复环境判断与名称定义并恢复 base/publicPath(第 4–9、21–22 行)。示例:base: isProdSite ? /${name}/ : '/', publicPath: isProdSite ? /${name}/ : '/'。
  • 若已迁移到根域名(Vercel/Netlify),在 PR 描述中声明迁移并改为固定根路径或保留注释以避免误回滚。
🤖 Prompt for AI Agents
.dumirc.ts around lines 4–9 and 21–22: currently isProdSite/name and
base/publicPath lines are commented out causing builds to output to root and
breaking gh-pages subpath routing; restore the environment check and name
definition and re-enable base/publicPath with the conditional values (e.g. base:
isProdSite ? `/${name}/` : '/', publicPath: isProdSite ? `/${name}/` : '/'),
ensure the name variable is defined consistently with isProdSite usage, and if
the site has intentionally migrated to a root domain (Vercel/Netlify) note that
migration in the PR description instead of un-commenting to avoid accidental
rollbacks.

});
12 changes: 12 additions & 0 deletions docs/demo/twoButtons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Two Buttons
order: 8
---

Demonstrates two buttons with different tooltips on hover.

```jsx
import TwoButtonsDemo from '../examples/twoButtons';

export default () => <TwoButtonsDemo />;
```
29 changes: 29 additions & 0 deletions docs/examples/twoButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { UniqueProvider } from '@rc-component/trigger';
import React from 'react';
import '../../assets/bootstrap.less';
import Tooltip from '../../src';

const TwoButtonsDemo = () => (
<UniqueProvider>
<div style={{ margin: 100 }}>
<Tooltip
placement="top"
trigger={['hover']}
overlay="This is the first tooltip"
motion={{ motionName: 'rc-tooltip-zoom' }}
>
<button type="button">Button 1</button>
</Tooltip>
<Tooltip
placement="top"
trigger={['hover']}
overlay="This is the second tooltip"
motion={{ motionName: 'rc-tooltip-zoom' }}
>
<button type="button">Button 2</button>
</Tooltip>
</div>
</UniqueProvider>
);

export default TwoButtonsDemo;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"test": "rc-test"
},
"dependencies": {
"@rc-component/trigger": "^3.0.0",
"@rc-component/util": "^1.0.1",
"@rc-component/trigger": "^3.6.0",
"@rc-component/util": "^1.3.0",
"classnames": "^2.3.1"
},
"devDependencies": {
Expand Down
5 changes: 5 additions & 0 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export interface TooltipProps
zIndex?: number;
styles?: TooltipStyles;
classNames?: TooltipClassNames;
/**
* Configures Tooltip to reuse the background for transition usage.
* This is an experimental API and may not be stable.
*/
unique?: TriggerProps['unique'];
}

export interface TooltipStyles {
Expand Down