Skip to content

Commit

Permalink
add build tag: amisgo_use-_local_sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
zrcoder committed Dec 30, 2024
1 parent 8562411 commit cc1d3c6
Show file tree
Hide file tree
Showing 134 changed files with 85,164 additions and 44 deletions.
12 changes: 0 additions & 12 deletions amis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/zrcoder/amisgo/conf"
"github.com/zrcoder/amisgo/internal/servermux"
"github.com/zrcoder/amisgo/util"
)

Expand All @@ -16,17 +15,6 @@ type Engine struct {
mux *http.ServeMux
}

// New creates an Engine instance with options
func New(opts ...conf.Option) *Engine {
cfg := conf.Default()
cfg.Apply(opts...)

return &Engine{
Config: cfg,
mux: servermux.Mux(),
}
}

// Mount registers an Amis component at the given path
func (e *Engine) Mount(path string, component any, middlewares ...func(http.Handler) http.Handler) *Engine {
var h http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 3 additions & 3 deletions comp/carousel.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c carousel) ItemSchema(value string) carousel {
}

// Multiple 设置 multiple 属性
func (c carousel) Multiple(value string) carousel {
func (c carousel) Multiple(value any) carousel {
return c.set("multiple", value)
}

Expand All @@ -114,7 +114,7 @@ func (c carousel) OnEvent(value any) carousel {
}

// Options 设置 options 属性
func (c carousel) Options(value ...MOption) carousel {
func (c carousel) Options(value ...any) carousel {
return c.set("options", value)
}

Expand Down Expand Up @@ -173,7 +173,7 @@ func (c carousel) TestID(value string) carousel {
return c.set("testid", value)
}

// ThumbMode 设置 thumbMode 属性
// ThumbMode 设置 thumbMode 属性, contain | cover
func (c carousel) ThumbMode(value string) carousel {
return c.set("thumbMode", value)
}
Expand Down
2 changes: 1 addition & 1 deletion comp/chainedSelect.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (c chainedSelect) OnEvent(value any) chainedSelect {
}

// Options 选项集合
func (c chainedSelect) Options(value ...MOption) chainedSelect {
func (c chainedSelect) Options(value ...any) chainedSelect {
return c.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/checkboxes.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (c checkboxes) OnEvent(value any) checkboxes {
}

// 选项集合
func (c checkboxes) Options(value ...MOption) checkboxes {
func (c checkboxes) Options(value ...any) checkboxes {
return c.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/gridNav.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (g gridNav) ItemClassName(value string) gridNav {
}

// Options 列表项图标
func (g gridNav) Options(value ...MOption) gridNav {
func (g gridNav) Options(value ...any) gridNav {
return g.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/i_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (b MApi) Method(value string) MApi {
}

// QsOptions qs 配置项
func (b MApi) QsOptions(value ...MOption) MApi {
func (b MApi) QsOptions(value ...any) MApi {
return b.set("qsOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (i images) OnEvent(value any) images {
}

// Options
func (i images) Options(value ...MOption) images {
func (i images) Options(value ...any) images {
return i.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/inputImage.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (i inputImage) Compress(value bool) inputImage {
}

// CompressOptions 压缩选项
func (i inputImage) CompressOptions(value ...MOption) inputImage {
func (i inputImage) CompressOptions(value ...any) inputImage {
return i.set("compressOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/inputNumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (nc inputNumber) TestIdBuilder(value string) inputNumber {
}

// UnitOptions 单位列表
func (nc inputNumber) UnitOptions(value ...MOption) inputNumber {
func (nc inputNumber) UnitOptions(value ...any) inputNumber {
return nc.set("unitOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/inputRepeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (rc inputRepeat) OnEvent(value any) inputRepeat {
}

// Options
func (rc inputRepeat) Options(value ...MOption) inputRepeat {
func (rc inputRepeat) Options(value ...any) inputRepeat {
return rc.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/inputTag.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (t inputTag) OnEvent(value map[string]string) inputTag {
}

// Options 选项 (选项)
func (t inputTag) Options(value ...MOption) inputTag {
func (t inputTag) Options(value ...any) inputTag {
return t.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/listSelect.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (lc listSelect) OnEvent(value any) listSelect {
}

// Options 选项集合
func (lc listSelect) Options(value ...MOption) listSelect {
func (lc listSelect) Options(value ...any) listSelect {
return lc.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (o options) Name(value string) options {
}

// Options 选项组,供用户选择
func (o options) Options(value ...MOption) options {
func (o options) Options(value ...any) options {
return o.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (pc picker) OnEvent(value any) picker {
}

// Options 选项列表
func (pc picker) Options(value ...MOption) picker {
func (pc picker) Options(value ...any) picker {
return pc.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/radios.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (rc radios) Option(value any) radios {
}

// Options 配置选项列表
func (rc radios) Options(value ...MOption) radios {
func (rc radios) Options(value ...any) radios {
return rc.set("options", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/schemaApi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s schemaApi) Method(value string) schemaApi {
}

// QsOptions qs 配置项
func (s schemaApi) QsOptions(value ...MOption) schemaApi {
func (s schemaApi) QsOptions(value ...any) schemaApi {
return s.set("qsOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (sc selectControl) Mode(value string) selectControl {
}

// noneOptions 对于 `autoComplete` API 提供的值不被选择项本身支持的时候,用于配置没有值时的提示文字
func (sc selectControl) NoneOptions(value ...MOption) selectControl {
func (sc selectControl) NoneOptions(value ...any) selectControl {
return sc.set("noneOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/tabsTransfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (t tabsTransfer) Nested(value bool) tabsTransfer {
}

// Options 选项
func (t tabsTransfer) Options(value ...MOption) tabsTransfer {
func (t tabsTransfer) Options(value ...any) tabsTransfer {
return t.set("options", value)
}

Expand Down
4 changes: 2 additions & 2 deletions comp/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (tc transfer) Option(value string) transfer {
}

// Options 选项数据
func (tc transfer) Options(value ...MOption) transfer {
func (tc transfer) Options(value ...any) transfer {
return tc.set("options", value)
}

Expand All @@ -295,7 +295,7 @@ func (tc transfer) ReadOnly(value bool) transfer {
}

// RemoteOptions 远程获取选项
func (tc transfer) RemoteOptions(value ...MOption) transfer {
func (tc transfer) RemoteOptions(value ...any) transfer {
return tc.set("remoteOptions", value)
}

Expand Down
2 changes: 1 addition & 1 deletion comp/transferPicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (tpc transferPicker) Name(value string) transferPicker {
}

// Options 数据源配置
func (tpc transferPicker) Options(value ...MOption) transferPicker {
func (tpc transferPicker) Options(value ...any) transferPicker {
return tpc.set("options", value)
}

Expand Down
4 changes: 2 additions & 2 deletions comp/userSelect.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (usc userSelect) OnEvent(value any) userSelect {
}

// Options 选项集合
func (usc userSelect) Options(value ...MOption) userSelect {
func (usc userSelect) Options(value ...any) userSelect {
return usc.set("options", value)
}

Expand Down Expand Up @@ -309,7 +309,7 @@ func (usc userSelect) StaticPlaceholder(value string) userSelect {
}

// StaticOptions 静态选项集合
func (usc userSelect) StaticOptions(value ...MOption) userSelect {
func (usc userSelect) StaticOptions(value ...any) userSelect {
return usc.set("staticOptions", value)
}

Expand Down
13 changes: 7 additions & 6 deletions conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ const (

// Config holds all configuration options for the application
type Config struct {
Theme Theme
Lang Lang
Title string
Icon string
CustomCSS string
CustomJS string
Theme Theme
Lang Lang
Title string
Icon string
CustomCSS string
CustomJS string
UseLocalSDK bool
template.Template
}

Expand Down
23 changes: 21 additions & 2 deletions internal/template/template.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@
<link rel="icon" href="{{.Icon}}" />
{{ end }}
{{ if .Theme }}
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/{{ .Theme }}.min.css" />
{{ if .UseLocalSDK }}
<link rel="stylesheet" href="/__amisgo__sdk/{{ .Theme}}.css" />
{{ else }}
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/{{ .Theme }}.min.css" />
{{ end }}
{{ else }}
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/sdk.min.css" />
{{ if .UseLocalSDK }}
<link rel="stylesheet" href="/__amisgo__sdk/sdk.css" />
{{ else }}
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/sdk.min.css" />
{{ end }}
{{ end }}

{{ if .UseLocalSDK }}
<link rel="stylesheet" href="/__amisgo__sdk/helper.css" />
<link rel="stylesheet" href="/__amisgo__sdk/iconfont.css" />
{{ else }}
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/helper.min.css" />
<link rel="stylesheet" href="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/iconfont.min.css" />
{{ end }}

<style>
html,
body,
Expand All @@ -34,7 +49,11 @@
</head>
<body>
<div id="root" class="app-wrapper"></div>
{{ if .UseLocalSDK }}
<script src="/__amisgo__sdk/sdk.js"></script>
{{ else }}
<script src="{{ .AmisBaseURL }}@{{ .AmisVersion }}/sdk/sdk.min.js"></script>
{{ end }}
{{ if .CustomJS }}
<script type="text/javascript">
{{ .CustomJS }}
Expand Down
353 changes: 353 additions & 0 deletions jssdk/ang-ie11.css

Large diffs are not rendered by default.

292 changes: 292 additions & 0 deletions jssdk/ang.css

Large diffs are not rendered by default.

352 changes: 352 additions & 0 deletions jssdk/antd-ie11.css

Large diffs are not rendered by default.

291 changes: 291 additions & 0 deletions jssdk/antd.css

Large diffs are not rendered by default.

Loading

0 comments on commit cc1d3c6

Please sign in to comment.