mirror of
https://github.com/usememos/memos.git
synced 2025-04-02 20:10:45 +02:00
chore: remove unused flags
This commit is contained in:
parent
5742f9ca13
commit
10c57167cc
@ -36,8 +36,6 @@ var (
|
|||||||
data string
|
data string
|
||||||
driver string
|
driver string
|
||||||
dsn string
|
dsn string
|
||||||
serveFrontend bool
|
|
||||||
allowedOrigins []string
|
|
||||||
instanceProfile *profile.Profile
|
instanceProfile *profile.Profile
|
||||||
|
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
@ -111,8 +109,6 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&data, "data", "d", "", "data directory")
|
rootCmd.PersistentFlags().StringVarP(&data, "data", "d", "", "data directory")
|
||||||
rootCmd.PersistentFlags().StringVarP(&driver, "driver", "", "", "database driver")
|
rootCmd.PersistentFlags().StringVarP(&driver, "driver", "", "", "database driver")
|
||||||
rootCmd.PersistentFlags().StringVarP(&dsn, "dsn", "", "", "database source name(aka. DSN)")
|
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"))
|
err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -138,21 +134,11 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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("mode", "demo")
|
||||||
viper.SetDefault("driver", "sqlite")
|
viper.SetDefault("driver", "sqlite")
|
||||||
viper.SetDefault("addr", "")
|
viper.SetDefault("addr", "")
|
||||||
viper.SetDefault("port", 8081)
|
viper.SetDefault("port", 8081)
|
||||||
viper.SetDefault("frontend", true)
|
|
||||||
viper.SetDefault("origins", []string{})
|
|
||||||
viper.SetEnvPrefix("memos")
|
viper.SetEnvPrefix("memos")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +160,8 @@ addr: %s
|
|||||||
port: %d
|
port: %d
|
||||||
mode: %s
|
mode: %s
|
||||||
driver: %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() {
|
func printGreetings() {
|
||||||
|
@ -30,10 +30,6 @@ type Profile struct {
|
|||||||
Driver string `json:"-"`
|
Driver string `json:"-"`
|
||||||
// Version is the current version of server
|
// Version is the current version of server
|
||||||
Version string `json:"version"`
|
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 {
|
func (p *Profile) IsDev() bool {
|
||||||
|
@ -61,11 +61,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
|||||||
return c.String(http.StatusOK, "Service ready.")
|
return c.String(http.StatusOK, "Service ready.")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Only serve frontend when it's enabled.
|
// Serve frontend resources.
|
||||||
if profile.Frontend {
|
frontend.NewFrontendService(profile, store).Serve(ctx, echoServer)
|
||||||
frontendService := frontend.NewFrontendService(profile, store)
|
|
||||||
frontendService.Serve(ctx, echoServer)
|
|
||||||
}
|
|
||||||
|
|
||||||
rootGroup := echoServer.Group("")
|
rootGroup := echoServer.Group("")
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
VITE_API_BASE_URL=http://localhost:8081
|
|
@ -13,7 +13,7 @@ import { WorkspaceServiceDefinition } from "./types/proto/api/v1/workspace_servi
|
|||||||
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v1/workspace_setting_service";
|
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v1/workspace_setting_service";
|
||||||
|
|
||||||
const channel = createChannel(
|
const channel = createChannel(
|
||||||
import.meta.env.VITE_API_BASE_URL || window.location.origin,
|
window.location.origin,
|
||||||
FetchTransport({
|
FetchTransport({
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
}),
|
}),
|
||||||
|
@ -5,7 +5,7 @@ export const getResourceUrl = (resource: Resource) => {
|
|||||||
return resource.externalLink;
|
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) => {
|
export const getResourceType = (resource: Resource) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user