Wood Chen

Show the key in one-api Channel Settings

0 comments179 views45 words

This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文

1697338111507.png

This is hidden by default, but if you're using it only yourself, or want to make management easier, you can display it here.

Where to Make the Change

In the source file model/channel.go

Original code

func GetChannelById(id int, selectAll bool) (*Channel, error) {
    channel := Channel{Id: id}
    var err error = nil;
    if selectAll {
        err = DB.First(&channel, "id = ?", id).Error
    } else {
        err = DB.Omit("key").First(&channel, "id = ?", id).Error
    }
    return &channel, err
}

Replace with

func GetChannelById(id int, selectAll bool) (*Channel, error) {
    channel := Channel{Id: id}
    var err error = nil
    err = DB.First(&channel, "id = ?", id).Error
    return &channel, err
}

Rebuild to Apply the Change

Last updated 2025-06-25

Related posts

Comments 0