style(search): 引擎图标统一使用组件库图标
- 移除内联品牌 SVG,改用 @stash/ui 的 Icon 名称 - 快捷栏每个选项都显示图标,左侧触发器同步切换
This commit is contained in:
@@ -1500,6 +1500,9 @@ html.theme-transition .site-background {
|
||||
}
|
||||
|
||||
.engine-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: var(--su-space-1) var(--su-space-2);
|
||||
border: 0;
|
||||
border-radius: var(--su-radius-xs);
|
||||
@@ -1511,6 +1514,11 @@ html.theme-transition .site-background {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.engine-option-icon {
|
||||
display: inline-flex;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.engine-option:hover {
|
||||
background-color: var(--su-bg-subtle);
|
||||
color: var(--su-text-main);
|
||||
|
||||
+10
-47
@@ -64,42 +64,12 @@ type Route =
|
||||
| { kind: 'api' }
|
||||
|
||||
const SEARCH_ENGINES = [
|
||||
{ key: 'local', name: '本地', search: '', path: '', color: '' },
|
||||
{
|
||||
key: 'google',
|
||||
name: 'Google',
|
||||
search: 'https://www.google.com/search?q=',
|
||||
path: 'M12.24 10.285V14.4h6.806c-.275 1.765-2.056 5.174-6.806 5.174-4.095 0-7.439-3.389-7.439-7.574s3.345-7.574 7.439-7.574c2.33 0 3.891.989 4.785 1.849l3.254-3.138C18.189 1.186 15.479 0 12.24 0c-6.635 0-12 5.365-12 12s5.365 12 12 12c6.926 0 11.52-4.869 11.52-11.726 0-.788-.085-1.39-.189-1.989H12.24z',
|
||||
color: '#4285F4',
|
||||
},
|
||||
{
|
||||
key: 'bing',
|
||||
name: 'Bing',
|
||||
search: 'https://www.bing.com/search?q=',
|
||||
path: 'M5 3v14.895l4.09 2.33v-9.497l6.218 3.535 4.692-2.63-8.724-5.031V3z',
|
||||
color: '#00809D',
|
||||
},
|
||||
{
|
||||
key: 'baidu',
|
||||
name: '百度',
|
||||
search: 'https://www.baidu.com/s?wd=',
|
||||
path: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-3-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm6 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-3 6.5c-2.33 0-4.31-1.46-5.11-3.5h10.22c-.8 2.04-2.78 3.5-5.11 3.5z',
|
||||
color: '#2932E1',
|
||||
},
|
||||
{
|
||||
key: 'sogou',
|
||||
name: '搜狗',
|
||||
search: 'https://www.sogou.com/web?query=',
|
||||
path: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1.5 14.5c-2.48 0-4.5-2.02-4.5-4.5h2c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5h2c0 2.48-2.02 4.5-4.5 4.5zM8 9c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm8 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1z',
|
||||
color: '#FB6022',
|
||||
},
|
||||
{
|
||||
key: '360',
|
||||
name: '360',
|
||||
search: 'https://www.so.com/s?q=',
|
||||
path: 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 16c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm0-9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z',
|
||||
color: '#19B955',
|
||||
},
|
||||
{ key: 'local', name: '本地', search: '', icon: 'search_3_line' },
|
||||
{ key: 'google', name: 'Google', search: 'https://www.google.com/search?q=', icon: 'google_fill' },
|
||||
{ key: 'bing', name: 'Bing', search: 'https://www.bing.com/search?q=', icon: 'edge_fill' },
|
||||
{ key: 'baidu', name: '百度', search: 'https://www.baidu.com/s?wd=', icon: 'compass_line' },
|
||||
{ key: 'sogou', name: '搜狗', search: 'https://www.sogou.com/web?query=', icon: 'search_2_line' },
|
||||
{ key: '360', name: '360', search: 'https://www.so.com/s?q=', icon: 'safety_certificate_line' },
|
||||
] as const
|
||||
|
||||
type SearchEngine = (typeof SEARCH_ENGINES)[number]
|
||||
@@ -115,16 +85,6 @@ function readSearchEngine(): SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/** 本地用放大镜;外部引擎用各自的品牌轮廓 */
|
||||
function SearchEngineIcon({ engine }: { engine: SearchEngine }) {
|
||||
if (engine.path === '') return <Icon name="search_3_line" />
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true" focusable="false">
|
||||
<path d={engine.path} fill={engine.color} />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
function parseRoute(pathname: string): Route {
|
||||
const segments = pathname.split('/').filter(Boolean)
|
||||
if (segments[0] === 'interface') return { kind: 'api' }
|
||||
@@ -898,7 +858,7 @@ export default function AppNext() {
|
||||
}
|
||||
onClick={() => setEngineOpen((open) => !open)}
|
||||
>
|
||||
<SearchEngineIcon engine={searchEngine} />
|
||||
<Icon name={searchEngine.icon} />
|
||||
</button>
|
||||
{engineOpen && (
|
||||
<div className="engine-menu" role="menu" aria-label="选择搜索引擎">
|
||||
@@ -911,6 +871,9 @@ export default function AppNext() {
|
||||
className={`engine-option${engine.key === searchEngine.key ? ' is-active' : ''}`}
|
||||
onClick={() => chooseEngine(engine)}
|
||||
>
|
||||
<span className="engine-option-icon">
|
||||
<Icon name={engine.icon} />
|
||||
</span>
|
||||
{engine.name}
|
||||
</button>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user