@gct-paas/core 0.1.6-dev.9 → 6.0.0-dev.2
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.md +322 -0
- package/dist/index.esm.min.js +2 -1
- package/dist/{redirect-index-Ck5Ddtcb.js → redirect-index-B9IS3qL6.js} +1 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/constants/expression-type/modeCfg.mjs +6 -0
- package/es/constants/index.d.ts +4 -0
- package/es/constants/index.mjs +5 -1
- package/es/enums/app-designer/index.d.ts +29 -3
- package/es/enums/app-designer/index.mjs +33 -4
- package/es/enums/appEnum.d.ts +5 -1
- package/es/enums/appEnum.mjs +6 -1
- package/es/enums/authActionEnum.d.ts +5 -1
- package/es/enums/authActionEnum.mjs +4 -0
- package/es/enums/developer-center/integration.d.ts +6 -0
- package/es/enums/developer-center/integration.mjs +8 -1
- package/es/enums/expressionEnum.d.ts +4 -2
- package/es/enums/expressionEnum.mjs +2 -0
- package/es/enums/globalEnum.d.ts +30 -0
- package/es/enums/globalEnum.mjs +40 -1
- package/es/enums/index.d.ts +11 -0
- package/es/enums/index.mjs +13 -1
- package/es/enums/page-designer/designer.d.ts +2 -0
- package/es/enums/page-designer/designer.mjs +2 -0
- package/es/enums/page-designer/layout.d.ts +6 -0
- package/es/enums/page-designer/layout.mjs +8 -1
- package/es/enums/page-designer/panel.d.ts +9 -2
- package/es/enums/page-designer/panel.mjs +10 -2
- package/es/enums/pageEnum.d.ts +2 -1
- package/es/enums/pageEnum.mjs +1 -0
- package/es/enums/process.d.ts +5 -0
- package/es/enums/process.mjs +9 -0
- package/es/enums/sizeEnum.d.ts +4 -0
- package/es/enums/sizeEnum.mjs +6 -1
- package/es/global/gct/gct.d.ts +25 -19
- package/es/global/gct/gct.mjs +9 -5
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.mjs +1 -0
- package/es/hooks/useDebouncePromise.d.ts +14 -0
- package/es/hooks/useDebouncePromise.mjs +56 -0
- package/es/index.d.ts +2 -0
- package/es/index.mjs +37 -28
- package/es/interface/i-action-item/i-action-item.d.ts +65 -0
- package/es/interface/i-app-context/i-app-context.d.ts +25 -1
- package/es/interface/i-dictionary/i-dictionary-item.d.ts +80 -0
- package/es/interface/i-pinia-action/i-global-actions.d.ts +9 -0
- package/es/interface/i-pinia-getter/i-global-getters.d.ts +22 -1
- package/es/interface/i-pinia-state/i-global-state.d.ts +9 -2
- package/es/interface/index.d.ts +2 -1
- package/es/interface/open-util/i-confirm-util/i-confirm-util.d.ts +65 -0
- package/es/interface/open-util/i-drawer-options/i-drawer-options.d.ts +298 -0
- package/es/interface/open-util/i-modal/i-modal.d.ts +14 -1
- package/es/interface/open-util/i-modal-data/i-modal-data.d.ts +3 -3
- package/es/interface/open-util/i-modal-options/i-modal-options.d.ts +2 -1
- package/es/interface/open-util/i-overlay-controller/i-overlay-controller.d.ts +9 -0
- package/es/interface/open-util/index.d.ts +2 -0
- package/es/locale/auto-register.d.ts +2 -0
- package/es/locale/auto-register.mjs +13 -0
- package/es/locale/index.d.ts +25 -1
- package/es/locale/index.mjs +57 -3
- package/es/locale/sys/model.mjs +9 -0
- package/es/locale/sys.d.ts +17 -0
- package/es/locale/sys.mjs +26 -0
- package/es/modules/env-manager/env-manager.const.d.ts +2 -0
- package/es/modules/env-manager/env-manager.const.mjs +4 -2
- package/es/modules/env-manager/env-manager.d.ts +8 -13
- package/es/modules/env-manager/env-manager.interface.d.ts +5 -9
- package/es/modules/env-manager/env-manager.interface.mjs +2 -0
- package/es/modules/env-manager/env-manager.mjs +19 -27
- package/es/modules/env-manager/env-manager.util.d.ts +5 -0
- package/es/modules/env-manager/env-manager.util.mjs +11 -0
- package/es/modules/env-manager/index.d.ts +1 -0
- package/es/modules/env-manager/index.mjs +1 -0
- package/es/modules/mqtt/interfaces/i-mqtt.d.ts +6 -2
- package/es/modules/mqtt/mqtt-client.d.ts +8 -7
- package/es/modules/mqtt/mqtt-client.mjs +30 -19
- package/es/modules/platform-config/constants/theme.const.d.ts +9 -1
- package/es/modules/platform-config/constants/theme.const.mjs +13 -2
- package/es/modules/platform-config/enums/login.enum.d.ts +3 -1
- package/es/modules/platform-config/enums/login.enum.mjs +2 -0
- package/es/modules/platform-config/store.d.ts +18 -18
- package/es/modules/platform-config/useDeploySetting.d.ts +1 -2
- package/es/modules/platform-config/useDeploySetting.mjs +6 -3
- package/es/modules/platform-config/useLoginSetting.d.ts +2 -2
- package/es/modules/platform-config/useLoginSetting.mjs +29 -31
- package/es/modules/platform-config/useOrgSetting.d.ts +2 -2
- package/es/modules/platform-config/useOrgSetting.mjs +4 -6
- package/es/modules/platform-config/useSecuritySetting.d.ts +2 -2
- package/es/modules/platform-config/useSecuritySetting.mjs +2 -3
- package/es/modules/platform-config/useThemeSetting.d.ts +1 -1
- package/es/modules/platform-config/useThemeSetting.mjs +32 -4
- package/es/modules/platform-config/useWatermarkSetting.d.ts +5 -2
- package/es/modules/platform-config/useWatermarkSetting.mjs +2 -3
- package/es/modules/sign-log/index.d.ts +1 -0
- package/es/modules/sign-log/index.mjs +1 -0
- package/es/modules/sign-log/sign-log.d.ts +10 -0
- package/es/modules/sign-log/sign-log.mjs +109 -0
- package/es/modules/sign-log/sing-log.interface.d.ts +9 -0
- package/es/modules/system-mqtt/index.d.ts +2 -0
- package/es/modules/system-mqtt/index.mjs +1 -0
- package/es/modules/system-mqtt/system-mqtt.interface.d.ts +71 -0
- package/es/modules/system-mqtt/system-mqtt.service.d.ts +104 -0
- package/es/modules/system-mqtt/system-mqtt.service.mjs +199 -0
- package/es/modules/user-stores/store/permission.store.d.ts +1 -0
- package/es/modules/user-stores/store/permission.store.mjs +10 -0
- package/es/modules/user-stores/store/user.store.mjs +4 -2
- package/es/router/guard/index.d.ts +4 -0
- package/es/router/guard/index.mjs +41 -0
- package/es/router/index.mjs +2 -0
- package/es/setup-app.mjs +2 -9
- package/es/state/global-pinia-state/global-pinia-state.d.ts +6 -0
- package/es/state/global-pinia-state/global-pinia-state.mjs +6 -0
- package/es/store/global-store.mjs +15 -1
- package/es/types/index.d.ts +7 -0
- package/es/utils/auth-util/auth-util.d.ts +37 -0
- package/es/utils/auth-util/auth-util.mjs +79 -0
- package/es/utils/axios/check-status.d.ts +1 -0
- package/es/utils/axios/check-status.mjs +64 -0
- package/es/utils/axios/interceptors.mjs +30 -0
- package/es/utils/deviceFingerprint.mjs +5 -1
- package/es/utils/i18n/index.mjs +1 -0
- package/es/utils/index.d.ts +4 -2
- package/es/utils/index.mjs +3 -1
- package/es/utils/openUtil/modal/modal.d.ts +1 -1
- package/es/utils/openUtil/modal/modal.mjs +1 -1
- package/es/utils/openUtil/overlay-container/overlay-container.mjs +1 -1
- package/es/utils/select-user-utils.d.ts +50 -0
- package/es/utils/select-user-utils.mjs +129 -0
- package/es/utils/tools/tools.d.ts +6 -0
- package/es/utils/tools/tools.mjs +12 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1 +1,323 @@
|
|
|
1
|
+
# @gct-paas/core
|
|
1
2
|
|
|
3
|
+
PaaS 平台工程开发公共底包。提供全局运行时对象 `_gct`、Pinia 状态、路由/i18n 脚手架、环境管理、MQTT、HTTP 拦截、BEM 命名空间及各类工具方法。上层包(`core-web` / `core-mobile` / `design` / `render` 等)均依赖本包。
|
|
4
|
+
|
|
5
|
+
> 本文档面向后续开发与 AI 模型阅读:说明依赖用途、全局 `_gct` 能力与典型用法。
|
|
6
|
+
|
|
7
|
+
## 包信息
|
|
8
|
+
|
|
9
|
+
| 项 | 值 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| 包名 | `@gct-paas/core` |
|
|
12
|
+
| 入口 | `es/index.mjs`(类型:`es/index.d.ts`) |
|
|
13
|
+
| 全局类型 | `@gct-paas/core/types` → `es/types/index.d.ts` |
|
|
14
|
+
| CDN/loader | `dist/index.esm.min.js` |
|
|
15
|
+
| peer | `vue>=3`、`vue-i18n>=11`、`vue-router>=4`、`@gct-paas/api` |
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { setupApp, createAppVue, useNamespace, t } from '@gct-paas/core';
|
|
19
|
+
// 引入本包后会自动执行 onInit(),挂载 window._gct / window._api
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 在 monorepo 中的位置
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
core ← 本包:平台无关公共逻辑与全局运行时
|
|
28
|
+
├── core-components
|
|
29
|
+
├── core-web / core-mobile / core-pad ← 会挂载 message / confirm / openUtil 等端侧实现
|
|
30
|
+
│ ├── design / design-*
|
|
31
|
+
│ └── render / render-*
|
|
32
|
+
├── scss / schema / v-ben / native
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
兄弟底包说明文档见各 `packages/*/README.md`(如 `core-web`、`design`、`render`、`schema`、`scss` 等)。
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 依赖说明(供模型选型)
|
|
40
|
+
|
|
41
|
+
### Peer Dependencies(宿主必须提供)
|
|
42
|
+
|
|
43
|
+
| 依赖 | 用途 | 典型用法 |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `vue` | 应用框架 | `setupApp` / `createAppVue` |
|
|
46
|
+
| `vue-router` | 路由 | `_gct.router`、`RouterUtil` |
|
|
47
|
+
| `vue-i18n` | 多语言 | `_gct.i18n`、`t()`、`window.$t` |
|
|
48
|
+
| `@gct-paas/api` | OpenAPI 生成的 API 客户端 | `_gct.api` / `window._api`(只读) |
|
|
49
|
+
|
|
50
|
+
`@gct-paas/api` 通过 pnpm catalog 管理版本(见仓库根 `pnpm-workspace.yaml`)。全局类型中拆分为:
|
|
51
|
+
|
|
52
|
+
- `_api.apaas` — aPaaS / 设计器相关 API
|
|
53
|
+
- `_api.platform` — 平台(租户、用户等)API
|
|
54
|
+
|
|
55
|
+
### Runtime Dependencies
|
|
56
|
+
|
|
57
|
+
| 依赖 | 用途 | 在 core 中的落点 |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `pinia` | 全局/平台配置状态 | `_gct.store`、`_gct.platformStore`、`GlobalStoreUtil` |
|
|
60
|
+
| `axios` | HTTP(经 `@gct-paas/api` 的 `HttpUtil`) | `interceptors`、状态码处理 |
|
|
61
|
+
| `mqtt` | MQTT 客户端 | `_gct.mqtt`(`MqttManager`) |
|
|
62
|
+
| `wujie` | 微前端子应用通信类型 | `window.$wujie`、`useWuJieBus` 等 hooks |
|
|
63
|
+
| `dayjs` | 日期处理 | 工具/业务时间逻辑 |
|
|
64
|
+
| `lodash-es` | 通用工具 | 深合并等 |
|
|
65
|
+
| `mitt` | 事件总线 | `mitt` 导出 |
|
|
66
|
+
| `qs` | querystring | 请求参数序列化 |
|
|
67
|
+
| `async-validator` | 表单/规则校验 | `validate` / lowcode 规则 |
|
|
68
|
+
| `nprogress` | 页面加载进度条 | 路由守卫相关 |
|
|
69
|
+
| `overlayscrollbars` | 自定义滚动条 | UI 辅助 |
|
|
70
|
+
| `@vueuse/core` | Vue 组合式工具 | hooks |
|
|
71
|
+
| `@floating-ui/dom` | 浮层定位 | overlay / popover |
|
|
72
|
+
| `@fingerprintjs/fingerprintjs` | 浏览器指纹 | 签到日志、MQTT 踢人等 |
|
|
73
|
+
| `js-sha256` | 哈希 | 签名/校验场景 |
|
|
74
|
+
| `qx-util` | UUID 等小工具 | MQTT clientId 等 |
|
|
75
|
+
| `@module-federation/runtime` | 模块联邦(代码中暂注释) | 预留 `_gct.mf` |
|
|
76
|
+
|
|
77
|
+
### 不要直接替代的能力
|
|
78
|
+
|
|
79
|
+
- **API 调用**:优先 `_gct.api` / `_api`,不要在业务里再包一层裸 axios(除非扩展拦截器)。
|
|
80
|
+
- **多语言**:用 `t()` 或 `_gct.i18n`,不要另建 i18n 实例覆盖全局(主项目可挂载正式实例到 `_gct.i18n`)。
|
|
81
|
+
- **BEM 类名**:用 `useNamespace('block')`,不要手写 `gct-xxx` 拼接。
|
|
82
|
+
- **环境判断**:用 `_gct.env`(`isSandbox` / `isTestEnv` / `getEnv()` 等),不要散落解析 URL。
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 源码结构
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
packages/core/src/
|
|
90
|
+
├── index.ts # 导出 + 自动 onInit → window._gct
|
|
91
|
+
├── global/gct/gct.ts # GctGlobal 类定义
|
|
92
|
+
├── setup-app.ts # 应用启动:拦截器、_gct.init、平台配置、locale
|
|
93
|
+
├── create-app-vue.ts # 挂 i18n + router
|
|
94
|
+
├── modules/
|
|
95
|
+
│ ├── env-manager/ # 环境检测(dev/test/prod/sbx)
|
|
96
|
+
│ ├── error-handler/ # 错误处理策略
|
|
97
|
+
│ ├── mqtt/ # MqttManager / MqttClient
|
|
98
|
+
│ ├── system-mqtt/ # 系统级 MQTT(踢人、站内信等)
|
|
99
|
+
│ ├── sign-log/ # 签到/登录日志
|
|
100
|
+
│ ├── platform-config/ # 平台配置 store + composables
|
|
101
|
+
│ └── user-stores/ # user / tenant / permission store
|
|
102
|
+
├── store/ # GlobalStoreUtil、session/local storage 辅助
|
|
103
|
+
├── router/ # RouterUtil、守卫
|
|
104
|
+
├── locale/ # LocaleUtil、core 文案自动注册
|
|
105
|
+
├── utils/ # axios、namespace、uploader、treeHelper…
|
|
106
|
+
├── hooks/ # useModal、useWuJie*、useAppInst…
|
|
107
|
+
├── constants/ / enums/ / interface/ / types/
|
|
108
|
+
└── types/index.d.ts # Window / 全局 _gct、_api、$t、$wujie 声明
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 全局对象:`_gct` / `_api`
|
|
114
|
+
|
|
115
|
+
### 初始化时机
|
|
116
|
+
|
|
117
|
+
引入 `@gct-paas/core`(或其依赖方)时,`index.ts` 会**同步**执行 `onInit()`:
|
|
118
|
+
|
|
119
|
+
1. 若已存在 `window._gct`,打印警告并跳过。
|
|
120
|
+
2. 否则 `window._gct = new GctGlobal()`。
|
|
121
|
+
3. 将 `api`(来自 `@gct-paas/api`)以**只读 getter** 挂到:
|
|
122
|
+
- `window._gct.api`
|
|
123
|
+
- `window._api`
|
|
124
|
+
|
|
125
|
+
全局类型声明(`packages/core/src/types/index.d.ts`)使业务代码可直接写 `_gct`、`_api`,无需 import。
|
|
126
|
+
|
|
127
|
+
### `GctGlobal` 成员一览
|
|
128
|
+
|
|
129
|
+
| 成员 | 类型/实现 | 说明 |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `store` | Pinia `global-store` | 上下文 `context`、用户、应用信息、pageLoading 等 |
|
|
132
|
+
| `platformStore` | 平台配置 store | 主题/登录/组织/水印等平台级配置 |
|
|
133
|
+
| `storeUtil` | `GlobalStoreUtil` | 持有 pinia 实例与上述 store |
|
|
134
|
+
| `router` / `routerUtil` | vue-router | 全局路由 |
|
|
135
|
+
| `i18n` / `i18nUtil` | vue-i18n | 默认轻量实例;正式文案由主项目/setup 挂载与注册 |
|
|
136
|
+
| `env` | `EnvironmentManager` | 环境、单应用、沙箱、Android 混合模式等 |
|
|
137
|
+
| `mqtt` | `MqttManager` | 多实例 MQTT 创建/获取/销毁 |
|
|
138
|
+
| `dictionary` | `DictionaryUtil` | 数据字典 |
|
|
139
|
+
| `api` | `ApiMap`(只读) | 同 `_api` |
|
|
140
|
+
| `register` | `IGlobalRegister` | 注册中心;端侧包可挂载 editor/formItem 等 |
|
|
141
|
+
| `message` | `IMessageUtil` | **需端侧挂载**(如 `@gct-paas/core-web`) |
|
|
142
|
+
| `confirm` | `IConfirmUtil` | **需端侧挂载** |
|
|
143
|
+
| `openUtil` | `IOverlayController` | **需端侧挂载**(弹层/抽屉等) |
|
|
144
|
+
|
|
145
|
+
异步初始化:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
await _gct.init();
|
|
149
|
+
// 内部:store.init() → env.checkIsTestEnv() → i18nUtil.init()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
通常不要单独调用,应走 `setupApp(app)`。
|
|
153
|
+
|
|
154
|
+
### 端侧挂载示例(core-web)
|
|
155
|
+
|
|
156
|
+
`@gct-paas/core-web` 引入时会补充 UI 能力:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
_gct.confirm = new ConfirmUtil();
|
|
160
|
+
_gct.message = new MessageUtil();
|
|
161
|
+
_gct.openUtil = overlay;
|
|
162
|
+
_gct.register.editor = new EditorRegister();
|
|
163
|
+
// …
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
在**仅依赖 core、未加载对应端侧包**的环境中,调用 `_gct.message` / `confirm` / `openUtil` 会失败——模型生成代码时需确认宿主已加载端侧包。
|
|
167
|
+
|
|
168
|
+
### 其他全局
|
|
169
|
+
|
|
170
|
+
| 全局 | 说明 |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `_api` | 与 `_gct.api` 相同,只读 |
|
|
173
|
+
| `window.$t` | 同 `t()`,非组件上下文翻译 |
|
|
174
|
+
| `window.$wujie` | 作为 wujie 子应用运行时由容器注入 |
|
|
175
|
+
| `window.__GCT_ANDROID__` | 原生注入;`_gct.env.isAndroid` 读取 |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 应用启动流程(推荐)
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { createApp } from 'vue';
|
|
183
|
+
import { setupApp, createAppVue } from '@gct-paas/core';
|
|
184
|
+
// 按端引入,挂载 message/confirm/openUtil
|
|
185
|
+
import '@gct-paas/core-web';
|
|
186
|
+
|
|
187
|
+
const app = createApp(Root);
|
|
188
|
+
|
|
189
|
+
await setupApp(app);
|
|
190
|
+
// 1. HttpUtil.use(interceptors)
|
|
191
|
+
// 2. await _gct.init()
|
|
192
|
+
// 3. registerCoreLocale()
|
|
193
|
+
// 4. await platformConfigStore.init()
|
|
194
|
+
|
|
195
|
+
createAppVue(app);
|
|
196
|
+
// provide APP_INST + setupI18n + setupRouter
|
|
197
|
+
|
|
198
|
+
app.mount('#app');
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
插件模块约定接口(见 `IKitPluginModule`):同样暴露 `setupApp` / `createAppVue`。
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## `_gct` 常用用法
|
|
206
|
+
|
|
207
|
+
### 环境与上下文
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
const env = _gct.env.getEnv(); // 'dev' | 'test' | 'prod' | 'sbx'
|
|
211
|
+
if (_gct.env.isSandbox || _gct.env.isAppSingle) { /* … */ }
|
|
212
|
+
if (_gct.env.isAndroid) { /* 混合 App */ }
|
|
213
|
+
|
|
214
|
+
const { aid, bid, env: ctxEnv, mode } = _gct.store.context;
|
|
215
|
+
await _gct.store.setContext({ aid: 'xxx' });
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 用户与应用
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
const userId = _gct.store.userInfo?.userId;
|
|
222
|
+
const appId = _gct.store.appInfo?.id;
|
|
223
|
+
_gct.store.setPageLoading(true);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
另有独立 Pinia store(可从包导出使用):
|
|
227
|
+
|
|
228
|
+
- `useUserStore` / `useTenantStore` / `usePermissionStore`
|
|
229
|
+
- `usePlatformConfigStore`(亦挂于 `_gct.platformStore`)
|
|
230
|
+
|
|
231
|
+
### API
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// 推荐
|
|
235
|
+
const app = await _api.apaas.designerCommon.getGetApp();
|
|
236
|
+
const tenant = await _api.platform.tenant.getInfoByPortOrDomain({ domain });
|
|
237
|
+
|
|
238
|
+
// 等价
|
|
239
|
+
await _gct.api.apaas.basicConfig.getDetail({ configEnum });
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 消息 / 确认 / 弹层
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
_gct.message.error('失败');
|
|
246
|
+
await _gct.confirm.confirm({ /* … */ }); // 以端侧 IConfirmUtil 为准
|
|
247
|
+
_gct.openUtil.open(/* overlay 选项 */);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### MQTT
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
const client = _gct.mqtt.create('my-instance', {
|
|
254
|
+
username: '…',
|
|
255
|
+
password: '…',
|
|
256
|
+
});
|
|
257
|
+
const off = client.subscribe('topic/#', (topic, payload) => { /* … */ });
|
|
258
|
+
await client.publish('topic/cmd', 'on');
|
|
259
|
+
_gct.mqtt.destroy('my-instance');
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 多语言
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { t } from '@gct-paas/core';
|
|
266
|
+
|
|
267
|
+
t('sys.xxx');
|
|
268
|
+
window.$t('sys.xxx');
|
|
269
|
+
_gct.i18n.global.t('sys.xxx');
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### BEM 命名空间
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import { useNamespace } from '@gct-paas/core';
|
|
276
|
+
|
|
277
|
+
const ns = useNamespace('button');
|
|
278
|
+
ns.b(); // gct-button
|
|
279
|
+
ns.e('icon'); // gct-button__icon
|
|
280
|
+
ns.m('primary'); // gct-button--primary
|
|
281
|
+
ns.is('disabled', true);
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 主要导出速查
|
|
287
|
+
|
|
288
|
+
从 `@gct-paas/core` 可直接 import(完整列表以 `src/index.ts` 为准):
|
|
289
|
+
|
|
290
|
+
| 类别 | 示例 |
|
|
291
|
+
| --- | --- |
|
|
292
|
+
| 启动 | `setupApp`、`createAppVue`、`GctGlobal` |
|
|
293
|
+
| 模块 | `EnvironmentManager`、`EnvironmentType`、`MqttManager`、`usePlatformConfigStore`、`useUserStore`… |
|
|
294
|
+
| Store 辅助 | `globalRefStorage`、`globalRefSession`、`ENV` |
|
|
295
|
+
| 工具 | `useNamespace`、`t`、`mitt`、`cssLoader`、`TreeHelper`、`AuthUtil`、`interceptors`、`getToken`/`setToken`、`gctMemoizeAsync`、`PluginPgkUtil`… |
|
|
296
|
+
| Hooks | `useModal`、`useAppInst`、`useWuJieBus`、`useWuJieProps`… |
|
|
297
|
+
| 常量/枚举/接口 | `constants/*`、`enums/*`、`interface/*` |
|
|
298
|
+
| 路由常量 | `REDIRECT_NAME` |
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 给后续模型的约束摘要
|
|
303
|
+
|
|
304
|
+
1. **全局单例**:业务侧读写运行时状态优先 `_gct.*` / `_api`,不要新建第二套全局。
|
|
305
|
+
2. **不要改写 `_gct.api` / `_api`**:属性为只读,赋值会抛错。
|
|
306
|
+
3. **端侧能力**:`message` / `confirm` / `openUtil` / 部分 `register.*` 由 `core-web` 等包挂载,生成代码前确认宿主依赖链。
|
|
307
|
+
4. **启动顺序**:`setupApp` → `createAppVue` → `mount`;在 `setupApp` 完成前不要依赖已初始化的 env/平台配置。
|
|
308
|
+
5. **类型**:需要全局声明时引用 `@gct-paas/core/types`(或宿主已引入的全局类型)。
|
|
309
|
+
6. **样式**:组件类名走 `useNamespace`;SCSS 侧遵循仓库 BEM skill(`.agents/skills/gct-bem-best`)。
|
|
310
|
+
7. **导入**:禁止从 `@/index`、`@/loader`、父目录 `..` 导入(ESLint 限制);跨包用包名 `@gct-paas/core`。
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 本地命令
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
cd packages/core
|
|
318
|
+
npm run dev # watch
|
|
319
|
+
npm run build # lint + vue-tsc + 双 Vite 构建
|
|
320
|
+
npm run lint
|
|
321
|
+
npm run test:run
|
|
322
|
+
npm run test:coverage
|
|
323
|
+
```
|