mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-20 08:01:46 +00:00
feat(admin): add image model shortcut to account allowlists
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1389,6 +1389,7 @@ Key 预算及其访问状态随互联默认公开,不要求开启 `shareQuota`
|
||||
最多 256 项,每个 ID 最多 256 字节;重复 ID 去重,不接受空白、控制字符、`__` 前缀或 `*` 通配符。
|
||||
允许保存当前上游目录尚未返回的 ID。限制按全局模型映射后的上游 ID 判断,不扩大账号本身的上游权限。
|
||||
管理端刷新目录只更新目录,不修改模型限制。全选与取消全选只作用于上游目录中符合当前搜索条件的模型。
|
||||
账号白名单中,“添加模型”旁的图片按钮可勾选 `gpt-image-2` 和 `gpt-image-1.5`。
|
||||
自定义模型取消勾选后在本次编辑期间保留,可再次勾选。保存时以最终选中项更新限制,关闭或取消编辑会丢弃草稿。
|
||||
白名单的清理按钮列出当前目录未返回的已选 ID,默认不选中任何项,
|
||||
由管理员确认后从当前表单移除,保存账号后生效。目录未就绪、刷新失败或返回空目录时不能清理,清理也不能将白名单置空。
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"searchOrAddModels": "Search or add models",
|
||||
"searchOrEnterId": "Search models or enter a full ID",
|
||||
"addModel": "Add model",
|
||||
"addImageModels": "Add common OpenAI image models",
|
||||
"customModels": "Custom",
|
||||
"availableModels": "Available models",
|
||||
"upstreamCatalog": "Upstream catalog",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"searchOrAddModels": "搜索或添加模型",
|
||||
"searchOrEnterId": "搜索模型或输入完整 ID",
|
||||
"addModel": "添加模型",
|
||||
"addImageModels": "添加常用 OpenAI 生图模型",
|
||||
"customModels": "自定义",
|
||||
"availableModels": "可选模型",
|
||||
"upstreamCatalog": "上游目录",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"searchOrAddModels": "搜索或添加模型",
|
||||
"searchOrEnterId": "搜索模型或輸入完整 ID",
|
||||
"addModel": "添加模型",
|
||||
"addImageModels": "加入常用 OpenAI 圖像生成模型",
|
||||
"customModels": "自定義",
|
||||
"availableModels": "可選模型",
|
||||
"upstreamCatalog": "上游目錄",
|
||||
|
||||
@@ -3,12 +3,12 @@ import type { AccountModelAccess } from '@/api'
|
||||
|
||||
import { ZButton, ZEmpty, ZFormItem, ZIconButton, ZInput, ZPopover, ZSegmented } from '@codex-proxy/ui'
|
||||
|
||||
import { CircleAlert, ListChecks, ListMinus, Plus, RefreshCw, Search } from '@lucide/vue'
|
||||
import { CircleAlert, ImagePlus, ListChecks, ListMinus, Plus, RefreshCw, Search } from '@lucide/vue'
|
||||
import { computed, ref, useTemplateRef, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getAccountGroupModels, getAccountModels, refreshAccountModels } from '@/api'
|
||||
import { useRequestState } from '@/composables/useRequestState'
|
||||
import { accountModelAccessError, accountModelIdError } from '../utils/modelAccess'
|
||||
import { accountModelAccessError, accountModelIdError, commonImageModels } from '../utils/modelAccess'
|
||||
import AccountModelCleanupPopover from './AccountModelCleanupPopover.vue'
|
||||
import AccountModelOption from './AccountModelOption.vue'
|
||||
|
||||
@@ -82,6 +82,7 @@ const mode = computed({
|
||||
})
|
||||
const restricted = computed(() => mode.value === 'allowlist' || mode.value === 'denylist')
|
||||
const selectedIds = computed(() => new Set(model.value?.models))
|
||||
const allImageModelsSelected = computed(() => commonImageModels.every(id => selectedIds.value.has(id)))
|
||||
// 候选项保留到本次编辑结束,取消勾选只修改待保存的模型限制。
|
||||
const availableIds = ref<string[]>([])
|
||||
const catalogReady = computed(() => catalog.value !== undefined && !loading.value && !error.value)
|
||||
@@ -164,10 +165,8 @@ function select(modelIds: string[], selected: boolean) {
|
||||
model.value = next
|
||||
}
|
||||
|
||||
function addModel() {
|
||||
if (props.disabled || !restricted.value || !canAdd.value)
|
||||
return
|
||||
select([newModelId.value], true)
|
||||
function addModels(ids: string[]) {
|
||||
select(ids, true)
|
||||
if (!selectionError.value) {
|
||||
search.value = ''
|
||||
searchInput.value?.focus()
|
||||
@@ -178,7 +177,8 @@ function handleSearchEnter(event: KeyboardEvent) {
|
||||
if (event.isComposing)
|
||||
return
|
||||
event.preventDefault()
|
||||
addModel()
|
||||
if (canAdd.value)
|
||||
addModels([newModelId.value])
|
||||
}
|
||||
|
||||
function handleCatalogHelpKeydown(event: KeyboardEvent, open: boolean, close: () => void) {
|
||||
@@ -306,10 +306,20 @@ watch(search, () => {
|
||||
<Search class="size-4" aria-hidden="true" />
|
||||
</template>
|
||||
</ZInput>
|
||||
<ZButton v-if="!groupCatalog" class="shrink-0" :disabled="disabled || !canAdd" @click="addModel">
|
||||
<ZButton v-if="!groupCatalog" class="shrink-0" :disabled="disabled || !canAdd" @click="addModels([newModelId])">
|
||||
<Plus class="size-4" aria-hidden="true" />
|
||||
{{ t('accounts.modelAccess.addModel') }}
|
||||
</ZButton>
|
||||
<ZIconButton
|
||||
v-if="!groupCatalog && mode === 'allowlist'"
|
||||
variant="plain"
|
||||
:aria-label="t('accounts.modelAccess.addImageModels')"
|
||||
:title="t('accounts.modelAccess.addImageModels')"
|
||||
:disabled="disabled || allImageModelsSelected"
|
||||
@click="addModels(commonImageModels)"
|
||||
>
|
||||
<ImagePlus aria-hidden="true" />
|
||||
</ZIconButton>
|
||||
</div>
|
||||
<p v-if="inputError" class="m-0 text-z-xs text-z-error-text" role="alert">
|
||||
{{ inputError }}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import type { AccountModelAccess } from '@/api'
|
||||
import { t } from '@/i18n'
|
||||
|
||||
// Codex 原生生图使用 gpt-image-2,另保留 gpt-image-1.5 供客户端显式选择
|
||||
export const commonImageModels = [
|
||||
'gpt-image-2',
|
||||
'gpt-image-1.5',
|
||||
]
|
||||
|
||||
export function accountModelAccessError(value: AccountModelAccess | undefined): string | undefined {
|
||||
if (!value || value.mode === 'all')
|
||||
return undefined
|
||||
|
||||
Reference in New Issue
Block a user