File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import IoC from "@App/app/ioc";
66import LoggerCore from "@App/app/logger/core" ;
77import Logger from "@App/app/logger/logger" ;
88import { SystemConfig } from "@App/pkg/config/config" ;
9- import { checkSilenceUpdate , ltever } from "@App/pkg/utils/utils" ;
9+ import {
10+ checkSilenceUpdate ,
11+ ltever ,
12+ openInCurrentTab ,
13+ } from "@App/pkg/utils/utils" ;
1014import Manager from "../manager" ;
1115import { Script , SCRIPT_STATUS_DISABLE , ScriptDAO } from "../../repo/scripts" ;
1216import ScriptEventListener from "./event" ;
@@ -118,9 +122,7 @@ export class ScriptManager extends Manager {
118122 // 清理缓存
119123 Cache . getInstance ( ) . del ( CacheKey . scriptInfo ( info . uuid ) ) ;
120124 } , 60 * 1000 ) ;
121- chrome . tabs . create ( {
122- url : `/src/install.html?uuid=${ info . uuid } ` ,
123- } ) ;
125+ openInCurrentTab ( `/src/install.html?uuid=${ info . uuid } ` ) ;
124126 } ) ;
125127 }
126128
Original file line number Diff line number Diff line change @@ -101,8 +101,10 @@ export default function Description() {
101101 if ( t > 0 ) {
102102 return t - 1 ;
103103 }
104- closeWindow ( ) ;
105- return 0 ;
104+ if ( t === 0 ) {
105+ closeWindow ( ) ;
106+ }
107+ return t ;
106108 } ) ;
107109 } , 1000 ) ;
108110 } , [ countdown ] ) ;
@@ -308,9 +310,15 @@ export default function Description() {
308310 type = "primary"
309311 status = "danger"
310312 size = "small"
311- onClick = { closeWindow }
313+ onClick = { ( ) => {
314+ if ( countdown === - 1 ) {
315+ closeWindow ( ) ;
316+ } else {
317+ setCountdown ( - 1 ) ;
318+ }
319+ } }
312320 >
313- 关闭 { countdown !== - 1 && < > ( { countdown } )</ > }
321+ { countdown === - 1 ? "关闭" : `停止( $ {countdown } )` }
314322 </ Button >
315323 </ Space >
316324 </ div >
Original file line number Diff line number Diff line change @@ -217,11 +217,11 @@ function ScriptList() {
217217 }
218218 } ,
219219 className : "max-w-[240px]" ,
220- render : ( col ) => {
220+ render : ( col , item : ListType ) => {
221221 return (
222222 < Tooltip content = { col } position = "tl" >
223223 < Link
224- to = { `/script/editor/${ col . id } ` }
224+ to = { `/script/editor/${ item . id } ` }
225225 style = { {
226226 textDecoration : "none" ,
227227 } }
Original file line number Diff line number Diff line change @@ -272,3 +272,24 @@ export function calculateMd5(blob: Blob) {
272272 } ;
273273 } ) ;
274274}
275+
276+ // 在当前页后打开一个新页面
277+ export function openInCurrentTab ( url : string ) {
278+ chrome . tabs . query (
279+ {
280+ active : true ,
281+ } ,
282+ ( tabs ) => {
283+ if ( tabs . length ) {
284+ chrome . tabs . create ( {
285+ url,
286+ index : tabs [ 0 ] . index + 1 ,
287+ } ) ;
288+ } else {
289+ chrome . tabs . create ( {
290+ url,
291+ } ) ;
292+ }
293+ }
294+ ) ;
295+ }
You can’t perform that action at this time.
0 commit comments