vue-layout-gitcode 1.9.20 → 1.9.22
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/{dist/GloabarSearch-C3xidv95.js → GloabarSearch-RdF8iq7P.js} +3 -3
- package/{dist/MenuItem-BnjaSbHz.js → MenuItem-D-6V-e9q.js} +1 -1
- package/{dist/ProjectMenuList-BQCMWEWu.js → ProjectMenuList-DrwBMawO.js} +4 -4
- package/{dist/ProjectMenuListV2-B283u7iP.js → ProjectMenuListV2-DHiYVus4.js} +3 -3
- package/{dist/ProjectSearch-D4NlcQuD.js → ProjectSearch-CKv_y8SW.js} +1 -1
- package/{dist/SearchHistoryList-XTxYkKa2.js → SearchHistoryList-B1_dOf1o.js} +1 -1
- package/{dist/SearchPrefixTag-Vr_4bRFF.js → SearchPrefixTag-CV1LjR8t.js} +1 -1
- package/{dist/SearchRecommed-C6r_e7Wu.js → SearchRecommed-CFRMLyYb.js} +2 -2
- package/{dist/SearchScopeList-BwIX06FA.js → SearchScopeList-D2wjoTji.js} +1 -1
- package/{dist/UserSearch-B0Sxpmx5.js → UserSearch-BZcotSfD.js} +2 -11
- package/{dist/index-C9cnK3pA.js → index-B0FboNO8.js} +1 -1
- package/{dist/index-CNwaKo3C.js → index-C7_YkPbO.js} +548 -919
- package/{dist/index-DbYSkair.js → index-CAVuy618.js} +3 -2
- package/{dist/index-CHM1rIrp.js → index-CX6Ws4cX.js} +12 -9
- package/{dist/index.d.ts → index.d.ts} +0 -11
- package/index.js +14 -0
- package/{dist/notice-kNQVIEMi.js → notice-BL4L53eD.js} +7 -5
- package/package.json +11 -72
- package/style.css +1 -0
- package/{dist/transWebUrl-CYbHu4ea.js → transWebUrl-BP9hBhvr.js} +1 -1
- package/README.md +0 -519
- package/dist/index.js +0 -14
- package/dist/package.json +0 -13
- package/dist/style.css +0 -1
package/README.md
DELETED
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
# GitcodeLayoutLib
|
|
2
|
-
|
|
3
|
-
GitcodeLayoutLib 是 GitCode 前端项目的基础布局组件库,提供 GitCode 通用布局组件,供各项目调用,保持各站点功能和视觉效果的一致性,目前提供的布局模块有:
|
|
4
|
-
|
|
5
|
-
- Header:全站头部导航
|
|
6
|
-
- Aside: 全站侧边栏
|
|
7
|
-
- ToolsFloat:全站右下角工具条
|
|
8
|
-
|
|
9
|
-
具体的场景模块划分,见 [BaseLayout业务组件抽离 - GitCode - 文档中心@CSDN](https://c.csdn.net/pages/viewpage.action?pageId=171750801)
|
|
10
|
-
|
|
11
|
-
npm package 地址:<https://www.npmjs.com/package/vue-layout-gitcode>
|
|
12
|
-
|
|
13
|
-
## 协作流程
|
|
14
|
-
|
|
15
|
-
- 从 main 拉取 feat 分支,进行开发
|
|
16
|
-
- 确定当天要上的 feat 分支,测试完成后,再提交 pr 到 main
|
|
17
|
-
|
|
18
|
-
## npm 发布
|
|
19
|
-
|
|
20
|
-
- 在 `CHANGELOG.md` 中,更新发布记录
|
|
21
|
-
|
|
22
|
-
- 在 `package.json` 中,手动更新版本号,也可以运行 `npm version` 自动升级版本
|
|
23
|
-
|
|
24
|
-
- **`patch`**: 用于发布向后兼容的 bug 修复。例如,如果当前版本是 `1.0.0`,运行 `npm version patch` 后会变为 `1.0.1`。
|
|
25
|
-
- **`minor`**: 用于发布向后兼容的新功能。例如,如果当前版本是 `1.0.0`,运行 `npm version minor` 后会变为 `1.1.0`。
|
|
26
|
-
- **`major`**: 用于发布不向后兼容的重大更改。例如,如果当前版本是 `1.0.0`,运行 `npm version major` 后会变为 `2.0.0`。
|
|
27
|
-
- 这个命令会自动生成一次 git 提交和 tag 记录
|
|
28
|
-
|
|
29
|
-
- 运行 `npm run build` 执行构建
|
|
30
|
-
|
|
31
|
-
- 构建完成后,执行 `npm run publish`,进行发布;
|
|
32
|
-
|
|
33
|
-
### 常见问题
|
|
34
|
-
|
|
35
|
-
#### 未切换到 npm 官方源
|
|
36
|
-
|
|
37
|
-
如 publish 时,提示:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm ERR! code ENEEDAUTH
|
|
41
|
-
npm ERR! need auth This command requires you to be logged in to https://registry.npmmirror.com/
|
|
42
|
-
npm ERR! need auth You need to authorize this machine using `npm adduser`
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
则可能当前使用的是非 npm 官方源,需要切换到官方源:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm config set registry https://registry.npmjs.org
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
#### 需要登录
|
|
52
|
-
|
|
53
|
-
命令行提示需要登录的话,执行 `npm adduser`,按提示,跳转到浏览器中,打开相应登录页面,登录验证后,会继续 publish 流程
|
|
54
|
-
|
|
55
|
-
#### 无权限
|
|
56
|
-
|
|
57
|
-
如果没有发包权限,联系奥林
|
|
58
|
-
|
|
59
|
-
#### 发布失败
|
|
60
|
-
|
|
61
|
-
如果提示**发布失败**,可能是其他同事已经发布了版本,当前本地的版本号被占用了,可以去 <https://www.npmjs.com/package/vue-layout-gitcode> 查看当前最新版本,如有冲突,进行版本号调整
|
|
62
|
-
|
|
63
|
-
错误信息:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npm ERR! code E403
|
|
67
|
-
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/vue-layout-gitcode - You cannot publish over the previously published versions: 1.3.11
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## 本地调试
|
|
71
|
-
|
|
72
|
-
本地调试:在项目中引入 layout 布局组件
|
|
73
|
-
|
|
74
|
-
场景:在 gitcode-fe 等外部项目中,本地调试 layout 布局组件
|
|
75
|
-
|
|
76
|
-
优点:
|
|
77
|
-
|
|
78
|
-
- 不需要频繁发版:layout 修改后,本地 `npm run build` 后,layout 的改动能立即反映在外部项目中
|
|
79
|
-
- 可以本地验证外部项目的 route、上报等功能是否符合预期
|
|
80
|
-
|
|
81
|
-
### 包关联说明
|
|
82
|
-
|
|
83
|
-
注意:使用项目中的包管理器来运行对应命令,如 gitcode-fe 中使用 npm,gitcode-homeweb-seo-fe 使用 pnpm,下面命令行示例中,统一使用 npm;
|
|
84
|
-
|
|
85
|
-
以 gitcode-fe 项目,本地调试 layout 为例:
|
|
86
|
-
|
|
87
|
-
1. gitcode-fe 根目录下,`npm uninstall vue-layout-gitcode` 卸载原先安装的 vue-layout-gitcode
|
|
88
|
-
2. gitcode-layout-lib-fe 根目录下,`npm run build:watch`,构建 layout,并在发生变更后,重新打包 layout
|
|
89
|
-
3. gitcode-layout-lib-fe 根目录下,运行 `npm link`,创建包的符号链接
|
|
90
|
-
4. gitcode-fe 根目录下执行 `npm link vue-layout-gitcode` 进行关联
|
|
91
|
-
|
|
92
|
-
### 包取消关联
|
|
93
|
-
|
|
94
|
-
1. gitcode-fe 根目录下,执行`npm unlink vue-layout-gitcode`
|
|
95
|
-
2. gitcode-layout-lib-fe 根目录下,执行`npm unlink vue-layout-gitcode --global`
|
|
96
|
-
|
|
97
|
-
### 引入组件并使用
|
|
98
|
-
|
|
99
|
-
gitcode-fe 中引入 Demo 组件示例:
|
|
100
|
-
|
|
101
|
-
```js
|
|
102
|
-
import { Demo, HelloWorld } from 'gitcode-layout-lib'
|
|
103
|
-
import "gitcode-layout-lib/style.css";
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
然后就可以在 template 中使用了:
|
|
107
|
-
|
|
108
|
-
```html
|
|
109
|
-
<Demo></Demo>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### devui-icomoon 无法加载
|
|
113
|
-
|
|
114
|
-
本地调试时,报错:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
ERROR The request url "/gitcode-layout-lib-fe/node_modules/@devui-design/icons/icomoon/fonts/devui-icomoon.woff" is outside of Vite serving allow list.
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Vite开发服务器默认只允许在项目根目录下的文件被访问,这种情况下,可以在 vite.server 配置中,增加配置:
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
import path from 'node:path'
|
|
124
|
-
|
|
125
|
-
// nuxt 项目举例
|
|
126
|
-
export default defineNuxtConfig({
|
|
127
|
-
vite: {
|
|
128
|
-
server: {
|
|
129
|
-
fs: {
|
|
130
|
-
// 允许访问的项目根目录
|
|
131
|
-
allow: [
|
|
132
|
-
// 默认允许当前项目目录
|
|
133
|
-
process.cwd(),
|
|
134
|
-
|
|
135
|
-
// 添加布局组件包的 node_modules 目录
|
|
136
|
-
path.resolve(__dirname, '../../../gitcode-layout-lib-fe/node_modules'),
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 布局组件使用 - 固定版本号
|
|
145
|
-
|
|
146
|
-
比如在 gitcode-fe 中,升级 vue-gitcode-layout,建议在 package.json 中锁定版本。
|
|
147
|
-
|
|
148
|
-
# Header 导航栏组件
|
|
149
|
-
|
|
150
|
-
导航栏头部组件
|
|
151
|
-
|
|
152
|
-
## 使用方式
|
|
153
|
-
|
|
154
|
-
传入场景值以及在该场景下所需的必要参数。
|
|
155
|
-
使用方式功能较多示例见 Home.vue
|
|
156
|
-
|
|
157
|
-
## Props
|
|
158
|
-
|
|
159
|
-
### 参数说明
|
|
160
|
-
|
|
161
|
-
### 常规参数
|
|
162
|
-
|
|
163
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
164
|
-
|--------|------|------|--------|------|
|
|
165
|
-
| isLogin | boolean | 是 | - | 是否登录 |
|
|
166
|
-
| sceneValue | SceneValue | 是 | SceneValue.home | 场景值 |
|
|
167
|
-
| request | Function | 是 | () => Promise.resolve({ data: null }) | 请求实例 |
|
|
168
|
-
| globalStore | Object | 否 | {} | 用来上报当前界面状态 只需要其中的httpStatus |
|
|
169
|
-
| headerBorder | boolean | 否 | false | header是否需要边框 |
|
|
170
|
-
|
|
171
|
-
### 登录相关参数
|
|
172
|
-
|
|
173
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
174
|
-
|--------|------|------|--------|------|
|
|
175
|
-
| loginSuccess | Function | 是 | - | 登录成功之后的回调函数 |
|
|
176
|
-
| openHarmonyGuide | boolean | 否 | - | 是否开启该功能 |
|
|
177
|
-
| loginOutFinish | Function | 是 | - | 退出接口调用结束以后得回调函数 |
|
|
178
|
-
| userInfo | UserInfo | 否 | {} | 用户数据,有了就传入,没登录功能的就不用传 |
|
|
179
|
-
|
|
180
|
-
### 项目相关参数
|
|
181
|
-
|
|
182
|
-
需要使用到项目命名空间的需要传 例如:场景值 repo
|
|
183
|
-
|
|
184
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
185
|
-
|--------|------|------|--------|------|
|
|
186
|
-
| repoInfo | repoInfoType | 是 | - | 项目信息 |
|
|
187
|
-
| headerCustomProps | HeaderPropsForCustom | 是 | - | 自定义custom所需信息 |
|
|
188
|
-
| headerCustomProps.errorCode | number | 是 | - | 错误码,正常传null或者0 错误情况传具体错误码 |
|
|
189
|
-
| headerCustomProps.repoProps | object | 是 | - | 见:HeaderPropsForCustom中仓库场景相关属性 |
|
|
190
|
-
|
|
191
|
-
### 组织相关参数
|
|
192
|
-
|
|
193
|
-
需要使用到项目命名空间的需要传 例如:场景值 org
|
|
194
|
-
|
|
195
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
196
|
-
|--------|------|------|--------|------|
|
|
197
|
-
| orgInfo | OrgInfo | 是 | - | 组织信息 |
|
|
198
|
-
| headerCustomProps | HeaderPropsForCustom | 是 | - | 自定义custom所需信息 |
|
|
199
|
-
| headerCustomProps.errorCode | number | 是 | - | 错误码,正常传null或者0 错误情况传具体错误码 |
|
|
200
|
-
| headerFunctions.orgProps | object | 是 | - | { isOrgFollow?: boolean } 组织的命名空间旁关注按钮 |
|
|
201
|
-
|
|
202
|
-
### 用户相关参数
|
|
203
|
-
|
|
204
|
-
需要使用到项目命名空间的需要传 例如:场景值 user
|
|
205
|
-
|
|
206
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
207
|
-
|--------|------|------|--------|------|
|
|
208
|
-
| otherUserInfo | UserInfo | 否 | - | 其他用户信息,看他人个人首页的场景 |
|
|
209
|
-
| headerCustomProps | HeaderPropsForCustom | 是 | - | 自定义custom所需信息 |
|
|
210
|
-
| headerCustomProps.errorCode | number | 是 | - | 错误码,正常传null或者0 错误情况传具体错误码 |
|
|
211
|
-
| headerFunctions.userProps | object | 是 | - | { isOtherUser?: boolean } 是否为其他用户 |
|
|
212
|
-
|
|
213
|
-
## Events
|
|
214
|
-
|
|
215
|
-
| 事件名 | 参数 | 说明 |
|
|
216
|
-
|--------|------|------|
|
|
217
|
-
| followDevCommunity | - | 关注组织 |
|
|
218
|
-
| followUser | - | 关注用户 |
|
|
219
|
-
|
|
220
|
-
## 插槽 保留了原本header中的头部中的底部插槽和search的插槽
|
|
221
|
-
|
|
222
|
-
| 插槽名 | 说明 |
|
|
223
|
-
|--------|------|
|
|
224
|
-
| bodyHeader | 头部底下第一行的位置一般用户放tab 例如:项目/组织的tab |
|
|
225
|
-
| info | bodyHeader的子插槽 细分 |
|
|
226
|
-
| menu | bodyHeader的子插槽 细分 |
|
|
227
|
-
| headerBottom | bodyHeader再往下 |
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
// SceneValue 枚举值
|
|
231
|
-
enum SceneValue {
|
|
232
|
-
home = 'home',
|
|
233
|
-
repo = 'repo',
|
|
234
|
-
org = 'org',
|
|
235
|
-
aiHome = 'aiHome',
|
|
236
|
-
aiRepo = 'aiRepo',
|
|
237
|
-
aiGuide = 'aiGuide',
|
|
238
|
-
blog = 'blog',
|
|
239
|
-
news = 'news',
|
|
240
|
-
active = 'active',
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
interface HeaderPropsForCustom {
|
|
244
|
-
/** 根据权限及是否允许显示设置错误页面 */
|
|
245
|
-
errorCode?: number;
|
|
246
|
-
/** 组织场景相关属性 */
|
|
247
|
-
orgProps?: {
|
|
248
|
-
/** 是否关注组织 */
|
|
249
|
-
isOrgFollow?: boolean;
|
|
250
|
-
};
|
|
251
|
-
/** 仓库场景相关属性 */
|
|
252
|
-
repoProps?: {
|
|
253
|
-
/** 项目名称加载状态 */
|
|
254
|
-
repoNameLoading?: boolean;
|
|
255
|
-
/** 是否是 gh_mirrors 项目 */
|
|
256
|
-
isGhMirrors?: boolean;
|
|
257
|
-
/** 是否是私有项目 */
|
|
258
|
-
isPrivate?: boolean;
|
|
259
|
-
/** 是否为 space 项目 */
|
|
260
|
-
isSpaces?: boolean;
|
|
261
|
-
};
|
|
262
|
-
/** 用户场景相关属性 */
|
|
263
|
-
userProps?: {
|
|
264
|
-
/** 是否为其他用户 */
|
|
265
|
-
isOtherUser?: boolean;
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
// 用户数据类型
|
|
271
|
-
interface UserInfo {
|
|
272
|
-
domain_id?: string;
|
|
273
|
-
email?: string;
|
|
274
|
-
id?: string;
|
|
275
|
-
arts_id?: string;
|
|
276
|
-
mobile?: string;
|
|
277
|
-
avatar?: string;
|
|
278
|
-
nickname?: string;
|
|
279
|
-
username?: string;
|
|
280
|
-
access_token?: string;
|
|
281
|
-
refresh_token?: string;
|
|
282
|
-
xauth_token?: string;
|
|
283
|
-
isFollow?: boolean;
|
|
284
|
-
atomgit_username?: string;
|
|
285
|
-
[x: string]: any;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// 项目数据类型
|
|
289
|
-
interface repoInfoType {
|
|
290
|
-
id?: number;
|
|
291
|
-
name?: string;
|
|
292
|
-
path?: string;
|
|
293
|
-
path_with_namespace?: string;
|
|
294
|
-
created_at?: string;
|
|
295
|
-
star_count?: number;
|
|
296
|
-
starred?: boolean;
|
|
297
|
-
default_branch?: string; // 默认分支
|
|
298
|
-
creator?: {
|
|
299
|
-
id: number;
|
|
300
|
-
iam_id: string;
|
|
301
|
-
username: string;
|
|
302
|
-
nick_name: string;
|
|
303
|
-
avatar_url: string;
|
|
304
|
-
};
|
|
305
|
-
description?: string;
|
|
306
|
-
module_setting?: {
|
|
307
|
-
repo_id: string;
|
|
308
|
-
modules: {
|
|
309
|
-
key: string;
|
|
310
|
-
type: string;
|
|
311
|
-
value: string;
|
|
312
|
-
}[];
|
|
313
|
-
};
|
|
314
|
-
web_url?: string;
|
|
315
|
-
repo_type?: `${RepoType}`;
|
|
316
|
-
/* 是否由安全漏洞派生 */
|
|
317
|
-
forked_by_secure_issue: Record<string, any> | null
|
|
318
|
-
enterprise?: any;
|
|
319
|
-
audit_fields?: IAuditInfo[];
|
|
320
|
-
[propName: string]: any;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// 组织数据类型
|
|
324
|
-
interface OrgInfo {
|
|
325
|
-
create_ai?: boolean;
|
|
326
|
-
id?: number;
|
|
327
|
-
full_path?: string;
|
|
328
|
-
avatar?: string;
|
|
329
|
-
name?: string;
|
|
330
|
-
description?: string;
|
|
331
|
-
path?: string;
|
|
332
|
-
email?: string;
|
|
333
|
-
location?: string;
|
|
334
|
-
orgId?: string;
|
|
335
|
-
repoId?: string;
|
|
336
|
-
visibility?: string;
|
|
337
|
-
web_url?: string;
|
|
338
|
-
mode?: string | number;
|
|
339
|
-
readme_repo?: string;
|
|
340
|
-
readme_branch?: string;
|
|
341
|
-
readme_file_path?: string;
|
|
342
|
-
item_type?: string;
|
|
343
|
-
module_setting?: {
|
|
344
|
-
group_id: string;
|
|
345
|
-
modules: {
|
|
346
|
-
key: string;
|
|
347
|
-
type: string;
|
|
348
|
-
value: string;
|
|
349
|
-
}[];
|
|
350
|
-
};
|
|
351
|
-
my_role?: {
|
|
352
|
-
access_level: number;
|
|
353
|
-
};
|
|
354
|
-
orgModule?: OrgModuleType[];
|
|
355
|
-
audit_fields?: IAuditInfo[];
|
|
356
|
-
[proName: string]: any;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
#### 使用示例
|
|
362
|
-
|
|
363
|
-
### Aside
|
|
364
|
-
|
|
365
|
-
#### Aside 参数
|
|
366
|
-
|
|
367
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
368
|
-
|--------|------|------|--------|------|
|
|
369
|
-
| isLogin | boolean | 是 | - | 是否登录 |
|
|
370
|
-
| sceneValue | SceneValue | 否 | SceneValue.home | 传入侧边栏使用的场景值 |
|
|
371
|
-
| request | Function | 否 | () => Promise.resolve({ data: null }) | 请求实例 |
|
|
372
|
-
| globalStore | Object | 否 | {} | 全局状态存储对象,用于组件内部状态管理 |
|
|
373
|
-
| userInfo | AccountInfo | 否 | {} | 用户信息 |
|
|
374
|
-
| showPreferencesSetting | boolean\|undefined | 否 | undefined | 显式设置-是否展示偏好设置 |
|
|
375
|
-
| showThemeSetting | boolean\|undefined | 否 | undefined | 显式设置-是否展示偏好设置-多主题设置,需与showPreferencesSetting 一起使用 |
|
|
376
|
-
| showLangSetting | boolean\|undefined | 否 | undefined | 显式设置-是否展示偏好设置-多语言设置,需与showPreferencesSetting 一起使用 |
|
|
377
|
-
|
|
378
|
-
#### Aside 事件
|
|
379
|
-
|
|
380
|
-
无
|
|
381
|
-
|
|
382
|
-
#### Aside 插槽
|
|
383
|
-
|
|
384
|
-
无
|
|
385
|
-
|
|
386
|
-
#### 使用示例
|
|
387
|
-
|
|
388
|
-
### ToolsFloat
|
|
389
|
-
|
|
390
|
-
#### ToolsFloat 参数
|
|
391
|
-
|
|
392
|
-
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
|
393
|
-
|--------|------|------|--------|------|
|
|
394
|
-
| isLogin | boolean | 是 | - | 是否登录 |
|
|
395
|
-
| sceneValue | SceneValue | 否 | SceneValue.home | 传入右侧工具栏使用的场景值 |
|
|
396
|
-
| request | Function | 否 | () => Promise.resolve({ data: null }) | 请求实例 |
|
|
397
|
-
| globalStore | Object | 否 | {} | 全局状态存储对象,用于组件内部状态管理 |
|
|
398
|
-
|
|
399
|
-
#### ToolsFloat 事件
|
|
400
|
-
|
|
401
|
-
| 事件名 | 参数 | 说明 |
|
|
402
|
-
|--------|------|------|
|
|
403
|
-
| toggle-growth-center | - | 切换成长中心的显示状态 |
|
|
404
|
-
|
|
405
|
-
#### ToolsFloat 插槽
|
|
406
|
-
|
|
407
|
-
无
|
|
408
|
-
|
|
409
|
-
#### 使用示例
|
|
410
|
-
|
|
411
|
-
## GitCode 前端各项目接入示例
|
|
412
|
-
|
|
413
|
-
### gitcode-fe
|
|
414
|
-
|
|
415
|
-
- 安装
|
|
416
|
-
|
|
417
|
-
```bash
|
|
418
|
-
npm install vue-layout-gitcode
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
- 注入环境变量
|
|
422
|
-
|
|
423
|
-
各项目的测试、预发、生产环境变量,通过组件提供的 setLayoutConfig 方法进行注入,方便测试验证。
|
|
424
|
-
|
|
425
|
-
`main.ts` 中注入:
|
|
426
|
-
|
|
427
|
-
```ts
|
|
428
|
-
import { setLayoutConfig } from 'vue-layout-gitcode';
|
|
429
|
-
|
|
430
|
-
// 将 import.meta.env 中的所有环境变量转换为一个普通对象,传递给 vue-layout-gitcode
|
|
431
|
-
const layoutConfig = Object.fromEntries(
|
|
432
|
-
Object.entries(import.meta.env).map(([key, value]) => [key, value])
|
|
433
|
-
);
|
|
434
|
-
|
|
435
|
-
setLayoutConfig(layoutConfig);
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
- 代理特定事件,如 'login', 'logout',登录弹窗这块的功能已经迁移到了 vue-layout-gitcode 组件中,外部项目触发相关事件的 mitt emit 时,需代理到 vue-layout-gitcode 中处理:
|
|
439
|
-
|
|
440
|
-
`src/utils/eventBus.ts`
|
|
441
|
-
|
|
442
|
-
```ts
|
|
443
|
-
import { GitCodeLayoutEmitter } from 'vue-layout-gitcode';
|
|
444
|
-
|
|
445
|
-
// 转发 - 由 GitCode layout 组件库处理的事件
|
|
446
|
-
const GitCodeLayoutProxyEvents = ['login', 'logout', 'updateNotice', 'updateNoticeCount'];
|
|
447
|
-
|
|
448
|
-
const getEmitter = (evtName: keyof EventBus): Emitter<EventBus> =>
|
|
449
|
-
GitCodeLayoutProxyEvents.includes(evtName) ? (GitCodeLayoutEmitter as unknown as Emitter<EventBus>) : emitter;
|
|
450
|
-
|
|
451
|
-
export const addEventListener = (evtName: keyof EventBus, callback: (payload: any) => void) => emitter.on(evtName, callback);
|
|
452
|
-
|
|
453
|
-
export const emitEvent = (evtName: keyof EventBus, payload?: any) => getEmitter(evtName).emit(evtName, payload);
|
|
454
|
-
|
|
455
|
-
export const offEvent = (evtName: keyof EventBus, handler?: any) => getEmitter(evtName).off(evtName, handler || undefined);
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
- 多主题相关
|
|
459
|
-
|
|
460
|
-
组件导出 currentTheme 和 setTheme, 外部项目原 theme/index.js 中, 使用组件导出的 currentTheme 和 setTheme
|
|
461
|
-
|
|
462
|
-
gitcode/src/themes/index.js
|
|
463
|
-
|
|
464
|
-
```js
|
|
465
|
-
import { currentTheme as layoutCurrentTheme, setTheme as layoutSetTheme } from 'vue-gitcode-layout';
|
|
466
|
-
|
|
467
|
-
export const currentTheme = layoutCurrentTheme;
|
|
468
|
-
|
|
469
|
-
export const setTheme = (theme) => {
|
|
470
|
-
layoutSetTheme(theme);
|
|
471
|
-
};
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
- 在 layout 组件中引入布局模块
|
|
475
|
-
|
|
476
|
-
`BaseLayout/index.vue` 中引入,并使用:
|
|
477
|
-
|
|
478
|
-
```bash
|
|
479
|
-
import { ToolsFloat, GitCodeAside as Aside } from 'vue-layout-gitcode'
|
|
480
|
-
import 'vue-layout-gitcode/style.css';
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
## 本地开发
|
|
484
|
-
|
|
485
|
-
node 16及以上版本
|
|
486
|
-
|
|
487
|
-
### 安装及启动
|
|
488
|
-
|
|
489
|
-
```bash
|
|
490
|
-
# 安装依赖
|
|
491
|
-
npm install
|
|
492
|
-
|
|
493
|
-
# 启动开发服务器
|
|
494
|
-
npm run dev
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
### Cannot find module 的处理
|
|
498
|
-
|
|
499
|
-
碰到引入 Vue 组件时,IDE 提示报错:`Cannot find module '@/components/Icon/index.vue' or its corresponding`,可以检查下 VSCode 或者 Cursor 的插件,建议使用 Volar 来处理 Vue 组件,在“设置”中,把 vue.server.hybridMode 的值改为 false。
|
|
500
|
-
|
|
501
|
-
## 特性
|
|
502
|
-
|
|
503
|
-
- 基于 Vue 3 开发
|
|
504
|
-
- 提供完整的 TypeScript 类型支持
|
|
505
|
-
- 高度优化的打包体积
|
|
506
|
-
- ES 模块格式,支持现代构建工具
|
|
507
|
-
|
|
508
|
-
## 构建优化
|
|
509
|
-
|
|
510
|
-
该库使用了多种优化技术以确保最小的包体积:
|
|
511
|
-
|
|
512
|
-
- 代码压缩和混淆
|
|
513
|
-
- 移除控制台输出和调试代码
|
|
514
|
-
- CSS 最小化
|
|
515
|
-
- 代码空白和注释的移除
|
|
516
|
-
|
|
517
|
-
## 许可证
|
|
518
|
-
|
|
519
|
-
MIT
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { K, M, P, J, S, I, z, U, O, Q, N } from "./index-CNwaKo3C.js";
|
|
2
|
-
export {
|
|
3
|
-
K as GitCodeAside,
|
|
4
|
-
M as GitCodeHeader,
|
|
5
|
-
P as GitCodeLayoutEmitter,
|
|
6
|
-
J as Login,
|
|
7
|
-
S as SceneValue,
|
|
8
|
-
I as ToolsFloat,
|
|
9
|
-
z as currentTheme,
|
|
10
|
-
U as default,
|
|
11
|
-
O as setLayoutConfig,
|
|
12
|
-
Q as setTheme,
|
|
13
|
-
N as useLogin
|
|
14
|
-
};
|
package/dist/package.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vue-layout-gitcode",
|
|
3
|
-
"version": "1.9.20",
|
|
4
|
-
"description": "用于 gitcode 站点生产环境使用",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "./index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "站内导航侧边栏"
|
|
10
|
-
},
|
|
11
|
-
"author": "lal,nevins",
|
|
12
|
-
"license": "ISC"
|
|
13
|
-
}
|