bailinghub 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +7 -9
- package/README.md +7 -9
- package/docker-compose.images.yml +2 -2
- package/docs/AGENT_CLIENT_RUNTIME_API.en.md +46 -0
- package/docs/AGENT_CLIENT_RUNTIME_API.md +34 -0
- package/docs/AGENT_TASK_CONTROL.en.md +25 -0
- package/docs/AGENT_TASK_CONTROL.md +94 -0
- package/docs/AGENT_TASK_CONTROL_FOUNDATION.md +134 -0
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CHANGELOG.en.md +22 -1
- package/docs/CHANGELOG.md +22 -1
- package/docs/COMPATIBILITY.en.md +6 -0
- package/docs/CONTRACT.en.md +2 -0
- package/docs/CONTRACT.md +2 -0
- package/docs/GENERATED_ARTIFACTS.en.md +46 -0
- package/docs/GENERATED_ARTIFACTS.md +108 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
- package/docs/INDEPENDENT_VALIDATION.md +4 -4
- package/docs/INVOCATION_RECEIPTS.md +111 -0
- package/docs/MODEL_BILLING.en.md +123 -0
- package/docs/MODEL_BILLING.md +125 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.en.md +31 -0
- package/docs/PERIOD_ALLOWANCE_UPGRADE.md +31 -0
- package/docs/README.en.md +7 -0
- package/docs/README.md +7 -0
- package/docs/RELEASE_NOTES_NEXT.en.md +4 -2
- package/docs/RELEASE_NOTES_NEXT.md +4 -2
- package/docs/RELEASE_NOTES_v0.8.0.en.md +40 -0
- package/docs/RELEASE_NOTES_v0.8.0.md +62 -0
- package/docs/RELEASE_NOTES_v0.9.0.en.md +45 -0
- package/docs/RELEASE_NOTES_v0.9.0.md +45 -0
- package/docs/TOOL_RATE_LIMITS.md +50 -0
- package/docs/UPGRADE_v0.8.0.en.md +71 -0
- package/docs/UPGRADE_v0.8.0.md +73 -0
- package/docs/UPGRADE_v0.9.0.en.md +54 -0
- package/docs/UPGRADE_v0.9.0.md +54 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +6 -0
- package/package.json +1 -1
- package/schemas/config/route.schema.json +1 -0
- package/schemas/config/tool-provider.schema.json +2 -1
- package/scripts/check-doc-links.mjs +5 -0
- package/scripts/check-image-tags.sh +1 -1
- package/scripts/check-release-consistency.test.mjs +2 -2
- package/scripts/e2e-console.mjs +32 -2
- package/scripts/install.sh +1 -1
- package/scripts/publish-images.sh +1 -1
- package/scripts/release-audit.mjs +2 -0
- package/scripts/sdk-runtime-test.mjs +6 -0
- package/scripts/verify-billing-install-upgrade.mjs +225 -0
- package/scripts/verify-github-repo.mjs +2 -0
- package/sdk/node/README.md +17 -0
- package/sdk/node/examples/billing.mjs +21 -0
- package/sdk/node/package.json +5 -1
- package/sdk/node/src/index.mjs +2 -0
- package/sdk/node/src/usage.d.mts +74 -0
- package/sdk/node/src/usage.mjs +62 -0
- package/sdk/node/tests/usage-types.mts +23 -0
- package/sdk/node/tests/usage.test.mjs +81 -0
- package/sdk/php7/README.md +19 -2
- package/sdk/php7/examples/billing.php +27 -0
- package/sdk/php7/examples/well-known.php +1 -1
- package/sdk/php7/src/ToolSpec.php +1 -1
- package/sdk/php7/src/UsageClient.php +95 -0
- package/sdk/php7/src/UsageClientException.php +22 -0
- package/sdk/php7/tests/billing-core-http.php +59 -0
- package/sdk/php7/tests/usage-client.php +78 -0
- package/sql/060_agent_artifacts.sql +11 -0
- package/sql/061_tool_rate_limit_policies.sql +3 -0
- package/sql/062_agent_task_control.sql +92 -0
- package/sql/063_usage_model_billing.sql +153 -0
- package/sql/064_period_plan_allowance.sql +25 -0
- package/sql/README.en.md +12 -4
- package/sql/README.md +14 -6
- package/src/adapters/storage/object-storage.ts +15 -3
- package/src/adapters/storage/oss-signature.test.ts +40 -0
- package/src/adapters/storage/oss-signature.ts +21 -0
- package/src/app/agent-artifacts.test.ts +165 -0
- package/src/app/agent-artifacts.ts +85 -0
- package/src/app/agent-client-runtime.test.ts +76 -1
- package/src/app/agent-client-runtime.ts +13 -0
- package/src/app/agent-invocation-snapshot.ts +35 -0
- package/src/app/agent-task-control.ts +187 -0
- package/src/app/agent-task-runtime.ts +68 -0
- package/src/app/agent-tool-invocations.test.ts +329 -1
- package/src/app/agent-tool-invocations.ts +223 -10
- package/src/app/agent-tool-job.test.ts +11 -1
- package/src/app/agent-tool-job.ts +8 -1
- package/src/app/auth.ts +2 -0
- package/src/app/builtin-tools.ts +4 -0
- package/src/app/oss-edition.ts +2 -0
- package/src/app/tool-approvals.ts +4 -0
- package/src/app/tool-assembly.ts +5 -0
- package/src/core/config/artifact-config.ts +15 -0
- package/src/core/config/config-codec.ts +3 -1
- package/src/core/config/config-models.ts +11 -1
- package/src/core/config/route-config.ts +3 -2
- package/src/core/contracts/tool-rate-limits.test.ts +59 -0
- package/src/core/contracts/tool-rate-limits.ts +48 -0
- package/src/core/contracts/tools.ts +122 -43
- package/src/core/contracts/types.ts +3 -1
- package/src/core/runtime/agent-task-control.test.ts +114 -0
- package/src/core/runtime/agent-task-control.ts +227 -0
- package/src/infrastructure/config/config-agent-artifact-repository.ts +32 -0
- package/src/infrastructure/config/config-agent-client-runtime-repository.ts +7 -1
- package/src/infrastructure/config/config-agent-task-control-journal-mysql.test.ts +315 -0
- package/src/infrastructure/config/config-agent-task-control-mysql.test.ts +331 -0
- package/src/infrastructure/config/config-agent-task-control-repository.ts +640 -0
- package/src/infrastructure/config/config-rate-limit-ledger.integration.test.ts +52 -0
- package/src/infrastructure/config/config-rate-limit-ledger.ts +48 -0
- package/src/infrastructure/config/config-storage-bucket-repository.ts +2 -2
- package/src/infrastructure/config/config-tool-provider-repository.ts +4 -4
- package/src/infrastructure/config/configstore.ts +15 -1
- package/src/modules/usage/allowance-reset.mysql.test.ts +122 -0
- package/src/modules/usage/billing-contracts.ts +59 -0
- package/src/modules/usage/billing-decimal.test.ts +22 -0
- package/src/modules/usage/billing-decimal.ts +36 -0
- package/src/modules/usage/billing-external.ts +39 -0
- package/src/modules/usage/billing-gateway.mysql.test.ts +24 -0
- package/src/modules/usage/billing-ledger.test.ts +51 -0
- package/src/modules/usage/billing-ledger.ts +104 -0
- package/src/modules/usage/billing-presentation.mysql.test.ts +95 -0
- package/src/modules/usage/billing-presentation.test.ts +49 -0
- package/src/modules/usage/billing-presentation.ts +34 -0
- package/src/modules/usage/billing-prices.mysql.test.ts +88 -0
- package/src/modules/usage/billing-repository.mysql.test.ts +181 -0
- package/src/modules/usage/billing-repository.ts +463 -0
- package/src/modules/usage/contracts.ts +49 -0
- package/src/modules/usage/dynamic-plan-models.mysql.test.ts +221 -0
- package/src/modules/usage/errors.ts +19 -0
- package/src/modules/usage/http.ts +85 -0
- package/src/modules/usage/identity-revocation.mysql.test.ts +286 -0
- package/src/modules/usage/identity.mysql.test.ts +120 -0
- package/src/modules/usage/identity.ts +303 -0
- package/src/modules/usage/issuer-sdk-billing.mysql.test.ts +92 -0
- package/src/modules/usage/model-gateway.mysql.test.ts +207 -0
- package/src/modules/usage/model-gateway.ts +229 -0
- package/src/modules/usage/model-tool-gateway.mysql.test.ts +137 -0
- package/src/modules/usage/model-tool-provider.test.ts +37 -0
- package/src/modules/usage/model-tool-provider.ts +110 -0
- package/src/modules/usage/model-tools.test.ts +36 -0
- package/src/modules/usage/model-tools.ts +62 -0
- package/src/modules/usage/period-allowance.mysql.test.ts +97 -0
- package/src/modules/usage/period.test.ts +26 -0
- package/src/modules/usage/period.ts +96 -0
- package/src/modules/usage/pricing.test.ts +178 -0
- package/src/modules/usage/pricing.ts +228 -0
- package/src/modules/usage/provider-failure.ts +37 -0
- package/src/modules/usage/provider-stream.test.ts +85 -0
- package/src/modules/usage/provider-stream.ts +77 -0
- package/src/modules/usage/provider.test.ts +67 -0
- package/src/modules/usage/provider.ts +142 -0
- package/src/modules/usage/repository.ts +539 -0
- package/src/modules/usage/service-availability.mysql.test.ts +68 -0
- package/src/modules/usage/service-availability.ts +13 -0
- package/src/modules/usage/service-delete.mysql.test.ts +87 -0
- package/src/modules/usage/stream-http.ts +32 -0
- package/src/modules/usage/test-harness.ts +108 -0
- package/src/modules/usage/usage-deletion.mysql.test.ts +312 -0
- package/src/modules/usage/usage-deletion.ts +119 -0
- package/src/modules/usage/validation.test.ts +18 -0
- package/src/modules/usage/validation.ts +33 -0
- package/src/routes/admin-agent-tasks.ts +32 -0
- package/src/routes/admin-billing-usage.ts +73 -0
- package/src/routes/admin-tool-providers.test.ts +22 -0
- package/src/routes/admin-tool-providers.ts +9 -1
- package/src/routes/admin-usage.ts +147 -0
- package/src/routes/admin.ts +7 -0
- package/src/routes/agent-api.test.ts +76 -0
- package/src/routes/agent-api.ts +42 -1
- package/src/routes/agent-artifacts.ts +29 -0
- package/src/routes/agent-task-control-http-mysql.test.ts +246 -0
- package/src/routes/private.ts +9 -0
- package/src/routes/run.ts +2 -1
- package/src/test-support/agent-task-control-mysql-fixture.ts +75 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/console/assets/Accounts-Bervi5JU.css +1 -0
- package/web/console/assets/Accounts-DnddhY6t.js +3 -0
- package/web/console/assets/AgentClients-VInbD7JS.js +1 -0
- package/web/console/assets/AgentClients-i52AI6YV.css +1 -0
- package/web/console/assets/AgentTasks-B-1XklBg.js +2 -0
- package/web/console/assets/AgentTasks-BsG850Il.css +1 -0
- package/web/console/assets/{Approvals-Bs6FGbp2.js → Approvals-34qUPHf0.js} +1 -1
- package/web/console/assets/{Audit-4WWYhkFM.js → Audit-BbVgkSm2.js} +1 -1
- package/web/console/assets/{BrandLockup-D2GhCipL.js → BrandLockup-DgscF28e.js} +1 -1
- package/web/console/assets/{Channels-CmoGpiCJ.js → Channels-Bp-yuk8d.js} +1 -1
- package/web/console/assets/{ChatEntries-BFRMtwta.js → ChatEntries-C9Ft60TS.js} +1 -1
- package/web/console/assets/{Clients-DGkkSXyA.js → Clients-NPldD-DD.js} +1 -1
- package/web/console/assets/{Cost-BmGt0MfS.js → Cost-DZcuB-EB.js} +1 -1
- package/web/console/assets/{Credentials-CR-sYINT.js → Credentials-RTT7N6zl.js} +1 -1
- package/web/console/assets/{Diagnostics-DAPbKSJp.js → Diagnostics-_LeK8cce.js} +1 -1
- package/web/console/assets/{Executors-CgpiT3o8.js → Executors-Bi7H8rIm.js} +1 -1
- package/web/console/assets/{HelpTip-i-KJhf5s.js → HelpTip-BfyWrxCE.js} +1 -1
- package/web/console/assets/{Kb-Cm9dVSQw.js → Kb-BHamz8NP.js} +2 -2
- package/web/console/assets/{Login-CyUcsTZ_.js → Login-C1rJR-6w.js} +1 -1
- package/web/console/assets/{Projects-DldFPgWg.js → Projects-BRA4a48v.js} +1 -1
- package/web/console/assets/Routes-CTC7U-fQ.js +124 -0
- package/web/console/assets/Routes-CyXV4Pba.css +1 -0
- package/web/console/assets/{Runs-1hxgkuR4.js → Runs-B_fa_BlD.js} +1 -1
- package/web/console/assets/{Setup-DBLOnI2_.js → Setup-C1_d0mFy.js} +1 -1
- package/web/console/assets/Shell-CHEV6RGC.js +1 -0
- package/web/console/assets/Shell-ykb-tUfo.css +1 -0
- package/web/console/assets/StorageBuckets-CVgpZRWY.css +1 -0
- package/web/console/assets/StorageBuckets-DlG3ojhA.js +1 -0
- package/web/console/assets/{SystemSettings-cDkudo2y.js → SystemSettings-DYo2gg6d.js} +1 -1
- package/web/console/assets/{SystemStatus-DZd6s8OX.js → SystemStatus-DKCoUZlq.js} +1 -1
- package/web/console/assets/{Targets-DYNGq1NU.js → Targets-CdkG6BPR.js} +1 -1
- package/web/console/assets/Tools-DU8ei6sd.css +1 -0
- package/web/console/assets/Tools-DVpCt0ox.js +2 -0
- package/web/console/assets/Usage-CAeDGjrb.css +1 -0
- package/web/console/assets/Usage-DWCpLugC.js +1 -0
- package/web/console/assets/UsageAccess-B_Xq7ARW.js +1 -0
- package/web/console/assets/UsageAccess-CGGaWTuj.css +1 -0
- package/web/console/assets/UsageHelp-CSM4xO0K.css +1 -0
- package/web/console/assets/UsageHelp-t5ZG_f-e.js +1 -0
- package/web/console/assets/{index-QnmD7N7F.js → index-C6W4LWVV.js} +1 -1
- package/web/console/assets/{index-Fi9gkGxV.css → index-Cxuc9OCj.css} +1 -1
- package/web/console/assets/index-H1kfa0Mj.js +2 -0
- package/web/console/assets/{request-B7MLvOqo.js → request-DLsP1_ot.js} +1 -1
- package/web/console/assets/{schema-CMuwjYdJ.js → schema-BLOHvAJQ.js} +1 -1
- package/web/console/assets/{util-4bN2dv7B.js → util-CGVh2Jvr.js} +1 -1
- package/web/console/assets/{vendor-element-CZoEjZr8.js → vendor-element-BD089KxE.js} +1 -1
- package/web/console/assets/{vendor-mammoth-BUEEDX6A.js → vendor-mammoth-Bv-CZhmH.js} +1 -1
- package/web/console/index.html +3 -3
- package/web-admin/README.md +17 -0
- package/web-admin/scripts/agent-task-control-smoke.mjs +120 -0
- package/web-admin/src/components/AgentSetupPanel.vue +13 -0
- package/web-admin/src/components/ToolRateLimitEditor.vue +28 -0
- package/web-admin/src/components/UsageDeletionPreview.vue +44 -0
- package/web-admin/src/components/UsageHelp.vue +72 -0
- package/web-admin/src/components/UsageServiceReferences.vue +169 -0
- package/web-admin/src/layout/Shell.vue +23 -6
- package/web-admin/src/pages/Accounts.vue +3 -3
- package/web-admin/src/pages/AgentClients.vue +3 -1
- package/web-admin/src/pages/AgentTasks.vue +281 -0
- package/web-admin/src/pages/Routes.vue +5 -1
- package/web-admin/src/pages/StorageBuckets.vue +6 -6
- package/web-admin/src/pages/Tools.vue +53 -4
- package/web-admin/src/pages/Usage.vue +2470 -0
- package/web-admin/src/pages/UsageAccess.vue +1147 -0
- package/web-admin/src/router.ts +10 -4
- package/web-admin/src/styles/base.css +57 -0
- package/web-admin/src/table-widths.ts +16 -1
- package/web-admin/src/usage-deletion.ts +40 -0
- package/web-admin/src/usage-management.ts +13 -0
- package/web-admin/src/usage-presentation.test.ts +21 -0
- package/web-admin/src/usage-presentation.ts +107 -0
- package/web-admin/src/usage-price-preview.test.ts +60 -0
- package/web-admin/src/usage-price-preview.ts +54 -0
- package/web-admin/tests/token-usage.browser.mjs +773 -0
- package/web-admin/tests/usage-access.browser.mjs +398 -0
- package/web/console/assets/Accounts-B4ePH5jp.css +0 -1
- package/web/console/assets/Accounts-ChL9k-XA.js +0 -3
- package/web/console/assets/AgentClients-Bs7UgVDj.js +0 -1
- package/web/console/assets/AgentClients-DkgPTEbq.css +0 -1
- package/web/console/assets/Routes-DkMIjMQA.css +0 -1
- package/web/console/assets/Routes-DubfjlBD.js +0 -124
- package/web/console/assets/Shell-D9Uw-fsa.css +0 -1
- package/web/console/assets/Shell-gJ5Vz_E7.js +0 -1
- package/web/console/assets/StorageBuckets-DkDW16tj.js +0 -1
- package/web/console/assets/StorageBuckets-GnXnVvF0.css +0 -1
- package/web/console/assets/Tools-A20oaMaQ.css +0 -1
- package/web/console/assets/Tools-DpWM59vV.js +0 -2
- package/web/console/assets/index-DGqs28gI.js +0 -2
|
@@ -0,0 +1,1147 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="usage-access" shadow="never">
|
|
3
|
+
<template #header>
|
|
4
|
+
<div class="heading">
|
|
5
|
+
<div class="page-title">
|
|
6
|
+
<b>接入设置</b>
|
|
7
|
+
<UsageHelp title="接入设置说明">
|
|
8
|
+
<template v-if="tab === 'issuers'">
|
|
9
|
+
<p><b>身份来源:</b>业务产品负责登录,中枢按可信使用人管理模型额度。例如企业统一登录服务或独立 AI 助手后端。</p>
|
|
10
|
+
<p>创建来源时选择允许的模型服务;产品校验登录后,以稳定主体标识交换短期使用凭证。来源凭证仅交给可信服务端,不放入客户端或模型上下文。</p>
|
|
11
|
+
<p>闲置来源可以删除;已有登录身份或用量关联时请停用,删除前会显示占用原因。</p>
|
|
12
|
+
<p>登录会自动建立个人账户;团队共享额度时,再创建组织账户并添加成员。</p>
|
|
13
|
+
</template>
|
|
14
|
+
<template v-else>
|
|
15
|
+
<p><b>账户与成员:</b>登录会自动建立个人账户。组织账户需明确添加成员,再从套餐页开通共用额度。</p>
|
|
16
|
+
<p>个人和共享账户停用后均可移除,历史不受影响。在“已移除”中可恢复原账户,恢复后仍停用,不补发额度;原使用凭证不恢复。组织成员在账户详情中管理。</p>
|
|
17
|
+
<p>这里管理共享账户与成员;业务授权与审批仍由原系统负责,共享用量账户不会额外授予业务权限。</p>
|
|
18
|
+
</template>
|
|
19
|
+
</UsageHelp>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="actions">
|
|
22
|
+
<router-link to="/usage"
|
|
23
|
+
><el-button>返回模型与套餐</el-button></router-link
|
|
24
|
+
><el-button :loading="loading" @click="load">刷新设置</el-button>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
<el-alert
|
|
29
|
+
v-if="error"
|
|
30
|
+
:title="error"
|
|
31
|
+
type="error"
|
|
32
|
+
:closable="false"
|
|
33
|
+
show-icon
|
|
34
|
+
/>
|
|
35
|
+
<section v-if="pending" class="panel pending">
|
|
36
|
+
<b>有一项配置需要核对原结果</b>
|
|
37
|
+
<p>
|
|
38
|
+
已保留原提交内容。重试继续使用原请求,不会新建另一份账户或重复变更成员。
|
|
39
|
+
</p>
|
|
40
|
+
<el-button type="primary" :loading="saving" @click="retryPending"
|
|
41
|
+
>核对 / 重试原配置</el-button
|
|
42
|
+
>
|
|
43
|
+
</section>
|
|
44
|
+
<div class="console-page-tabs">
|
|
45
|
+
<div class="console-page-tabs-actions">
|
|
46
|
+
<el-button v-if="tab === 'issuers' && canManageIssuers" type="primary" :disabled="blocked" @click="openForm('issuer')">新增身份来源</el-button>
|
|
47
|
+
<template v-else-if="tab === 'accounts'">
|
|
48
|
+
<el-select v-model="accountView" aria-label="账户视图" style="width: 140px" :disabled="accountsLoading || blocked" @change="changeAccountView">
|
|
49
|
+
<el-option label="账户列表" value="current" /><el-option label="已移除" value="archived" />
|
|
50
|
+
</el-select>
|
|
51
|
+
<el-button v-if="canWrite && accountView === 'current'" type="primary" :disabled="blocked" @click="openForm('account')">创建共享账户</el-button>
|
|
52
|
+
</template>
|
|
53
|
+
</div>
|
|
54
|
+
<el-tabs v-model="tab">
|
|
55
|
+
<el-tab-pane label="身份来源" name="issuers">
|
|
56
|
+
<el-alert
|
|
57
|
+
v-if="!canViewIssuers"
|
|
58
|
+
title="当前管理员可以查看用量,但没有身份来源管理权限。"
|
|
59
|
+
type="info"
|
|
60
|
+
:closable="false"
|
|
61
|
+
/>
|
|
62
|
+
<el-table v-else :data="issuers" row-key="id"
|
|
63
|
+
><el-table-column label="身份来源" min-width="200"
|
|
64
|
+
><template #default="{ row }"
|
|
65
|
+
><b>{{ row.label }}</b>
|
|
66
|
+
<div class="muted mono">{{ row.id }}</div></template
|
|
67
|
+
></el-table-column
|
|
68
|
+
><el-table-column label="允许的模型服务" min-width="160"
|
|
69
|
+
><template #default="{ row }"
|
|
70
|
+
><div v-for="id in row.serviceIds" :key="id">
|
|
71
|
+
{{ serviceLabel(id) }}
|
|
72
|
+
</div></template
|
|
73
|
+
></el-table-column
|
|
74
|
+
><el-table-column label="服务端权限" min-width="180"
|
|
75
|
+
><template #default="{ row }"
|
|
76
|
+
><div v-for="permission in row.permissions" :key="permission">
|
|
77
|
+
{{ permissionLabel(permission) }}
|
|
78
|
+
</div></template
|
|
79
|
+
></el-table-column
|
|
80
|
+
><el-table-column label="状态" width="100"
|
|
81
|
+
><template #default="{ row }"
|
|
82
|
+
><el-tag :type="row.state === 'active' ? 'success' : 'info'">{{
|
|
83
|
+
row.state === "active" ? "启用" : "停用"
|
|
84
|
+
}}</el-tag></template
|
|
85
|
+
></el-table-column
|
|
86
|
+
><el-table-column v-if="canManageIssuers" label="操作" width="250" align="right" fixed="right"
|
|
87
|
+
><template #default="{ row }"
|
|
88
|
+
><el-button
|
|
89
|
+
link
|
|
90
|
+
:disabled="blocked"
|
|
91
|
+
@click="controlIssuer(row, false)"
|
|
92
|
+
>{{
|
|
93
|
+
row.state === "active" ? "停用来源" : "恢复来源"
|
|
94
|
+
}}</el-button
|
|
95
|
+
><el-button
|
|
96
|
+
link
|
|
97
|
+
type="primary"
|
|
98
|
+
:disabled="blocked"
|
|
99
|
+
@click="controlIssuer(row, true)"
|
|
100
|
+
>轮换凭证</el-button
|
|
101
|
+
><el-button link type="danger" :disabled="blocked" @click="deleteResource('issuer', row)">删除</el-button></template
|
|
102
|
+
></el-table-column
|
|
103
|
+
><template #empty
|
|
104
|
+
>还没有可信身份来源。新增后将专用凭证交给业务登录后端配置。</template
|
|
105
|
+
></el-table
|
|
106
|
+
>
|
|
107
|
+
</el-tab-pane>
|
|
108
|
+
<el-tab-pane label="账户与成员" name="accounts">
|
|
109
|
+
<el-table :data="accounts" row-key="id"
|
|
110
|
+
><el-table-column label="账户" min-width="220"
|
|
111
|
+
><template #default="{ row }"
|
|
112
|
+
><el-button link type="primary" @click="openAccount(row)">{{
|
|
113
|
+
row.label
|
|
114
|
+
}}</el-button>
|
|
115
|
+
<div class="muted mono">{{ row.id }}</div></template
|
|
116
|
+
></el-table-column
|
|
117
|
+
><el-table-column label="类型" width="140"
|
|
118
|
+
><template #default="{ row }">{{
|
|
119
|
+
row.kind === "organization" ? "组织共享" : "个人"
|
|
120
|
+
}}</template></el-table-column
|
|
121
|
+
><el-table-column label="状态" width="120"
|
|
122
|
+
><template #default="{ row }"
|
|
123
|
+
><el-tag :type="row.state === 'active' ? 'success' : 'info'">{{
|
|
124
|
+
row.state === "archived" ? "已移除" : row.state === "active" ? "可用" : "停用"
|
|
125
|
+
}}</el-tag></template
|
|
126
|
+
></el-table-column
|
|
127
|
+
><el-table-column label="创建时间" min-width="175"
|
|
128
|
+
><template #default="{ row }">{{
|
|
129
|
+
time(row.createdAt)
|
|
130
|
+
}}</template></el-table-column
|
|
131
|
+
><el-table-column label="操作" width="195" align="right" fixed="right"
|
|
132
|
+
><template #default="{ row }"
|
|
133
|
+
><el-button link type="primary" @click="openAccount(row)"
|
|
134
|
+
>账户与成员</el-button
|
|
135
|
+
><el-button v-if="canWrite && row.state === 'archived'" link type="primary" :disabled="blocked" @click="restoreAccount(row)">恢复</el-button><el-button v-else-if="canWrite" link type="danger" :disabled="blocked" @click="deleteResource('account', row)">移除</el-button></template
|
|
136
|
+
></el-table-column
|
|
137
|
+
><template #empty
|
|
138
|
+
>{{ accountView === "archived" ? "暂无已移除账户。" : "还没有用量账户。请先让产品通过可信身份来源完成一次登录。" }}</template
|
|
139
|
+
></el-table
|
|
140
|
+
>
|
|
141
|
+
<div v-if="cursor" class="more">
|
|
142
|
+
<el-button :loading="accountsLoading" @click="loadMoreAccounts"
|
|
143
|
+
>加载更多账户</el-button
|
|
144
|
+
>
|
|
145
|
+
</div>
|
|
146
|
+
</el-tab-pane>
|
|
147
|
+
</el-tabs>
|
|
148
|
+
</div>
|
|
149
|
+
</el-card>
|
|
150
|
+
|
|
151
|
+
<UsageDeletionPreview v-model="deletion.open.value" :label="deletion.label.value"
|
|
152
|
+
:report="deletion.report.value" :loading="deletion.loading.value" :busy="blocked"
|
|
153
|
+
:error="deletion.error.value" @refresh="deletion.refresh" @delete="confirmDeleteResource" />
|
|
154
|
+
<el-drawer
|
|
155
|
+
v-model="detailOpen"
|
|
156
|
+
:title="selected?.label || '账户与成员'"
|
|
157
|
+
size="min(780px,96vw)"
|
|
158
|
+
@closed="openDeferredForm"
|
|
159
|
+
><div class="detail" v-loading="detailLoading">
|
|
160
|
+
<el-alert
|
|
161
|
+
v-if="detailError"
|
|
162
|
+
:title="detailError"
|
|
163
|
+
type="error"
|
|
164
|
+
:closable="false"
|
|
165
|
+
/><template v-if="selected"
|
|
166
|
+
><div class="section-heading">
|
|
167
|
+
<div>
|
|
168
|
+
<p class="mono muted">{{ selected.id }}</p>
|
|
169
|
+
<p>
|
|
170
|
+
{{
|
|
171
|
+
selected.kind === "organization" ? "组织共享账户" : "个人账户"
|
|
172
|
+
}}
|
|
173
|
+
· {{ selected.state === "archived" ? "已移除" : selected.state === "active" ? "可用" : "已停用" }}
|
|
174
|
+
</p>
|
|
175
|
+
</div>
|
|
176
|
+
<el-button
|
|
177
|
+
v-if="canWrite && selected.state !== 'archived'"
|
|
178
|
+
:disabled="blocked"
|
|
179
|
+
@click="controlAccount"
|
|
180
|
+
>{{
|
|
181
|
+
selected.state === "active" ? "停用账户" : "启用账户"
|
|
182
|
+
}}</el-button
|
|
183
|
+
>
|
|
184
|
+
<el-button v-if="canWrite && selected.state === 'archived'" :disabled="blocked" @click="restoreAccount(selected)">恢复至账户列表</el-button>
|
|
185
|
+
</div>
|
|
186
|
+
<p class="muted">
|
|
187
|
+
停用账户会停止新的模型请求,已发生的用量仍保留原归属。账户成员资格不授予任何业务系统权限。
|
|
188
|
+
</p>
|
|
189
|
+
<div class="section-heading">
|
|
190
|
+
<h3>账户成员</h3>
|
|
191
|
+
<el-button
|
|
192
|
+
v-if="canWrite && selected.state !== 'archived' && selected.kind === 'organization'"
|
|
193
|
+
:disabled="blocked"
|
|
194
|
+
@click="openForm('member')"
|
|
195
|
+
>添加成员</el-button
|
|
196
|
+
>
|
|
197
|
+
</div>
|
|
198
|
+
<el-table :data="members" row-key="userId"
|
|
199
|
+
><el-table-column
|
|
200
|
+
prop="userId"
|
|
201
|
+
label="AI 使用人标识"
|
|
202
|
+
min-width="260"
|
|
203
|
+
/><el-table-column label="资格" width="110"
|
|
204
|
+
><template #default="{ row }">{{
|
|
205
|
+
row.state === "active" ? "有效" : "已移除"
|
|
206
|
+
}}</template></el-table-column
|
|
207
|
+
><el-table-column
|
|
208
|
+
v-if="canWrite && selected.state !== 'archived' && selected.kind === 'organization'"
|
|
209
|
+
width="100"
|
|
210
|
+
><template #default="{ row }"
|
|
211
|
+
><el-button
|
|
212
|
+
link
|
|
213
|
+
:disabled="blocked"
|
|
214
|
+
@click="controlMember(row)"
|
|
215
|
+
>{{
|
|
216
|
+
row.state === "active" ? "移除成员" : "恢复成员"
|
|
217
|
+
}}</el-button
|
|
218
|
+
></template
|
|
219
|
+
></el-table-column
|
|
220
|
+
></el-table
|
|
221
|
+
>
|
|
222
|
+
<p v-if="members.length >= 500" class="muted">
|
|
223
|
+
当前显示前 500 位成员。
|
|
224
|
+
</p></template
|
|
225
|
+
>
|
|
226
|
+
</div></el-drawer
|
|
227
|
+
>
|
|
228
|
+
|
|
229
|
+
<el-drawer
|
|
230
|
+
v-model="formOpen"
|
|
231
|
+
:title="formTitle"
|
|
232
|
+
size="min(540px,100vw)"
|
|
233
|
+
class="access-config-drawer"
|
|
234
|
+
@closed="finishFormClose"
|
|
235
|
+
:close-on-click-modal="false"
|
|
236
|
+
><el-form
|
|
237
|
+
novalidate
|
|
238
|
+
label-position="top"
|
|
239
|
+
:disabled="blocked"
|
|
240
|
+
@submit.prevent="submit"
|
|
241
|
+
>
|
|
242
|
+
<template v-if="formKind === 'issuer'"
|
|
243
|
+
><div class="form-grid">
|
|
244
|
+
<el-form-item label="来源名称"
|
|
245
|
+
><el-input
|
|
246
|
+
v-model="form.label"
|
|
247
|
+
placeholder="例如:企业统一登录服务"
|
|
248
|
+
maxlength="120" /></el-form-item
|
|
249
|
+
><el-form-item label="稳定标识"
|
|
250
|
+
><el-input
|
|
251
|
+
v-model="form.id"
|
|
252
|
+
placeholder="例如 commerce-login"
|
|
253
|
+
maxlength="64"
|
|
254
|
+
/></el-form-item>
|
|
255
|
+
</div>
|
|
256
|
+
<el-form-item label="允许的模型服务"
|
|
257
|
+
><el-select
|
|
258
|
+
v-model="form.serviceIds"
|
|
259
|
+
multiple
|
|
260
|
+
placeholder="选择该来源允许使用的服务"
|
|
261
|
+
><el-option
|
|
262
|
+
v-for="service in services"
|
|
263
|
+
:key="service.id"
|
|
264
|
+
:value="service.id"
|
|
265
|
+
:label="service.label"
|
|
266
|
+
:disabled="
|
|
267
|
+
service.state !== 'active'
|
|
268
|
+
" /></el-select></el-form-item
|
|
269
|
+
><el-form-item label="服务端权限"
|
|
270
|
+
><el-checkbox-group v-model="form.permissions" class="permissions"
|
|
271
|
+
><el-checkbox
|
|
272
|
+
v-for="permission in permissions"
|
|
273
|
+
:key="permission.value"
|
|
274
|
+
:value="permission.value"
|
|
275
|
+
><span
|
|
276
|
+
>{{ permission.label
|
|
277
|
+
}}<small>{{ permission.description }}</small></span
|
|
278
|
+
></el-checkbox
|
|
279
|
+
></el-checkbox-group
|
|
280
|
+
></el-form-item
|
|
281
|
+
><el-form-item
|
|
282
|
+
><template #label
|
|
283
|
+
>允许访问的组织账户(可选)
|
|
284
|
+
<UsageHelp title="来源的账户范围"
|
|
285
|
+
><p>
|
|
286
|
+
来源只能管理自己的个人账户,或明确选中的组织账户;不会自动获得全部模型与账户。
|
|
287
|
+
</p>
|
|
288
|
+
<p>
|
|
289
|
+
组织账户白名单不代替成员资格,使用人仍需是有效成员。
|
|
290
|
+
</p></UsageHelp
|
|
291
|
+
></template
|
|
292
|
+
><el-select
|
|
293
|
+
v-model="form.accountIds"
|
|
294
|
+
multiple
|
|
295
|
+
filterable
|
|
296
|
+
placeholder="仅在需要共享账户时选择"
|
|
297
|
+
><el-option
|
|
298
|
+
v-for="account in accounts.filter(
|
|
299
|
+
(a) => a.kind === 'organization',
|
|
300
|
+
)"
|
|
301
|
+
:key="account.id"
|
|
302
|
+
:value="account.id"
|
|
303
|
+
:label="account.label"
|
|
304
|
+
:disabled="account.state !== 'active'" /></el-select
|
|
305
|
+
><el-button
|
|
306
|
+
v-if="cursor"
|
|
307
|
+
link
|
|
308
|
+
:loading="accountsLoading"
|
|
309
|
+
@click="loadMoreAccounts"
|
|
310
|
+
>加载更多账户</el-button
|
|
311
|
+
></el-form-item
|
|
312
|
+
>
|
|
313
|
+
</template>
|
|
314
|
+
<template v-else-if="formKind === 'account'"
|
|
315
|
+
><el-form-item label="共享账户名称"
|
|
316
|
+
><el-input
|
|
317
|
+
v-model="form.label"
|
|
318
|
+
placeholder="例如:产品运营团队"
|
|
319
|
+
maxlength="120" /></el-form-item
|
|
320
|
+
><el-form-item
|
|
321
|
+
><template #label
|
|
322
|
+
>首位成员的 AI 使用人标识
|
|
323
|
+
<UsageHelp title="从哪里取得使用人标识"
|
|
324
|
+
><p>
|
|
325
|
+
填写可信登录交换结果中的 user_id。首位成员需已通过产品登录建立
|
|
326
|
+
AI 使用身份,不填写手机号、组织名称或业务系统本地编号。
|
|
327
|
+
</p>
|
|
328
|
+
<p>创建后再为共享账户开通套餐。</p></UsageHelp
|
|
329
|
+
></template
|
|
330
|
+
><el-input
|
|
331
|
+
v-model="form.userId"
|
|
332
|
+
placeholder="从可信登录交换结果取得的 user_id"
|
|
333
|
+
/></el-form-item>
|
|
334
|
+
</template>
|
|
335
|
+
<template v-else
|
|
336
|
+
><el-form-item
|
|
337
|
+
><template #label
|
|
338
|
+
>成员的 AI 使用人标识
|
|
339
|
+
<UsageHelp title="添加共享账户成员"
|
|
340
|
+
><p>使用可信登录交换结果中的 user_id,成员仍使用原身份。</p>
|
|
341
|
+
<p>
|
|
342
|
+
加入后共用当前组织账户的模型额度,不改变业务授权范围。
|
|
343
|
+
</p></UsageHelp
|
|
344
|
+
></template
|
|
345
|
+
><el-input
|
|
346
|
+
v-model="form.userId"
|
|
347
|
+
placeholder="可信登录交换结果中的 user_id"
|
|
348
|
+
/></el-form-item>
|
|
349
|
+
<p class="muted">
|
|
350
|
+
加入后即可共用“{{ selected?.label }}”的已开通额度。
|
|
351
|
+
</p></template
|
|
352
|
+
>
|
|
353
|
+
<el-alert
|
|
354
|
+
v-if="formError"
|
|
355
|
+
:title="formError"
|
|
356
|
+
type="error"
|
|
357
|
+
:closable="false"
|
|
358
|
+
/>
|
|
359
|
+
</el-form>
|
|
360
|
+
<template #footer
|
|
361
|
+
><div class="drawer-actions">
|
|
362
|
+
<el-button @click="formOpen = false">取消</el-button>
|
|
363
|
+
<el-button
|
|
364
|
+
type="primary"
|
|
365
|
+
:loading="saving"
|
|
366
|
+
:disabled="
|
|
367
|
+
blocked || (formKind === 'issuer' ? !canManageIssuers : !canWrite)
|
|
368
|
+
"
|
|
369
|
+
@click="submit"
|
|
370
|
+
>{{
|
|
371
|
+
formKind === "issuer"
|
|
372
|
+
? "创建身份来源"
|
|
373
|
+
: formKind === "account"
|
|
374
|
+
? "创建共享账户"
|
|
375
|
+
: "添加成员"
|
|
376
|
+
}}</el-button
|
|
377
|
+
>
|
|
378
|
+
</div></template
|
|
379
|
+
>
|
|
380
|
+
</el-drawer>
|
|
381
|
+
<el-drawer
|
|
382
|
+
v-model="credentialOpen"
|
|
383
|
+
title="保存服务端来源凭证"
|
|
384
|
+
size="min(520px,100vw)"
|
|
385
|
+
class="access-config-drawer"
|
|
386
|
+
:close-on-click-modal="false"
|
|
387
|
+
@closed="credential = ''"
|
|
388
|
+
>
|
|
389
|
+
<el-alert
|
|
390
|
+
title="凭证仅显示这一次。请保存到产品后端的安全配置中,不放入浏览器、智能体提示词或公开文档。"
|
|
391
|
+
type="warning"
|
|
392
|
+
:closable="false"
|
|
393
|
+
/><el-input
|
|
394
|
+
class="credential"
|
|
395
|
+
:model-value="credential"
|
|
396
|
+
type="password"
|
|
397
|
+
readonly
|
|
398
|
+
show-password
|
|
399
|
+
autocomplete="off"
|
|
400
|
+
/><template #footer
|
|
401
|
+
><div class="drawer-actions">
|
|
402
|
+
<el-button @click="copyCredential">复制凭证</el-button
|
|
403
|
+
><el-button type="primary" @click="credentialOpen = false"
|
|
404
|
+
>已安全保存</el-button
|
|
405
|
+
>
|
|
406
|
+
</div></template
|
|
407
|
+
>
|
|
408
|
+
</el-drawer>
|
|
409
|
+
</template>
|
|
410
|
+
<script setup lang="ts">
|
|
411
|
+
import { computed, onMounted, reactive, ref } from "vue";
|
|
412
|
+
import { useRoute } from "vue-router";
|
|
413
|
+
import { ElCheckboxGroup } from "element-plus/es/components/checkbox/index";
|
|
414
|
+
import { ElMessage } from "element-plus/es/components/message/index";
|
|
415
|
+
import { ElMessageBox } from "element-plus/es/components/message-box/index";
|
|
416
|
+
import { api } from "../request";
|
|
417
|
+
import { useMe } from "../store";
|
|
418
|
+
import { kernelMountPath } from "../runtime-path";
|
|
419
|
+
import UsageDeletionPreview from "../components/UsageDeletionPreview.vue";
|
|
420
|
+
import { useUsageDeletion } from "../usage-deletion";
|
|
421
|
+
import UsageHelp from "../components/UsageHelp.vue";
|
|
422
|
+
interface Account {
|
|
423
|
+
id: string;
|
|
424
|
+
label: string;
|
|
425
|
+
kind: "personal" | "organization";
|
|
426
|
+
state: "active" | "suspended" | "archived";
|
|
427
|
+
revision: number;
|
|
428
|
+
createdAt: number;
|
|
429
|
+
}
|
|
430
|
+
interface Member {
|
|
431
|
+
userId: string;
|
|
432
|
+
state: "active" | "revoked";
|
|
433
|
+
revision: number;
|
|
434
|
+
}
|
|
435
|
+
interface Service {
|
|
436
|
+
id: string;
|
|
437
|
+
label: string;
|
|
438
|
+
state: "active" | "suspended";
|
|
439
|
+
}
|
|
440
|
+
interface Issuer {
|
|
441
|
+
id: string;
|
|
442
|
+
label: string;
|
|
443
|
+
revision: number;
|
|
444
|
+
state: "active" | "suspended";
|
|
445
|
+
serviceIds: string[];
|
|
446
|
+
permissions: string[];
|
|
447
|
+
accountIds: string[];
|
|
448
|
+
}
|
|
449
|
+
type FormKind = "issuer" | "account" | "member";
|
|
450
|
+
interface Attempt {
|
|
451
|
+
path: string;
|
|
452
|
+
method: "POST" | "PUT" | "DELETE";
|
|
453
|
+
body: Record<string, unknown>;
|
|
454
|
+
kind: FormKind | "issuer_control" | "account_control" | "member_control" | "issuer_delete" | "account_delete" | "account_restore";
|
|
455
|
+
}
|
|
456
|
+
const base = "/admin/api/usage",
|
|
457
|
+
me = useMe(),
|
|
458
|
+
route = useRoute();
|
|
459
|
+
const canWrite = computed(() => me.can("usage:write")),
|
|
460
|
+
canViewIssuers = computed(() => me.can("usage:issuers")),
|
|
461
|
+
canManageIssuers = computed(() => canWrite.value && canViewIssuers.value);
|
|
462
|
+
const tab = ref(route.query.tab === "accounts" ? "accounts" : "issuers"),
|
|
463
|
+
loading = ref(false),
|
|
464
|
+
saving = ref(false),
|
|
465
|
+
error = ref(""),
|
|
466
|
+
pending = ref<Attempt | null>(null),
|
|
467
|
+
storageFailed = ref(false);
|
|
468
|
+
const blocked = computed(
|
|
469
|
+
() => loading.value || saving.value || !!pending.value || storageFailed.value,
|
|
470
|
+
);
|
|
471
|
+
const accountView = ref<"current" | "archived">("current");
|
|
472
|
+
const accounts = ref<Account[]>([]),
|
|
473
|
+
issuers = ref<Issuer[]>([]),
|
|
474
|
+
services = ref<Service[]>([]),
|
|
475
|
+
cursor = ref<string | null>(null),
|
|
476
|
+
accountsLoading = ref(false);
|
|
477
|
+
const selected = ref<Account | null>(null),
|
|
478
|
+
members = ref<Member[]>([]),
|
|
479
|
+
detailOpen = ref(false),
|
|
480
|
+
detailLoading = ref(false),
|
|
481
|
+
detailError = ref("");
|
|
482
|
+
const formFromAccount = ref(false),
|
|
483
|
+
deferredForm = ref(false),
|
|
484
|
+
deferredCredential = ref(false);
|
|
485
|
+
const formOpen = ref(false),
|
|
486
|
+
formKind = ref<FormKind>("issuer"),
|
|
487
|
+
formError = ref("");
|
|
488
|
+
const defaults = () => ({
|
|
489
|
+
id: "",
|
|
490
|
+
label: "",
|
|
491
|
+
userId: "",
|
|
492
|
+
serviceIds: [] as string[],
|
|
493
|
+
accountIds: [] as string[],
|
|
494
|
+
permissions: ["identity:exchange", "identity:revoke"] as string[],
|
|
495
|
+
});
|
|
496
|
+
const form = reactive(defaults());
|
|
497
|
+
const formTitle = computed(
|
|
498
|
+
() =>
|
|
499
|
+
({
|
|
500
|
+
issuer: "新增身份来源",
|
|
501
|
+
account: "创建共享账户",
|
|
502
|
+
member: "添加账户成员",
|
|
503
|
+
})[formKind.value],
|
|
504
|
+
);
|
|
505
|
+
const credentialOpen = ref(false),
|
|
506
|
+
credential = ref("");
|
|
507
|
+
const permissions = [
|
|
508
|
+
{
|
|
509
|
+
value: "identity:exchange",
|
|
510
|
+
label: "交换登录身份",
|
|
511
|
+
description: "为已经登录的用户取得短期模型使用凭证。",
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
value: "identity:revoke",
|
|
515
|
+
label: "撤销使用身份",
|
|
516
|
+
description: "产品账号停用时,让对应的模型使用身份失效。",
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
value: "entitlements:write",
|
|
520
|
+
label: "管理套餐状态",
|
|
521
|
+
description: "允许产品后端开通套餐、暂停或恢复使用。",
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
value: "allowance:grant",
|
|
525
|
+
label: "开通用量额度",
|
|
526
|
+
description: "配合套餐管理权限,按选定套餐发放一份额度。",
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
value: "usage:read",
|
|
530
|
+
label: "读取用量",
|
|
531
|
+
description: "读取本来源有权访问的账户用量与套餐目录。",
|
|
532
|
+
},
|
|
533
|
+
];
|
|
534
|
+
const permissionLabel = (key: string) =>
|
|
535
|
+
permissions.find((p) => p.value === key)?.label || key;
|
|
536
|
+
const segment = (id: string) => encodeURIComponent(id).replaceAll("%3A", ":");
|
|
537
|
+
const serviceLabel = (id: string) =>
|
|
538
|
+
services.value.find((s) => s.id === id)?.label || id;
|
|
539
|
+
const time = (n: number) =>
|
|
540
|
+
new Date(n).toLocaleString("zh-CN", { hour12: false });
|
|
541
|
+
function message(e: unknown) {
|
|
542
|
+
const code = e instanceof Error ? e.message : "请求失败";
|
|
543
|
+
const known: Record<string, string> = {
|
|
544
|
+
USAGE_RESOURCE_IN_USE: "该记录已有使用关联,请查看删除抽屉中的占用原因。",
|
|
545
|
+
USAGE_RESOURCE_DELETED: "记录已删除,原标识不能重新使用。",
|
|
546
|
+
USAGE_RESOURCE_NOT_FOUND: "记录已不存在,请刷新列表。",
|
|
547
|
+
USAGE_FORBIDDEN: "当前管理员没有此操作权限。",
|
|
548
|
+
USAGE_REVISION_CONFLICT: "记录已更新,请刷新并核对当前状态。",
|
|
549
|
+
USAGE_USER_NOT_FOUND: "该 AI 使用身份不存在,请先让成员通过可信产品登录。",
|
|
550
|
+
USAGE_ACCOUNT_FORBIDDEN: "所选账户不可用或已删除,请刷新并核对来源的账户范围。",
|
|
551
|
+
USAGE_ACCOUNT_SUSPENDED: "账户已停用或移除,请先在账户列表核对并恢复原账户。",
|
|
552
|
+
USAGE_ACCOUNT_NOT_FOUND: "账户已不存在,请刷新。",
|
|
553
|
+
USAGE_NOT_FOUND: "记录已不存在,请刷新。",
|
|
554
|
+
USAGE_INVALID_INPUT: "配置不符合要求,请检查填写内容。",
|
|
555
|
+
USAGE_IDEMPOTENCY_CONFLICT: "原请求内容发生冲突,请核对原操作。",
|
|
556
|
+
USAGE_UNSUPPORTED: "用量模块尚未就绪,请核对版本与迁移。",
|
|
557
|
+
};
|
|
558
|
+
return known[code] || `操作未完成:${code}`;
|
|
559
|
+
}
|
|
560
|
+
async function load() {
|
|
561
|
+
if (loading.value) return;
|
|
562
|
+
loading.value = true;
|
|
563
|
+
if (!storageFailed.value) error.value = "";
|
|
564
|
+
try {
|
|
565
|
+
const results = await Promise.allSettled([
|
|
566
|
+
loadAccounts(),
|
|
567
|
+
api<{ items: Service[] }>(`${base}/services`).then(
|
|
568
|
+
(r) => (services.value = r.items),
|
|
569
|
+
),
|
|
570
|
+
canViewIssuers.value
|
|
571
|
+
? api<{ items: Issuer[] }>(`${base}/issuers`).then(
|
|
572
|
+
(r) => (issuers.value = r.items),
|
|
573
|
+
)
|
|
574
|
+
: Promise.resolve(),
|
|
575
|
+
]);
|
|
576
|
+
for (const r of results) if (r.status === "rejected") throw r.reason;
|
|
577
|
+
} catch (e) {
|
|
578
|
+
error.value = message(e);
|
|
579
|
+
} finally {
|
|
580
|
+
loading.value = false;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function loadAccounts(more = false) {
|
|
584
|
+
if (accountsLoading.value) return;
|
|
585
|
+
accountsLoading.value = true;
|
|
586
|
+
try {
|
|
587
|
+
const query = new URLSearchParams({ limit: "30", view: accountView.value });
|
|
588
|
+
if (more && cursor.value) query.set("cursor", cursor.value);
|
|
589
|
+
const r = await api<{ items: Account[]; next_cursor: string | null }>(
|
|
590
|
+
`${base}/accounts?${query}`,
|
|
591
|
+
);
|
|
592
|
+
accounts.value = more ? [...accounts.value, ...r.items] : r.items;
|
|
593
|
+
cursor.value = r.next_cursor;
|
|
594
|
+
} finally {
|
|
595
|
+
accountsLoading.value = false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
async function changeAccountView() {
|
|
599
|
+
accounts.value = []; cursor.value = null;
|
|
600
|
+
try { await loadAccounts(); } catch (e) { error.value = message(e); }
|
|
601
|
+
}
|
|
602
|
+
async function loadMoreAccounts() {
|
|
603
|
+
try {
|
|
604
|
+
await loadAccounts(true);
|
|
605
|
+
} catch (e) {
|
|
606
|
+
error.value = message(e);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
async function openAccount(account: Account) {
|
|
610
|
+
selected.value = account;
|
|
611
|
+
detailOpen.value = true;
|
|
612
|
+
await loadDetail();
|
|
613
|
+
}
|
|
614
|
+
async function loadDetail() {
|
|
615
|
+
const id = selected.value?.id;
|
|
616
|
+
if (!id) return;
|
|
617
|
+
detailLoading.value = true;
|
|
618
|
+
detailError.value = "";
|
|
619
|
+
members.value = [];
|
|
620
|
+
try {
|
|
621
|
+
const result = await api<{ account: Account | null; members: Member[] }>(
|
|
622
|
+
`${base}/accounts/${segment(id)}`,
|
|
623
|
+
);
|
|
624
|
+
if (selected.value?.id !== id) return;
|
|
625
|
+
if (!result.account) throw new Error("USAGE_ACCOUNT_NOT_FOUND");
|
|
626
|
+
selected.value = result.account;
|
|
627
|
+
members.value = result.members;
|
|
628
|
+
} catch (e) {
|
|
629
|
+
detailError.value = message(e);
|
|
630
|
+
} finally {
|
|
631
|
+
detailLoading.value = false;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
async function openForm(kind: FormKind) {
|
|
635
|
+
if (kind === 'issuer' && accountView.value !== 'current') {
|
|
636
|
+
accountView.value = 'current';
|
|
637
|
+
try { await changeAccountView(); } catch { return; }
|
|
638
|
+
}
|
|
639
|
+
formKind.value = kind;
|
|
640
|
+
Object.assign(form, defaults());
|
|
641
|
+
formError.value = "";
|
|
642
|
+
formFromAccount.value = detailOpen.value;
|
|
643
|
+
if (detailOpen.value) {
|
|
644
|
+
deferredForm.value = true;
|
|
645
|
+
detailOpen.value = false;
|
|
646
|
+
} else formOpen.value = true;
|
|
647
|
+
}
|
|
648
|
+
function openDeferredForm() {
|
|
649
|
+
if (deferredForm.value) {
|
|
650
|
+
deferredForm.value = false;
|
|
651
|
+
formOpen.value = true;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
async function finishFormClose() {
|
|
655
|
+
if (deferredCredential.value) {
|
|
656
|
+
deferredCredential.value = false;
|
|
657
|
+
credentialOpen.value = true;
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (!formFromAccount.value || !selected.value) return;
|
|
661
|
+
formFromAccount.value = false;
|
|
662
|
+
detailOpen.value = true;
|
|
663
|
+
await loadDetail();
|
|
664
|
+
}
|
|
665
|
+
const stableId = (value: string, label: string) => {
|
|
666
|
+
const text = value.trim();
|
|
667
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.:-]*$/.test(text) || text.length > 191)
|
|
668
|
+
throw new Error(`请填写有效的${label}。`);
|
|
669
|
+
return text;
|
|
670
|
+
};
|
|
671
|
+
async function submit() {
|
|
672
|
+
formError.value = "";
|
|
673
|
+
try {
|
|
674
|
+
const request_key = crypto.randomUUID();
|
|
675
|
+
if (formKind.value === "issuer") {
|
|
676
|
+
if (!canManageIssuers.value) throw new Error("USAGE_FORBIDDEN");
|
|
677
|
+
if (!form.label.trim() || !form.serviceIds.length)
|
|
678
|
+
throw new Error("请填写来源名称,并至少选择一个模型服务。");
|
|
679
|
+
if (!form.permissions.length)
|
|
680
|
+
throw new Error("请至少选择一项服务端权限。");
|
|
681
|
+
if (
|
|
682
|
+
form.permissions.includes("allowance:grant") &&
|
|
683
|
+
!form.permissions.includes("entitlements:write")
|
|
684
|
+
)
|
|
685
|
+
throw new Error("开通用量额度需要同时允许管理套餐状态。");
|
|
686
|
+
await mutate({
|
|
687
|
+
kind: "issuer",
|
|
688
|
+
path: `${base}/issuers`,
|
|
689
|
+
method: "POST",
|
|
690
|
+
body: {
|
|
691
|
+
id: stableId(form.id, "来源标识"),
|
|
692
|
+
label: form.label.trim(),
|
|
693
|
+
service_ids: [...form.serviceIds],
|
|
694
|
+
account_ids: [...form.accountIds],
|
|
695
|
+
permissions: [...form.permissions],
|
|
696
|
+
},
|
|
697
|
+
});
|
|
698
|
+
} else if (formKind.value === "account") {
|
|
699
|
+
if (!canWrite.value) throw new Error("USAGE_FORBIDDEN");
|
|
700
|
+
if (!form.label.trim()) throw new Error("请填写共享账户名称。");
|
|
701
|
+
await mutate({
|
|
702
|
+
kind: "account",
|
|
703
|
+
path: `${base}/accounts`,
|
|
704
|
+
method: "POST",
|
|
705
|
+
body: {
|
|
706
|
+
request_key,
|
|
707
|
+
source_id: request_key,
|
|
708
|
+
kind: "organization",
|
|
709
|
+
label: form.label.trim(),
|
|
710
|
+
user_id: stableId(form.userId, "AI 使用人标识"),
|
|
711
|
+
},
|
|
712
|
+
});
|
|
713
|
+
} else {
|
|
714
|
+
if (!canWrite.value || selected.value?.kind !== "organization")
|
|
715
|
+
throw new Error("USAGE_FORBIDDEN");
|
|
716
|
+
const userId = stableId(form.userId, "AI 使用人标识");
|
|
717
|
+
if (members.value.some((m) => m.userId === userId))
|
|
718
|
+
throw new Error("此成员已存在;如已移除,请从成员列表恢复。");
|
|
719
|
+
await mutate({
|
|
720
|
+
kind: "member",
|
|
721
|
+
path: `${base}/accounts/${segment(selected.value.id)}/members/${segment(userId)}`,
|
|
722
|
+
method: "PUT",
|
|
723
|
+
body: { request_key, expected_revision: 0, state: "active" },
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
} catch (e) {
|
|
727
|
+
formError.value = message(e);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async function confirm(text: string) {
|
|
731
|
+
try {
|
|
732
|
+
await ElMessageBox.confirm(text, "确认操作", {
|
|
733
|
+
confirmButtonText: "确认",
|
|
734
|
+
cancelButtonText: "返回",
|
|
735
|
+
type: "warning",
|
|
736
|
+
});
|
|
737
|
+
return true;
|
|
738
|
+
} catch {
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
async function controlIssuer(issuer: Issuer, rotate: boolean) {
|
|
743
|
+
if (!canManageIssuers.value) return;
|
|
744
|
+
if (
|
|
745
|
+
!(await confirm(
|
|
746
|
+
rotate
|
|
747
|
+
? "轮换后原来源凭证与短期使用凭证失效。新凭证仅显示一次,请同步更新产品后端。"
|
|
748
|
+
: "修改来源状态后,原短期使用凭证失效。原用量记录与在途结算仍保留。",
|
|
749
|
+
))
|
|
750
|
+
)
|
|
751
|
+
return;
|
|
752
|
+
try {
|
|
753
|
+
await mutate({
|
|
754
|
+
kind: "issuer_control",
|
|
755
|
+
path: `${base}/issuers/${segment(issuer.id)}/control`,
|
|
756
|
+
method: "POST",
|
|
757
|
+
body: {
|
|
758
|
+
expected_revision: issuer.revision,
|
|
759
|
+
state: rotate
|
|
760
|
+
? issuer.state
|
|
761
|
+
: issuer.state === "active"
|
|
762
|
+
? "suspended"
|
|
763
|
+
: "active",
|
|
764
|
+
rotate,
|
|
765
|
+
},
|
|
766
|
+
});
|
|
767
|
+
} catch (e) {
|
|
768
|
+
error.value = message(e);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
async function restoreAccount(account: Account) {
|
|
772
|
+
if (!canWrite.value || blocked.value || account.state !== 'archived' || !(await confirm('恢复原账户至停用状态;保留原套餐、已用额度和成员记录,不补发额度,不恢复旧使用凭证。需要使用时再启用账户。'))) return;
|
|
773
|
+
try {
|
|
774
|
+
await mutate({ kind: 'account_restore', path: `${base}/accounts/${segment(account.id)}/restore`, method: 'POST',
|
|
775
|
+
body: { request_key: crypto.randomUUID(), expected_revision: account.revision } });
|
|
776
|
+
} catch (e) { error.value = message(e); }
|
|
777
|
+
}
|
|
778
|
+
async function controlAccount() {
|
|
779
|
+
const account = selected.value;
|
|
780
|
+
if (
|
|
781
|
+
!canWrite.value ||
|
|
782
|
+
!account || account.state === "archived" ||
|
|
783
|
+
!(await confirm(
|
|
784
|
+
"更新账户状态会影响全部成员的后续模型请求,不修改原用量归属或业务授权。",
|
|
785
|
+
))
|
|
786
|
+
)
|
|
787
|
+
return;
|
|
788
|
+
try {
|
|
789
|
+
await mutate({
|
|
790
|
+
kind: "account_control",
|
|
791
|
+
path: `${base}/accounts/${segment(account.id)}/control`,
|
|
792
|
+
method: "POST",
|
|
793
|
+
body: {
|
|
794
|
+
request_key: crypto.randomUUID(),
|
|
795
|
+
expected_revision: account.revision,
|
|
796
|
+
state: account.state === "active" ? "suspended" : "active",
|
|
797
|
+
},
|
|
798
|
+
});
|
|
799
|
+
} catch (e) {
|
|
800
|
+
detailError.value = message(e);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async function controlMember(member: Member) {
|
|
804
|
+
if (
|
|
805
|
+
!canWrite.value ||
|
|
806
|
+
selected.value?.kind !== "organization" || selected.value.state === "archived" ||
|
|
807
|
+
!(await confirm(
|
|
808
|
+
"更新此成员使用组织共享模型额度的资格;原用量和业务权限不变。",
|
|
809
|
+
))
|
|
810
|
+
)
|
|
811
|
+
return;
|
|
812
|
+
try {
|
|
813
|
+
await mutate({
|
|
814
|
+
kind: "member_control",
|
|
815
|
+
path: `${base}/accounts/${segment(selected.value.id)}/members/${segment(member.userId)}`,
|
|
816
|
+
method: "PUT",
|
|
817
|
+
body: {
|
|
818
|
+
request_key: crypto.randomUUID(),
|
|
819
|
+
expected_revision: member.revision,
|
|
820
|
+
state: member.state === "active" ? "revoked" : "active",
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
} catch (e) {
|
|
824
|
+
detailError.value = message(e);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const deletion = useUsageDeletion(message);
|
|
828
|
+
async function deleteResource(kind: "issuer" | "account", resource: Issuer | Account) {
|
|
829
|
+
if (blocked.value || !canWrite.value || (kind === "issuer" && !canManageIssuers.value)) return;
|
|
830
|
+
await deletion.show(`${base}/${kind === "issuer" ? "issuers" : "accounts"}/${encodeURIComponent(resource.id)}`, resource.label);
|
|
831
|
+
}
|
|
832
|
+
async function confirmDeleteResource() {
|
|
833
|
+
const report = deletion.report.value;
|
|
834
|
+
if (!report?.can_delete || deletion.loading.value || blocked.value || !canWrite.value) return;
|
|
835
|
+
if (report.kind !== "issuer" && report.kind !== "account") return;
|
|
836
|
+
if (report.kind === "issuer" && !canManageIssuers.value) return;
|
|
837
|
+
try {
|
|
838
|
+
await mutate({ kind: report.kind === "issuer" ? "issuer_delete" : "account_delete",
|
|
839
|
+
method: "DELETE", path: deletion.path.value,
|
|
840
|
+
body: { request_key: crypto.randomUUID(), expected_revision: report.revision } });
|
|
841
|
+
} catch (e) { deletion.error.value = message(e); }
|
|
842
|
+
}
|
|
843
|
+
const storageKey = () =>
|
|
844
|
+
`bailing:usage-access:pending:v1:${kernelMountPath()}:${me.me?.username || ""}`;
|
|
845
|
+
function validAttempt(value: unknown): value is Attempt {
|
|
846
|
+
if (!value || typeof value !== "object") return false;
|
|
847
|
+
const a = value as Attempt;
|
|
848
|
+
if (
|
|
849
|
+
!a.body ||
|
|
850
|
+
typeof a.body !== "object" ||
|
|
851
|
+
!["POST", "PUT", "DELETE"].includes(a.method)
|
|
852
|
+
)
|
|
853
|
+
return false;
|
|
854
|
+
const path = a.path;
|
|
855
|
+
if (typeof path !== "string") return false;
|
|
856
|
+
return (
|
|
857
|
+
(a.kind === "issuer_delete" && a.method === "DELETE" && /^\/admin\/api\/usage\/issuers\/[A-Za-z0-9_.:%-]+$/.test(path)) ||
|
|
858
|
+
(a.kind === "account_delete" && a.method === "DELETE" && /^\/admin\/api\/usage\/accounts\/[A-Za-z0-9_.:%-]+$/.test(path)) ||
|
|
859
|
+
(a.kind === "issuer" &&
|
|
860
|
+
a.method === "POST" &&
|
|
861
|
+
path === `${base}/issuers`) ||
|
|
862
|
+
(a.kind === "account" &&
|
|
863
|
+
a.method === "POST" &&
|
|
864
|
+
path === `${base}/accounts`) ||
|
|
865
|
+
(a.kind === "issuer_control" &&
|
|
866
|
+
a.method === "POST" &&
|
|
867
|
+
/^\/admin\/api\/usage\/issuers\/[A-Za-z0-9_.:%-]+\/control$/.test(
|
|
868
|
+
path,
|
|
869
|
+
)) ||
|
|
870
|
+
(a.kind === "account_restore" && a.method === "POST" && /^\/admin\/api\/usage\/accounts\/[A-Za-z0-9_.:%-]+\/restore$/.test(path)) ||
|
|
871
|
+
(a.kind === "account_control" &&
|
|
872
|
+
a.method === "POST" &&
|
|
873
|
+
/^\/admin\/api\/usage\/accounts\/[A-Za-z0-9_.:%-]+\/control$/.test(
|
|
874
|
+
path,
|
|
875
|
+
)) ||
|
|
876
|
+
(["member", "member_control"].includes(a.kind) &&
|
|
877
|
+
a.method === "PUT" &&
|
|
878
|
+
/^\/admin\/api\/usage\/accounts\/[A-Za-z0-9_.:%-]+\/members\/[A-Za-z0-9_.:%-]+$/.test(
|
|
879
|
+
path,
|
|
880
|
+
))
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
async function mutate(attempt: Attempt) {
|
|
884
|
+
if (blocked.value) throw new Error("请先完成上一次操作或等待刷新。");
|
|
885
|
+
try {
|
|
886
|
+
sessionStorage.setItem(storageKey(), JSON.stringify(attempt));
|
|
887
|
+
} catch {
|
|
888
|
+
storageFailed.value = true;
|
|
889
|
+
throw new Error("无法保存原请求,本次尚未提交。请恢复会话存储后刷新。");
|
|
890
|
+
}
|
|
891
|
+
pending.value = attempt;
|
|
892
|
+
await retryPending();
|
|
893
|
+
}
|
|
894
|
+
async function clearPending() {
|
|
895
|
+
sessionStorage.removeItem(storageKey());
|
|
896
|
+
pending.value = null;
|
|
897
|
+
}
|
|
898
|
+
const definitive = new Set([
|
|
899
|
+
"USAGE_RESOURCE_IN_USE",
|
|
900
|
+
"USAGE_RESOURCE_DELETED",
|
|
901
|
+
"USAGE_RESOURCE_NOT_FOUND",
|
|
902
|
+
"USAGE_INVALID_INPUT",
|
|
903
|
+
"USAGE_FORBIDDEN",
|
|
904
|
+
"USAGE_REVISION_CONFLICT",
|
|
905
|
+
"USAGE_IDEMPOTENCY_CONFLICT",
|
|
906
|
+
"USAGE_USER_NOT_FOUND",
|
|
907
|
+
"USAGE_ACCOUNT_FORBIDDEN",
|
|
908
|
+
"USAGE_ACCOUNT_NOT_FOUND",
|
|
909
|
+
"USAGE_ACCOUNT_SUSPENDED",
|
|
910
|
+
"USAGE_NOT_FOUND",
|
|
911
|
+
"USAGE_UNSUPPORTED",
|
|
912
|
+
]);
|
|
913
|
+
async function retryPending() {
|
|
914
|
+
if (!pending.value || saving.value) return;
|
|
915
|
+
const attempt = pending.value;
|
|
916
|
+
saving.value = true;
|
|
917
|
+
error.value = "";
|
|
918
|
+
try {
|
|
919
|
+
const response = await api<{
|
|
920
|
+
credential?: string | null;
|
|
921
|
+
created?: boolean;
|
|
922
|
+
}>(attempt.path, {
|
|
923
|
+
method: attempt.method,
|
|
924
|
+
body: JSON.stringify(attempt.body),
|
|
925
|
+
});
|
|
926
|
+
await clearPending();
|
|
927
|
+
const wasFormOpen = formOpen.value;
|
|
928
|
+
if (typeof response.credential === "string") {
|
|
929
|
+
credential.value = response.credential;
|
|
930
|
+
if (wasFormOpen) deferredCredential.value = true;
|
|
931
|
+
else credentialOpen.value = true;
|
|
932
|
+
} else if (attempt.kind === "issuer" && response.created === false) {
|
|
933
|
+
ElMessage.warning(
|
|
934
|
+
"来源已创建,凭证不再回显。若上次未保存,请轮换来源凭证后更新产品后端。",
|
|
935
|
+
);
|
|
936
|
+
} else if (attempt.kind.endsWith("_delete")) {
|
|
937
|
+
deletion.open.value = false;
|
|
938
|
+
if (attempt.kind === "account_delete" && selected.value && attempt.path.endsWith(`/${encodeURIComponent(selected.value.id)}`)) detailOpen.value = false;
|
|
939
|
+
ElMessage.success(attempt.kind === "account_delete" ? "账户已移除,可在“已移除”中恢复原账户。" : "已删除,历史记录保留。");
|
|
940
|
+
} else if (attempt.kind === "account_restore") ElMessage.success("原账户已恢复至停用状态;需要使用时请再启用。");
|
|
941
|
+
else ElMessage.success("接入配置已保存。");
|
|
942
|
+
formOpen.value = false;
|
|
943
|
+
await load();
|
|
944
|
+
if (detailOpen.value) await loadDetail();
|
|
945
|
+
} catch (e) {
|
|
946
|
+
const code = e instanceof Error ? e.message : "";
|
|
947
|
+
let description = message(e);
|
|
948
|
+
if (definitive.has(code)) {
|
|
949
|
+
await clearPending();
|
|
950
|
+
if (
|
|
951
|
+
code === "USAGE_REVISION_CONFLICT" &&
|
|
952
|
+
attempt.kind === "issuer_control" &&
|
|
953
|
+
attempt.body.rotate === true
|
|
954
|
+
)
|
|
955
|
+
description =
|
|
956
|
+
"来源修订已变化,无法恢复上次生成的凭证。已刷新当前来源,请重新轮换并安全保存新凭证。";
|
|
957
|
+
await load();
|
|
958
|
+
if (detailOpen.value) await loadDetail();
|
|
959
|
+
}
|
|
960
|
+
if (attempt.kind.endsWith("_delete") && deletion.open.value) {
|
|
961
|
+
await deletion.refresh();
|
|
962
|
+
deletion.error.value = description;
|
|
963
|
+
}
|
|
964
|
+
error.value = description;
|
|
965
|
+
if (formOpen.value) formError.value = description;
|
|
966
|
+
if (detailOpen.value) detailError.value = description;
|
|
967
|
+
} finally {
|
|
968
|
+
saving.value = false;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
async function copyCredential() {
|
|
972
|
+
try {
|
|
973
|
+
await navigator.clipboard.writeText(credential.value);
|
|
974
|
+
ElMessage.success("已复制,请保存到可信产品后端。");
|
|
975
|
+
} catch {
|
|
976
|
+
ElMessage.warning("复制失败,请手动安全保存。");
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
onMounted(() => {
|
|
980
|
+
try {
|
|
981
|
+
const stored = JSON.parse(sessionStorage.getItem(storageKey()) || "null");
|
|
982
|
+
if (stored) {
|
|
983
|
+
if (validAttempt(stored)) pending.value = stored;
|
|
984
|
+
else {
|
|
985
|
+
storageFailed.value = true;
|
|
986
|
+
error.value = "原配置请求无法识别,请先核对当前记录。";
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
} catch {
|
|
990
|
+
storageFailed.value = true;
|
|
991
|
+
error.value = "无法读取原配置请求,请恢复会话存储后刷新。";
|
|
992
|
+
}
|
|
993
|
+
void load();
|
|
994
|
+
});
|
|
995
|
+
</script>
|
|
996
|
+
<style scoped>
|
|
997
|
+
.usage-access {
|
|
998
|
+
min-width: 0;
|
|
999
|
+
}
|
|
1000
|
+
.usage-access :deep(.el-card__body) {
|
|
1001
|
+
display: grid;
|
|
1002
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1003
|
+
gap: 16px;
|
|
1004
|
+
min-width: 0;
|
|
1005
|
+
}
|
|
1006
|
+
.page-title {
|
|
1007
|
+
display: flex;
|
|
1008
|
+
align-items: center;
|
|
1009
|
+
gap: 5px;
|
|
1010
|
+
}
|
|
1011
|
+
.detail {
|
|
1012
|
+
display: grid;
|
|
1013
|
+
gap: 22px;
|
|
1014
|
+
}
|
|
1015
|
+
.heading,
|
|
1016
|
+
.section-heading,
|
|
1017
|
+
.actions,
|
|
1018
|
+
.dialog-footer {
|
|
1019
|
+
display: flex;
|
|
1020
|
+
align-items: center;
|
|
1021
|
+
justify-content: space-between;
|
|
1022
|
+
gap: 16px;
|
|
1023
|
+
}
|
|
1024
|
+
.section-heading p {
|
|
1025
|
+
font-size: 13px;
|
|
1026
|
+
color: var(--el-text-color-secondary);
|
|
1027
|
+
line-height: 1.8;
|
|
1028
|
+
margin: 5px 0;
|
|
1029
|
+
}
|
|
1030
|
+
h2 {
|
|
1031
|
+
font-size: 20px;
|
|
1032
|
+
margin: 0 0 7px;
|
|
1033
|
+
}
|
|
1034
|
+
h3 {
|
|
1035
|
+
font-size: 16px;
|
|
1036
|
+
margin: 0;
|
|
1037
|
+
}
|
|
1038
|
+
.actions {
|
|
1039
|
+
justify-content: flex-start;
|
|
1040
|
+
flex-wrap: wrap;
|
|
1041
|
+
}
|
|
1042
|
+
.section-heading {
|
|
1043
|
+
margin-bottom: 20px;
|
|
1044
|
+
}
|
|
1045
|
+
.panel {
|
|
1046
|
+
padding: 22px 25px;
|
|
1047
|
+
border: 1px solid var(--el-border-color-light);
|
|
1048
|
+
background: var(--el-fill-color-blank);
|
|
1049
|
+
}
|
|
1050
|
+
.pending {
|
|
1051
|
+
border-color: var(--el-color-warning);
|
|
1052
|
+
}
|
|
1053
|
+
.pending p,
|
|
1054
|
+
.guide li,
|
|
1055
|
+
.muted {
|
|
1056
|
+
font-size: 12px;
|
|
1057
|
+
line-height: 1.85;
|
|
1058
|
+
color: var(--el-text-color-secondary);
|
|
1059
|
+
}
|
|
1060
|
+
.guide {
|
|
1061
|
+
margin-top: 24px;
|
|
1062
|
+
border-left: 3px solid var(--el-color-primary);
|
|
1063
|
+
}
|
|
1064
|
+
.guide ol {
|
|
1065
|
+
padding-left: 20px;
|
|
1066
|
+
display: grid;
|
|
1067
|
+
gap: 8px;
|
|
1068
|
+
}
|
|
1069
|
+
.form-grid {
|
|
1070
|
+
display: grid;
|
|
1071
|
+
grid-template-columns: 1fr 1fr;
|
|
1072
|
+
gap: 18px;
|
|
1073
|
+
}
|
|
1074
|
+
.usage-access :deep(.el-select) {
|
|
1075
|
+
width: 100%;
|
|
1076
|
+
}
|
|
1077
|
+
.usage-access :deep(.el-tabs__content) {
|
|
1078
|
+
padding-top: 20px;
|
|
1079
|
+
}
|
|
1080
|
+
.permissions {
|
|
1081
|
+
display: grid;
|
|
1082
|
+
gap: 12px;
|
|
1083
|
+
}
|
|
1084
|
+
.permissions :deep(.el-checkbox) {
|
|
1085
|
+
height: auto;
|
|
1086
|
+
margin-right: 0;
|
|
1087
|
+
align-items: flex-start;
|
|
1088
|
+
}
|
|
1089
|
+
.permissions :deep(.el-checkbox__input) {
|
|
1090
|
+
margin-top: 3px;
|
|
1091
|
+
}
|
|
1092
|
+
.permissions :deep(.el-checkbox__label) {
|
|
1093
|
+
white-space: normal;
|
|
1094
|
+
}
|
|
1095
|
+
.permissions small {
|
|
1096
|
+
display: block;
|
|
1097
|
+
font-size: 11px;
|
|
1098
|
+
line-height: 1.8;
|
|
1099
|
+
color: var(--el-text-color-secondary);
|
|
1100
|
+
margin-top: 3px;
|
|
1101
|
+
}
|
|
1102
|
+
.drawer-actions {
|
|
1103
|
+
display: flex;
|
|
1104
|
+
justify-content: flex-end;
|
|
1105
|
+
gap: 10px;
|
|
1106
|
+
flex-wrap: wrap;
|
|
1107
|
+
}
|
|
1108
|
+
.drawer-actions :deep(.el-button + .el-button) {
|
|
1109
|
+
margin-left: 0;
|
|
1110
|
+
}
|
|
1111
|
+
.access-config-drawer :deep(.el-drawer__footer) {
|
|
1112
|
+
border-top: 1px solid var(--el-border-color-light);
|
|
1113
|
+
padding: 16px 20px;
|
|
1114
|
+
}
|
|
1115
|
+
.access-config-drawer .form-grid {
|
|
1116
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1117
|
+
}
|
|
1118
|
+
.access-config-drawer :deep(.el-select) {
|
|
1119
|
+
width: 100%;
|
|
1120
|
+
}
|
|
1121
|
+
.credential {
|
|
1122
|
+
margin-top: 20px;
|
|
1123
|
+
}
|
|
1124
|
+
.mono {
|
|
1125
|
+
overflow-wrap: anywhere;
|
|
1126
|
+
}
|
|
1127
|
+
.more {
|
|
1128
|
+
text-align: center;
|
|
1129
|
+
padding: 18px;
|
|
1130
|
+
}
|
|
1131
|
+
.detail .section-heading {
|
|
1132
|
+
margin: 0;
|
|
1133
|
+
}
|
|
1134
|
+
@media (max-width: 800px) {
|
|
1135
|
+
.heading,
|
|
1136
|
+
.section-heading {
|
|
1137
|
+
align-items: flex-start;
|
|
1138
|
+
flex-wrap: wrap;
|
|
1139
|
+
}
|
|
1140
|
+
.form-grid {
|
|
1141
|
+
grid-template-columns: 1fr;
|
|
1142
|
+
}
|
|
1143
|
+
.panel {
|
|
1144
|
+
padding: 18px;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
</style>
|