mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 14:13:49 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e8758b5f2 | |||
| e84c1d86bf | |||
| e39525901e |
@@ -26,6 +26,7 @@ linux:
|
||||
Categories: "System;"
|
||||
mimeTypes:
|
||||
- "x-scheme-handler/spk"
|
||||
- "x-scheme-handler/apt"
|
||||
target:
|
||||
- "AppImage"
|
||||
- "deb"
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
|
||||
@@ -318,6 +318,21 @@ ipcMain.handle("check-for-updates", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Register custom protocol handlers
|
||||
if (process.defaultApp) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient("spk", process.execPath, [
|
||||
path.resolve(process.argv[1]),
|
||||
]);
|
||||
app.setAsDefaultProtocolClient("apt", process.execPath, [
|
||||
path.resolve(process.argv[1]),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
app.setAsDefaultProtocolClient("spk");
|
||||
app.setAsDefaultProtocolClient("apt");
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// Set User-Agent for client
|
||||
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
|
||||
|
||||
@@ -10,4 +10,4 @@ Keywords=appstore;
|
||||
Terminal=false
|
||||
StartupNotify=true
|
||||
StartupWMClass=spark-store
|
||||
MimeType=x-scheme-handler/spk
|
||||
MimeType=x-scheme-handler/spk;x-scheme-handler/apt
|
||||
|
||||
@@ -262,23 +262,6 @@
|
||||
|
||||
<!-- 右侧:应用详情(上)+ 截图(下) -->
|
||||
<div class="flex-1 min-w-0 space-y-5">
|
||||
<!-- 警醒横幅 - 早于一年未更新 -->
|
||||
<div
|
||||
v-if="displayApp?.update && isOutdated(displayApp.update)"
|
||||
class="rounded-2xl border-l-4 border-amber-500 bg-amber-50 p-4 dark:bg-amber-950/30 dark:border-amber-600"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-exclamation-triangle text-amber-500 text-lg"></i>
|
||||
<div>
|
||||
<p class="text-sm font-medium text-amber-800 dark:text-amber-300">
|
||||
注意:该软件已超过一年未更新
|
||||
</p>
|
||||
<p class="text-xs text-amber-700/80 dark:text-amber-400/80 mt-0.5">
|
||||
最后更新于 {{ displayApp.update }},可能存在兼容性或安全问题,请谨慎安装。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 应用详情 -->
|
||||
<div
|
||||
v-if="displayApp?.more && displayApp.more.trim() !== ''"
|
||||
@@ -650,19 +633,4 @@ const onOverlayWheel = (e: WheelEvent) => {
|
||||
if (target.closest(".overflow-y-auto, .overflow-auto")) return;
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
// 判断是否超过一年未更新
|
||||
const isOutdated = (updateDate: string) => {
|
||||
if (!updateDate) return false;
|
||||
try {
|
||||
// 假设日期格式如 "2023-01-15" 或 "2024年12月20日"
|
||||
const date = new Date(updateDate);
|
||||
if (isNaN(date.getTime())) return false;
|
||||
const oneYearAgo = new Date();
|
||||
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1);
|
||||
return date < oneYearAgo;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user