@@ -13,13 +13,17 @@ import { store } from "@/state";
1313import { exit , writeStderr } from "@/utils/otherApi" ;
1414import { getCurrentWindow , isDesktop , isMobile , isWeb } from "@/utils/platform" ;
1515import { getMatches } from "@tauri-apps/plugin-cli" ;
16+ import { exists } from "@tauri-apps/plugin-fs" ;
1617import "driver.js/dist/driver.css" ;
1718import i18next from "i18next" ;
1819import { Provider } from "jotai" ;
1920import { createRoot } from "react-dom/client" ;
2021import { initReactI18next } from "react-i18next" ;
22+ import { toast } from "sonner" ;
2123import VConsole from "vconsole" ;
24+ import { URI } from "vscode-uri" ;
2225import App from "./App" ;
26+ import { onOpenFile } from "./core/service/GlobalMenu" ;
2327import "./css/index.css" ;
2428
2529if ( import . meta. env . DEV && isMobile ) {
@@ -45,6 +49,7 @@ const el = document.getElementById("root")!;
4549 // 这些东西依赖上面的东西,所以单独一个Promise.all
4650 await Promise . all ( [ loadLanguageFiles ( ) , loadSyncModules ( ) ] ) ;
4751 await renderApp ( isCliMode ) ;
52+ await loadStartFile ( ) ;
4853 if ( isCliMode ) {
4954 try {
5055 await runCli ( matches ) ;
@@ -104,3 +109,16 @@ async function renderApp(cli: boolean = false) {
104109 ) ;
105110 }
106111}
112+
113+ async function loadStartFile ( ) {
114+ const cliMatches = await getMatches ( ) ;
115+ if ( cliMatches . args . path . value ) {
116+ const path = cliMatches . args . path . value as string ;
117+ const isExists = await exists ( path ) ;
118+ if ( isExists ) {
119+ onOpenFile ( URI . file ( path ) , "CLI或双击文件" ) ;
120+ } else {
121+ toast . error ( "文件不存在" ) ;
122+ }
123+ }
124+ }
0 commit comments