bailinghub 0.3.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/.dockerignore +42 -0
- package/.env.example +83 -0
- package/.gitignore +44 -0
- package/.npmignore +56 -0
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +74 -0
- package/Dockerfile +16 -0
- package/LICENSE +176 -0
- package/LICENSING.md +9 -0
- package/NOTICE +23 -0
- package/README.en.md +264 -0
- package/README.md +279 -0
- package/SECURITY.md +30 -0
- package/THIRD_PARTY_NOTICES.md +254 -0
- package/VISION.md +41 -0
- package/assets/architecture-overview.en-dark.png +0 -0
- package/assets/architecture-overview.en-dark.svg +57 -0
- package/assets/architecture-overview.en.png +0 -0
- package/assets/architecture-overview.en.svg +57 -0
- package/assets/architecture-overview.zh-CN-dark.png +0 -0
- package/assets/architecture-overview.zh-CN-dark.svg +57 -0
- package/assets/architecture-overview.zh-CN.png +0 -0
- package/assets/architecture-overview.zh-CN.svg +57 -0
- package/assets/bailinghub-lockup-dark.png +0 -0
- package/assets/bailinghub-lockup-dark.svg +8 -0
- package/assets/bailinghub-lockup.png +0 -0
- package/assets/bailinghub-lockup.svg +8 -0
- package/brain/README.en.md +23 -0
- package/brain/README.md +45 -0
- package/brain/agents/code-review.md +41 -0
- package/brain/agents/triage.md +37 -0
- package/brain/profiles.json +114 -0
- package/brain/runbooks/ticket-triage.md +24 -0
- package/config.example.json +58 -0
- package/contracts/client-api/consumers.json +28 -0
- package/contracts/client-api/v1/error-response.schema.json +21 -0
- package/contracts/client-api/v1/health-response.schema.json +13 -0
- package/contracts/client-api/v1/job-response.schema.json +49 -0
- package/contracts/client-api/v1/manifest.json +63 -0
- package/contracts/client-api/v1/run-request.schema.json +42 -0
- package/contracts/client-api/v1/submit-response.schema.json +35 -0
- package/contracts/client-api/v1/vectors.json +153 -0
- package/demo/business/Dockerfile +8 -0
- package/demo/business/server.mjs +483 -0
- package/docker-compose.images.yml +67 -0
- package/docker-compose.yml +79 -0
- package/docs/AI_FRIENDLY_TOOLS.en.md +69 -0
- package/docs/AI/345/217/213/345/245/275/345/267/245/345/205/267/350/256/276/350/256/241/346/214/207/345/215/227.md +198 -0
- package/docs/ARCHITECTURE.en.md +81 -0
- package/docs/ARCHITECTURE.md +795 -0
- package/docs/CHANGELOG.en.md +275 -0
- package/docs/CHANGELOG.md +279 -0
- package/docs/CHANNELS.en.md +35 -0
- package/docs/CHANNELS.md +72 -0
- package/docs/CLIENT_API.md +89 -0
- package/docs/COMPATIBILITY.en.md +103 -0
- package/docs/CONTRACT.en.md +254 -0
- package/docs/CONTRACT.md +653 -0
- package/docs/DEMO.en.md +90 -0
- package/docs/DEMO.md +297 -0
- package/docs/ECOSYSTEM.en.md +39 -0
- package/docs/ECOSYSTEM.md +39 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +184 -0
- package/docs/INDEPENDENT_VALIDATION.md +184 -0
- package/docs/INTEGRATION.en.md +120 -0
- package/docs/KERNEL_HOST_API.en.md +59 -0
- package/docs/KERNEL_HOST_API.md +59 -0
- package/docs/OPERATIONS.en.md +182 -0
- package/docs/OPERATIONS.md +231 -0
- package/docs/PIPELINE.en.md +74 -0
- package/docs/PIPELINE.md +67 -0
- package/docs/QUICKSTART.en.md +297 -0
- package/docs/QUICKSTART.md +152 -0
- package/docs/README.en.md +103 -0
- package/docs/README.md +119 -0
- package/docs/RELEASE_NOTES_v0.1.0.en.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.0.md +66 -0
- package/docs/RELEASE_NOTES_v0.1.1.en.md +38 -0
- package/docs/RELEASE_NOTES_v0.1.1.md +38 -0
- package/docs/RELEASE_NOTES_v0.1.10.en.md +102 -0
- package/docs/RELEASE_NOTES_v0.1.10.md +102 -0
- package/docs/RELEASE_NOTES_v0.1.11.en.md +99 -0
- package/docs/RELEASE_NOTES_v0.1.11.md +99 -0
- package/docs/RELEASE_NOTES_v0.1.12.en.md +64 -0
- package/docs/RELEASE_NOTES_v0.1.12.md +64 -0
- package/docs/RELEASE_NOTES_v0.1.13.en.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.13.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.14.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.14.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.15.en.md +50 -0
- package/docs/RELEASE_NOTES_v0.1.15.md +50 -0
- package/docs/RELEASE_NOTES_v0.1.16.en.md +106 -0
- package/docs/RELEASE_NOTES_v0.1.16.md +105 -0
- package/docs/RELEASE_NOTES_v0.1.2.en.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.2.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.3.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.3.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.4.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.4.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.5.en.md +49 -0
- package/docs/RELEASE_NOTES_v0.1.5.md +49 -0
- package/docs/RELEASE_NOTES_v0.1.6.en.md +41 -0
- package/docs/RELEASE_NOTES_v0.1.6.md +41 -0
- package/docs/RELEASE_NOTES_v0.1.7.en.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.7.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.8.en.md +88 -0
- package/docs/RELEASE_NOTES_v0.1.8.md +88 -0
- package/docs/RELEASE_NOTES_v0.1.9.en.md +127 -0
- package/docs/RELEASE_NOTES_v0.1.9.md +127 -0
- package/docs/RELEASE_NOTES_v0.2.0.en.md +95 -0
- package/docs/RELEASE_NOTES_v0.2.0.md +96 -0
- package/docs/RELEASE_NOTES_v0.3.0.en.md +77 -0
- package/docs/RELEASE_NOTES_v0.3.0.md +77 -0
- package/docs/SDK.en.md +177 -0
- package/docs/STREAMING.en.md +78 -0
- package/docs/STREAMING.md +109 -0
- package/docs/TOOLS.en.md +205 -0
- package/docs/TOOLS_DESIGN.en.md +142 -0
- package/docs/TOOLS_DESIGN.md +466 -0
- package/docs/TOOLS_MODEL.en.md +56 -0
- package/docs/TOOLS_MODEL.md +903 -0
- package/docs/WIDGET_RENDERERS.en.md +133 -0
- package/docs/WIDGET_RENDERERS.md +139 -0
- package/docs/examples/bailing-tool-verify.mjs +94 -0
- package/docs/examples/bailing-tool-verify.php +154 -0
- package/docs/examples/bailing-tool-verify.py +107 -0
- package/docs/examples/custom-streaming-chat-client.mjs +108 -0
- package/docs/examples/widget-chart-renderer-adapter.mjs +44 -0
- package/docs/integrations/bailian/README.en.md +181 -0
- package/docs/integrations/bailian/README.md +165 -0
- package/docs/integrations/bailian/bailian-mcp-config.json +17 -0
- package/docs/integrations/bailian/verify_recipe.py +97 -0
- package/docs/integrations/deepseek/README.en.md +225 -0
- package/docs/integrations/deepseek/README.md +225 -0
- package/docs/integrations/deepseek/verify_e2e.py +131 -0
- package/docs/integrations/dify/README.en.md +131 -0
- package/docs/integrations/dify/README.md +131 -0
- package/docs/integrations/dify/bailinghub-control-plane.openapi.json +129 -0
- package/docs/integrations/dify/verify_contract.py +88 -0
- package/docs/integrations/dify/verify_e2e.py +117 -0
- package/docs/integrations/jeecgboot/README.en.md +193 -0
- package/docs/integrations/jeecgboot/README.md +161 -0
- package/docs/integrations/jeecgboot/adapter-contract.v1.json +94 -0
- package/docs/integrations/jeecgboot/jeecgboot-user-adapter.openapi.json +183 -0
- package/docs/integrations/jeecgboot/verify_recipe.mjs +97 -0
- package/docs/integrations/ruoyi-vue-pro/README.en.md +91 -0
- package/docs/integrations/ruoyi-vue-pro/README.md +155 -0
- package/docs/integrations/ruoyi-vue-pro/adapter-contract.v1.json +71 -0
- package/docs/integrations/ruoyi-vue-pro/ruoyi-vue-pro-trade-adapter.openapi.json +148 -0
- package/docs/integrations/ruoyi-vue-pro/verify_recipe.mjs +71 -0
- package/docs/user-guide/README.en.md +39 -0
- package/docs/user-guide/README.md +40 -0
- package/docs/user-guide/concepts.en.md +69 -0
- package/docs/user-guide/concepts.md +225 -0
- package/docs/user-guide/console-map.en.md +58 -0
- package/docs/user-guide/console-map.md +473 -0
- package/docs/user-guide/overview.en.md +61 -0
- package/docs/user-guide/overview.md +156 -0
- package/docs/user-guide/scenarios.en.md +70 -0
- package/docs/user-guide/scenarios.md +398 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +134 -0
- package/docs//347/254/254/344/270/211/346/226/271/345/257/271/346/216/245/346/214/207/345/215/227.md +625 -0
- package/package.json +119 -0
- package/schemas/agent-capability-contract.schema.json +104 -0
- package/schemas/api/approval-decision.schema.json +28 -0
- package/schemas/api/approval-request.schema.json +31 -0
- package/schemas/api/delivery-callback.schema.json +28 -0
- package/schemas/api/job-response.schema.json +6 -0
- package/schemas/api/kb-doc-upsert.schema.json +21 -0
- package/schemas/api/run-request.schema.json +6 -0
- package/schemas/api/run-response.schema.json +6 -0
- package/schemas/api/tool-spec.schema.json +38 -0
- package/schemas/config/alert-rule.schema.json +22 -0
- package/schemas/config/channel.schema.json +91 -0
- package/schemas/config/chat-entry.schema.json +47 -0
- package/schemas/config/client.schema.json +56 -0
- package/schemas/config/common.schema.json +215 -0
- package/schemas/config/credential.schema.json +48 -0
- package/schemas/config/executor-token.schema.json +20 -0
- package/schemas/config/page-context.schema.json +21 -0
- package/schemas/config/route.schema.json +152 -0
- package/schemas/config/storage-bucket.schema.json +31 -0
- package/schemas/config/target.schema.json +17 -0
- package/schemas/config/tool-provider.schema.json +60 -0
- package/schemas/tool-definition.schema.json +188 -0
- package/scripts/check-client-api-ecosystem.mjs +69 -0
- package/scripts/check-doc-links.mjs +136 -0
- package/scripts/check-image-tags.sh +43 -0
- package/scripts/check-package-artifact.mjs +185 -0
- package/scripts/check-release-consistency.mjs +199 -0
- package/scripts/check-release-consistency.test.mjs +63 -0
- package/scripts/client-api-contract-test.ts +127 -0
- package/scripts/create-admin.ts +27 -0
- package/scripts/demo-e2e.ts +133 -0
- package/scripts/docker-entrypoint.sh +33 -0
- package/scripts/doctor.ts +107 -0
- package/scripts/e2e-console.mjs +214 -0
- package/scripts/export-oss.mjs +204 -0
- package/scripts/generate-readme-assets.mjs +181 -0
- package/scripts/generate-third-party-notices.mjs +93 -0
- package/scripts/image-release-policy.mjs +75 -0
- package/scripts/image-release-policy.test.mjs +58 -0
- package/scripts/init-db.ts +21 -0
- package/scripts/install.sh +461 -0
- package/scripts/oss-boundary-check.mjs +183 -0
- package/scripts/publish-images.sh +63 -0
- package/scripts/publish-mysql-image.sh +41 -0
- package/scripts/release-audit.mjs +348 -0
- package/scripts/sdk-contract-test.ts +62 -0
- package/scripts/sdk-p1-check.mjs +58 -0
- package/scripts/sdk-runtime-test.mjs +106 -0
- package/scripts/security-scan.mjs +110 -0
- package/scripts/seed-demo.ts +116 -0
- package/scripts/selftest.ts +226 -0
- package/scripts/smoke.ts +31 -0
- package/scripts/validate-examples.mjs +93 -0
- package/scripts/verify-bootstrap-admin-restart.ts +66 -0
- package/scripts/verify-github-repo.mjs +195 -0
- package/scripts/verify-oss-export.mjs +192 -0
- package/scripts/verify-routing.ts +29 -0
- package/scripts/widget-renderer-test.mjs +206 -0
- package/scripts/write-build-info.mjs +29 -0
- package/sdk/dotnet/Bailing.Connect/Bailing.Connect.csproj +12 -0
- package/sdk/dotnet/Bailing.Connect/BailingConnect.cs +260 -0
- package/sdk/dotnet/README.md +32 -0
- package/sdk/dotnet/examples/BuildSpec/BuildSpec.csproj +11 -0
- package/sdk/dotnet/examples/BuildSpec/Program.cs +36 -0
- package/sdk/go/README.md +33 -0
- package/sdk/go/bailingconnect/connect.go +367 -0
- package/sdk/go/examples/build-spec/main.go +39 -0
- package/sdk/go/go.mod +3 -0
- package/sdk/java/README.md +43 -0
- package/sdk/java/examples/BuildSpec.java +31 -0
- package/sdk/java/src/main/java/com/bailing/connect/BailingConnect.java +376 -0
- package/sdk/node/README.md +107 -0
- package/sdk/node/examples/build-spec.mjs +84 -0
- package/sdk/node/package.json +22 -0
- package/sdk/node/src/index.mjs +250 -0
- package/sdk/php/README.md +204 -0
- package/sdk/php/composer.json +18 -0
- package/sdk/php/examples/DemoStaffController.php +108 -0
- package/sdk/php/examples/build-spec.php +27 -0
- package/sdk/php/examples/thinkphp-integration.php +81 -0
- package/sdk/php/src/Attributes/AiParam.php +40 -0
- package/sdk/php/src/Attributes/AiTool.php +75 -0
- package/sdk/php/src/HubClient.php +122 -0
- package/sdk/php/src/SpecBuilder.php +328 -0
- package/sdk/php/src/SpecServer.php +209 -0
- package/sdk/php/src/Ticket.php +37 -0
- package/sdk/php/src/Verify.php +178 -0
- package/sdk/php7/README.md +191 -0
- package/sdk/php7/composer.json +18 -0
- package/sdk/php7/examples/build-spec.php +68 -0
- package/sdk/php7/examples/well-known.php +33 -0
- package/sdk/php7/src/HubClient.php +111 -0
- package/sdk/php7/src/SpecServer.php +203 -0
- package/sdk/php7/src/Ticket.php +33 -0
- package/sdk/php7/src/ToolDef.php +169 -0
- package/sdk/php7/src/ToolSpec.php +334 -0
- package/sdk/php7/src/Verify.php +165 -0
- package/sdk/python/README.md +107 -0
- package/sdk/python/bailing_connect/__init__.py +307 -0
- package/sdk/python/examples/build_spec.py +90 -0
- package/sdk/python/pyproject.toml +24 -0
- package/sql/001_init_state.sql +66 -0
- package/sql/002_routes.sql +44 -0
- package/sql/003_executor.sql +15 -0
- package/sql/004_clients.sql +22 -0
- package/sql/005_admins.sql +25 -0
- package/sql/006_ledger.sql +57 -0
- package/sql/007_delivery.sql +8 -0
- package/sql/008_kb.sql +66 -0
- package/sql/009_rbac.sql +5 -0
- package/sql/010_targets.sql +28 -0
- package/sql/011_observability.sql +11 -0
- package/sql/012_generic.sql +5 -0
- package/sql/013_tools.sql +24 -0
- package/sql/014_approvals.sql +27 -0
- package/sql/015_chat.sql +21 -0
- package/sql/016_chat_feedback.sql +19 -0
- package/sql/017_provider_autorefresh.sql +6 -0
- package/sql/018_kb_ingest.sql +11 -0
- package/sql/019_kb_datasources.sql +32 -0
- package/sql/022_storage_buckets.sql +25 -0
- package/sql/024_channels.sql +15 -0
- package/sql/025_chat_appearance.sql +7 -0
- package/sql/026_thread_memory.sql +10 -0
- package/sql/027_page_contexts.sql +23 -0
- package/sql/028_executor_capabilities.sql +4 -0
- package/sql/029_executor_tokens.sql +13 -0
- package/sql/030_route_permission.sql +5 -0
- package/sql/031_tool_embeddings.sql +20 -0
- package/sql/032_tool_provider_embed.sql +7 -0
- package/sql/033_alert_rules.sql +21 -0
- package/sql/034_client_allowed_channels.sql +6 -0
- package/sql/035_tool_idempotency.sql +15 -0
- package/sql/036_delivery_dlq.sql +15 -0
- package/sql/038_audit_trace_shape.sql +15 -0
- package/sql/039_runtime_locks.sql +9 -0
- package/sql/040_budget_policy.sql +3 -0
- package/sql/041_approval_intent.sql +14 -0
- package/sql/042_approval_decision_contract.sql +11 -0
- package/sql/043_rate_limits.sql +7 -0
- package/sql/044_job_run_after.sql +3 -0
- package/sql/045_job_claim_lease.sql +7 -0
- package/sql/046_tool_authz_probe.sql +5 -0
- package/sql/047_route_audience.sql +4 -0
- package/sql/048_llm_target.sql +17 -0
- package/sql/049_llm_input_shape.sql +11 -0
- package/sql/050_operational_metrics_indexes.sql +8 -0
- package/sql/051_instance_branding.sql +17 -0
- package/sql/052_tool_execution_journal.sql +19 -0
- package/sql/053_tool_spec_access_policy.sql +9 -0
- package/sql/README.en.md +41 -0
- package/sql/README.md +40 -0
- package/src/adapters/channels/wecom-api.test.ts +77 -0
- package/src/adapters/channels/wecom-api.ts +224 -0
- package/src/adapters/channels/wecom-crypto.test.ts +85 -0
- package/src/adapters/channels/wecom-crypto.ts +77 -0
- package/src/adapters/executors/claudecode.ts +39 -0
- package/src/adapters/executors/profiles.ts +86 -0
- package/src/adapters/executors/report.ts +35 -0
- package/src/adapters/executors/runner.ts +114 -0
- package/src/adapters/executors/wecomnotify.ts +63 -0
- package/src/adapters/llm/file.test.ts +81 -0
- package/src/adapters/llm/file.ts +250 -0
- package/src/adapters/llm/openai-chat-stream.test.ts +74 -0
- package/src/adapters/llm/openai-chat-stream.ts +154 -0
- package/src/adapters/llm/perception.ts +159 -0
- package/src/adapters/llm/speech.test.ts +75 -0
- package/src/adapters/llm/speech.ts +146 -0
- package/src/adapters/storage/object-storage.test.ts +38 -0
- package/src/adapters/storage/object-storage.ts +140 -0
- package/src/adapters/targets/demo-agent.ts +88 -0
- package/src/adapters/targets/llm.test.ts +733 -0
- package/src/adapters/targets/llm.ts +862 -0
- package/src/app/admin-bootstrap.test.ts +112 -0
- package/src/app/admin-bootstrap.ts +48 -0
- package/src/app/auth-default.ts +26 -0
- package/src/app/auth.test.ts +57 -0
- package/src/app/auth.ts +207 -0
- package/src/app/builtin-tools-default.ts +17 -0
- package/src/app/builtin-tools.test.ts +202 -0
- package/src/app/builtin-tools.ts +380 -0
- package/src/app/channels-default.ts +8 -0
- package/src/app/channels.ts +141 -0
- package/src/app/delivery-default.ts +14 -0
- package/src/app/delivery.test.ts +46 -0
- package/src/app/delivery.ts +215 -0
- package/src/app/engine-default.ts +54 -0
- package/src/app/engine.ts +427 -0
- package/src/app/http-mount.test.ts +27 -0
- package/src/app/http-server.test.ts +114 -0
- package/src/app/http-server.ts +127 -0
- package/src/app/http.test.ts +27 -0
- package/src/app/http.ts +118 -0
- package/src/app/kernel.test.ts +191 -0
- package/src/app/kernel.ts +544 -0
- package/src/app/monitor-default.ts +9 -0
- package/src/app/monitor.ts +46 -0
- package/src/app/operational-metrics.test.ts +73 -0
- package/src/app/operational-metrics.ts +124 -0
- package/src/app/oss-edition.test.ts +71 -0
- package/src/app/oss-edition.ts +108 -0
- package/src/app/outbound-default.ts +57 -0
- package/src/app/outbound.ts +133 -0
- package/src/app/readiness.test.ts +37 -0
- package/src/app/readiness.ts +39 -0
- package/src/app/runtime-composition.test.ts +51 -0
- package/src/app/runtime-composition.ts +73 -0
- package/src/app/runtime-context-default.ts +30 -0
- package/src/app/runtime-context.test.ts +60 -0
- package/src/app/runtime-context.ts +79 -0
- package/src/app/runtime-lifecycle-default.ts +48 -0
- package/src/app/runtime-lifecycle.test.ts +322 -0
- package/src/app/runtime-lifecycle.ts +440 -0
- package/src/app/runtime.ts +36 -0
- package/src/app/tool-approvals-default.ts +16 -0
- package/src/app/tool-approvals.ts +214 -0
- package/src/app/tool-assembly-default.ts +11 -0
- package/src/app/tool-assembly.test.ts +112 -0
- package/src/app/tool-assembly.ts +83 -0
- package/src/app/tool-context-default.ts +7 -0
- package/src/app/tool-context.test.ts +82 -0
- package/src/app/tool-context.ts +109 -0
- package/src/app/tool-debug.test.ts +111 -0
- package/src/app/tool-debug.ts +152 -0
- package/src/app/tool-proxy-default.ts +35 -0
- package/src/app/tool-proxy.ts +173 -0
- package/src/app/tool-specs-default.ts +33 -0
- package/src/app/tool-specs.test.ts +322 -0
- package/src/app/tool-specs.ts +555 -0
- package/src/app/tools-runtime-default.ts +14 -0
- package/src/app/tools-runtime.ts +23 -0
- package/src/architecture-boundary.test.ts +119 -0
- package/src/core/config/config-codec.test.ts +105 -0
- package/src/core/config/config-codec.ts +231 -0
- package/src/core/config/config-diagnostics.test.ts +285 -0
- package/src/core/config/config-diagnostics.ts +436 -0
- package/src/core/config/config-models.test.ts +584 -0
- package/src/core/config/config-models.ts +392 -0
- package/src/core/config/config-schema.test.ts +153 -0
- package/src/core/config/config.test.ts +314 -0
- package/src/core/config/config.ts +324 -0
- package/src/core/config/route-config.test.ts +232 -0
- package/src/core/config/route-config.ts +246 -0
- package/src/core/config/target-config.test.ts +139 -0
- package/src/core/config/target-config.ts +219 -0
- package/src/core/config/tools-config.test.ts +124 -0
- package/src/core/config/tools-config.ts +126 -0
- package/src/core/contracts/approval-decision.test.ts +67 -0
- package/src/core/contracts/approval-decision.ts +93 -0
- package/src/core/contracts/openapi-tools.ts +201 -0
- package/src/core/contracts/tool-annotations.ts +121 -0
- package/src/core/contracts/tool-definition.test.ts +147 -0
- package/src/core/contracts/tool-definition.ts +304 -0
- package/src/core/contracts/tools-idempotency.test.ts +435 -0
- package/src/core/contracts/tools.test.ts +487 -0
- package/src/core/contracts/tools.ts +831 -0
- package/src/core/contracts/types.ts +408 -0
- package/src/core/edition/capabilities.ts +6 -0
- package/src/core/edition/context.test.ts +20 -0
- package/src/core/edition/context.ts +78 -0
- package/src/core/edition/index.ts +4 -0
- package/src/core/edition/scope-resolver.ts +24 -0
- package/src/core/edition/store-factory.ts +6 -0
- package/src/core/observability/openmetrics.test.ts +57 -0
- package/src/core/observability/openmetrics.ts +103 -0
- package/src/core/platform/content.test.ts +46 -0
- package/src/core/platform/content.ts +90 -0
- package/src/core/platform/fence.test.ts +31 -0
- package/src/core/platform/fence.ts +11 -0
- package/src/core/platform/instance-branding.test.ts +65 -0
- package/src/core/platform/instance-branding.ts +202 -0
- package/src/core/platform/metrics-token.test.ts +31 -0
- package/src/core/platform/metrics-token.ts +42 -0
- package/src/core/platform/pagecontext.ts +0 -0
- package/src/core/platform/password.test.ts +13 -0
- package/src/core/platform/password.ts +38 -0
- package/src/core/platform/queue.test.ts +59 -0
- package/src/core/platform/queue.ts +75 -0
- package/src/core/platform/serial.test.ts +73 -0
- package/src/core/platform/serial.ts +64 -0
- package/src/core/platform/server-token.test.ts +46 -0
- package/src/core/platform/server-token.ts +60 -0
- package/src/core/platform/signing.test.ts +24 -0
- package/src/core/platform/signing.ts +22 -0
- package/src/core/platform/time.ts +73 -0
- package/src/core/platform/version.test.ts +19 -0
- package/src/core/platform/version.ts +90 -0
- package/src/core/runtime/budget-runtime.test.ts +93 -0
- package/src/core/runtime/budget-runtime.ts +110 -0
- package/src/core/runtime/context-runtime.test.ts +106 -0
- package/src/core/runtime/context-runtime.ts +95 -0
- package/src/core/runtime/credential-resolver.test.ts +129 -0
- package/src/core/runtime/credential-resolver.ts +93 -0
- package/src/core/runtime/credential-verify.test.ts +76 -0
- package/src/core/runtime/credential-verify.ts +161 -0
- package/src/core/runtime/debug-report.test.ts +20 -0
- package/src/core/runtime/debug-report.ts +100 -0
- package/src/core/runtime/execution-runtime.test.ts +350 -0
- package/src/core/runtime/execution-runtime.ts +197 -0
- package/src/core/runtime/finish-runtime.test.ts +168 -0
- package/src/core/runtime/finish-runtime.ts +83 -0
- package/src/core/runtime/identity-runtime.test.ts +38 -0
- package/src/core/runtime/identity-runtime.ts +104 -0
- package/src/core/runtime/inhub-runtime.test.ts +297 -0
- package/src/core/runtime/inhub-runtime.ts +198 -0
- package/src/core/runtime/job-stream.test.ts +55 -0
- package/src/core/runtime/job-stream.ts +187 -0
- package/src/core/runtime/knowledge-runtime.test.ts +120 -0
- package/src/core/runtime/knowledge-runtime.ts +98 -0
- package/src/core/runtime/launch-runtime.test.ts +187 -0
- package/src/core/runtime/launch-runtime.ts +182 -0
- package/src/core/runtime/memory-runtime.test.ts +85 -0
- package/src/core/runtime/memory-runtime.ts +32 -0
- package/src/core/runtime/memory.ts +141 -0
- package/src/core/runtime/redaction-runtime.test.ts +35 -0
- package/src/core/runtime/redaction-runtime.ts +60 -0
- package/src/core/runtime/routing-runtime.test.ts +89 -0
- package/src/core/runtime/routing-runtime.ts +146 -0
- package/src/core/runtime/smoke-runtime.test.ts +65 -0
- package/src/core/runtime/smoke-runtime.ts +237 -0
- package/src/core/runtime/summary-runtime.test.ts +234 -0
- package/src/core/runtime/summary-runtime.ts +153 -0
- package/src/core/runtime/trace-runtime.test.ts +234 -0
- package/src/core/runtime/trace-runtime.ts +330 -0
- package/src/core/state/audit-observability.test.ts +51 -0
- package/src/core/state/audit-observability.ts +74 -0
- package/src/core/state/state-codec.ts +44 -0
- package/src/core/state/state-contracts.ts +59 -0
- package/src/core/targets/adapter.ts +69 -0
- package/src/core/targets/registry.test.ts +65 -0
- package/src/core/targets/registry.ts +153 -0
- package/src/core/targets/resolve.ts +21 -0
- package/src/executor.ts +201 -0
- package/src/extension-api.test.ts +84 -0
- package/src/extension-api.ts +194 -0
- package/src/infrastructure/config/config-admin-repository.test.ts +193 -0
- package/src/infrastructure/config/config-admin-repository.ts +175 -0
- package/src/infrastructure/config/config-alert-rule-repository.ts +38 -0
- package/src/infrastructure/config/config-approval-ledger.ts +74 -0
- package/src/infrastructure/config/config-channel-repository.ts +31 -0
- package/src/infrastructure/config/config-chat-repository.ts +83 -0
- package/src/infrastructure/config/config-client-repository.ts +46 -0
- package/src/infrastructure/config/config-conversation-ledger.ts +222 -0
- package/src/infrastructure/config/config-credential-repository.test.ts +32 -0
- package/src/infrastructure/config/config-credential-repository.ts +47 -0
- package/src/infrastructure/config/config-delivery-dlq-ledger.ts +49 -0
- package/src/infrastructure/config/config-executor-ledger.ts +30 -0
- package/src/infrastructure/config/config-executor-token-repository.ts +44 -0
- package/src/infrastructure/config/config-instance-branding-repository.ts +75 -0
- package/src/infrastructure/config/config-knowledge-repository.ts +249 -0
- package/src/infrastructure/config/config-observability-ledger.ts +262 -0
- package/src/infrastructure/config/config-project-repository.ts +30 -0
- package/src/infrastructure/config/config-rate-limit-ledger.ts +56 -0
- package/src/infrastructure/config/config-route-repository.ts +41 -0
- package/src/infrastructure/config/config-storage-bucket-repository.ts +43 -0
- package/src/infrastructure/config/config-target-repository.ts +25 -0
- package/src/infrastructure/config/config-tool-call-ledger.ts +142 -0
- package/src/infrastructure/config/config-tool-embedding-repository.test.ts +124 -0
- package/src/infrastructure/config/config-tool-embedding-repository.ts +78 -0
- package/src/infrastructure/config/config-tool-provider-repository.test.ts +71 -0
- package/src/infrastructure/config/config-tool-provider-repository.ts +50 -0
- package/src/infrastructure/config/configstore.ts +130 -0
- package/src/infrastructure/config/local-instance-branding-provider.test.ts +94 -0
- package/src/infrastructure/config/local-instance-branding-provider.ts +79 -0
- package/src/infrastructure/mysql/pool-owner.test.ts +36 -0
- package/src/infrastructure/mysql/pool-owner.ts +56 -0
- package/src/infrastructure/schema/core-schema-migrator.test.ts +340 -0
- package/src/infrastructure/schema/core-schema-migrator.ts +461 -0
- package/src/infrastructure/schema/migration-files.test.ts +18 -0
- package/src/infrastructure/schema/migration-files.ts +27 -0
- package/src/infrastructure/schema/retired-migrations.ts +35 -0
- package/src/infrastructure/state/operational-metrics-storage.test.ts +107 -0
- package/src/infrastructure/state/state-jsonl.ts +268 -0
- package/src/infrastructure/state/state-mysql-update-plan.test.ts +54 -0
- package/src/infrastructure/state/state-mysql-update-plan.ts +63 -0
- package/src/infrastructure/state/state-mysql.ts +359 -0
- package/src/infrastructure/state/state.test.ts +319 -0
- package/src/infrastructure/state/state.ts +11 -0
- package/src/kernel-api/v1/artifact.test.ts +46 -0
- package/src/kernel-api/v1/artifact.ts +71 -0
- package/src/kernel-api/v1/contracts.ts +168 -0
- package/src/kernel-api/v1/execution-gate.test.ts +25 -0
- package/src/kernel-api/v1/execution-gate.ts +18 -0
- package/src/kernel-api/v1/index.ts +51 -0
- package/src/openclaw-stdio.test.ts +60 -0
- package/src/routes/admin-access-default.ts +20 -0
- package/src/routes/admin-access.ts +94 -0
- package/src/routes/admin-branding.test.ts +116 -0
- package/src/routes/admin-branding.ts +48 -0
- package/src/routes/admin-chat-default.ts +12 -0
- package/src/routes/admin-chat.ts +84 -0
- package/src/routes/admin-default.ts +35 -0
- package/src/routes/admin-dispatch-config-default.ts +13 -0
- package/src/routes/admin-dispatch-config.ts +121 -0
- package/src/routes/admin-format.ts +12 -0
- package/src/routes/admin-host.test.ts +56 -0
- package/src/routes/admin-infra-default.ts +12 -0
- package/src/routes/admin-infra.ts +142 -0
- package/src/routes/admin-kb-default.ts +13 -0
- package/src/routes/admin-kb.ts +160 -0
- package/src/routes/admin-runtime-default.ts +31 -0
- package/src/routes/admin-runtime.ts +444 -0
- package/src/routes/admin-tool-providers-default.ts +20 -0
- package/src/routes/admin-tool-providers.test.ts +114 -0
- package/src/routes/admin-tool-providers.ts +186 -0
- package/src/routes/admin.ts +246 -0
- package/src/routes/approvals-default.ts +32 -0
- package/src/routes/approvals.ts +120 -0
- package/src/routes/chat-default.ts +61 -0
- package/src/routes/chat-mount.test.ts +58 -0
- package/src/routes/chat.test.ts +222 -0
- package/src/routes/chat.ts +478 -0
- package/src/routes/critical-routes.test.ts +292 -0
- package/src/routes/executor-default.ts +45 -0
- package/src/routes/executor.ts +226 -0
- package/src/routes/kb-default.ts +23 -0
- package/src/routes/kb.ts +92 -0
- package/src/routes/private-default.ts +38 -0
- package/src/routes/private-host-auth.test.ts +84 -0
- package/src/routes/private.ts +210 -0
- package/src/routes/public-default.ts +46 -0
- package/src/routes/public.test.ts +504 -0
- package/src/routes/public.ts +313 -0
- package/src/routes/run-default.ts +25 -0
- package/src/routes/run.ts +188 -0
- package/src/routes/send-default.ts +24 -0
- package/src/routes/send.ts +143 -0
- package/src/routes/wecom-default.ts +27 -0
- package/src/routes/wecom.ts +307 -0
- package/src/server.ts +13 -0
- package/src/services/embedding.test.ts +185 -0
- package/src/services/embedding.ts +138 -0
- package/src/services/kb-repository.ts +79 -0
- package/src/services/kb.ts +328 -0
- package/src/services/kbsync.ts +166 -0
- package/src/services/tool-index-repository.ts +50 -0
- package/src/services/tools-index.test.ts +756 -0
- package/src/services/tools-index.ts +427 -0
- package/tsconfig.json +17 -0
- package/web/connect/bailing-connect-php.tgz +0 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/connect/executor.mjs +152 -0
- package/web/connect/openclaw-stdio.mjs +145 -0
- package/web/connect/skills/connect-bailinghub-executor/SKILL.md +97 -0
- package/web/connect/skills/connect-bailinghub-executor/agents/openai.yaml +4 -0
- package/web/connect/skills/connect-bailinghub-executor/references/direct-protocol.md +99 -0
- package/web/connect/skills/connect-bailinghub-executor/references/openclaw.md +39 -0
- package/web/console/assets/Accounts-B4ePH5jp.css +1 -0
- package/web/console/assets/Accounts-Dwzm4D_V.js +3 -0
- package/web/console/assets/Approvals-BxhuI0ku.js +1 -0
- package/web/console/assets/Approvals-DlTSHl_7.css +1 -0
- package/web/console/assets/Audit-CSu6_3oD.css +1 -0
- package/web/console/assets/Audit-dFAbGynl.js +1 -0
- package/web/console/assets/BrandLockup-BtZyvkM5.js +1 -0
- package/web/console/assets/BrandLockup-DKYBYzKU.css +1 -0
- package/web/console/assets/Channels-CCn0L1jg.css +1 -0
- package/web/console/assets/Channels-Dqg4-_yr.js +105 -0
- package/web/console/assets/ChatEntries-BweMx_CU.css +1 -0
- package/web/console/assets/ChatEntries-CEGZ3NnJ.js +7 -0
- package/web/console/assets/Clients-C0QD1x7g.js +3 -0
- package/web/console/assets/Clients-DcTYN-Js.css +1 -0
- package/web/console/assets/Cost-BAJqLhpK.js +1 -0
- package/web/console/assets/Cost-CjT39DSZ.css +1 -0
- package/web/console/assets/Credentials-D_GDRgWi.js +1 -0
- package/web/console/assets/Credentials-ioLP0qYN.css +1 -0
- package/web/console/assets/Diagnostics-BWYnDxRj.js +1 -0
- package/web/console/assets/Diagnostics-Ya05PTDp.css +1 -0
- package/web/console/assets/Executors-CjhEM54c.css +1 -0
- package/web/console/assets/Executors-Cmryk4Vk.js +1 -0
- package/web/console/assets/HelpTip-CA6Bm7Nx.css +1 -0
- package/web/console/assets/HelpTip-CT07o3kB.js +1 -0
- package/web/console/assets/Kb-BSXQE0Fa.js +5 -0
- package/web/console/assets/Kb-CzIzd9xr.css +1 -0
- package/web/console/assets/Login-BnBPqC8Z.js +1 -0
- package/web/console/assets/Login-xtPwDB5_.css +1 -0
- package/web/console/assets/Projects-Bm8AjsNx.css +1 -0
- package/web/console/assets/Projects-CNHx4L_7.js +1 -0
- package/web/console/assets/Routes-DWGQN5Pv.css +1 -0
- package/web/console/assets/Routes-u5cEAEXQ.js +124 -0
- package/web/console/assets/Runs-BeFUR77_.js +3 -0
- package/web/console/assets/Runs-CUtSsPW-.css +1 -0
- package/web/console/assets/Setup-BjZfrmfN.js +1 -0
- package/web/console/assets/Setup-QjlHZKdB.css +1 -0
- package/web/console/assets/Shell-CbGNTN91.css +1 -0
- package/web/console/assets/Shell-EJuYf3OO.js +1 -0
- package/web/console/assets/StorageBuckets-DMXRJxUA.js +1 -0
- package/web/console/assets/StorageBuckets-GnXnVvF0.css +1 -0
- package/web/console/assets/SystemSettings-B72F-loY.js +1 -0
- package/web/console/assets/SystemSettings-BjiHyrXO.css +1 -0
- package/web/console/assets/SystemStatus-I11I67rw.css +1 -0
- package/web/console/assets/SystemStatus-hOj_TPYE.js +1 -0
- package/web/console/assets/Targets-DTb5tn6z.css +1 -0
- package/web/console/assets/Targets-UVVf7twC.js +1 -0
- package/web/console/assets/Tools-A20oaMaQ.css +1 -0
- package/web/console/assets/Tools-ihkr9R9x.js +2 -0
- package/web/console/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
- package/web/console/assets/docs-DPUOCa7R.js +1 -0
- package/web/console/assets/index-DZEQL_yy.js +1 -0
- package/web/console/assets/index-DxvruykG.js +2 -0
- package/web/console/assets/index-Fi9gkGxV.css +1 -0
- package/web/console/assets/llm-catalog-HwRIrS94.js +1 -0
- package/web/console/assets/request-BisL2T9B.js +1 -0
- package/web/console/assets/schema-CzpUpoLk.js +1 -0
- package/web/console/assets/util-SiQC2MJh.js +1 -0
- package/web/console/assets/vendor-element-D7WRzHhy.js +37 -0
- package/web/console/assets/vendor-mammoth-DvgsHdlx.js +231 -0
- package/web/console/assets/vendor-turndown-kLzRgxYD.js +61 -0
- package/web/console/assets/vendor-vue-B2uhHUfE.js +29 -0
- package/web/console/index.html +16 -0
- package/web/widget/widget.js +1490 -0
- package/web-admin/index.html +13 -0
- package/web-admin/package-lock.json +1854 -0
- package/web-admin/package.json +25 -0
- package/web-admin/src/App.vue +9 -0
- package/web-admin/src/branding.ts +90 -0
- package/web-admin/src/components/BrandLockup.vue +40 -0
- package/web-admin/src/components/HelpTip.vue +51 -0
- package/web-admin/src/components/RichText.vue +35 -0
- package/web-admin/src/docs.ts +16 -0
- package/web-admin/src/layout/Shell.vue +356 -0
- package/web-admin/src/llm-catalog.ts +129 -0
- package/web-admin/src/main.ts +116 -0
- package/web-admin/src/pages/Accounts.vue +162 -0
- package/web-admin/src/pages/Approvals.vue +179 -0
- package/web-admin/src/pages/Audit.vue +110 -0
- package/web-admin/src/pages/Channels.vue +738 -0
- package/web-admin/src/pages/ChatEntries.vue +778 -0
- package/web-admin/src/pages/Clients.vue +353 -0
- package/web-admin/src/pages/Cost.vue +314 -0
- package/web-admin/src/pages/Credentials.vue +418 -0
- package/web-admin/src/pages/Diagnostics.vue +440 -0
- package/web-admin/src/pages/Executors.vue +398 -0
- package/web-admin/src/pages/Kb.vue +698 -0
- package/web-admin/src/pages/Login.vue +314 -0
- package/web-admin/src/pages/Projects.vue +106 -0
- package/web-admin/src/pages/Routes.vue +1661 -0
- package/web-admin/src/pages/Runs.vue +1113 -0
- package/web-admin/src/pages/Setup.vue +354 -0
- package/web-admin/src/pages/StorageBuckets.vue +182 -0
- package/web-admin/src/pages/SystemSettings.vue +281 -0
- package/web-admin/src/pages/SystemStatus.vue +185 -0
- package/web-admin/src/pages/Targets.vue +193 -0
- package/web-admin/src/pages/Tools.vue +1051 -0
- package/web-admin/src/request.ts +18 -0
- package/web-admin/src/router.ts +142 -0
- package/web-admin/src/runtime-path.ts +27 -0
- package/web-admin/src/schema.ts +52 -0
- package/web-admin/src/store.ts +35 -0
- package/web-admin/src/styles/base.css +272 -0
- package/web-admin/src/table-widths.ts +603 -0
- package/web-admin/src/util.ts +16 -0
- package/web-admin/tsconfig.json +15 -0
- package/web-admin/vite.config.ts +35 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import { nextTick, watch } from 'vue';
|
|
2
|
+
import type { ComponentInternalInstance } from 'vue';
|
|
3
|
+
import type { Router } from 'vue-router';
|
|
4
|
+
|
|
5
|
+
const STORAGE_KEY = 'bailing.console.tableWidths.v1';
|
|
6
|
+
const HARD_MIN_WIDTH = 44;
|
|
7
|
+
|
|
8
|
+
type WidthEntry = {
|
|
9
|
+
width: number;
|
|
10
|
+
percent: number;
|
|
11
|
+
label: string;
|
|
12
|
+
prop: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type TableEntry = {
|
|
17
|
+
route: string;
|
|
18
|
+
table_index: number;
|
|
19
|
+
table_hint: string;
|
|
20
|
+
table_width: number;
|
|
21
|
+
columns: Record<string, WidthEntry>;
|
|
22
|
+
updated_at: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type WidthState = {
|
|
26
|
+
version: 1;
|
|
27
|
+
tables: Record<string, TableEntry>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type DefaultWidthEntry = {
|
|
31
|
+
percent: number;
|
|
32
|
+
min?: number;
|
|
33
|
+
max?: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const DEFAULT_COLUMN_WIDTHS: Record<string, Record<string, DefaultWidthEntry>> = {
|
|
37
|
+
'/routes::table:0': {
|
|
38
|
+
'场景标识': { percent: 11.2, min: 160 },
|
|
39
|
+
name: { percent: 9.8, min: 130 },
|
|
40
|
+
'调度目标': { percent: 10.5, min: 120 },
|
|
41
|
+
'项目': { percent: 6.5, min: 100 },
|
|
42
|
+
'会话连续性': { percent: 6.6, min: 120 },
|
|
43
|
+
'知识/送达': { percent: 34, min: 220 },
|
|
44
|
+
'权限': { percent: 4.8, min: 86 },
|
|
45
|
+
'可执行性': { percent: 4.9, min: 104 },
|
|
46
|
+
'启用': { percent: 4.3, min: 64, max: 110 },
|
|
47
|
+
default: { percent: 7, min: 146, max: 180 },
|
|
48
|
+
},
|
|
49
|
+
'/clients::table:0': {
|
|
50
|
+
AppID: { percent: 8.1, min: 150 },
|
|
51
|
+
name: { percent: 8.1, min: 130 },
|
|
52
|
+
Token: { percent: 8, min: 160 },
|
|
53
|
+
'可调路由': { percent: 19, min: 180 },
|
|
54
|
+
'可推渠道': { percent: 17.4, min: 160 },
|
|
55
|
+
'聊天票据': { percent: 11.1, min: 140 },
|
|
56
|
+
'限速/分': { percent: 5.3, min: 82, max: 128 },
|
|
57
|
+
'预算': { percent: 4.3, min: 76, max: 112 },
|
|
58
|
+
'启用': { percent: 5.5, min: 64, max: 118 },
|
|
59
|
+
'最近调用': { percent: 6.2, min: 124, max: 160 },
|
|
60
|
+
default: { percent: 6.5, min: 146, max: 180 },
|
|
61
|
+
},
|
|
62
|
+
'/chat::table:0': {
|
|
63
|
+
'名称': { percent: 11.4, min: 160 },
|
|
64
|
+
'绑定路由': { percent: 13.4, min: 150 },
|
|
65
|
+
'嵌入站点': { percent: 52, min: 260 },
|
|
66
|
+
'限速': { percent: 4.2, min: 92, max: 128 },
|
|
67
|
+
'启用': { percent: 3.8, min: 64, max: 104 },
|
|
68
|
+
default: { percent: 12.2, min: 240, max: 310 },
|
|
69
|
+
},
|
|
70
|
+
'/channels::table:0': {
|
|
71
|
+
'标识': { percent: 10, min: 140 },
|
|
72
|
+
'类型': { percent: 6.5, min: 92, max: 120 },
|
|
73
|
+
'绑定路由': { percent: 11, min: 150 },
|
|
74
|
+
'回调地址': { percent: 52, min: 320 },
|
|
75
|
+
'启用': { percent: 5, min: 68, max: 104 },
|
|
76
|
+
default: { percent: 12, min: 176, max: 220 },
|
|
77
|
+
},
|
|
78
|
+
'/channels::table:1': {
|
|
79
|
+
'触发事件': { percent: 27, min: 150 },
|
|
80
|
+
'渠道': { percent: 16, min: 140 },
|
|
81
|
+
'收件人': { percent: 34, min: 180 },
|
|
82
|
+
'冷却': { percent: 7, min: 72, max: 100 },
|
|
83
|
+
'启用': { percent: 6, min: 68, max: 104 },
|
|
84
|
+
default: { percent: 10, min: 104, max: 140 },
|
|
85
|
+
},
|
|
86
|
+
'/tools::table:0': {
|
|
87
|
+
'名称': { percent: 11, min: 150 },
|
|
88
|
+
'Base_URL': { percent: 25, min: 260 },
|
|
89
|
+
'接口清单': { percent: 13, min: 166 },
|
|
90
|
+
'授权探针': { percent: 12, min: 146 },
|
|
91
|
+
'签名密钥': { percent: 11, min: 146 },
|
|
92
|
+
'审计': { percent: 6, min: 84, max: 110 },
|
|
93
|
+
'启用': { percent: 5, min: 64, max: 100 },
|
|
94
|
+
default: { percent: 17, min: 280, max: 350 },
|
|
95
|
+
},
|
|
96
|
+
'/targets::table:0': {
|
|
97
|
+
'名称': { percent: 13, min: 160 },
|
|
98
|
+
'类型': { percent: 10, min: 112 },
|
|
99
|
+
'特性': { percent: 16, min: 188 },
|
|
100
|
+
'服务执行器(池)': { percent: 24, min: 190 },
|
|
101
|
+
'超时': { percent: 7, min: 80, max: 110 },
|
|
102
|
+
'启用': { percent: 5, min: 64, max: 100 },
|
|
103
|
+
description: { percent: 17, min: 220 },
|
|
104
|
+
default: { percent: 8, min: 110, max: 150 },
|
|
105
|
+
},
|
|
106
|
+
'/executors::table:0': {
|
|
107
|
+
'标识': { percent: 13, min: 160 },
|
|
108
|
+
'可认领_target': { percent: 26, min: 200 },
|
|
109
|
+
'令牌': { percent: 13, min: 150 },
|
|
110
|
+
'启用': { percent: 5, min: 64, max: 100 },
|
|
111
|
+
'最近接入': { percent: 12, min: 150 },
|
|
112
|
+
description: { percent: 16, min: 140 },
|
|
113
|
+
default: { percent: 15, min: 190, max: 240 },
|
|
114
|
+
},
|
|
115
|
+
'/executors::table:4': {
|
|
116
|
+
'执行器': { percent: 13, min: 160 },
|
|
117
|
+
'状态': { percent: 15, min: 170 },
|
|
118
|
+
'接的_target': { percent: 20, min: 180 },
|
|
119
|
+
'能跑的_profile': { percent: 25, min: 220 },
|
|
120
|
+
'运行时': { percent: 12, min: 150 },
|
|
121
|
+
'标签': { percent: 10, min: 130 },
|
|
122
|
+
default: { percent: 5, min: 70, max: 100 },
|
|
123
|
+
},
|
|
124
|
+
'/runs::table:0': {
|
|
125
|
+
'时间': { percent: 10, min: 120 },
|
|
126
|
+
'调度目标': { percent: 9, min: 110 },
|
|
127
|
+
'触发方': { percent: 18, min: 140 },
|
|
128
|
+
'输入': { percent: 27, min: 170 },
|
|
129
|
+
'状态': { percent: 8, min: 86, max: 120 },
|
|
130
|
+
severity: { percent: 7, min: 70, max: 110 },
|
|
131
|
+
summary: { percent: 21, min: 220 },
|
|
132
|
+
},
|
|
133
|
+
'/audit::table:0': {
|
|
134
|
+
'时间': { percent: 14, min: 150 },
|
|
135
|
+
'操作人': { percent: 14, min: 150 },
|
|
136
|
+
'动作': { percent: 8, min: 90, max: 120 },
|
|
137
|
+
'配置对象': { percent: 64, min: 300 },
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type TableInstanceLike = ComponentInternalInstance & {
|
|
142
|
+
emit?: (event: string, ...args: unknown[]) => void;
|
|
143
|
+
store?: {
|
|
144
|
+
states?: {
|
|
145
|
+
columns?: { value?: any[] };
|
|
146
|
+
};
|
|
147
|
+
scheduleLayout?: (needUpdateColumns?: boolean, immediate?: boolean) => void;
|
|
148
|
+
};
|
|
149
|
+
state?: {
|
|
150
|
+
doLayout?: () => void;
|
|
151
|
+
debouncedUpdateLayout?: () => void;
|
|
152
|
+
};
|
|
153
|
+
vnode: ComponentInternalInstance['vnode'] & { el?: HTMLElement };
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const patched = new WeakSet<TableInstanceLike>();
|
|
157
|
+
const originalEmit = new WeakMap<TableInstanceLike, TableInstanceLike['emit']>();
|
|
158
|
+
const mountedTables = new Set<TableInstanceLike>();
|
|
159
|
+
let exportApiInstalled = false;
|
|
160
|
+
|
|
161
|
+
function emptyState(): WidthState {
|
|
162
|
+
return { version: 1, tables: {} };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function readState(): WidthState {
|
|
166
|
+
try {
|
|
167
|
+
const raw = window.localStorage.getItem(STORAGE_KEY);
|
|
168
|
+
if (!raw) return emptyState();
|
|
169
|
+
const parsed = JSON.parse(raw) as WidthState;
|
|
170
|
+
if (parsed?.version !== 1 || !parsed.tables) return emptyState();
|
|
171
|
+
return parsed;
|
|
172
|
+
} catch {
|
|
173
|
+
return emptyState();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function writeState(state: WidthState): void {
|
|
178
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function routeKey(router: Router): string {
|
|
182
|
+
return router.currentRoute.value.path || '/';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function tableEl(instance: TableInstanceLike): HTMLElement | null {
|
|
186
|
+
return instance.vnode.el instanceof HTMLElement ? instance.vnode.el : null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function tableIndex(instance: TableInstanceLike): number {
|
|
190
|
+
const el = tableEl(instance);
|
|
191
|
+
if (!el) return 0;
|
|
192
|
+
const tables = Array.from(document.querySelectorAll<HTMLElement>('.el-table'));
|
|
193
|
+
const index = tables.indexOf(el);
|
|
194
|
+
return index >= 0 ? index : 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function tableHint(instance: TableInstanceLike): string {
|
|
198
|
+
const el = tableEl(instance);
|
|
199
|
+
const card = el?.closest('.el-card');
|
|
200
|
+
const header = card?.querySelector('.el-card__header')?.textContent?.replace(/\s+/g, ' ').trim();
|
|
201
|
+
return header?.slice(0, 80) || '';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function tableKey(instance: TableInstanceLike, router: Router): string {
|
|
205
|
+
return `${routeKey(router)}::table:${tableIndex(instance)}`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function columnsOf(instance: TableInstanceLike): any[] {
|
|
209
|
+
return instance.store?.states?.columns?.value || [];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function columnKey(column: any, index: number): string {
|
|
213
|
+
const base = column.columnKey || column.property || column.rawColumnKey || column.label || column.type || `col_${index}`;
|
|
214
|
+
return String(base || `col_${index}`).replace(/\s+/g, '_');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function columnWidth(column: any): number {
|
|
218
|
+
const raw = Number(column.realWidth || column.width);
|
|
219
|
+
return Number.isFinite(raw) && raw > 0 ? Math.round(raw) : 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function setColumnWidth(column: any, width: number): void {
|
|
223
|
+
const nextWidth = Math.max(HARD_MIN_WIDTH, Math.round(width));
|
|
224
|
+
column.width = nextWidth;
|
|
225
|
+
column.realWidth = nextWidth;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function numericSize(value: unknown): number {
|
|
229
|
+
if (value == null || value === '') return 0;
|
|
230
|
+
const raw = Number.parseFloat(String(value));
|
|
231
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function clamp(value: number, min: number, max?: number): number {
|
|
235
|
+
const upper = max && max > min ? max : Number.POSITIVE_INFINITY;
|
|
236
|
+
return Math.round(Math.min(Math.max(value, min), upper));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function defaultWidth(column: any, tableWidth: number, pref: DefaultWidthEntry): number {
|
|
240
|
+
const min = pref.min || numericSize(column.minWidth) || numericSize(column.width) || 64;
|
|
241
|
+
return clamp((tableWidth * pref.percent) / 100, min, pref.max);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function savedWidth(saved: WidthEntry, column: any, tableWidth: number, pref?: DefaultWidthEntry): number {
|
|
245
|
+
const percent = Number(saved.percent);
|
|
246
|
+
const raw = Number.isFinite(percent) && percent > 0 ? (tableWidth * percent) / 100 : Number(saved.width);
|
|
247
|
+
const min = pref?.min || numericSize(column.minWidth) || 64;
|
|
248
|
+
return clamp(raw, min, pref?.max);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function columnMinWidth(column: any, index: number, defaults?: Record<string, DefaultWidthEntry>): number {
|
|
252
|
+
const key = columnKey(column, index);
|
|
253
|
+
return defaults?.[key]?.min || numericSize(column.minWidth) || 64;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function isActionColumn(column: any): boolean {
|
|
257
|
+
const type = String(column.type || '');
|
|
258
|
+
return !column.label && !column.property && !column.columnKey && !column.rawColumnKey && !['expand', 'selection', 'index'].includes(type);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function actionColumn(instance: TableInstanceLike): any | null {
|
|
262
|
+
const columns = columnsOf(instance);
|
|
263
|
+
if (columns.length < 2) return null;
|
|
264
|
+
const last = columns[columns.length - 1];
|
|
265
|
+
return last && isActionColumn(last) ? last : null;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function markActionColumn(instance: TableInstanceLike): void {
|
|
269
|
+
tableEl(instance)?.classList.toggle('bailing-has-action-column', !!actionColumn(instance));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function tableContentWidth(instance: TableInstanceLike): number {
|
|
273
|
+
const el = tableEl(instance);
|
|
274
|
+
const scrollWrap = el?.querySelector<HTMLElement>('.el-table__body-wrapper .el-scrollbar__wrap');
|
|
275
|
+
const bodyWrapper = el?.querySelector<HTMLElement>('.el-table__body-wrapper');
|
|
276
|
+
const innerWrapper = el?.querySelector<HTMLElement>('.el-table__inner-wrapper');
|
|
277
|
+
const candidates = [
|
|
278
|
+
scrollWrap,
|
|
279
|
+
bodyWrapper,
|
|
280
|
+
innerWrapper,
|
|
281
|
+
el,
|
|
282
|
+
el?.parentElement,
|
|
283
|
+
el?.closest<HTMLElement>('.el-tab-pane'),
|
|
284
|
+
el?.closest<HTMLElement>('.el-card__body'),
|
|
285
|
+
el?.closest<HTMLElement>('.el-drawer__body'),
|
|
286
|
+
];
|
|
287
|
+
for (const node of candidates) {
|
|
288
|
+
const rectWidth = Math.round(node?.getBoundingClientRect().width || 0);
|
|
289
|
+
const clientWidth = Math.round(node?.clientWidth || 0);
|
|
290
|
+
const width = Math.min(rectWidth || clientWidth, clientWidth || rectWidth);
|
|
291
|
+
if (width > 16) return Math.max(1, width - 2);
|
|
292
|
+
}
|
|
293
|
+
return 1;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function assignedColumnsWidth(columns: any[]): number {
|
|
297
|
+
return columns.reduce((sum, column) => sum + columnWidth(column), 0);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function actualScrollOverflow(instance: TableInstanceLike): number {
|
|
301
|
+
const el = tableEl(instance);
|
|
302
|
+
const wrap = el?.querySelector<HTMLElement>('.el-table__body-wrapper .el-scrollbar__wrap');
|
|
303
|
+
const body = el?.querySelector<HTMLElement>('.el-table__body-wrapper');
|
|
304
|
+
const node = wrap || body || el;
|
|
305
|
+
const clientWidth = Math.round(node?.clientWidth || 0);
|
|
306
|
+
const scrollWidth = Math.round(node?.scrollWidth || 0);
|
|
307
|
+
return clientWidth > 16 ? Math.max(0, scrollWidth - clientWidth) : 0;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function canStretchColumn(column: any, index: number, defaults?: Record<string, DefaultWidthEntry>): boolean {
|
|
311
|
+
if (!column || column.fixed) return false;
|
|
312
|
+
if (['expand', 'selection', 'index'].includes(String(column.type || ''))) return false;
|
|
313
|
+
const key = columnKey(column, index);
|
|
314
|
+
if (defaults?.[key]?.max) return false;
|
|
315
|
+
const label = String(column.label || column.property || '');
|
|
316
|
+
return !['启用', '状态', '审计', '冷却', '预算', '超时', '权限', '动作', '级别'].includes(label);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function canForceShrinkColumn(column: any): boolean {
|
|
320
|
+
if (!column || column.fixed) return false;
|
|
321
|
+
return !['expand', 'selection', 'index'].includes(String(column.type || ''));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function stretchColumnForSlack(
|
|
325
|
+
instance: TableInstanceLike,
|
|
326
|
+
tableWidth: number,
|
|
327
|
+
defaults?: Record<string, DefaultWidthEntry>,
|
|
328
|
+
): boolean {
|
|
329
|
+
const columns = columnsOf(instance);
|
|
330
|
+
const action = actionColumn(instance);
|
|
331
|
+
const slack = tableWidth - assignedColumnsWidth(columns);
|
|
332
|
+
if (slack <= 2) return false;
|
|
333
|
+
|
|
334
|
+
const endIndex = action ? columns.indexOf(action) : columns.length;
|
|
335
|
+
const candidates = columns.slice(0, endIndex).filter((column, index) => canStretchColumn(column, index, defaults));
|
|
336
|
+
const target = candidates[candidates.length - 1] || columns[Math.max(0, endIndex - 1)];
|
|
337
|
+
const width = columnWidth(target);
|
|
338
|
+
if (!target || !width) return false;
|
|
339
|
+
setColumnWidth(target, width + slack);
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function shrinkColumnsForOverflow(
|
|
344
|
+
instance: TableInstanceLike,
|
|
345
|
+
tableWidth: number,
|
|
346
|
+
defaults?: Record<string, DefaultWidthEntry>,
|
|
347
|
+
): boolean {
|
|
348
|
+
const columns = columnsOf(instance);
|
|
349
|
+
let overflow = assignedColumnsWidth(columns) - tableWidth;
|
|
350
|
+
if (overflow <= 2) return false;
|
|
351
|
+
let changed = false;
|
|
352
|
+
const candidates = columns
|
|
353
|
+
.map((column, index) => ({ column, index }))
|
|
354
|
+
.filter(({ column, index }) => canStretchColumn(column, index, defaults))
|
|
355
|
+
.reverse();
|
|
356
|
+
|
|
357
|
+
for (const { column, index } of candidates) {
|
|
358
|
+
if (overflow <= 2) break;
|
|
359
|
+
const width = columnWidth(column);
|
|
360
|
+
const min = columnMinWidth(column, index, defaults);
|
|
361
|
+
const cut = Math.min(Math.max(0, width - min), overflow);
|
|
362
|
+
if (cut <= 0) continue;
|
|
363
|
+
setColumnWidth(column, width - cut);
|
|
364
|
+
overflow -= cut;
|
|
365
|
+
changed = true;
|
|
366
|
+
}
|
|
367
|
+
if (overflow <= 2) return changed;
|
|
368
|
+
|
|
369
|
+
const fallback = columns
|
|
370
|
+
.map((column, index) => ({ column, index }))
|
|
371
|
+
.filter(({ column }) => canForceShrinkColumn(column))
|
|
372
|
+
.reverse();
|
|
373
|
+
for (const { column } of fallback) {
|
|
374
|
+
if (overflow <= 2) break;
|
|
375
|
+
const width = columnWidth(column);
|
|
376
|
+
const cut = Math.min(Math.max(0, width - HARD_MIN_WIDTH), overflow);
|
|
377
|
+
if (cut <= 0) continue;
|
|
378
|
+
setColumnWidth(column, width - cut);
|
|
379
|
+
overflow -= cut;
|
|
380
|
+
changed = true;
|
|
381
|
+
}
|
|
382
|
+
return changed;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function normalizeTableWidths(instance: TableInstanceLike, router: Router): boolean {
|
|
386
|
+
const tableWidth = tableContentWidth(instance);
|
|
387
|
+
if (tableWidth <= 16) return false;
|
|
388
|
+
const defaults = DEFAULT_COLUMN_WIDTHS[tableKey(instance, router)];
|
|
389
|
+
let changed = false;
|
|
390
|
+
if (shrinkColumnsForOverflow(instance, tableWidth, defaults)) changed = true;
|
|
391
|
+
if (stretchColumnForSlack(instance, tableWidth, defaults)) changed = true;
|
|
392
|
+
const overflow = actualScrollOverflow(instance);
|
|
393
|
+
if (overflow > 2 && shrinkColumnsForOverflow(instance, Math.max(1, assignedColumnsWidth(columnsOf(instance)) - overflow - 2), defaults)) {
|
|
394
|
+
changed = true;
|
|
395
|
+
}
|
|
396
|
+
return changed;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function doLayout(instance: TableInstanceLike): void {
|
|
400
|
+
instance.store?.scheduleLayout?.(false, true);
|
|
401
|
+
instance.state?.doLayout?.();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function scheduleColumnsLayout(instance: TableInstanceLike): void {
|
|
405
|
+
instance.store?.scheduleLayout?.(true, true);
|
|
406
|
+
instance.state?.doLayout?.();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function pinLastColumnRight(instance: TableInstanceLike): boolean {
|
|
410
|
+
const last = actionColumn(instance);
|
|
411
|
+
if (!last || last.fixed === 'right') return false;
|
|
412
|
+
last.fixed = 'right';
|
|
413
|
+
if (last.rawColumn) last.rawColumn.fixed = 'right';
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function saveTableWidths(instance: TableInstanceLike, router: Router): void {
|
|
418
|
+
const tableWidth = tableContentWidth(instance);
|
|
419
|
+
const columns = columnsOf(instance);
|
|
420
|
+
if (!columns.length || tableWidth <= 16) return;
|
|
421
|
+
const now = new Date().toISOString();
|
|
422
|
+
const state = readState();
|
|
423
|
+
const key = tableKey(instance, router);
|
|
424
|
+
const entry: TableEntry = state.tables[key] || {
|
|
425
|
+
route: routeKey(router),
|
|
426
|
+
table_index: tableIndex(instance),
|
|
427
|
+
table_hint: tableHint(instance),
|
|
428
|
+
table_width: tableWidth,
|
|
429
|
+
columns: {},
|
|
430
|
+
updated_at: now,
|
|
431
|
+
};
|
|
432
|
+
entry.route = routeKey(router);
|
|
433
|
+
entry.table_index = tableIndex(instance);
|
|
434
|
+
entry.table_hint = tableHint(instance);
|
|
435
|
+
entry.table_width = tableWidth;
|
|
436
|
+
entry.updated_at = now;
|
|
437
|
+
entry.columns = {};
|
|
438
|
+
columns.forEach((column, index) => {
|
|
439
|
+
const width = columnWidth(column);
|
|
440
|
+
if (!width) return;
|
|
441
|
+
entry.columns[columnKey(column, index)] = {
|
|
442
|
+
width,
|
|
443
|
+
percent: Number(((width / tableWidth) * 100).toFixed(2)),
|
|
444
|
+
label: String(column.label || ''),
|
|
445
|
+
prop: String(column.property || ''),
|
|
446
|
+
updated_at: now,
|
|
447
|
+
};
|
|
448
|
+
});
|
|
449
|
+
state.tables[key] = entry;
|
|
450
|
+
writeState(state);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function applyTablePrefs(instance: TableInstanceLike, router: Router): void {
|
|
454
|
+
if ((instance as any).__bailingUserDragging) return;
|
|
455
|
+
const key = tableKey(instance, router);
|
|
456
|
+
const tableWidth = tableContentWidth(instance);
|
|
457
|
+
if (tableWidth <= 16) return;
|
|
458
|
+
const entry = readState().tables[tableKey(instance, router)];
|
|
459
|
+
const defaults = DEFAULT_COLUMN_WIDTHS[key];
|
|
460
|
+
let widthChanged = false;
|
|
461
|
+
markActionColumn(instance);
|
|
462
|
+
const pinChanged = pinLastColumnRight(instance);
|
|
463
|
+
columnsOf(instance).forEach((column, index) => {
|
|
464
|
+
const key = columnKey(column, index);
|
|
465
|
+
const saved = entry?.columns[key];
|
|
466
|
+
const nextWidth = saved ? savedWidth(saved, column, tableWidth, defaults?.[key]) : (defaults?.[key] ? defaultWidth(column, tableWidth, defaults[key]) : 0);
|
|
467
|
+
if (!nextWidth) return;
|
|
468
|
+
if (column.width === nextWidth && column.realWidth === nextWidth) return;
|
|
469
|
+
setColumnWidth(column, nextWidth);
|
|
470
|
+
widthChanged = true;
|
|
471
|
+
});
|
|
472
|
+
if (normalizeTableWidths(instance, router)) widthChanged = true;
|
|
473
|
+
if (pinChanged) scheduleColumnsLayout(instance);
|
|
474
|
+
else if (widthChanged) doLayout(instance);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function installExportApi(): void {
|
|
478
|
+
if (exportApiInstalled || typeof window === 'undefined') return;
|
|
479
|
+
exportApiInstalled = true;
|
|
480
|
+
(window as any).__BailingTableWidths = {
|
|
481
|
+
export: () => readState(),
|
|
482
|
+
copy: async () => {
|
|
483
|
+
const text = JSON.stringify(readState(), null, 2);
|
|
484
|
+
await navigator.clipboard.writeText(text);
|
|
485
|
+
return text;
|
|
486
|
+
},
|
|
487
|
+
download: () => {
|
|
488
|
+
const text = JSON.stringify(readState(), null, 2);
|
|
489
|
+
const blob = new Blob([text], { type: 'application/json;charset=utf-8' });
|
|
490
|
+
const link = document.createElement('a');
|
|
491
|
+
link.href = URL.createObjectURL(blob);
|
|
492
|
+
link.download = `bailing-table-widths-${new Date().toISOString().slice(0, 10)}.json`;
|
|
493
|
+
document.body.appendChild(link);
|
|
494
|
+
link.click();
|
|
495
|
+
link.remove();
|
|
496
|
+
setTimeout(() => URL.revokeObjectURL(link.href), 0);
|
|
497
|
+
return text;
|
|
498
|
+
},
|
|
499
|
+
inspect: () => Array.from(mountedTables).map((instance) => {
|
|
500
|
+
const columns = columnsOf(instance);
|
|
501
|
+
const el = tableEl(instance);
|
|
502
|
+
const scrollWrap = el?.querySelector<HTMLElement>('.el-table__body-wrapper .el-scrollbar__wrap');
|
|
503
|
+
const bodyWrapper = el?.querySelector<HTMLElement>('.el-table__body-wrapper');
|
|
504
|
+
return {
|
|
505
|
+
key: tableKey(instance, { currentRoute: { value: { path: location.pathname.replace(/^\/console/, '') || '/' } } } as Router),
|
|
506
|
+
hint: tableHint(instance),
|
|
507
|
+
table_width: tableContentWidth(instance),
|
|
508
|
+
columns_width: assignedColumnsWidth(columns),
|
|
509
|
+
dom_width: {
|
|
510
|
+
root_client: el?.clientWidth || 0,
|
|
511
|
+
root_scroll: el?.scrollWidth || 0,
|
|
512
|
+
body_client: bodyWrapper?.clientWidth || 0,
|
|
513
|
+
body_scroll: bodyWrapper?.scrollWidth || 0,
|
|
514
|
+
wrap_client: scrollWrap?.clientWidth || 0,
|
|
515
|
+
wrap_scroll: scrollWrap?.scrollWidth || 0,
|
|
516
|
+
},
|
|
517
|
+
has_action_column: !!actionColumn(instance),
|
|
518
|
+
action_fixed: actionColumn(instance)?.fixed || '',
|
|
519
|
+
columns: columns.map((column, index) => ({
|
|
520
|
+
key: columnKey(column, index),
|
|
521
|
+
label: String(column.label || ''),
|
|
522
|
+
type: String(column.type || ''),
|
|
523
|
+
width: columnWidth(column),
|
|
524
|
+
fixed: column.fixed || '',
|
|
525
|
+
})),
|
|
526
|
+
};
|
|
527
|
+
}),
|
|
528
|
+
clear: () => window.localStorage.removeItem(STORAGE_KEY),
|
|
529
|
+
storageKey: STORAGE_KEY,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export function installTableWidthPersistence(app: any, router: Router): void {
|
|
534
|
+
installExportApi();
|
|
535
|
+
app.mixin({
|
|
536
|
+
mounted() {
|
|
537
|
+
const instance = this.$ as TableInstanceLike;
|
|
538
|
+
if (instance?.type?.name !== 'ElTable' || patched.has(instance)) return;
|
|
539
|
+
patched.add(instance);
|
|
540
|
+
mountedTables.add(instance);
|
|
541
|
+
const emit = instance.emit?.bind(instance);
|
|
542
|
+
originalEmit.set(instance, emit);
|
|
543
|
+
instance.emit = (event: string, ...args: unknown[]) => {
|
|
544
|
+
const result = emit?.(event, ...args);
|
|
545
|
+
if (event === 'header-dragend') {
|
|
546
|
+
(instance as any).__bailingUserDragging = true;
|
|
547
|
+
requestAnimationFrame(() => {
|
|
548
|
+
const pinChanged = pinLastColumnRight(instance);
|
|
549
|
+
const widthChanged = normalizeTableWidths(instance, router);
|
|
550
|
+
if (pinChanged || widthChanged) scheduleColumnsLayout(instance);
|
|
551
|
+
else doLayout(instance);
|
|
552
|
+
saveTableWidths(instance, router);
|
|
553
|
+
(instance as any).__bailingUserDragging = false;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
return result;
|
|
557
|
+
};
|
|
558
|
+
void nextTick(() => applyTablePrefs(instance, router));
|
|
559
|
+
setTimeout(() => applyTablePrefs(instance, router), 120);
|
|
560
|
+
let frame = 0;
|
|
561
|
+
const scheduleApply = () => {
|
|
562
|
+
if (frame) cancelAnimationFrame(frame);
|
|
563
|
+
frame = requestAnimationFrame(() => {
|
|
564
|
+
frame = 0;
|
|
565
|
+
applyTablePrefs(instance, router);
|
|
566
|
+
});
|
|
567
|
+
};
|
|
568
|
+
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(scheduleApply);
|
|
569
|
+
const el = tableEl(instance);
|
|
570
|
+
const observed = [
|
|
571
|
+
el,
|
|
572
|
+
el?.parentElement,
|
|
573
|
+
el?.closest<HTMLElement>('.el-tab-pane'),
|
|
574
|
+
el?.closest<HTMLElement>('.el-card__body'),
|
|
575
|
+
el?.closest<HTMLElement>('.el-drawer__body'),
|
|
576
|
+
].filter((node): node is HTMLElement => !!node);
|
|
577
|
+
observed.forEach((node) => observer?.observe(node));
|
|
578
|
+
window.addEventListener('resize', scheduleApply);
|
|
579
|
+
const stop = watch(
|
|
580
|
+
() => columnsOf(instance).map((column, index) => `${columnKey(column, index)}:${columnWidth(column)}`).join('|'),
|
|
581
|
+
() => void nextTick(() => applyTablePrefs(instance, router)),
|
|
582
|
+
{ flush: 'post' },
|
|
583
|
+
);
|
|
584
|
+
(instance as any).__bailingStopTableWidthWatch = stop;
|
|
585
|
+
(instance as any).__bailingStopTableWidthResize = () => {
|
|
586
|
+
if (frame) cancelAnimationFrame(frame);
|
|
587
|
+
observer?.disconnect();
|
|
588
|
+
window.removeEventListener('resize', scheduleApply);
|
|
589
|
+
};
|
|
590
|
+
},
|
|
591
|
+
beforeUnmount() {
|
|
592
|
+
const instance = this.$ as TableInstanceLike;
|
|
593
|
+
if (instance?.type?.name !== 'ElTable') return;
|
|
594
|
+
const emit = originalEmit.get(instance);
|
|
595
|
+
if (emit) instance.emit = emit;
|
|
596
|
+
originalEmit.delete(instance);
|
|
597
|
+
(instance as any).__bailingStopTableWidthWatch?.();
|
|
598
|
+
(instance as any).__bailingStopTableWidthResize?.();
|
|
599
|
+
patched.delete(instance);
|
|
600
|
+
mountedTables.delete(instance);
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElMessage } from 'element-plus/es/components/message/index';
|
|
2
|
+
import { ElMessageBox } from 'element-plus/es/components/message-box/index';
|
|
3
|
+
|
|
4
|
+
export async function copyText(t: string, tip = '已复制到剪贴板'): Promise<void> {
|
|
5
|
+
try { await navigator.clipboard.writeText(t); ElMessage.success(tip); }
|
|
6
|
+
catch { await ElMessageBox.alert(t, '手动复制', { confirmButtonText: '关闭' }).catch(() => undefined); }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** 后端统一存/出 UTC(ISO 带 Z),时区转换归显示层——按浏览器本地时区渲染(上海用户即北京时间)。 */
|
|
10
|
+
export function fmtTime(t?: string, withSec = false): string {
|
|
11
|
+
if (!t) return '-';
|
|
12
|
+
const d = new Date(t);
|
|
13
|
+
if (isNaN(d.getTime())) return String(t); // 解析不了的原样显示,别吞
|
|
14
|
+
const p = (n: number) => String(n).padStart(2, '0');
|
|
15
|
+
return `${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}${withSec ? ':' + p(d.getSeconds()) : ''}`;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"useDefineForClassFields": true,
|
|
12
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*.ts", "src/**/*.vue", "vite.config.ts"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import vue from '@vitejs/plugin-vue';
|
|
3
|
+
|
|
4
|
+
const hubDevTarget = process.env.VITE_BAILING_HUB_DEV_TARGET || 'http://127.0.0.1:18900';
|
|
5
|
+
|
|
6
|
+
// 构建产物进 hub 的 web/console/,由中枢静态托管(/console),服务器零构建。
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
// Relative assets let one immutable console build run at /console/ or at a
|
|
9
|
+
// trusted embedding prefix such as /tenant/<id>/console/.
|
|
10
|
+
base: './',
|
|
11
|
+
plugins: [vue()],
|
|
12
|
+
build: {
|
|
13
|
+
outDir: '../web/console',
|
|
14
|
+
emptyOutDir: true,
|
|
15
|
+
chunkSizeWarningLimit: 520,
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
output: {
|
|
18
|
+
manualChunks: {
|
|
19
|
+
'vendor-vue': ['vue', 'vue-router', 'pinia'],
|
|
20
|
+
'vendor-element': ['element-plus', '@element-plus/icons-vue'],
|
|
21
|
+
'vendor-mammoth': ['mammoth'],
|
|
22
|
+
'vendor-turndown': ['turndown'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
server: {
|
|
28
|
+
// 本地开发默认代理到本机中枢;如需连远端实例,用 VITE_BAILING_HUB_DEV_TARGET 覆盖。
|
|
29
|
+
proxy: {
|
|
30
|
+
'/admin': { target: hubDevTarget, changeOrigin: true },
|
|
31
|
+
'/kb': { target: hubDevTarget, changeOrigin: true },
|
|
32
|
+
'/health': { target: hubDevTarget, changeOrigin: true },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|