mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-21 21:53:50 +08:00
!394 新增 spark-store 支持处理 apt://包名 格式的链接,转成 spk://search/包名协议来处理
Merge pull request !394 from 球球代码研发助手/implement-33298693-hy0X
This commit is contained in:
@@ -45,7 +45,7 @@ class ListenersMap {
|
||||
}
|
||||
}
|
||||
|
||||
const protocols = ["spk"];
|
||||
const protocols = ["spk", "apt"];
|
||||
const listeners = new ListenersMap();
|
||||
|
||||
export const deepLink = {
|
||||
@@ -81,6 +81,22 @@ export function handleCommandLine(commandLine: string[]) {
|
||||
try {
|
||||
const url = new URL(target);
|
||||
|
||||
// Handle apt:// protocol: convert to spk://search/pkgname
|
||||
if (url.protocol === "apt:") {
|
||||
// Format: apt://pkgname
|
||||
const pkgname = url.hostname || url.pathname.split("/").filter(Boolean)[0];
|
||||
if (pkgname) {
|
||||
const query: Query = { pkgname };
|
||||
logger.info(`Deep link: apt protocol converted to search: ${pkgname}`);
|
||||
listeners.emit("search", query);
|
||||
} else {
|
||||
logger.warn(
|
||||
`Deep link: invalid apt format, expected //pkgname, got ${target}`,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const action = url.hostname; // 'search'
|
||||
logger.info(`Deep link: action found: ${action}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user