go-admin-ui
repository·master·Indexed 23 days ago
https://github.com/go-admin-team/go-admin-uiA Vue and Element UI based frontend for go-admin, a decoupled authority management system. It provides an out-of-box UI solution for enterprise applications featuring RBAC (Role-Based Access Control), JWT authentication, and administrative modules for managing users, roles, and system configurations. Version 2.0.9.
What's inside go-admin-ui
- go-admin is a decoupled permission management system built with Gin (backend) and Vue + Element UI (frontend). It is designed for rapid application development with features including RESTful API design, RBAC access control via Casbin, JWT authentication, and Swagger documentation. It uses GORM for database abstraction and includes powerful tools for code generation and form building.
Run go-admin using Docker
masterYou can build and run the backend service using Docker containers.
- Build the image:
docker build -t go-admin .
2. **Run the container**: Map the local configuration file to the container and expose port 8000. ```shell docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-serverdocker build -t go-admin . docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server- Build the image:
Run the go-admin UI (frontend)
masterTo start the Vue-based user interface:
- Navigate to the UI directory.
- Install dependencies using npm. It is recommended to use a mirror if you are in a region with slow access to the default registry to avoid bugs associated with
cnpm. - Run the development server.
# Install dependencies npm install --registry=https://registry.npm.taobao.org # Start service npm run devnpm install --registry=https://registry.npm.taobao.org npm run devRun the go-admin UI (Frontend)
masterTo start the interactive terminal for the UI, navigate to thego-admin-uidirectory, install the dependencies, and run the development script.Deploy go-admin using Docker
masterYou can compile and run the backend using Docker.
- Build the image:
docker build -t go-admin .- Run the container: Map the local configuration file to the container and expose port 8000.
docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-serverdocker build -t go-admin . docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-serverRun the go-admin backend server
masterFollow these steps to compile and start the backend service.
- Compile the project: Navigate to the
go-admindirectory and rungo build. - Configure Database: Edit
go-admin/config/settings.ymlto update thesettings.databasesection with your database credentials and verify the log path. - Initialize Database: Run the migration command to set up the initial database schema.
- Start Server: Run the server command.
Note for Windows users: If you encounter CGO errors (e.g.,
exec: "gcc": executable file not found), ensure you have a C compiler installed and configured in your PATH.Commands for macOS/Linux:
cd ./go-admin go build # Initialize database ./go-admin migrate -c=config/settings.dev.yml # Start server ./go-admin server -c config/settings.ymlCommands for Windows:
cd ./go-admin go build # Initialize database go-admin.exe migrate -c=config/settings.dev.yml # Start server go-admin.exe server -c config/settings.yml# macOS/Linux ./go-admin migrate -c=config/settings.dev.yml ./go-admin server -c config/settings.yml # Windows go-admin.exe migrate -c=config/settings.dev.yml go-admin.exe server -c config/settings.yml- Compile the project: Navigate to the
Set up the go-admin development environment
masterTo develop with go-admin, you need to set up both the backend and the frontend.
Prerequisites:
- Go 1.17+
- Node.js v18+
- npm 6.14.11+
- Git
Step 1: Create a workspace Create a parent directory and clone both the backend (
go-admin) and the frontend (go-admin-ui) repositories into it. Important: The two projects must be placed in the same folder level.# Create a development directory mkdir goadmin cd goadmin # Get backend code git clone https://github.com/go-admin-team/go-admin.git # Get the front-end code git clone https://github.com/go-admin-team/go-admin-ui.git# Create a development directory mkdir goadmin cd goadmin # Get backend code git clone https://github.com/go-admin-team/go-admin.git # Get the front-end code git clone https://github.com/go-admin-team/go-admin-ui.gitRun the go-admin backend service
masterFollow these steps to compile and start the backend service:
Compile the project:
cd ./go-admin go buildNote: On Windows, if you encounter CGO errors related to
go-sqlite3, ensure you have a C compiler (like gcc) installed and configured in your PATH.Configure Database: Edit the configuration file at
go-admin/config/settings.yml. Update thesettings.databasesection with your database credentials.Initialize Database: Run the migration command to set up the initial database schema and resources.
- macOS/Linux:
./go-admin migrate -c=config/settings.dev.yml - Windows:
go-admin.exe migrate -c=config/settings.dev.yml
- macOS/Linux:
Start the Server:
- macOS/Linux:
./go-admin server -c config/settings.yml - Windows:
go-admin.exe server -c config/settings.yml
- macOS/Linux:
Configure route metadata for sidebar and breadcrumbs
masterWhen defining routes in
go-admin-ui, you can use themetaobject and specific route properties to control how items appear in the sidebar, breadcrumbs, and tags-view.Route Properties
hidden: true: The item will not show in the sidebar.alwaysShow: true: The root menu will always show. Iffalse(default), the root menu only shows if it has exactly one child; otherwise, it becomes a nested menu.redirect: 'noRedirect': Prevents redirection in the breadcrumb.name: 'router-name': Required for<keep-alive>functionality.
Meta Object Keys
roles: ['admin', 'editor']: Controls page access based on user roles.title: 'title': The name displayed in the sidebar and breadcrumb.icon: 'svg-name': The icon displayed in the sidebar.noCache: true: If true, the page will not be cached.affix: true: If true, the tab will be fixed (affixed) in the tags-view.breadcrumb: false: If false, the item is hidden in the breadcrumb.activeMenu: '/example/list': Sets the path that the sidebar will highlight.
Change the development server port
masterThe default development port is
9527. You can change the port using one of the following methods:- Via CLI flag: Pass the
--portflag to the dev command. - Via Environment Variable: Set the
portenvironment variable.
Note: If you attempt to use port
80, you may need administrator privileges (e.g.,sudo npm run devon macOS).- Via CLI flag: Pass the
Install the permission and permisaction directives
masterTo use element-level permission control in your Vue application, you can install the
permissionandpermisactiondirectives.If you are using a standard Vue build system (like Webpack or Vite), you can import the default export and use
Vue.use()to register them globally. If you are working in an environment whereVueis available on thewindowobject, the directives will be automatically installed and attached to thewindowobject.Configure global application settings in settings.js
masterThe
src/settings.jsfile is used to configure global UI behaviors and application settings for thego-admininterface. You can toggle features like the settings panel, top navigation, tags view, and header behavior here.module.exports = { title: 'go-admin后台管理系统', /** * @type {boolean} true | false * @description Whether show the settings right-panel */ showSettings: true, /** * 是否显示顶部导航 */ topNav: true, /** * @type {boolean} true | false * @description Whether need tagsView */ tagsView: true, /** * @type {boolean} true | false * @description Whether fix the header */ fixedHeader: true, /** * @type {boolean} true | false * @description Whether show the logo in sidebar */ sidebarLogo: true, /** * @type {string | array} 'production' | ['production', 'development'] * @description Need show err logs component. * The default is only used in the production env * If you want to also use it in dev, you can pass ['production', 'development'] */ errorLog: 'production', themeStyle: 'dark' }