搜索框支持 spk 链接跳转

This commit is contained in:
柚子
2025-03-08 00:22:55 +08:00
parent e0566ba440
commit 1495d806aa

View File

@@ -18,7 +18,17 @@ const TitleBar: Component<TitleBarProps> = (props) => {
const handleSearch = () => {
if (searchInput?.value) {
navigate(`/search?q=${encodeURIComponent(searchInput.value)}`);
if (searchInput.value.startsWith('spk://')) {
// 处理 spk:// 协议
const path = searchInput.value.replace('spk://', '');
const parts = path.split('/');
const category = parts[parts.length - 2];
const pkgname = parts[parts.length - 1];
navigate(`/app/${category}/${pkgname}`);
} else {
// 处理普通搜索
navigate(`/search?q=${encodeURIComponent(searchInput.value)}`);
}
searchInput.value = "";
}
};