This commit is contained in:
josc146 2023-06-02 22:20:57 +08:00
parent b41a2e7039
commit e1df1bfc3f
4 changed files with 16 additions and 14 deletions

View File

@ -28,12 +28,12 @@ func NewApp() *App {
// so we can call the runtime methods
func (a *App) OnStartup(ctx context.Context) {
a.ctx = ctx
ex, _ := os.Executable()
a.exDir = filepath.Dir(ex)
a.exDir = ""
a.cmdPrefix = ""
if runtime.GOOS == "darwin" {
a.exDir += "/../../../"
ex, _ := os.Executable()
a.exDir = filepath.Dir(ex) + "/../../../"
a.cmdPrefix = "cd " + a.exDir + " && "
}

View File

@ -26,7 +26,7 @@ func (a *App) ConvertModel(python string, modelPath string, strategy string, out
if err != nil {
return "", err
}
return Cmd(python, "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", `"`+strategy+`"`)
return Cmd(python, "./backend-python/convert_model.py", "--in", modelPath, "--out", outPath, "--strategy", strategy)
}
func (a *App) DepCheck(python string) error {

View File

@ -46,7 +46,7 @@ func Cmd(args ...string) (string, error) {
return "", err
}
exDir := filepath.Dir(ex) + "/../../../"
cmd := exec.Command("osascript", "-e", `tell application "Terminal" to do script "`+"cd "+exDir+" && "+strings.Join(args, " ")+`"`)
cmd := exec.Command("osascript", "-e", `tell application 'Terminal' to do script '`+"cd "+exDir+" && "+strings.Join(args, " ")+`'`)
err = cmd.Start()
if err != nil {
return "", err

View File

@ -118,15 +118,17 @@ export const Settings: FC = observer(() => {
<AccordionHeader ref={advancedHeaderRef} size="large">{t('Advanced')}</AccordionHeader>
<AccordionPanel>
<div className="flex flex-col gap-2 overflow-hidden">
<Labeled label={t('Custom Models Path')}
content={
<Input className="grow" placeholder="./models" value={commonStore.settings.customModelsPath}
onChange={(e, data) => {
commonStore.setSettings({
customModelsPath: data.value
});
}} />
} />
{commonStore.platform !== 'darwin' &&
<Labeled label={t('Custom Models Path')}
content={
<Input className="grow" placeholder="./models" value={commonStore.settings.customModelsPath}
onChange={(e, data) => {
commonStore.setSettings({
customModelsPath: data.value
});
}} />
} />
}
<Labeled label={t('Custom Python Path')}
content={
<Input className="grow" placeholder="./py310/python" value={commonStore.settings.customPythonPath}