chore: remove unused flags

This commit is contained in:
Steven 2024-05-03 07:16:07 +08:00
parent 5742f9ca13
commit 10c57167cc
6 changed files with 5 additions and 28 deletions

View File

@ -36,8 +36,6 @@ var (
data string
driver string
dsn string
serveFrontend bool
allowedOrigins []string
instanceProfile *profile.Profile
rootCmd = &cobra.Command{
@ -111,8 +109,6 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&data, "data", "d", "", "data directory")
rootCmd.PersistentFlags().StringVarP(&driver, "driver", "", "", "database driver")
rootCmd.PersistentFlags().StringVarP(&dsn, "dsn", "", "", "database source name(aka. DSN)")
rootCmd.PersistentFlags().BoolVarP(&serveFrontend, "frontend", "", true, "serve frontend files")
rootCmd.PersistentFlags().StringArrayVarP(&allowedOrigins, "origins", "", []string{}, "CORS allowed domain origins")
err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))
if err != nil {
@ -138,21 +134,11 @@ func init() {
if err != nil {
panic(err)
}
err = viper.BindPFlag("frontend", rootCmd.PersistentFlags().Lookup("frontend"))
if err != nil {
panic(err)
}
err = viper.BindPFlag("origins", rootCmd.PersistentFlags().Lookup("origins"))
if err != nil {
panic(err)
}
viper.SetDefault("mode", "demo")
viper.SetDefault("driver", "sqlite")
viper.SetDefault("addr", "")
viper.SetDefault("port", 8081)
viper.SetDefault("frontend", true)
viper.SetDefault("origins", []string{})
viper.SetEnvPrefix("memos")
}
@ -174,9 +160,8 @@ addr: %s
port: %d
mode: %s
driver: %s
frontend: %t
---
`, instanceProfile.Version, instanceProfile.Data, instanceProfile.DSN, instanceProfile.Addr, instanceProfile.Port, instanceProfile.Mode, instanceProfile.Driver, instanceProfile.Frontend)
`, instanceProfile.Version, instanceProfile.Data, instanceProfile.DSN, instanceProfile.Addr, instanceProfile.Port, instanceProfile.Mode, instanceProfile.Driver)
}
func printGreetings() {

View File

@ -30,10 +30,6 @@ type Profile struct {
Driver string `json:"-"`
// Version is the current version of server
Version string `json:"version"`
// Frontend indicate the frontend is enabled or not
Frontend bool `json:"-"`
// Origins is the list of allowed origins
Origins []string `json:"-"`
}
func (p *Profile) IsDev() bool {

View File

@ -61,11 +61,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
return c.String(http.StatusOK, "Service ready.")
})
// Only serve frontend when it's enabled.
if profile.Frontend {
frontendService := frontend.NewFrontendService(profile, store)
frontendService.Serve(ctx, echoServer)
}
// Serve frontend resources.
frontend.NewFrontendService(profile, store).Serve(ctx, echoServer)
rootGroup := echoServer.Group("")

View File

@ -1 +0,0 @@
VITE_API_BASE_URL=http://localhost:8081

View File

@ -13,7 +13,7 @@ import { WorkspaceServiceDefinition } from "./types/proto/api/v1/workspace_servi
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v1/workspace_setting_service";
const channel = createChannel(
import.meta.env.VITE_API_BASE_URL || window.location.origin,
window.location.origin,
FetchTransport({
credentials: "include",
}),

View File

@ -5,7 +5,7 @@ export const getResourceUrl = (resource: Resource) => {
return resource.externalLink;
}
return `${import.meta.env.VITE_API_BASE_URL || window.location.origin}/file/${resource.name}`;
return `${window.location.origin}/file/${resource.name}`;
};
export const getResourceType = (resource: Resource) => {