### Backend Setup and Initialization with Django Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.zh.md Provides detailed steps for setting up the Django backend. This includes navigating to the backend directory, configuring environment variables, installing Python dependencies, performing database migrations, initializing data, and starting the development server. It also offers an alternative using uvicorn. ```bash 1. 进入项目目录 cd backend 2. 在项目根目录中,复制 ./conf/env.example.py 文件为一份新的到 ./conf 文件夹下,并重命名为 env.py 3. 在 env.py 中配置数据库信息 mysql数据库版本建议:8.0 mysql数据库字符集:utf8mb4 4. 安装依赖环境 pip3 install -r requirements.txt 5. 执行迁移命令: python3 manage.py makemigrations python3 manage.py migrate 6. 初始化数据 python3 manage.py init 7. 初始化省市县数据: python3 manage.py init_area 8. 启动项目 python3 manage.py runserver 0.0.0.0:8000 或使用 uvicorn : uvicorn application.asgi:application --port 8000 --host 0.0.0.0 --workers 8 ``` -------------------------------- ### Install Frontend Dependencies and Start Service with Yarn Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.zh.md Installs project dependencies using npm and yarn, then starts the development server. It also includes commands for building the production environment and notes that .env.development can configure startup parameters like the port. ```bash npm install yarn yarn install --registry=https://registry.npmmirror.com yarn build # 浏览器访问 http://localhost:8080 # .env.development 文件中可配置启动端口等参数 # 构建生产环境 # yarn run build ``` -------------------------------- ### Docker Compose for Project Setup and Management Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.zh.md Guides users on setting up and managing the project using Docker Compose. It covers starting services, initializing backend data within the Docker container, accessing the application, and stopping or restarting services. The `--build` flag is included for rebuilding images. ```shell # 先安装docker-compose (自行百度安装),执行此命令等待安装,如有使用celery插件请打开docker-compose.yml中celery 部分注释 docker-compose up -d # 初始化后端数据(第一次执行即可) docker exec -ti dvadmin3-django bash python manage.py makemigrations python manage.py migrate python manage.py init_area python manage.py init exit 前端地址:http://127.0.0.1:8080 后端地址:http://127.0.0.1:8080/api # 在服务器上请把127.0.0.1 换成自己公网ip 账号:superadmin 密码:admin123456 # docker-compose 停止 docker-compose down # docker-compose 重启 docker-compose restart # docker-compose 启动时重新进行 build docker-compose up -d --build ``` -------------------------------- ### Configure and Run Backend (Bash) Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.md Provides a comprehensive set of bash commands to set up the Django backend. This includes navigating to the backend directory, copying and configuring the environment file, installing pip dependencies, running database migrations, initializing data, and starting the development server using Django's runserver or uvicorn. ```bash 1. enter code dir cd backend 2. copy ./conf/env.example.py to ./conf dir,rename as env.py 3. in env.py configure database information mysql database recommended version: 8.0 mysql database character set: utf8mb4 4. install pip dependence pip3 install -r requirements.txt 5. Execute the migration command: python3 manage.py makemigrations python3 manage.py migrate 6. Initialization data python3 manage.py init 7. Initialize provincial, municipal and county data: python3 manage.py init_area 8. start backend python3 manage.py runserver 0.0.0.0:8000 or uvicorn : uvicorn application.asgi:application --port 8000 --host 0.0.0.0 --workers 8 ``` -------------------------------- ### Install and Manage Redis Windows Service Source: https://github.com/huge-dream/django-vue3-admin/blob/master/redis-8.2.1/README.md Provides commands for installing, starting, stopping, and uninstalling Redis as a Windows service. Requires administrator privileges and correct path to RedisService.exe. Enables automatic startup on boot. ```shell sc.exe create Redis binpath=C:\\Software\\Redis\\RedisService.exe start= auto ``` ```shell net start Redis ``` ```shell net stop Redis ``` ```shell sc.exe delete Redis ``` -------------------------------- ### Manage Redis as a Windows Service (Shell) Source: https://github.com/huge-dream/django-vue3-admin/blob/master/redis-8.2.1/README.zh_CN.md Commands to install, start, stop, and uninstall Redis as a Windows system service. This enables automatic startup on boot and background operation. Requires administrator privileges to run these commands. ```shell sc.exe create Redis binpath=C:\Software\Redis\RedisService.exe start= auto ``` ```shell net start Redis ``` ```shell net stop Redis ``` ```shell sc.exe delete Redis ``` -------------------------------- ### Clone and Install Frontend Dependencies (Bash) Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.md Clones the Django Vue3 Admin project from Gitee, navigates into the web directory, and installs frontend dependencies using npm and yarn. It also configures a specific registry for package installation. ```bash git clone https://gitee.com/huge-dream/django-vue3-admin.git cd web npm install yarn yarn install --registry=https://registry.npm.taobao.org ``` -------------------------------- ### Get System Settings API Request and Response (cURL) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt This example shows how to retrieve all system configurations. The API returns a hierarchical structure of settings, including their keys, values, and status. An authentication token is required. This is useful for initial frontend bootstrapping. ```bash # Get all system configuration curl -X GET http://localhost:8000/api/system/system_config/ \ -H "Authorization: Bearer " # Response { "code": 2000, "data": [ { "id": 1, "parent": null, "title": "Base Configuration", "key": "base", "value": {}, "status": true, "children": [ { "id": 2, "title": "Site Name", "key": "base.site_name", "value": "Django Vue3 Admin", "form_item_type": "text" }, { "id": 3, "title": "Enable CAPTCHA", "key": "base.captcha_state", "value": true, "form_item_type": "switch" } ] } ] } ``` -------------------------------- ### Start Frontend Development Server (Bash) Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.md Starts the frontend development server for the Django Vue3 Admin project. It also mentions where to configure environment variables like the boot port and provides the command for building the production environment. ```bash # Start service yarn run dev # Visit http://localhost:8080 in your browser # Parameters such as boot port can be configured in the #.env.development file # Build the production environment # yarn run build ``` -------------------------------- ### Start Redis Server via Command Line Source: https://github.com/huge-dream/django-vue3-admin/blob/master/redis-8.2.1/README.md Demonstrates how to start the Redis server using the command line. This requires the redis-server.exe executable and a redis.conf configuration file. It can be executed in both CMD and PowerShell environments. ```shell redis-server.exe redis.conf ``` ```shell ./redis-server.exe redis.conf ``` -------------------------------- ### Manage Services with Docker Compose Source: https://github.com/huge-dream/django-vue3-admin/blob/master/docker_env/README.md This extensive snippet covers the usage of docker-compose for managing the application's services. It includes commands for initial setup, starting services in detached mode, initializing backend data, stopping, restarting, and rebuilding services. It also provides access details for the frontend and backend. ```shell # 先安装docker-compose (自行百度安装),执行此命令等待安装,如有使用celery插件请打开docker-compose.yml中celery 部分注释 docker-compose up -d # 初始化后端数据(第一次执行即可) docker exec -ti dvadmin-django bash python manage.py makemigrations python manage.py migrate python manage.py init -y exit 前端地址:http://127.0.0.1:8080 后端地址:http://127.0.0.1:8000 # 在服务器上请把127.0.0.1 换成自己公网ip 账号:superadmin 密码:admin123456 # docker-compose 停止 docker-compose down # docker-compose 重启 docker-compose restart # docker-compose 启动时重新进行 build docker-compose up -d --build ``` -------------------------------- ### GET /init/dictionary/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Initializes dictionaries for system configuration, typically fetching all available dictionaries. ```APIDOC ## GET /init/dictionary/ ### Description Initializes dictionaries for system configuration, typically fetching all available dictionaries. ### Method GET ### Endpoint /init/dictionary/ ### Parameters #### Path Parameters None #### Query Parameters - **dictionary_key** (string) - Required - A key to specify which dictionaries to fetch. Use 'all' to get all dictionaries. #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/api/init/dictionary/?dictionary_key=all" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (object) - An object where keys are dictionary types (e.g., 'user_status', 'gender') and values are arrays of dictionary items (label, value, color). #### Response Example ```json { "code": 2000, "data": { "user_status": [ {"label": "Active", "value": "1", "color": "success"}, {"label": "Inactive", "value": "0", "color": "danger"} ], "gender": [ {"label": "Male", "value": "1"}, {"label": "Female", "value": "2"} ] } } ``` ``` -------------------------------- ### Initialize Dictionary (System Config) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Fetches all dictionaries needed for system initialization, identified by a `dictionary_key`. This GET request requires an Authorization token. ```bash # Get all dictionaries for system initialization curl -X GET "http://localhost:8000/api/init/dictionary/?dictionary_key=all" \ -H "Authorization: Bearer " ``` -------------------------------- ### Clone Django-Vue3-Admin Frontend Repository Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.zh.md This snippet demonstrates how to clone the frontend repository of the Django-Vue3-Admin project using Git and navigate into the project directory. It requires Git to be installed. ```bash git clone https://gitee.com/huge-dream/django-vue3-admin.git # 进入项目目录 cd web ``` -------------------------------- ### Deploy with Docker Compose (Shell) Source: https://github.com/huge-dream/django-vue3-admin/blob/master/README.md Demonstrates how to use Docker Compose to manage the deployment of the Django Vue3 Admin project. It includes commands to start the services in detached mode, execute backend initialization commands within a running container, and stop or restart the services. It also covers rebuilding the images if necessary. ```shell docker-compose up -d # Initialize backend data (first execution only) docker exec -ti dvadmin3-django bash python manage.py makemigrations python manage.py migrate python manage.py init_area python manage.py init exit frontend url:http://127.0.0.1:8080 backend url:http://127.0.0.1:8080/api # Change 127.0.0.1 to your own public ip address on the server account:`superadmin` password:`admin123456` # docker-compose stop docker-compose down # docker-compose restart docker-compose restart # docker-compose on start build docker-compose up -d --build ``` -------------------------------- ### Get Complete Menu Hierarchy Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves the complete menu hierarchy for the system. It requires an Authorization token and returns a nested structure of menu items. ```bash # Get complete menu hierarchy curl -X GET http://localhost:8000/api/system/menu/get_all_menu \ -H "Authorization: Bearer " ``` -------------------------------- ### Run Django Migrations and Initialization Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/dvadmin3_build/README.md Applies database migrations and initializes the project with necessary data. These commands are essential after setting up the database or when deploying for the first time. If the project has already been migrated, these steps might be redundant. ```python python manage.py makemigrations python manage.py migrate python manage.py init python manage.py init_data ``` -------------------------------- ### Get Regional Hierarchy API Request and Response (cURL) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt This example demonstrates retrieving regional data hierarchically. You can fetch provinces by specifying level 1, or fetch cities/districts under a specific province by providing its code (pcode). Authentication is required. The response includes region name, code, level, and parent code. ```bash # Get provinces (level 1) curl -X GET "http://localhost:8000/api/system/area/?level=1" \ -H "Authorization: Bearer " # Response { "code": 2000, "data": [ { "id": 1, "name": "Beijing", "code": "110000", "level": 1, "pinyin": "beijing", "initials": "B", "pcode": null, "enable": true } ] } # Get cities under a province curl -X GET "http://localhost:8000/api/system/area/?pcode=110000" \ -H "Authorization: Bearer " # Response - Returns districts under Beijing { "code": 2000, "data": [ {"id": 2, "name": "Dongcheng District", "code": "110101", "level": 2}, {"id": 3, "name": "Xicheng District", "code": "110102", "level": 2} ] } ``` -------------------------------- ### GET /api-auth/logout/ Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/base.html Provides API endpoint documentation for GET requests to the logout endpoint. ```APIDOC ## GET /api-auth/logout/ ### Description This endpoint allows users to log out of the system via a GET request. It invalidates the current session or token. ### Method GET ### Endpoint /api-auth/logout/ ### Parameters None ### Request Example ```json { "message": "Initiate logout process" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "Successfully logged out." } ``` ``` -------------------------------- ### GET /api-auth/login/ Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/base.html Provides API endpoint documentation for GET requests to the login endpoint. ```APIDOC ## GET /api-auth/login/ ### Description This endpoint allows for authentication via a GET request. It is typically used to initiate a login flow. ### Method GET ### Endpoint /api-auth/login/ ### Parameters #### Query Parameters - **next** (string) - Optional - The URL to redirect to after successful login. ### Request Example ```json { "message": "Initiate login process" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "Login initiated. Please check your credentials." } ``` ``` -------------------------------- ### Get Field-Level Permissions Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves column (field-level) permissions for the current user associated with a specific menu. This GET request requires an Authorization token and a `menu` query parameter. ```bash # Get column permissions for current user curl -X GET http://localhost:8000/api/system/column/?menu=2 \ -H "Authorization: Bearer " ``` -------------------------------- ### Initialize Frontend Settings API Request and Response (cURL) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt This API endpoint is designed to fetch system settings specifically for frontend initialization. It returns a flattened key-value map of essential configurations like site name, logo, and pagination limits. Authentication is required. ```bash # Get system settings for frontend initialization curl -X GET http://localhost:8000/api/init/settings/ \ -H "Authorization: Bearer " # Response { "code": 2000, "data": { "base.site_name": "Django Vue3 Admin", "base.captcha_state": true, "base.logo": "/media/logo.png", "system.pagination_limit": 20 } } ``` -------------------------------- ### Get Role Menu Permissions Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves the menu permissions assigned to a specific role. This GET request requires an Authorization token and a `role` query parameter to filter permissions by role ID. ```bash # Get menus assigned to a role curl -X GET "http://localhost:8000/api/system/role_menu_permission/?role=2" \ -H "Authorization: Bearer " ``` -------------------------------- ### Frontend Bootstrap Settings API Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Provides system settings required for frontend initialization, such as site name, logo, and pagination limits. ```APIDOC ## GET /api/init/settings/ ### Description Retrieves system settings necessary for frontend bootstrapping. ### Method GET ### Endpoint /api/init/settings/ ### Response #### Success Response (2000) - **code** (integer) - Response code, 2000 indicates success. - **data** (object) - An object containing key-value pairs of system settings. - **base.site_name** (string) - The name of the website. - **base.captcha_state** (boolean) - Indicates if CAPTCHA is enabled. - **base.logo** (string) - The URL path to the site logo. - **system.pagination_limit** (integer) - The default number of items per page for pagination. #### Response Example ```json { "code": 2000, "data": { "base.site_name": "Django Vue3 Admin", "base.captcha_state": true, "base.logo": "/media/logo.png", "system.pagination_limit": 20 } } ``` ``` -------------------------------- ### Get Role Button Permissions Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Fetches button permissions for a given role. This GET request needs an Authorization token and a `role` query parameter. It also explains `data_range` values for permission scope. ```bash # Get button permissions for a role curl -X GET "http://localhost:8000/api/system/role_menu_button_permission/?role=2" \ -H "Authorization: Bearer " ``` -------------------------------- ### Build Django Project with dvadmin3-build Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/dvadmin3_build/README.md Compiles the django-vue3-admin project into an executable file, typically located in the 'dist' directory. For Windows packaging, it requires InstallForge and a specific template file (dvadmin3_build/windows_build_tools/dvadmin3_InstallForge.ifp). ```python # windows 打包需要安装 InstallForgeSetup.exe,使用 dvadmin3_build/windows_build_tools/dvadmin3_InstallForge.ifp 模板(dvadmin3_build/windows_build_tools 目录下) # InstallForge 打包教程:https://www.pythonguis.com/tutorials/packaging-pyqt6-applications-windows-pyinstaller/#setup python manage.py build ``` -------------------------------- ### Template Usage of Vue.js Permission Directives Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Provides examples of how to use the `v-auth` and `v-auths` directives in Vue.js templates for controlling button visibility. `v-auth` is used for single permission checks, while `v-auths` is used for scenarios requiring any of multiple permissions. These examples illustrate practical application within a component. ```html ``` -------------------------------- ### GET /api/users/ Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/base.html Retrieves a list of users. ```APIDOC ## GET /api/users/ ### Description Retrieves a list of all users registered in the system. ### Method GET ### Endpoint /api/users/ ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of users to return. - **offset** (integer) - Optional - The number of users to skip before starting to collect the result set. ### Request Example ```json { "message": "Request to list users" } ``` ### Response #### Success Response (200) - **count** (integer) - The total number of users. - **next** (string) - URL for the next page of results, or null. - **previous** (string) - URL for the previous page of results, or null. - **results** (array) - An array of user objects. - **id** (integer) - The user's unique identifier. - **username** (string) - The user's username. - **email** (string) - The user's email address. #### Response Example ```json { "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "username": "user1", "email": "user1@example.com" }, { "id": 2, "username": "user2", "email": "user2@example.com" } ] } ``` ``` -------------------------------- ### API Interaction with coreapi in Python Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/docs/langs/python.html This Python code snippet demonstrates how to initialize a coreapi client, load an API schema document, and interact with API endpoints. It shows how to define actions and optionally provide parameters for the action. Dependencies include the 'coreapi' library. ```python import coreapi # Initialize a client & load the schema document client = coreapi.Client() schema = client.get("{{ document.url }}"{% if schema_format %}, format="{{ schema_format }}"{% endif %}) # Interact with the API endpoint action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"] {% if link.fields %}params = { {% for field in link.fields %} "{{ field.name }}": ...{% if not loop.last %},{% endif %} {% endfor %}} {% endif %} result = client.action(schema, action{% if link.fields %}, params=params{% endif %}) ``` -------------------------------- ### Add dvadmin3_build to INSTALLED_APPS Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/dvadmin3_build/README.md Integrates the dvadmin3_build application into your Django project's settings. Ensure this is added to INSTALLED_APPS to enable the build command and other functionalities. ```python INSTALLED_APPS = [ ... "dvadmin3_build" ] ``` -------------------------------- ### GET /api/users/{id}/ Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/base.html Retrieves details for a specific user. ```APIDOC ## GET /api/users/{id}/ ### Description Retrieves the details of a specific user identified by their ID. ### Method GET ### Endpoint /api/users/{id}/ ### Parameters #### Path Parameters - **id** (integer) - Required - The unique identifier of the user. ### Request Example ```json { "message": "Request user details for ID 1" } ``` ### Response #### Success Response (200) - **id** (integer) - The user's unique identifier. - **username** (string) - The user's username. - **email** (string) - The user's email address. #### Response Example ```json { "id": 1, "username": "user1", "email": "user1@example.com" } ``` ``` -------------------------------- ### List Download Tasks (Bash) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves a list of export or download tasks from the system. It requires an authentication token and returns a JSON array of task objects, each containing details like task name, status, file name, URL, size, MD5 checksum, and creation timestamp. ```bash # Get export/download tasks curl -X GET http://localhost:8000/api/system/download_center/ \ -H "Authorization: Bearer " # Response { "code": 2000, "data": [ { "id": 1, "task_name": "User Data Export", "task_status": 2, "file_name": "users_20240115.xlsx", "url": "/media/exports/users_20240115.xlsx", "size": 1024000, "md5sum": "abc123...", "create_datetime": "2024-01-15 10:00:00" } ] } # task_status: 0=created, 1=in progress, 2=completed, 3=failed ``` -------------------------------- ### GET /api/system/dept/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves a list of departments, presented in a tree structure showing hierarchical relationships. ```APIDOC ## GET /api/system/dept/ ### Description Retrieves a list of departments, presented in a tree structure showing hierarchical relationships. ### Method GET ### Endpoint /api/system/dept/ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:8000/api/system/dept/ \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of department objects, each with details like `id`, `name`, `key`, `parent`, `sort`, `owner`, `phone`, `email`, `status`, and `children` for nested departments. #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "name": "Headquarters", "key": "HQ", "parent": null, "sort": 1, "owner": "CEO", "phone": "010-12345678", "email": "hq@example.com", "status": true, "children": [ { "id": 2, "name": "Sales Department", "parent": 1, "owner": "Sales Manager", "status": true }, { "id": 3, "name": "IT Department", "parent": 1, "owner": "CTO", "status": true } ] } ] } ``` ``` -------------------------------- ### Frontend Compilation Command Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/dvadmin3_build/README.md Executes the build script for the Vue.js frontend. This command is typically run before the backend compilation to ensure the frontend assets are prepared. ```shell yarn run build:local ``` -------------------------------- ### GET /api/system/role_menu_button_permission/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves the button permissions for a specific role. Requires the role ID as a query parameter. ```APIDOC ## GET /api/system/role_menu_button_permission/ ### Description Retrieves the button permissions for a specific role. Requires the role ID as a query parameter. ### Method GET ### Endpoint /api/system/role_menu_button_permission/ ### Parameters #### Path Parameters None #### Query Parameters - **role** (integer) - Required - The ID of the role for which to retrieve button permissions. #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/api/system/role_menu_button_permission/?role=2" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of button permission objects, including `role`, `menu_button`, `data_range`, and associated `dept` IDs. - **data_range values:** - 0: Only own data - 1: Department and sub-departments - 2: Current department only - 3: All data - 4: Custom departments #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "role": 2, "menu_button": 1, "data_range": 1, "dept": [1, 2] } ] } ``` ``` -------------------------------- ### Build and Push Backend Docker Image Source: https://github.com/huge-dream/django-vue3-admin/blob/master/docker_env/README.md This section provides the shell commands to build the Docker image for the Django backend. It specifies the Dockerfile to use and tags the image before pushing it to a registry, enabling backend deployment. ```shell # 编译打包到本地 docker build -f ./docker_env/django/DockerfileBuild -t registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-backend:latest . # 上传到阿里云仓库 docker push registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-backend:latest ``` -------------------------------- ### GET /api/system/menu/get_all_menu Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves the complete menu hierarchy for the system, typically used for navigation or display purposes. ```APIDOC ## GET /api/system/menu/get_all_menu ### Description Retrieves the complete menu hierarchy for the system, typically used for navigation or display purposes. ### Method GET ### Endpoint /api/system/menu/get_all_menu ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:8000/api/system/menu/get_all_menu \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of menu objects, each with an `id`, `name`, and optional `children` array for nested menus. #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "name": "System Management", "children": [ {"id": 2, "name": "User Management"}, {"id": 3, "name": "Role Management"} ] } ] } ``` ``` -------------------------------- ### GET /api/system/column/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves field-level (column) permissions for a given menu. Requires the menu ID as a query parameter. ```APIDOC ## GET /api/system/column/ ### Description Retrieves field-level (column) permissions for a given menu. Requires the menu ID as a query parameter. ### Method GET ### Endpoint /api/system/column/ ### Parameters #### Path Parameters None #### Query Parameters - **menu** (integer) - Required - The ID of the menu for which to retrieve column permissions. #### Request Body None ### Request Example ```bash curl -X GET http://localhost:8000/api/system/column/?menu=2 \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of column permission objects, detailing `role`, `field` information (including `id`, `model`, `menu`, `field_name`, `title`), and access flags (`is_query`, `is_create`, `is_update`). #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "role": 2, "field": { "id": 1, "model": "Users", "menu": 2, "field_name": "mobile", "title": "Mobile Phone" }, "is_query": true, "is_create": true, "is_update": true } ] } ``` ``` -------------------------------- ### Initialize and Interact with Django REST API using JavaScript Client Source: https://github.com/huge-dream/django-vue3-admin/blob/master/backend/templates/rest_framework/docs/langs/javascript.html This snippet demonstrates initializing a `coreapi.Client` and performing an API action. It requires `coreapi.js` and `schema.js` to be loaded. The `action` is constructed dynamically, and `params` can be provided if the API link has fields. The result of the action is handled in the `.then()` callback. ```javascript {% load rest_framework %} {% code javascript %}var coreapi = window.coreapi // Loaded by `coreapi.js` var schema = window.schema // Loaded by `schema.js` // Initialize a client var client = new coreapi.Client() // Interact with the API endpoint var action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"] {% if link.fields %}var params = { {% for field in link.fields %} {{ field.name }}: ...{% if not loop.last %},{% endif %} {% endfor %}} {% endif %}client.action(schema, action{% if link.fields %}, params{% endif %}).then(function(result) { // Return value is in 'result' }){% endcode %} ``` -------------------------------- ### GET /api/system/role_menu_permission/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves the menu permissions assigned to a specific role. Requires the role ID as a query parameter. ```APIDOC ## GET /api/system/role_menu_permission/ ### Description Retrieves the menu permissions assigned to a specific role. Requires the role ID as a query parameter. ### Method GET ### Endpoint /api/system/role_menu_permission/ ### Parameters #### Path Parameters None #### Query Parameters - **role** (integer) - Required - The ID of the role for which to retrieve menu permissions. #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/api/system/role_menu_permission/?role=2" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of permission objects, each indicating a role's access to a menu (`role`, `menu`). #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "role": 2, "menu": 1 }, { "id": 2, "role": 2, "menu": 2 } ] } ``` ``` -------------------------------- ### System Configuration API Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Manages system-wide settings and configurations. Supports fetching all settings and updating specific configuration values. ```APIDOC ## System Configuration API ### GET /api/system/system_config/ #### Description Retrieves all system configuration settings, organized hierarchically. #### Method GET #### Endpoint /api/system/system_config/ #### Response ##### Success Response (2000) - **code** (integer) - Response code, 2000 indicates success. - **data** (array) - A list of configuration objects. - **id** (integer) - Unique identifier for the configuration item. - **parent** (integer|null) - ID of the parent configuration item, null if it's a top-level item. - **title** (string) - The display title of the configuration item. - **key** (string) - The unique key for the configuration (e.g., "base.site_name"). - **value** (any) - The current value of the configuration. - **status** (boolean) - Indicates if the configuration is active. - **children** (array) - Nested configuration items. - **id** (integer) - Unique identifier for the child configuration item. - **title** (string) - The display title of the child configuration item. - **key** (string) - The unique key for the child configuration. - **value** (any) - The current value of the child configuration. - **form_item_type** (string) - The type of form input for this setting (e.g., "text", "switch"). #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "parent": null, "title": "Base Configuration", "key": "base", "value": {}, "status": true, "children": [ { "id": 2, "title": "Site Name", "key": "base.site_name", "value": "Django Vue3 Admin", "form_item_type": "text" }, { "id": 3, "title": "Enable CAPTCHA", "key": "base.captcha_state", "value": true, "form_item_type": "switch" } ] } ] } ``` ### PUT /api/system/system_config/save_content/ #### Description Updates a specific system configuration value. #### Method PUT #### Endpoint /api/system/system_config/save_content/ #### Parameters ##### Request Body - **key** (string) - Required - The key of the configuration to update (e.g., "base.site_name"). - **value** (any) - Required - The new value for the configuration. #### Request Example ```json { "key": "base.site_name", "value": "My Admin System" } ``` #### Response ##### Success Response (2000) - **code** (integer) - Response code, 2000 indicates success. - **msg** (string) - Success message, e.g., "保存成功". ##### Response Example ```json { "code": 2000, "msg": "保存成功" } ``` ``` -------------------------------- ### Django System Configuration Cache Initialization Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Initializes and caches system configurations from the database into Redis or memory. It allows for efficient retrieval of configuration values. Dependencies include Django's cache framework and the SystemConfig model. ```python from django.core.cache import cache from dvadmin.system.models import SystemConfig, Dictionary def init_system_config(): """ Initialize system configuration cache on startup Stores in Redis or memory depending on configuration """ configs = SystemConfig.objects.filter(status=True) config_dict = {} for config in configs: if config.parent: config_dict[config.key] = config.value cache.set('system_config', config_dict, timeout=None) return config_dict def get_system_config_values(key): """ Get configuration value from cache Usage: get_system_config_values('base.site_name') """ config_dict = cache.get('system_config') if not config_dict: config_dict = init_system_config() return config_dict.get(key) def refresh_system_config(): """Refresh configuration cache after updates""" cache.delete('system_config') return init_system_config() ``` -------------------------------- ### GET /api/system/dictionary/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves dictionary entries, supporting parent-child relationships and type filtering. Used for dropdowns and configuration selections. ```APIDOC ## GET /api/system/dictionary/ ### Description Retrieves dictionary entries, supporting parent-child relationships and type filtering. Used for dropdowns and configuration selections. ### Method GET ### Endpoint /api/system/dictionary/ ### Parameters #### Path Parameters None #### Query Parameters - **parent** (string/integer) - Optional - Filter by parent ID or leave empty for top-level dictionaries. - **type** (string) - Optional - Filter by dictionary type (e.g., 'select'). #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:8000/api/system/dictionary/?parent=&type=select" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (200) - **code** (integer) - Response code, typically 2000 for success. - **data** (array) - An array of dictionary objects, each with `id`, `label`, `value`, `type`, `parent`, `color`, `status`, `sort`, and optional `children` for nested entries. #### Response Example ```json { "code": 2000, "data": [ { "id": 1, "label": "User Status", "value": "user_status", "type": "select", "parent": null, "color": "primary", "status": true, "sort": 1, "children": [ {"id": 2, "label": "Active", "value": "1", "color": "success"}, {"id": 3, "label": "Inactive", "value": "0", "color": "danger"} ] } ] } ``` ``` -------------------------------- ### POST /api/system/file/ Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Uploads a file. The system handles automatic MD5 hashing and storage. ```APIDOC ## POST /api/system/file/ ### Description Uploads a file. The system handles automatic MD5 hashing and storage. ### Method POST ### Endpoint /api/system/file/ ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file** (file) - Required - The file to be uploaded (e.g., document.pdf). ### Request Example ```bash curl -X POST http://localhost:8000/api/system/file/ \ -H "Authorization: Bearer " \ -F "file=@document.pdf" ``` ### Response #### Success Response (200) - The response structure for successful file upload is not explicitly provided in the input, but typically includes details about the uploaded file (e.g., URL, filename, hash). #### Response Example (Example response structure not provided in the input.) ``` -------------------------------- ### Get Role Users (Authorized/Unauthorized) Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Retrieves users associated with a specific role, with options to filter by authorized or unauthorized status. ```APIDOC ## GET /api/system/role/get_role_users ### Description Retrieves users associated with a specific role. You can specify whether to get authorized or unauthorized users. ### Method GET ### Endpoint `/api/system/role/get_role_users` ### Parameters #### Query Parameters - **role_id** (integer) - Required - The ID of the role. - **authorized** (integer) - Required - 1 for authorized users, 0 for unauthorized users. - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page for pagination. ### Request Example ```bash # Get authorized users curl -X GET "http://localhost:8000/api/system/role/get_role_users?role_id=2&authorized=1&page=1&limit=10" \ -H "Authorization: Bearer " # Get unauthorized users curl -X GET "http://localhost:8000/api/system/role/get_role_users?role_id=2&authorized=0" \ -H "Authorization: Bearer " ``` ### Response #### Success Response (2000) - **code** (integer) - Success code, usually 2000. - **data** (object) - User data. - **total** (integer) - Total number of users matching the criteria. - **data** (array) - List of user objects. - **id** (integer) - User ID. - **name** (string) - User name. - **dept__name** (string) - The name of the department the user belongs to. #### Response Example (Authorized users) ```json { "code": 2000, "data": { "total": 5, "data": [ {"id": 3, "name": "John Doe", "dept__name": "Sales"}, {"id": 5, "name": "Jane Smith", "dept__name": "Marketing"} ] } } ``` #### Response Example (Unauthorized users) ```json { "code": 2000, "data": { "total": 20, "data": [ {"id": 8, "name": "Bob Wilson", "dept__name": "IT"}, {"id": 12, "name": "Alice Brown", "dept__name": "HR"} ] } } ``` ``` -------------------------------- ### Build and Push Web Frontend Docker Image Source: https://github.com/huge-dream/django-vue3-admin/blob/master/docker_env/README.md This snippet details the commands to build the Docker image for the web frontend using a specific Dockerfile and then push the compiled image to a remote Docker registry. It's essential for deploying the frontend application. ```shell # 编译打包到本地 docker build -f ./docker_env/web/DockerfileBuild -t registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-web:16.19-alpine . # 上传到阿里云仓库 docker push registry.cn-zhangjiakou.aliyuncs.com/dvadmin-pro/dvadmin3-base-web:16.19-alpine ``` -------------------------------- ### Django App Configuration Source: https://context7.com/huge-dream/django-vue3-admin/llms.txt Defines the configuration for the Django 'system' app, including initialization routines for system configuration and dictionary data. ```python from django.apps import AppConfig class SystemConfig(AppConfig): name = 'dvadmin.system' def ready(self): from application import dispatch dispatch.init_system_config() dispatch.init_dictionary() ```