Skip to content

Commit

Permalink
fix: 插件库与工具库分离,vue-cli-plugin-h-uni-build defineConfig 导入 bug
Browse files Browse the repository at this point in the history
插件库与工具库分离,vue-cli-plugin-h-uni-build defineConfig 导入 bug
  • Loading branch information
hewx815 committed Aug 31, 2023
1 parent 4fbb277 commit 1a14e9e
Show file tree
Hide file tree
Showing 53 changed files with 187 additions and 139 deletions.
22 changes: 18 additions & 4 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vitepress';
import { fileURLToPath } from 'url';
import components from './sidebar/components';
import utils from './sidebar/utils';
import plugins from './sidebar/plugins';

const CurrentPath = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
Expand Down Expand Up @@ -45,8 +46,9 @@ export default defineConfig({
nav: [
{ text: '主页', link: '/' },
{ text: '开始', link: '/README' },
{ text: '组件', link: '/for-vue2/components/HTab', activeMatch: '/components' },
{ text: '工具', link: '/for-vue2/utils/Hhttp', activeMatch: '/utils' },
{ text: '组件库', link: '/for-vue2/components/HTab', activeMatch: '/components' },
{ text: '函数库', link: '/for-vue2/utils/Hhttp', activeMatch: '/utils' },
{ text: '插件库', link: '/for-vue2/plugins/vue-cli-plugin-h-uni-build', activeMatch: '/plugins' },
{ text: '更新记录', link: '/CHANGELOG' },
{
text: '网站导航',
Expand All @@ -73,16 +75,28 @@ export default defineConfig({
],
'/for-vue2/utils/': [
{
text: '工具库',
text: '函数库',
items: utils,
},
],
'/for-vue3/utils/': [
{
text: '工具库',
text: '函数库',
items: utils,
},
],
'/for-vue2/plugins/': [
{
text: '插件库',
items: plugins,
},
],
'/for-vue3/plugins/': [
{
text: '插件库',
items: plugins,
},
],
},
// 链接图标
socialLinks: [{ icon: 'github', link: 'https://github.com/hewx815/h-uni' }],
Expand Down
16 changes: 16 additions & 0 deletions .vitepress/sidebar/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default [
{
text: 'for-vue2',
collapsed: false,
items: [
{ text: 'vue-cli-plugin-h-uni-build', link: '/for-vue2/plugins/vue-cli-plugin-h-uni-build' },
],
},
{
text: 'for-vue3',
collapsed: false,
items: [
{ text: 'vite-plugin-h-uni-build', link: '/for-vue3/plugins/vite-plugin-h-uni-build' },
],
},
];
2 changes: 0 additions & 2 deletions .vitepress/sidebar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default [
collapsed: false,
items: [
{ text: 'Hhttp 网络请求', link: '/for-vue2/utils/Hhttp' },
{ text: 'vue-cli-plugin-h-uni-build', link: '/for-vue2/utils/vue-cli-plugin-h-uni-build' },
{ text: 'cssConverter 样式转换器', link: '/for-vue2/utils/cssConverter' },
],
},
Expand All @@ -13,7 +12,6 @@ export default [
collapsed: false,
items: [
{ text: 'Hhttp 网络请求', link: '/for-vue3/utils/Hhttp' },
{ text: 'vite-plugin-h-uni-build', link: '/for-vue3/utils/vite-plugin-h-uni-build' },
],
},
];
39 changes: 13 additions & 26 deletions .vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,59 @@
--color-lighter: rgb(145, 145, 205);
--color-dark: rgb(75, 75, 205);
--color-darker: rgb(45, 45, 205);

--vp-c-green: var(--color);
--vp-c-green-light: var(--color-light);
--vp-c-green-lighter: var(--color-lighter);
--vp-c-green-dark: var(--color-dark);
--vp-c-green-darker: var(--color-darker);

--vp-c-brand: var(--vp-c-green);
--vp-c-brand-light: var(--vp-c-green-light);
--vp-c-brand-lighter: var(--vp-c-green-lighter);
--vp-c-brand-dark: var(--vp-c-green-dark);
--vp-c-brand-darker: var(--vp-c-green-darker);

--shadow-1: rgba(0, 0, 0, 0.2);
--shadow-2: rgba(0, 0, 0, 0.14);
--shadow-3: rgba(0, 0, 0, 0.12);

--vp-layout-max-width: 1460px;
--vp-code-block-bg: #292b30;
--vp-layout-max-width: 1460px;
}

.dark {
--color: rgb(95, 95, 205);
--color-light: rgb(115, 115, 205);
--color-lighter: rgb(145, 145, 205);
--color-dark: rgb(75, 75, 205);
--color-darker: rgb(45, 45, 205);
--vp-c-green: var(--color);
--vp-c-green-light: var(--color-light);
--vp-c-green-lighter: var(--color-lighter);
--vp-c-green-dark: var(--color-dark);
--vp-c-green-darker: var(--color-darker);

--shadow-1: rgba(255, 255, 255, 0.4);
--shadow-2: rgba(255, 255, 255, 0.34);
--shadow-3: rgba(255, 255, 255, 0.32);
}
.dark {
--color: rgb(95, 95, 205);
--color-light: rgb(115, 115, 205);
--color-lighter: rgb(255, 255, 255);
--color-dark: rgb(75, 75, 205);
--color-darker: rgb(45, 45, 205);
--vp-c-green: var(--color);
--vp-c-green-light: var(--color-light);
--vp-c-green-lighter: var(--color-lighter);
--vp-c-green-dark: var(--color-dark);
--vp-c-green-darker: var(--color-darker);

--vp-code-block-bg: #161618;
}

.content-container {
max-width: 100% !important;
padding: 0 30px;
}

table tbody tr {
background-color: rgba(0, 0, 0, 0) !important;
}

/* 滚动条*/
.vp-doc [class*="language-"] pre {
max-height: 500px;
}
/* 滚动条*/
.vp-doc [class*="language-"] pre:hover::-webkit-scrollbar {
width: 12px;
height: 12px;
}

/* 滚动条*/
.vp-doc [class*="language-"] pre::-webkit-scrollbar {
width: 0px;
height: 0px;
background-color: rgba(0, 0, 0, 0);
}

/* 滚动条滑块 */
.vp-doc [class*="language-"] pre::-webkit-scrollbar-thumb {
background-color: rgb(95, 95, 95);
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ outline: deep
---

# h-uni

主页: https://h-uni.hewxing.cn

仓库: https://github.com/hewx815/h-uni
Expand All @@ -20,14 +21,16 @@ outline: deep
- `uview plus`:支持`vue3`、组件丰富、文档清晰,支持nvue
- ...

**`h-uni`并不适合作为项目的主力,更适合做一个功能补充的库**
**`h-uni`并不是单纯的组件库,他更适合做一个功能补充的库**


## 安装

### npm方式安装
::: warning
目前只提供 npm方式 安装
:::

**1. 安装依赖包**
### 安装依赖包

运行以下命令安装`h-uni`

Expand Down Expand Up @@ -55,31 +58,31 @@ npm run h-uni

如果您看到了正确的版本号证明已经成功安装

### 安装 `scss`

**2. 安装 `SCSS`**

`h-uni`内的组件依赖`SCSS`,您必须要安装此插件,否则无法正常运行。
`h-uni`内的组件依赖`scss`,您必须要安装此插件,否则无法正常运行。

::: code-group
```shell [yarn]
yarn add sass -D
yarn add sass sass-loader -D
```

```shell [npm]
npm install sass-loader -D
npm install sass sass-loader -D
```
:::

**3. 在项目中配置**
### 挂载组件和函数

:::tip 插件的安装
通过以下教程安装`组件``函数`,对于`插件`的安装请参阅详细的插件文档
:::

根据项目类型选择一下配置方式
根据项目类型选择对应的配置方式

- [vue2项目配置](#vue2项目配置)
- [vue3项目配置](#vue3项目配置)

### HBuilderX方式安装
已经提上日程,最晚2099年前支持

## vue2项目配置

### 挂载主库
Expand Down Expand Up @@ -169,9 +172,6 @@ module.exports = {
}
```

### HBuilderX支持
已经提上日程,最晚2099年之前支持

## vue3项目配置

### 挂载主库
Expand Down Expand Up @@ -250,5 +250,5 @@ export function createApp() {
}
```

### HBuilderX支持
## HBuilderX支持
已经提上日程,最晚2099年之前支持
2 changes: 1 addition & 1 deletion bin/argvs/init-h-uni-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { execSync } from 'child_process';
export default {
description: '初始化 h-uni-build',
fn: () => {
execSync('yarn add file:node_modules/h-uni/dist/for-vue2/utils/vue-cli-plugin-h-uni-build');
execSync('yarn add file:node_modules/h-uni/dist/for-vue2/plugins/vue-cli-plugin-h-uni-build');

console.log('[h-uni]:vue-cli-plugin-h-uni-build 初始化成功!');
},
Expand Down
2 changes: 1 addition & 1 deletion for-vue2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"flyio": "^0.6.2",
"vue": ">= 2.6.14 < 2.7",
"vue-class-component": "^6.3.2",
"vue-cli-plugin-h-uni-build": "./src/packages/utils/vue-cli-plugin-h-uni-build",
"vue-cli-plugin-h-uni-build": "./src/packages/plugins/vue-cli-plugin-h-uni-build",
"vue-property-decorator": "^8.0.0",
"vuex": "^3.2.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DefineComponentsHelper } from './utils';
import UniComponents from './uniComponents/index';

export * from './uniComponents/index';
export * from './utils';

type UniCommonProps = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"extends": ["eslint-config-hewx/node-javascript"],
"globals": {
"require": "readonly",
"module": "writable"
"module": "writable",
"exports": "writable"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { ProjectOptions } from '@vue/cli-service/types/ProjectOptions';

/**
* 扩展的编译前和编译后的函数接口
*/
type Hooks = (api: ProjectOptions, options: object, args: Array<string>) => void;

interface Config {

/**
* 项目编译后自动打开开发者工具,适用于使用 cli 搭建的 uniapp 项目
* - https://h-uni.hewxing.cn/for-vue2/plugins/vue-cli-plugin-h-uni-build#opendevtools
*/
openDevTools?: '' | false | {
/**
* 开发者工具的安装路径
*/
paths?: {
'mp-weixin'?: string;
'mp-alipay'?: string;
'mp-baidu'?: string;
'mp-toutiao'?: string;
'mp-lark'?: string;
};
/**
* 退出进程时是否关闭开发者工具
*/
exitClose?: boolean;
/**
* 默认编译输出文件夹
*/
projectDir?: string;
};

/**
* 项目编译前提示选择模式启动,模式中可配置该模式使用的 manifest.json 文件、pages.json 文件、env 环境变量,或者只更改部分选择
* - https://h-uni.hewxing.cn/for-vue2/plugins/vue-cli-plugin-h-uni-build#setmode
*/
setMode?: '' | false | Array<{

/**
* 模式的名称
*/
name?: string;

/**
* 为此模式设置的环境变量
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
env?: Record<string, any>;

/**
* 该模式的manifest.json文件
*/
manifestJson?: string | object;

/**
* 该模式的pages.json文件
*/
pagesJson?: string | object;
}>;

/**
* `vue-cli-plugin-h-uni-build`构建前的回调函数
* - https://h-uni.hewxing.cn/for-vue2/plugins/vue-cli-plugin-h-uni-build#beforebuild-%E5%92%8C-afterbuild
*/
beforeBuild?: '' | false | ((api: ProjectOptions, options: object, args: Array<string>) => void);

/**
* `vue-cli-plugin-h-uni-build`构建后的回调函数
* - https://h-uni.hewxing.cn/for-vue2/plugins/vue-cli-plugin-h-uni-build#beforebuild-%E5%92%8C-afterbuild
*/
afterBuild?: '' | false | ((api: ProjectOptions, options: object, args: Array<string>) => void);

/**
* 是否在编译前删掉上一次编译的旧文件
* - https://h-uni.hewxing.cn/for-vue2/plugins/vue-cli-plugin-h-uni-build#deloldfile
*/
delOldFile?: boolean;
}

export function defineConfigHuniBuild(config: Config): Config;
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ module.exports = (api, options) => {

build.fn = (...args) => newBuildFn(...args);
};

module.exports.defineConfigHuniBuild = (config) => config;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "vue-cli-plugin-h-uni-build",
"version": "0.0.1",
"description": "vue-cli-plugin-h-uni-build",
"type": "commonjs",
"eslintConfig": {
"env": {
"browser": true,
Expand Down

0 comments on commit 1a14e9e

Please sign in to comment.