@@ -12,7 +12,7 @@ import PermissionVerify, { PermissionVerifyApiGet } from "./permission_verify";
1212import { cacheInstance } from "@App/app/cache" ;
1313import EventEmitter from "eventemitter3" ;
1414import { type RuntimeService } from "./runtime" ;
15- import { getIcon , isFirefox , openInCurrentTab , cleanFileName } from "@App/pkg/utils/utils" ;
15+ import { getIcon , isFirefox , openInCurrentTab , cleanFileName , getCurrentTab } from "@App/pkg/utils/utils" ;
1616import { type SystemConfig } from "@App/pkg/config/config" ;
1717import i18next , { i18nName } from "@App/locales/locales" ;
1818import FileSystemFactory from "@Packages/filesystem/factory" ;
@@ -854,9 +854,12 @@ export default class GMApi {
854854 const getNewTabId = async ( ) => {
855855 const { tabId, windowId } = sender . getExtMessageSender ( ) ;
856856 const active = options . active ;
857- const currentTab = await chrome . tabs . get ( tabId ) ;
857+ let currentTab : chrome . tabs . Tab | undefined ;
858+ if ( tabId !== - 1 ) {
859+ currentTab = await chrome . tabs . get ( tabId ) ;
860+ }
858861 let newTabIndex = - 1 ;
859- if ( options . incognito && ! currentTab . incognito ) {
862+ if ( options . incognito && ! currentTab ? .incognito ) {
860863 // incognito: "split" 在 normal 里不会看到 incognito
861864 // 只能创建新 incognito window
862865 // pinned 无效
0 commit comments