mirror of
https://github.com/usememos/memos.git
synced 2025-10-26 22:36:16 +08:00
refactor: remove unused constants
This commit is contained in:
parent
b685ffacdf
commit
bc7decf642
37 changed files with 38 additions and 62 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -4,8 +4,9 @@ tmp
|
|||
# Frontend asset
|
||||
web/dist
|
||||
|
||||
# build folder
|
||||
build
|
||||
# Build artifacts
|
||||
build/
|
||||
bin/
|
||||
|
||||
.DS_Store
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ before:
|
|||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- main: ./bin/memos
|
||||
- main: ./cmd/memos
|
||||
binary: memos
|
||||
goos:
|
||||
- linux
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
Memos pairs a Go backend with a Vite React client. The CLI entry in `bin/memos` boots the HTTP server under `server`, backed by shared domain logic in `internal` and persistence adapters in `store`. Frontend code lives in `web/src` with static assets in `web/public`; `pnpm release` publishes bundles into `server/router/frontend/dist`. API schemas sit in `proto/` (Buf-managed), extensions in `plugin/`, deployment helpers in `scripts/`, and sample SQLite databases in `build/`.
|
||||
Memos pairs a Go backend with a Vite React client. The CLI entry in `cmd/memos` boots the HTTP server under `server`, backed by shared domain logic in `internal` and persistence adapters in `store`. Frontend code lives in `web/src` with static assets in `web/public`; `pnpm release` publishes bundles into `server/router/frontend/dist`. API schemas sit in `proto/` (Buf-managed), extensions in `plugin/`, deployment helpers in `scripts/`, and sample SQLite databases in `build/`.
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
- `go run ./bin/memos --mode dev --port 8081` – start the backend with the default SQLite store.
|
||||
- `go build ./bin/memos` – compile the backend binary.
|
||||
- `go run ./cmd/memos --mode dev --port 8081` – start the backend with the default SQLite store.
|
||||
- `go build ./cmd/memos` – compile the backend binary.
|
||||
- `go test ./...` – run Go unit and store tests.
|
||||
- `cd web && pnpm install` – install frontend dependencies.
|
||||
- `cd web && pnpm dev` – start the Vite dev server with hot reload.
|
||||
|
|
|
|||
|
|
@ -278,6 +278,8 @@ func buildValueExpr(expr *exprv1.Expr, schema Schema) (ValueExpr, error) {
|
|||
if ok {
|
||||
return &LiteralValue{Value: value}, nil
|
||||
}
|
||||
default:
|
||||
// Fall through to error return below
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -402,10 +404,12 @@ func evaluateNumeric(expr *exprv1.Expr) (int64, bool, error) {
|
|||
return left - right, true, nil
|
||||
case "_*_":
|
||||
return left * right, true, nil
|
||||
default:
|
||||
return 0, false, errors.Errorf("unsupported arithmetic operator %q", call.Function)
|
||||
}
|
||||
default:
|
||||
return 0, false, nil
|
||||
}
|
||||
|
||||
return 0, false, nil
|
||||
}
|
||||
|
||||
func timeNowUnix() int64 {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ COPY . .
|
|||
# Refer to `pnpm release` in package.json for the build command.
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go build -ldflags="-s -w" -o memos ./bin/memos/main.go
|
||||
go build -ldflags="-s -w" -o memos ./cmd/memos
|
||||
|
||||
# Make workspace with above generated files.
|
||||
FROM alpine:latest AS monolithic
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export GOCACHE="$(pwd)/build/.gocache"
|
|||
export GOMODCACHE="$(pwd)/build/.gomodcache"
|
||||
|
||||
# Build the executable
|
||||
go build -o "$OUTPUT" ./bin/memos
|
||||
go build -o "$OUTPUT" ./cmd/memos
|
||||
|
||||
echo "Build successful!"
|
||||
echo "To run the application, execute the following command:"
|
||||
|
|
|
|||
|
|
@ -359,14 +359,12 @@ func (*APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.Sessio
|
|||
userAgent = strings.ToLower(userAgent)
|
||||
|
||||
// Detect device type
|
||||
if strings.Contains(userAgent, "ipad") {
|
||||
if strings.Contains(userAgent, "ipad") || strings.Contains(userAgent, "tablet") {
|
||||
clientInfo.DeviceType = "tablet"
|
||||
} else if strings.Contains(userAgent, "mobile") || strings.Contains(userAgent, "android") ||
|
||||
strings.Contains(userAgent, "iphone") || strings.Contains(userAgent, "ipod") ||
|
||||
strings.Contains(userAgent, "windows phone") || strings.Contains(userAgent, "blackberry") {
|
||||
clientInfo.DeviceType = "mobile"
|
||||
} else if strings.Contains(userAgent, "tablet") {
|
||||
clientInfo.DeviceType = "tablet"
|
||||
} else {
|
||||
clientInfo.DeviceType = "desktop"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ func convertStateFromStore(rowStatus store.RowStatus) v1pb.State {
|
|||
|
||||
func convertStateToStore(state v1pb.State) store.RowStatus {
|
||||
switch state {
|
||||
case v1pb.State_NORMAL:
|
||||
return store.Normal
|
||||
case v1pb.State_ARCHIVED:
|
||||
return store.Archived
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -216,8 +216,6 @@ func convertInboxStatusFromStore(status store.InboxStatus) v1pb.Inbox_Status {
|
|||
|
||||
func convertInboxStatusToStore(status v1pb.Inbox_Status) store.InboxStatus {
|
||||
switch status {
|
||||
case v1pb.Inbox_UNREAD:
|
||||
return store.UNREAD
|
||||
case v1pb.Inbox_ARCHIVED:
|
||||
return store.ARCHIVED
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -299,8 +299,6 @@ func convertListKindToASTNode(kind v1pb.ListNode_Kind) ast.ListKind {
|
|||
return ast.OrderedList
|
||||
case v1pb.ListNode_UNORDERED:
|
||||
return ast.UnorderedList
|
||||
case v1pb.ListNode_DESCRIPTION:
|
||||
return ast.DescriptionList
|
||||
default:
|
||||
// Default to description list.
|
||||
return ast.DescriptionList
|
||||
|
|
|
|||
|
|
@ -160,8 +160,6 @@ func convertMemoRelationTypeFromStore(relationType store.MemoRelationType) v1pb.
|
|||
|
||||
func convertMemoRelationTypeToStore(relationType v1pb.MemoRelation_Type) store.MemoRelationType {
|
||||
switch relationType {
|
||||
case v1pb.MemoRelation_REFERENCE:
|
||||
return store.MemoRelationReference
|
||||
case v1pb.MemoRelation_COMMENT:
|
||||
return store.MemoRelationComment
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -892,16 +892,11 @@ func (*APIV1Service) parseMemoOrderBy(orderBy string, memoFind *store.FindMemo)
|
|||
}
|
||||
|
||||
switch field {
|
||||
case "display_time":
|
||||
memoFind.OrderByTimeAsc = direction == "asc"
|
||||
case "create_time":
|
||||
case "display_time", "create_time", "name":
|
||||
memoFind.OrderByTimeAsc = direction == "asc"
|
||||
case "update_time":
|
||||
memoFind.OrderByUpdatedTs = true
|
||||
memoFind.OrderByTimeAsc = direction == "asc"
|
||||
case "name":
|
||||
// For ordering by memo name/id - not commonly used but supported
|
||||
memoFind.OrderByTimeAsc = direction == "asc"
|
||||
default:
|
||||
return errors.Errorf("unsupported order field: %s, supported fields are: display_time, create_time, update_time, name", field)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,8 +134,6 @@ func convertVisibilityFromStore(visibility store.Visibility) v1pb.Visibility {
|
|||
|
||||
func convertVisibilityToStore(visibility v1pb.Visibility) store.Visibility {
|
||||
switch visibility {
|
||||
case v1pb.Visibility_PRIVATE:
|
||||
return store.Private
|
||||
case v1pb.Visibility_PROTECTED:
|
||||
return store.Protected
|
||||
case v1pb.Visibility_PUBLIC:
|
||||
|
|
|
|||
|
|
@ -331,8 +331,6 @@ func (s *APIV1Service) validateFilter(ctx context.Context, filterStr string) err
|
|||
|
||||
var dialect filter.DialectName
|
||||
switch s.Profile.Driver {
|
||||
case "sqlite":
|
||||
dialect = filter.DialectSQLite
|
||||
case "mysql":
|
||||
dialect = filter.DialectMySQL
|
||||
case "postgres":
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package v1
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func (s *APIV1Service) ListUsers(ctx context.Context, request *v1pb.ListUsersReq
|
|||
userFind := &store.FindUser{}
|
||||
|
||||
if request.Filter != "" {
|
||||
if err := s.validateUserFilter(ctx, request.Filter); err != nil {
|
||||
if err := validateUserFilter(ctx, request.Filter); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid filter: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1065,8 +1065,6 @@ func convertUserRoleToStore(role v1pb.User_Role) store.Role {
|
|||
return store.RoleHost
|
||||
case v1pb.User_ADMIN:
|
||||
return store.RoleAdmin
|
||||
case v1pb.User_USER:
|
||||
return store.RoleUser
|
||||
default:
|
||||
return store.RoleUser
|
||||
}
|
||||
|
|
@ -1147,10 +1145,6 @@ func convertUserSettingFromStore(storeSetting *storepb.UserSetting, userID int32
|
|||
}
|
||||
|
||||
switch key {
|
||||
case storepb.UserSetting_GENERAL:
|
||||
setting.Value = &v1pb.UserSetting_GeneralSetting_{
|
||||
GeneralSetting: getDefaultUserGeneralSetting(),
|
||||
}
|
||||
case storepb.UserSetting_SESSIONS:
|
||||
setting.Value = &v1pb.UserSetting_SessionsSetting_{
|
||||
SessionsSetting: &v1pb.UserSetting_SessionsSetting{
|
||||
|
|
@ -1365,7 +1359,7 @@ func extractWebhookIDFromName(name string) string {
|
|||
}
|
||||
|
||||
// validateUserFilter validates the user filter string.
|
||||
func (s *APIV1Service) validateUserFilter(_ context.Context, filterStr string) error {
|
||||
func validateUserFilter(_ context.Context, filterStr string) error {
|
||||
if strings.TrimSpace(filterStr) != "" {
|
||||
return errors.New("user filters are not supported")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ func (v Visibility) String() string {
|
|||
return "PUBLIC"
|
||||
case Protected:
|
||||
return "PROTECTED"
|
||||
case Private:
|
||||
return "PRIVATE"
|
||||
default:
|
||||
return "PRIVATE"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package teststore
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ func (e Role) String() string {
|
|||
return "HOST"
|
||||
case RoleAdmin:
|
||||
return "ADMIN"
|
||||
case RoleUser:
|
||||
return "USER"
|
||||
default:
|
||||
return "USER"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue