123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package vuetify
- import (
- "embed"
- "strings"
- "github.com/qor5/web"
- )
- //go:embed dist
- var assetsbox embed.FS
- func JSComponentsPack() web.ComponentsPack {
- v, err := assetsbox.ReadFile("dist/vuetify.min.js")
- if err != nil {
- panic(err)
- }
- return web.ComponentsPack(v)
- }
- func CSSComponentsPack() web.ComponentsPack {
- v, err := assetsbox.ReadFile("dist/vuetify.min.css")
- if err != nil {
- panic(err)
- }
- return web.ComponentsPack(v)
- }
- const initVuetify = `
- (window.__goplaidVueComponentRegisters =
- window.__goplaidVueComponentRegisters || []).push(function(Vue, vueOptions) {
- var vuetify = new Vuetify({{vuetifyOpts}});
- Vue.use(Vuetify);
- vueOptions.vuetify = vuetify;
- });
- `
- const defaultVuetifyOpts = `{
- icons: {
- iconfont: 'md', // 'mdi' || 'mdiSvg' || 'md' || 'fa' || 'fa4'
- },
- }`
- func Vuetify(opts string) web.ComponentsPack {
- if opts == "" {
- opts = defaultVuetifyOpts
- }
- return web.ComponentsPack(
- strings.NewReplacer("{{vuetifyOpts}}", opts).
- Replace(initVuetify),
- )
- }
|