Coder Social home page Coder Social logo

quarkcloudio / quark-go Goto Github PK

View Code? Open in Web Editor NEW
189.0 3.0 28.0 16.73 MB

兼容 Echo & Gin & GoFiber & GoZero & Hertz & Kratos + Ant Design Pro 前后端分离的管理后台,Build Anything With QuarkGo

Home Page: https://quarkcloud.io/quark-go/

License: Other

Makefile 0.01% Go 69.59% Shell 0.05% HTML 0.05% JavaScript 30.30%
admin go-admin go golang go-antd

quark-go's Introduction

介绍

QuarkGO 是一个基于golang的低代码工具;它提供的丰富组件,能帮助您使用很少的代码就能搭建出功能完善的应用系统。

系统特性

  • 用户管理
  • 权限系统
  • 菜单管理
  • 系统配置
  • 操作日志
  • 附件管理
  • 组件丰富

快速开始

  1. 创建 demo 文件夹,进入该目录中执行如下命令,初始化项目:
go mod init demo/hello
  1. 创建 main.go 文件
  2. 在 main.go 文件中添加如下代码:
package main

import (
	"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/service"
	"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/install"
	"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/middleware"
	"github.com/quarkcloudio/quark-go/v2/pkg/builder"
	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
)

func main() {

	// 配置资源
	config := &builder.Config{

		// JWT加密密串
		AppKey:    "123456",

		// 加载服务
		Providers: service.Providers,

		// 数据库配置
		DBConfig: &builder.DBConfig{
			Dialector: sqlite.Open("./data.db"),
			Opts:      &gorm.Config{},
		},
	}

	// 实例化对象
	b := builder.New(config)

	// WEB根目录
	b.Static("/", "./web/app")

	// 自动构建数据库、拉取静态文件
	install.Handle()

	// 后台中间件
	b.Use(middleware.Handle)

	// 响应Get请求
	b.GET("/", func(ctx *builder.Context) error {
		return ctx.String(200, "Hello World!")
	})

	// 启动服务
	b.Run(":3000")
}
  1. 拉取依赖
go mod tidy
  1. 启动服务
go run main.go

后台地址: http://127.0.0.1:3000/admin/

账号:administrator 密码:123456

特别注意

  1. 后台用户认证使用了AppKey作为JWT的加密密串,生成环境请务必更改

相关项目

演示站点

香港站点,页面加载可能比较缓慢

技术支持

为了避免打扰作者日常工作,你可以在Github上提交 Issues

相关教程,你可以查看 在线文档

License

QuarkGo is licensed under The MIT License (MIT).

quark-go's People

Contributors

lnnt avatar mengxiangyu996 avatar tangtanglove avatar tclxljc43026 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

quark-go's Issues

用gin框架启动出现这种bug?

goroutine 1 [running]:
github.com/quarkcms/quark-go/pkg/builder.(*Engine).Use(0xc0002de620, {0x1559d20?, 0x1704bd8?})
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/builder/engine.go:310 +0x1f9
main.main()
C:/Users/project/Desktop/demo/main.go:34 +0x28b

Process finished with the exit code 2

按照文档写post服务,field := &builder.AdminField{}报错

// 字段
func (p *Post) Fields(ctx *builder.Context) []interface{} {

field := &builder.AdminField{}

return []interface{}{
	field.ID("id", "ID"),

	field.Text("title", "标题").
		SetRules(
			[]string{
				"required",
			},
			map[string]string{
				"required": "标题必须填写",
			},
		),

	field.Editor("content", "内容").OnlyOnForms(),

	field.Switch("status", "状态").
		SetTrueValue("正常").
		SetFalseValue("禁用").
		SetEditable(true).
		SetDefault(true),
}

}

项目无法启动

启动提示:vendor/modernc.org/sqlite/lib/sqlite_darwin_amd64.go:158407:9: undefined: libc.Xpread

按照文档gin框架运行直接报错

Downloading static files, please wait...
Download static files failed!
Please goto https://github.com/quarkcms/quark-go/tree/main/website url to download it
After downloading, you must make 'install.lock' file in the website dir
panic: Get "https://github.com/quarkcms/quark-go/tree/main/website/": dial tcp 199.59.149.235:443: connectex: A connection attempt failed because the connected p
arty did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

goroutine 1 [running]:
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:54 +0x93
github.com/quarkcms/quark-go/pkg/github.handle({{0x0, 0x0}, 0x0, {0x0, 0x0}, 0x0}, {0xe9695b, 0x37}, {0xe9698a, 0x7}, ...)
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:67 +0x10c
github.com/quarkcms/quark-go/pkg/github.Download({0xe9695b, 0x37}, {0x0?, 0x1?})
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:39 +0x185
github.com/quarkcms/quark-go/pkg/builder.New(0xc0006880f0)
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/builder/engine.go:109 +0x1a7
main.main()
github.com/quarkcms/quark-go/pkg/github.failedPrint({0xd2d440, 0xc000272ab0})
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:54 +0x93
github.com/quarkcms/quark-go/pkg/github.handle({{0x0, 0x0}, 0x0, {0x0, 0x0}, 0x0}, {0xc0695b, 0x37}, {0xc0698a, 0x7}, ...)
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:67 +0x10c
github.com/quarkcms/quark-go/pkg/github.Download({0xc0695b, 0x37}, {0x0?, 0x1?})
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/github/github.go:39 +0x185
github.com/quarkcms/quark-go/pkg/builder.New(0xc00058e190)
C:/Users/project/go/pkg/mod/github.com/quarkcms/[email protected]/pkg/builder/engine.go:109 +0x1a7
main.main()
C:/Users/project/Desktop/demo/main.go:33 +0x273
exit status 2

how to adapter to kratos

kratos: https://github.com/go-kratos/kratos

I did this, but it doesn’t jump to the homepage after logging in

package admin

import (
	stdhttp "net/http"

	"github.com/go-kratos/kratos/v2/transport/http"
	"github.com/quarkcms/quark-go/v2/pkg/app/admin/install"
	"github.com/quarkcms/quark-go/v2/pkg/app/admin/middleware"
	"github.com/quarkcms/quark-go/v2/pkg/app/admin/service"
	"github.com/quarkcms/quark-go/v2/pkg/builder"
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

func RegisterHander(s *http.Server) {
	// 配置资源
	config := &builder.Config{
		// JWT加密密串
		AppKey: "123456",

		// 加载服务
		Providers: service.Providers,

		// 数据库配置
		DBConfig: &builder.DBConfig{
			Dialector: sqlite.Open("./data.db"),
			Opts:      &gorm.Config{},
		},
	}

	// 实例化对象
	b := builder.New(config)

	// WEB根目录
	// b.Static("/", "./web/app")

	// 自动构建数据库、拉取静态文件
	install.Handle()

	// 后台中间件
	b.Use(middleware.Handle)

	Adapter(b, s)
}

func Adapter(b *builder.Engine, s *http.Server) {
	s.HandlePrefix("/", stdhttp.FileServer(stdhttp.Dir("./web/app")))

	// 获取注册的服务
	routePaths := b.GetRoutePaths()

	// 路由组列表
	r := s.Route("/")

	// 解析服务
	for _, v := range routePaths {
		if v.Method == "Any" {
			r.Handle(stdhttp.MethodGet, v.Path, RouteAdapter(b, v.Path))
			r.Handle(stdhttp.MethodPost, v.Path, RouteAdapter(b, v.Path))
			r.Handle(stdhttp.MethodDelete, v.Path, RouteAdapter(b, v.Path))
			r.Handle(stdhttp.MethodPut, v.Path, RouteAdapter(b, v.Path))
		} else {
			r.Handle(v.Method, v.Path, RouteAdapter(b, v.Path))
		}
	}
}

func RouteAdapter(b *builder.Engine, routePath string) http.HandlerFunc {
	return func(ctx http.Context) error {
		// 转换Request对象
		context := b.NewContext(ctx.Response(), ctx.Request())

		// 设置路由
		context.SetFullPath(routePath)

		return b.Render(context)
	}
}

List组件的数据无法展示

按照官方文档的例子定义List组件,数据库对应表格字段名是list

field.
	List("list", "嵌套表单组件").
	SetButton("添加数据","bottom").
	SetItem(func () interface{} {

		return field.Group([]interface{}{
			field.Text("title", "标题"),
			field.Number("num","奖品数量"),
			field.Number("probability","中奖概率"),
		})
	})

页面上填入数据保存后,据库表list字段的值为:[{"num":100,"probability":20,"title":"主题"}]

页面展示时报错
image

hi , how to use gorm preload in quark-go

`
func (p *Post) IndexQuery(ctx *builder.Context, query *gorm.DB) *gorm.DB {

query = query.Preload("User"))

return query

}

field.Text("User.nickname", "nickname")

`

not working for me

看一下这个bug (项目地址: http://43.139.150.116:6700/admin)

func (resource *PayConfig) Actions(ctx *builder.Context) []interface{} {

return []interface{}{
	(&actions.CreateModal{}).Init(resource.Title),
	(&actions.Delete{}).Init("批量删除"),
	(&actions.EditModal{}).Init("编辑"),
	(&actions.Delete{}).Init("删除"),
	(&actions.FormSubmit{}).Init(),
	(&actions.FormReset{}).Init(),
	(&actions.FormBack{}).Init(),
	(&actions.FormExtraBack{}).Init(),
}

}

1.点击创建 直接·报错 路径(小程序配置这个菜单下的所有业务)
2.ordinary 这个角色访问不了控制台 403

管理员列表【导入数据】相关错误问题

作者您好,我在使用该框架时遇到了导入数据问题,发现上传数据之后 点击提交时 提示报错【405】
(请求连接:http://127.0.0.1:3000/admin/admin/admin/import)
image

初步修改:将http://127.0.0.1:3000/admin/admin/admin/import 改为http://127.0.0.1:3000/api/admin/admin/import
但是报错参数错误,(不知道是不是接口用错了)

辛苦作者帮忙看下这个问题,或给出解决方案,感谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.