Help us learn about your current experience with the documentation. Take the survey.

应用外观 API

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab Self-Managed, GitLab Dedicated

使用此 API 控制您的 GitLab 实例的外观。更多信息,请参阅 GitLab 外观

先决条件:

  • 您必须具有该实例的管理员访问权限。

获取当前应用外观详情

获取此 GitLab 实例的当前外观配置详情。

GET /application/appearance

示例请求:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/application/appearance"

示例响应:

{
  "title": "GitLab Test Instance",
  "description": "gitlab-test.example.com",
  "pwa_name": "GitLab PWA",
  "pwa_short_name": "GitLab",
  "pwa_description": "GitLab as PWA",
  "pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
  "logo": "/uploads/-/system/appearance/logo/1/logo.png",
  "header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
  "favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
  "member_guidelines": "Custom member guidelines",
  "new_project_guidelines": "Please read the FAQs for help.",
  "profile_image_guidelines": "Custom profile image guidelines",
  "header_message": "",
  "footer_message": "",
  "message_background_color": "#e75e40",
  "message_font_color": "#ffffff",
  "email_header_and_footer_enabled": false
}

更新应用外观

更新此 GitLab 实例的当前外观配置。

PUT /application/appearance
属性 类型 必填 描述
title string 登录/注册页面上显示的实例标题
description string 登录/注册页面上显示的 Markdown 文本
pwa_name string Progressive Web App 的全名。用于 manifest.json 中的 name 属性。GitLab 15.8 中引入
pwa_short_name string Progressive Web App 的简称。GitLab 15.8 中引入
pwa_description string Progressive Web App 功能说明。用于 manifest.json 中的 description 属性。GitLab 15.8 中引入
pwa_icon mixed 用于 Progressive Web App 的图标。请参阅更新应用徽标GitLab 15.8 中引入
logo mixed 登录/注册页面上使用的实例图片。请参阅更新应用徽标
header_logo mixed 主导航栏中使用的实例图片
favicon mixed 实例的 favicon,格式为 .ico.png
member_guidelines string 在群组或项目成员页面上向有更改成员权限的用户显示的 Markdown 文本
new_project_guidelines string 新建项目页面上显示的 Markdown 文本
profile_image_guidelines string 个人资料页面上在公开头像下方显示的 Markdown 文本
header_message string 系统顶部栏中的消息
footer_message string 系统底部栏中的消息
message_background_color string 系统顶部/底部栏的背景颜色
message_font_color string 系统顶部/底部栏的字体颜色
email_header_and_footer_enabled boolean 如果启用,则为所有外发邮件添加页眉和页脚

示例请求:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/application/appearance?email_header_and_footer_enabled=true&header_message=test"

示例响应:

{
  "title": "GitLab Test Instance",
  "description": "gitlab-test.example.com",
  "pwa_name": "GitLab PWA",
  "pwa_short_name": "GitLab",
  "pwa_description": "GitLab as PWA",
  "pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
  "logo": "/uploads/-/system/appearance/logo/1/logo.png",
  "header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
  "favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
  "member_guidelines": "Custom member guidelines",
  "new_project_guidelines": "Please read the FAQs for help.",
  "profile_image_guidelines": "Custom profile image guidelines",
  "header_message": "test",
  "footer_message": "",
  "message_background_color": "#e75e40",
  "message_font_color": "#ffffff",
  "email_header_and_footer_enabled": true
}

更新应用徽标

使用包含的图像文件更新此 GitLab 实例的当前徽标。

要从本地文件系统上传头像,请使用 --form 参数来包含文件。 这会使 cURL 使用 Content-Type: multipart/form-data 标头发布数据。 file= 参数必须指向文件系统上的图像文件,并以 @ 开头。

PUT /application/appearance
属性 类型 必填 描述
logo mixed 用作徽标的图像。
pwa_icon mixed 用于 Progressive Web App 的图像。GitLab 15.8 中引入

示例请求:

curl --location --request PUT \
  --url "https://gitlab.example.com/api/v4/application/appearance?data=image/png" \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: multipart/form-data" \
  --form "logo=@/path/to/logo.png"

示例响应:

{
  "logo":"/uploads/-/system/appearance/logo/1/logo.png"
}