├── .babelrc
├── .gitignore
├── .npmignore
├── .npmrc
├── LICENSE
├── README.md
├── changelog.md
├── coverage
├── clover.xml
├── coverage-final.json
├── lcov-report
│ ├── base.css
│ ├── block-navigation.js
│ ├── clientAppEnhance.ts.html
│ ├── config.js.html
│ ├── errorId.js.html
│ ├── favicon.png
│ ├── index.html
│ ├── index.js.html
│ ├── prettify.css
│ ├── prettify.js
│ ├── sort-arrow-sprite.png
│ ├── sorter.js
│ └── utils.js.html
└── lcov.info
├── dist
├── plugins
│ └── index.js
└── project
│ ├── vue2
│ └── index.js
│ └── vue3
│ ├── index.d.ts
│ ├── index.js
│ ├── inject
│ └── componentInject.d.ts
│ └── provide
│ └── pageProvide.d.ts
├── docs
├── .vuepress
│ ├── clientAppEnhance.ts
│ ├── config.ts
│ ├── data
│ │ └── links.ts
│ ├── public
│ │ └── images
│ │ │ └── logo.png
│ ├── styles
│ │ └── index.scss
│ └── theme
│ │ ├── index.ts
│ │ └── layouts
│ │ └── Layout.vue
├── README.md
├── code
│ └── use
│ │ ├── 1
│ │ ├── App.vue
│ │ ├── afterPageA.vue
│ │ └── beforePageA.vue
│ │ ├── 2
│ │ ├── App.vue
│ │ ├── customCopyright.vue
│ │ └── main.js
│ │ ├── 3
│ │ ├── App.vue
│ │ ├── main.js
│ │ ├── pageA.vue
│ │ ├── pages.json
│ │ └── uni.scss
│ │ ├── 4
│ │ ├── App.vue
│ │ ├── main.js
│ │ ├── mixin.js
│ │ ├── pageA.vue
│ │ └── pageB.vue
│ │ ├── 5
│ │ ├── App.vue
│ │ ├── customSubmit.vue
│ │ ├── pageA.vue
│ │ └── pageB.vue
│ │ ├── 6
│ │ ├── App.vue
│ │ ├── main.js
│ │ ├── mixin.js
│ │ ├── pageA.vue
│ │ └── pageB.vue
│ │ ├── 7
│ │ ├── App.vue
│ │ ├── customSubmit.vue
│ │ ├── main.ts
│ │ ├── pageA.vue
│ │ └── toast.vue
│ │ ├── 8
│ │ ├── App.vue
│ │ ├── main.js
│ │ ├── pageA.vue
│ │ └── vite.config.js
│ │ └── 5-1
│ │ ├── App.vue
│ │ ├── customSubmit.vue
│ │ ├── pageA.vue
│ │ └── pageB.vue
├── components
│ ├── footer.vue
│ └── modal.vue
└── md
│ ├── aboutMe.md
│ ├── changeLog.md
│ ├── configure.md
│ ├── followUpPlan.md
│ ├── install.md
│ ├── introduce.md
│ ├── precautions.md
│ └── use.md
├── examples
├── uniapp-vue2-cli-loader
│ ├── .gitignore
│ ├── README.md
│ ├── babel.config.js
│ ├── jsconfig.json
│ ├── package.json
│ ├── postcss.config.js
│ ├── public
│ │ └── index.html
│ ├── src
│ │ ├── App.vue
│ │ ├── components
│ │ │ └── customSubmit.vue
│ │ ├── main.js
│ │ ├── manifest.json
│ │ ├── pages.json
│ │ ├── pages
│ │ │ └── index
│ │ │ │ └── index.vue
│ │ ├── plugin
│ │ │ ├── hack.h5.js
│ │ │ ├── hack.js
│ │ │ └── hack.wx.js
│ │ ├── static
│ │ │ └── logo.png
│ │ └── uni.scss
│ ├── tsconfig.json
│ └── vue.config.js
├── uniapp-vue2-hbuilder-nvue-loader
│ ├── .hbuilderx
│ │ └── launch.json
│ ├── App.vue
│ ├── components
│ │ └── submit.vue
│ ├── index.html
│ ├── main.js
│ ├── manifest.json
│ ├── mixins
│ │ └── index.js
│ ├── package.json
│ ├── pages.json
│ ├── pages
│ │ └── index
│ │ │ └── index.nvue
│ ├── static
│ │ └── logo.png
│ ├── uni.scss
│ └── vue.config.js
├── uniapp-vue2-hbuilderx-loader
│ ├── .hbuilderx
│ │ └── launch.json
│ ├── App.vue
│ ├── components
│ │ └── submit.vue
│ ├── global.scss
│ ├── index.html
│ ├── main.js
│ ├── manifest.json
│ ├── package.json
│ ├── pages.json
│ ├── pages
│ │ └── index
│ │ │ ├── index.vue
│ │ │ └── other.vue
│ ├── static
│ │ └── logo.png
│ ├── uni.scss
│ └── vue.config.js
├── uniapp-vue3-cli-vite-ts-plugin
│ ├── .gitignore
│ ├── .vscode
│ │ └── settings.json
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── plugin.js
│ ├── postcss.config.js
│ ├── project.config.json
│ ├── src
│ │ ├── App.vue
│ │ ├── components
│ │ │ ├── customSubmit.vue
│ │ │ ├── demo.vue
│ │ │ └── toast.vue
│ │ ├── env.d.ts
│ │ ├── main.ts
│ │ ├── manifest.json
│ │ ├── pages.json
│ │ ├── pages
│ │ │ ├── home
│ │ │ │ └── index.vue
│ │ │ └── mine
│ │ │ │ └── index
│ │ │ │ └── index.vue
│ │ ├── static
│ │ │ └── logo.png
│ │ └── uni.scss
│ ├── tsconfig.json
│ └── vite.config.ts
└── uniapp-vue3-hbuilderx-plugin
│ ├── .hbuilderx
│ └── launch.json
│ ├── App.vue
│ ├── components
│ ├── customSubmit.vue
│ └── toast.vue
│ ├── global.scss
│ ├── index.html
│ ├── main.js
│ ├── manifest.json
│ ├── package.json
│ ├── pages.json
│ ├── pages
│ └── index
│ │ ├── index.vue
│ │ └── other.vue
│ ├── plugin.js
│ ├── static
│ └── logo.png
│ ├── uni.scss
│ └── vite.config.js
├── jest.config.js
├── package.json
├── package.uniModules.json
├── rollup.config.js
├── scripts
├── addBaiduStatistics.js
├── chokidar.js
├── compressZipExample.js
├── compressZipSrc.js
├── copyChangelog.js
├── localPublish.js
└── localTest.js
├── src
├── config.d.ts
├── config.js
├── plugins
│ ├── errorId.js
│ ├── index.js
│ └── utils.js
└── project
│ ├── vue2
│ ├── index.js
│ └── mixins
│ │ ├── componentInject.js
│ │ └── pageProvide.js
│ └── vue3
│ ├── index.ts
│ ├── inject
│ └── componentInject.ts
│ └── provide
│ └── pageProvide.ts
├── test
├── addCode
│ └── index.test.js
├── appVueTemplate
│ └── index.test.js
├── getRouterFile
│ ├── data
│ │ ├── 1
│ │ │ └── pages.json
│ │ └── 2
│ │ │ └── pages.json
│ └── index.test.js
├── parse
│ ├── vite.spec.js
│ └── webpack.spec.js
├── parseHtml
│ └── index.test.js
└── print
│ └── index.test.js
├── tsconfig.xx.json
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/preset-env"
4 | ]
5 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/node_modules
2 | **/unpackage
3 | /examples**/dist
4 | /examples/**/yarn.lock
5 |
6 | /docs/.vuepress/.temp
7 | /docs/.vuepress/.cache
8 | /docs/.vuepress/dist
9 |
10 | **/DS_Store
11 | **/.DS_Store
12 | **/yarn-error.log
13 | /zip
14 | /temp
15 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | /coverage
2 | /docs
3 | /examples
4 | /node_modules
5 | /scripts
6 | /test
7 | /zip
8 | /temp
9 |
10 | **/.DS_Store
11 | /yarn-error.log
12 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://registry.npmjs.org
2 | always-auth=true
3 | email=fty2460392754@gmail.com
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 pocky
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # uniapp-router-view-loader
2 |
3 | [](https://github.com/2460392754/uniapp-router-view-loader)
4 | [](https://github.com/2460392754/uniapp-router-view-loader)
5 | [](https://github.com/2460392754/uniapp-router-view-loader)
6 | [](https://github.com/2460392754/uniapp-router-view-loader)
7 | [](https://www.npmjs.com/package/uniapp-router-view-loader)
8 | [](https://www.npmjs.com/package/uniapp-router-view-loader)
9 |
10 | [在线文档](https://docs.965.ink/uniapp-router-view-loader/)
11 |
12 | [demo 项目](./examples/)
13 |
14 |
15 | ## QQ 群
16 |
17 | 424521214
18 |
19 | ## 说明
20 |
21 | 全网首个专属于 `UniApp` 的编译工具插件,全面支持各平台、各环境、各语言、各类型文件、各编译工具。
22 |
23 | ## 功能
24 |
25 | - [路由模板](https://docs.965.ink/uniapp-router-view-loader/md/introduce.html#路由模板)
26 | - [虚拟标签](https://docs.965.ink/uniapp-router-view-loader/md/introduce.html#虚拟标签)
27 |
28 | ## 后续计划
29 |
30 | - 支持 `虚拟标签` ✅
31 | - 支持 `app-nvue`
32 | - 支持 `uni_modules`
33 | - 支持 `webpack hot` 和 `vite hot`
34 | - 重构 `TS`
35 | - 完善 `单元测试`
36 |
37 |
38 |
--------------------------------------------------------------------------------
/changelog.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 更新日志
4 | ---
5 |
6 | # 更新日志
7 |
8 | - 2022-04-14 - v1.1.2
9 |
10 | - bug: 修复 多 `template` 标签导致 “添加代码到尾部” 异常
11 |
12 | - 2022-04-11 - v1.1.1
13 |
14 | - bug: 修复 页面 `footer插槽` 解析匹配错误
15 |
16 | - 2022-03-10 - v1.1.0
17 |
18 | - feature: 新增 `虚拟标签`
19 |
20 | - 2022-03-04 - v1.0.3
21 |
22 | - feature: 优化插件配置
23 | - feature: 优化冗余文件
24 | - example: 更新 `demo` 项目配置
25 |
26 | - 2022-03-03 - v1.0.2
27 |
28 | - bug: 修复 `vue` 文件中存在多 `script` 标签导致 `vue-compile` 工具编译异常
29 |
30 | - 2022-03-02 - v1.0.1
31 |
32 | - bug: 修复 `window系统` 磁盘路径读取后正则匹配异常
33 | - example: 添加 nvue 项目
34 |
35 | - 2022-03-01 - v1.0.0
36 |
37 | - feature: 插件发布
38 |
--------------------------------------------------------------------------------
/coverage/clover.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/coverage/lcov-report/base.css:
--------------------------------------------------------------------------------
1 | body, html {
2 | margin:0; padding: 0;
3 | height: 100%;
4 | }
5 | body {
6 | font-family: Helvetica Neue, Helvetica, Arial;
7 | font-size: 14px;
8 | color:#333;
9 | }
10 | .small { font-size: 12px; }
11 | *, *:after, *:before {
12 | -webkit-box-sizing:border-box;
13 | -moz-box-sizing:border-box;
14 | box-sizing:border-box;
15 | }
16 | h1 { font-size: 20px; margin: 0;}
17 | h2 { font-size: 14px; }
18 | pre {
19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
20 | margin: 0;
21 | padding: 0;
22 | -moz-tab-size: 2;
23 | -o-tab-size: 2;
24 | tab-size: 2;
25 | }
26 | a { color:#0074D9; text-decoration:none; }
27 | a:hover { text-decoration:underline; }
28 | .strong { font-weight: bold; }
29 | .space-top1 { padding: 10px 0 0 0; }
30 | .pad2y { padding: 20px 0; }
31 | .pad1y { padding: 10px 0; }
32 | .pad2x { padding: 0 20px; }
33 | .pad2 { padding: 20px; }
34 | .pad1 { padding: 10px; }
35 | .space-left2 { padding-left:55px; }
36 | .space-right2 { padding-right:20px; }
37 | .center { text-align:center; }
38 | .clearfix { display:block; }
39 | .clearfix:after {
40 | content:'';
41 | display:block;
42 | height:0;
43 | clear:both;
44 | visibility:hidden;
45 | }
46 | .fl { float: left; }
47 | @media only screen and (max-width:640px) {
48 | .col3 { width:100%; max-width:100%; }
49 | .hide-mobile { display:none!important; }
50 | }
51 |
52 | .quiet {
53 | color: #7f7f7f;
54 | color: rgba(0,0,0,0.5);
55 | }
56 | .quiet a { opacity: 0.7; }
57 |
58 | .fraction {
59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
60 | font-size: 10px;
61 | color: #555;
62 | background: #E8E8E8;
63 | padding: 4px 5px;
64 | border-radius: 3px;
65 | vertical-align: middle;
66 | }
67 |
68 | div.path a:link, div.path a:visited { color: #333; }
69 | table.coverage {
70 | border-collapse: collapse;
71 | margin: 10px 0 0 0;
72 | padding: 0;
73 | }
74 |
75 | table.coverage td {
76 | margin: 0;
77 | padding: 0;
78 | vertical-align: top;
79 | }
80 | table.coverage td.line-count {
81 | text-align: right;
82 | padding: 0 5px 0 20px;
83 | }
84 | table.coverage td.line-coverage {
85 | text-align: right;
86 | padding-right: 10px;
87 | min-width:20px;
88 | }
89 |
90 | table.coverage td span.cline-any {
91 | display: inline-block;
92 | padding: 0 5px;
93 | width: 100%;
94 | }
95 | .missing-if-branch {
96 | display: inline-block;
97 | margin-right: 5px;
98 | border-radius: 3px;
99 | position: relative;
100 | padding: 0 4px;
101 | background: #333;
102 | color: yellow;
103 | }
104 |
105 | .skip-if-branch {
106 | display: none;
107 | margin-right: 10px;
108 | position: relative;
109 | padding: 0 4px;
110 | background: #ccc;
111 | color: white;
112 | }
113 | .missing-if-branch .typ, .skip-if-branch .typ {
114 | color: inherit !important;
115 | }
116 | .coverage-summary {
117 | border-collapse: collapse;
118 | width: 100%;
119 | }
120 | .coverage-summary tr { border-bottom: 1px solid #bbb; }
121 | .keyline-all { border: 1px solid #ddd; }
122 | .coverage-summary td, .coverage-summary th { padding: 10px; }
123 | .coverage-summary tbody { border: 1px solid #bbb; }
124 | .coverage-summary td { border-right: 1px solid #bbb; }
125 | .coverage-summary td:last-child { border-right: none; }
126 | .coverage-summary th {
127 | text-align: left;
128 | font-weight: normal;
129 | white-space: nowrap;
130 | }
131 | .coverage-summary th.file { border-right: none !important; }
132 | .coverage-summary th.pct { }
133 | .coverage-summary th.pic,
134 | .coverage-summary th.abs,
135 | .coverage-summary td.pct,
136 | .coverage-summary td.abs { text-align: right; }
137 | .coverage-summary td.file { white-space: nowrap; }
138 | .coverage-summary td.pic { min-width: 120px !important; }
139 | .coverage-summary tfoot td { }
140 |
141 | .coverage-summary .sorter {
142 | height: 10px;
143 | width: 7px;
144 | display: inline-block;
145 | margin-left: 0.5em;
146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
147 | }
148 | .coverage-summary .sorted .sorter {
149 | background-position: 0 -20px;
150 | }
151 | .coverage-summary .sorted-desc .sorter {
152 | background-position: 0 -10px;
153 | }
154 | .status-line { height: 10px; }
155 | /* yellow */
156 | .cbranch-no { background: yellow !important; color: #111; }
157 | /* dark red */
158 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
159 | .low .chart { border:1px solid #C21F39 }
160 | .highlighted,
161 | .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
162 | background: #C21F39 !important;
163 | }
164 | /* medium red */
165 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
166 | /* light red */
167 | .low, .cline-no { background:#FCE1E5 }
168 | /* light green */
169 | .high, .cline-yes { background:rgb(230,245,208) }
170 | /* medium green */
171 | .cstat-yes { background:rgb(161,215,106) }
172 | /* dark green */
173 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) }
174 | .high .chart { border:1px solid rgb(77,146,33) }
175 | /* dark yellow (gold) */
176 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; }
177 | .medium .chart { border:1px solid #f9cd0b; }
178 | /* light yellow */
179 | .medium { background: #fff4c2; }
180 |
181 | .cstat-skip { background: #ddd; color: #111; }
182 | .fstat-skip { background: #ddd; color: #111 !important; }
183 | .cbranch-skip { background: #ddd !important; color: #111; }
184 |
185 | span.cline-neutral { background: #eaeaea; }
186 |
187 | .coverage-summary td.empty {
188 | opacity: .5;
189 | padding-top: 4px;
190 | padding-bottom: 4px;
191 | line-height: 1;
192 | color: #888;
193 | }
194 |
195 | .cover-fill, .cover-empty {
196 | display:inline-block;
197 | height: 12px;
198 | }
199 | .chart {
200 | line-height: 0;
201 | }
202 | .cover-empty {
203 | background: white;
204 | }
205 | .cover-full {
206 | border-right: none !important;
207 | }
208 | pre.prettyprint {
209 | border: none !important;
210 | padding: 0 !important;
211 | margin: 0 !important;
212 | }
213 | .com { color: #999 !important; }
214 | .ignore-none { color: #999; font-weight: normal; }
215 |
216 | .wrapper {
217 | min-height: 100%;
218 | height: auto !important;
219 | height: 100%;
220 | margin: 0 auto -48px;
221 | }
222 | .footer, .push {
223 | height: 48px;
224 | }
225 |
--------------------------------------------------------------------------------
/coverage/lcov-report/block-navigation.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | var jumpToCode = (function init() {
3 | // Classes of code we would like to highlight in the file view
4 | var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
5 |
6 | // Elements to highlight in the file listing view
7 | var fileListingElements = ['td.pct.low'];
8 |
9 | // We don't want to select elements that are direct descendants of another match
10 | var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11 |
12 | // Selecter that finds elements on the page to which we can jump
13 | var selector =
14 | fileListingElements.join(', ') +
15 | ', ' +
16 | notSelector +
17 | missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18 |
19 | // The NodeList of matching elements
20 | var missingCoverageElements = document.querySelectorAll(selector);
21 |
22 | var currentIndex;
23 |
24 | function toggleClass(index) {
25 | missingCoverageElements
26 | .item(currentIndex)
27 | .classList.remove('highlighted');
28 | missingCoverageElements.item(index).classList.add('highlighted');
29 | }
30 |
31 | function makeCurrent(index) {
32 | toggleClass(index);
33 | currentIndex = index;
34 | missingCoverageElements.item(index).scrollIntoView({
35 | behavior: 'smooth',
36 | block: 'center',
37 | inline: 'center'
38 | });
39 | }
40 |
41 | function goToPrevious() {
42 | var nextIndex = 0;
43 | if (typeof currentIndex !== 'number' || currentIndex === 0) {
44 | nextIndex = missingCoverageElements.length - 1;
45 | } else if (missingCoverageElements.length > 1) {
46 | nextIndex = currentIndex - 1;
47 | }
48 |
49 | makeCurrent(nextIndex);
50 | }
51 |
52 | function goToNext() {
53 | var nextIndex = 0;
54 |
55 | if (
56 | typeof currentIndex === 'number' &&
57 | currentIndex < missingCoverageElements.length - 1
58 | ) {
59 | nextIndex = currentIndex + 1;
60 | }
61 |
62 | makeCurrent(nextIndex);
63 | }
64 |
65 | return function jump(event) {
66 | if (
67 | document.getElementById('fileSearch') === document.activeElement &&
68 | document.activeElement != null
69 | ) {
70 | // if we're currently focused on the search input, we don't want to navigate
71 | return;
72 | }
73 |
74 | switch (event.which) {
75 | case 78: // n
76 | case 74: // j
77 | goToNext();
78 | break;
79 | case 66: // b
80 | case 75: // k
81 | case 80: // p
82 | goToPrevious();
83 | break;
84 | }
85 | };
86 | })();
87 | window.addEventListener('keydown', jumpToCode);
88 |
--------------------------------------------------------------------------------
/coverage/lcov-report/clientAppEnhance.ts.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Code coverage report for clientAppEnhance.ts
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
All files clientAppEnhance.ts
23 |
24 |
25 |
26 | 0%
27 | Statements
28 | 0/1
29 |
30 |
31 |
32 |
33 | 100%
34 | Branches
35 | 0/0
36 |
37 |
38 |
39 |
40 | 0%
41 | Functions
42 | 0/1
43 |
44 |
45 |
46 |
47 | 0%
48 | Lines
49 | 0/1
50 |
51 |
52 |
53 |
54 |
55 | Press n or j to go to the next uncovered block, b, p or k for the previous block.
56 |
57 |
58 |
59 | Filter:
60 |
61 |
62 |
63 |
64 |
65 |
66 | 1
67 | 2
68 | 3
69 | 4
70 | 5
71 | 6
72 | 7 |
73 |
74 |
75 |
76 |
77 |
78 | | import { defineClientAppEnhance } from '@vuepress/client';
79 | import Modal from '../components/modal.vue';
80 |
81 | export default defineClientAppEnhance(({ app, router, siteData }) => {
82 | app.component('Modal', Modal);
83 | });
84 | |
85 |
86 |
87 |
88 |
93 |
94 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/coverage/lcov-report/config.js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Code coverage report for config.js
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | 100%
27 | Statements
28 | 2/2
29 |
30 |
31 |
32 |
33 | 100%
34 | Branches
35 | 0/0
36 |
37 |
38 |
39 |
40 | 100%
41 | Functions
42 | 0/0
43 |
44 |
45 |
46 |
47 | 100%
48 | Lines
49 | 2/2
50 |
51 |
52 |
53 |
54 |
55 | Press n or j to go to the next uncovered block, b, p or k for the previous block.
56 |
57 |
58 |
59 | Filter:
60 |
61 |
62 |
63 |
64 |
65 |
66 | 1
67 | 2
68 | 3
69 | 4
70 | 5
71 | 6
72 | 7
73 | 8
74 | 9
75 | 10
76 | 11
77 | 12
78 | 13
79 | 14 |
80 |
81 |
82 |
83 |
84 | 5x
85 |
86 |
87 |
88 |
89 | 5x
90 |
91 |
92 | | export { name, version } from '../package.json'
93 |
94 | /**
95 | * pages.json 在项目中的相对路径
96 | */
97 | export const publicPath = '../../'
98 |
99 | /**
100 | * vnode 节点
101 | */
102 | export const VNode = {
103 | 'VNode-Navbar': '/src/template/navbar',
104 | 'VNode-Copyright': '/src/template/copyright',
105 | } |
106 |
107 |
108 |
109 |
114 |
115 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/coverage/lcov-report/errorId.js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Code coverage report for errorId.js
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | 0%
27 | Statements
28 | 0/0
29 |
30 |
31 |
32 |
33 | 0%
34 | Branches
35 | 0/0
36 |
37 |
38 |
39 |
40 | 0%
41 | Functions
42 | 0/0
43 |
44 |
45 |
46 |
47 | 0%
48 | Lines
49 | 0/0
50 |
51 |
52 |
53 |
54 |
55 | Press n or j to go to the next uncovered block, b, p or k for the previous block.
56 |
57 |
58 |
59 | Filter:
60 |
61 |
62 |
63 |
64 |
65 |
66 | 1
67 | 2
68 | 3
69 | 4
70 | 5
71 | 6 |
72 |
73 |
74 |
75 |
76 | | export default {
77 | 10001: 'pages.json文件解析异常',
78 | 10101: 'App.vue文件中未找到<view-router />标签',
79 | 10102: 'App.vue文件中<view-router />标签数量超过1个以上',
80 | 10201: '运行环境异常'
81 | } |
82 |
83 |
84 |
85 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/coverage/lcov-report/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/coverage/lcov-report/favicon.png
--------------------------------------------------------------------------------
/coverage/lcov-report/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Code coverage report for All files
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
22 |
All files
23 |
24 |
25 |
26 | 67.92%
27 | Statements
28 | 72/106
29 |
30 |
31 |
32 |
33 | 70.96%
34 | Branches
35 | 22/31
36 |
37 |
38 |
39 |
40 | 70.37%
41 | Functions
42 | 19/27
43 |
44 |
45 |
46 |
47 | 68.31%
48 | Lines
49 | 69/101
50 |
51 |
52 |
53 |
54 |
55 | Press n or j to go to the next uncovered block, b, p or k for the previous block.
56 |
57 |
58 |
59 | Filter:
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | File |
70 | |
71 | Statements |
72 | |
73 | Branches |
74 | |
75 | Functions |
76 | |
77 | Lines |
78 | |
79 |
80 |
81 |
82 | config.js |
83 |
84 |
85 | |
86 | 100% |
87 | 2/2 |
88 | 100% |
89 | 0/0 |
90 | 100% |
91 | 0/0 |
92 | 100% |
93 | 2/2 |
94 |
95 |
96 |
97 | index.js |
98 |
99 |
100 | |
101 | 0% |
102 | 0/34 |
103 | 0% |
104 | 0/8 |
105 | 0% |
106 | 0/8 |
107 | 0% |
108 | 0/32 |
109 |
110 |
111 |
112 | utils.js |
113 |
114 |
115 | |
116 | 100% |
117 | 70/70 |
118 | 95.65% |
119 | 22/23 |
120 | 100% |
121 | 19/19 |
122 | 100% |
123 | 67/67 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
136 |
137 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/coverage/lcov-report/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
2 |
--------------------------------------------------------------------------------
/coverage/lcov-report/sort-arrow-sprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/coverage/lcov-report/sort-arrow-sprite.png
--------------------------------------------------------------------------------
/coverage/lcov-report/sorter.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | var addSorting = (function() {
3 | 'use strict';
4 | var cols,
5 | currentSort = {
6 | index: 0,
7 | desc: false
8 | };
9 |
10 | // returns the summary table element
11 | function getTable() {
12 | return document.querySelector('.coverage-summary');
13 | }
14 | // returns the thead element of the summary table
15 | function getTableHeader() {
16 | return getTable().querySelector('thead tr');
17 | }
18 | // returns the tbody element of the summary table
19 | function getTableBody() {
20 | return getTable().querySelector('tbody');
21 | }
22 | // returns the th element for nth column
23 | function getNthColumn(n) {
24 | return getTableHeader().querySelectorAll('th')[n];
25 | }
26 |
27 | function onFilterInput() {
28 | const searchValue = document.getElementById('fileSearch').value;
29 | const rows = document.getElementsByTagName('tbody')[0].children;
30 | for (let i = 0; i < rows.length; i++) {
31 | const row = rows[i];
32 | if (
33 | row.textContent
34 | .toLowerCase()
35 | .includes(searchValue.toLowerCase())
36 | ) {
37 | row.style.display = '';
38 | } else {
39 | row.style.display = 'none';
40 | }
41 | }
42 | }
43 |
44 | // loads the search box
45 | function addSearchBox() {
46 | var template = document.getElementById('filterTemplate');
47 | var templateClone = template.content.cloneNode(true);
48 | templateClone.getElementById('fileSearch').oninput = onFilterInput;
49 | template.parentElement.appendChild(templateClone);
50 | }
51 |
52 | // loads all columns
53 | function loadColumns() {
54 | var colNodes = getTableHeader().querySelectorAll('th'),
55 | colNode,
56 | cols = [],
57 | col,
58 | i;
59 |
60 | for (i = 0; i < colNodes.length; i += 1) {
61 | colNode = colNodes[i];
62 | col = {
63 | key: colNode.getAttribute('data-col'),
64 | sortable: !colNode.getAttribute('data-nosort'),
65 | type: colNode.getAttribute('data-type') || 'string'
66 | };
67 | cols.push(col);
68 | if (col.sortable) {
69 | col.defaultDescSort = col.type === 'number';
70 | colNode.innerHTML =
71 | colNode.innerHTML + '';
72 | }
73 | }
74 | return cols;
75 | }
76 | // attaches a data attribute to every tr element with an object
77 | // of data values keyed by column name
78 | function loadRowData(tableRow) {
79 | var tableCols = tableRow.querySelectorAll('td'),
80 | colNode,
81 | col,
82 | data = {},
83 | i,
84 | val;
85 | for (i = 0; i < tableCols.length; i += 1) {
86 | colNode = tableCols[i];
87 | col = cols[i];
88 | val = colNode.getAttribute('data-value');
89 | if (col.type === 'number') {
90 | val = Number(val);
91 | }
92 | data[col.key] = val;
93 | }
94 | return data;
95 | }
96 | // loads all row data
97 | function loadData() {
98 | var rows = getTableBody().querySelectorAll('tr'),
99 | i;
100 |
101 | for (i = 0; i < rows.length; i += 1) {
102 | rows[i].data = loadRowData(rows[i]);
103 | }
104 | }
105 | // sorts the table using the data for the ith column
106 | function sortByIndex(index, desc) {
107 | var key = cols[index].key,
108 | sorter = function(a, b) {
109 | a = a.data[key];
110 | b = b.data[key];
111 | return a < b ? -1 : a > b ? 1 : 0;
112 | },
113 | finalSorter = sorter,
114 | tableBody = document.querySelector('.coverage-summary tbody'),
115 | rowNodes = tableBody.querySelectorAll('tr'),
116 | rows = [],
117 | i;
118 |
119 | if (desc) {
120 | finalSorter = function(a, b) {
121 | return -1 * sorter(a, b);
122 | };
123 | }
124 |
125 | for (i = 0; i < rowNodes.length; i += 1) {
126 | rows.push(rowNodes[i]);
127 | tableBody.removeChild(rowNodes[i]);
128 | }
129 |
130 | rows.sort(finalSorter);
131 |
132 | for (i = 0; i < rows.length; i += 1) {
133 | tableBody.appendChild(rows[i]);
134 | }
135 | }
136 | // removes sort indicators for current column being sorted
137 | function removeSortIndicators() {
138 | var col = getNthColumn(currentSort.index),
139 | cls = col.className;
140 |
141 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
142 | col.className = cls;
143 | }
144 | // adds sort indicators for current column being sorted
145 | function addSortIndicators() {
146 | getNthColumn(currentSort.index).className += currentSort.desc
147 | ? ' sorted-desc'
148 | : ' sorted';
149 | }
150 | // adds event listeners for all sorter widgets
151 | function enableUI() {
152 | var i,
153 | el,
154 | ithSorter = function ithSorter(i) {
155 | var col = cols[i];
156 |
157 | return function() {
158 | var desc = col.defaultDescSort;
159 |
160 | if (currentSort.index === i) {
161 | desc = !currentSort.desc;
162 | }
163 | sortByIndex(i, desc);
164 | removeSortIndicators();
165 | currentSort.index = i;
166 | currentSort.desc = desc;
167 | addSortIndicators();
168 | };
169 | };
170 | for (i = 0; i < cols.length; i += 1) {
171 | if (cols[i].sortable) {
172 | // add the click event handler on the th so users
173 | // dont have to click on those tiny arrows
174 | el = getNthColumn(i).querySelector('.sorter').parentElement;
175 | if (el.addEventListener) {
176 | el.addEventListener('click', ithSorter(i));
177 | } else {
178 | el.attachEvent('onclick', ithSorter(i));
179 | }
180 | }
181 | }
182 | }
183 | // adds sorting functionality to the UI
184 | return function() {
185 | if (!getTable()) {
186 | return;
187 | }
188 | cols = loadColumns();
189 | loadData();
190 | addSearchBox();
191 | addSortIndicators();
192 | enableUI();
193 | };
194 | })();
195 |
196 | window.addEventListener('load', addSorting);
197 |
--------------------------------------------------------------------------------
/coverage/lcov.info:
--------------------------------------------------------------------------------
1 | TN:
2 | SF:src/config.js
3 | FNF:0
4 | FNH:0
5 | DA:6,5
6 | DA:11,5
7 | LF:2
8 | LH:2
9 | BRF:0
10 | BRH:0
11 | end_of_record
12 | TN:
13 | SF:src/index.js
14 | FN:14,getConfigure
15 | FN:30,handleAppVue
16 | FN:49,handleRouteFile
17 | FN:63,(anonymous_3)
18 | FN:72,(anonymous_4)
19 | FN:83,vitePlugin
20 | FN:90,(anonymous_6)
21 | FN:103,(anonymous_7)
22 | FNF:8
23 | FNH:0
24 | FNDA:0,getConfigure
25 | FNDA:0,handleAppVue
26 | FNDA:0,handleRouteFile
27 | FNDA:0,(anonymous_3)
28 | FNDA:0,(anonymous_4)
29 | FNDA:0,vitePlugin
30 | FNDA:0,(anonymous_6)
31 | FNDA:0,(anonymous_7)
32 | DA:4,0
33 | DA:15,0
34 | DA:18,0
35 | DA:20,0
36 | DA:31,0
37 | DA:33,0
38 | DA:34,0
39 | DA:35,0
40 | DA:37,0
41 | DA:38,0
42 | DA:40,0
43 | DA:50,0
44 | DA:52,0
45 | DA:53,0
46 | DA:55,0
47 | DA:64,0
48 | DA:67,0
49 | DA:68,0
50 | DA:72,0
51 | DA:73,0
52 | DA:76,0
53 | DA:84,0
54 | DA:86,0
55 | DA:92,0
56 | DA:93,0
57 | DA:95,0
58 | DA:96,0
59 | DA:97,0
60 | DA:99,0
61 | DA:103,0
62 | DA:104,0
63 | DA:106,0
64 | LF:32
65 | LH:0
66 | BRDA:67,0,0,0
67 | BRDA:67,0,1,0
68 | BRDA:72,1,0,0
69 | BRDA:72,1,1,0
70 | BRDA:92,2,0,0
71 | BRDA:92,2,1,0
72 | BRDA:103,3,0,0
73 | BRDA:103,3,1,0
74 | BRF:8
75 | BRH:0
76 | end_of_record
77 | TN:
78 | SF:src/utils.js
79 | FN:15,(anonymous_0)
80 | FN:25,(anonymous_1)
81 | FN:36,(anonymous_2)
82 | FN:43,(anonymous_3)
83 | FN:47,(anonymous_4)
84 | FN:48,(anonymous_5)
85 | FN:66,(anonymous_6)
86 | FN:67,(anonymous_7)
87 | FN:75,(anonymous_8)
88 | FN:76,(anonymous_9)
89 | FN:95,(anonymous_10)
90 | FN:102,(anonymous_11)
91 | FN:124,(anonymous_12)
92 | FN:152,(anonymous_13)
93 | FN:161,(anonymous_14)
94 | FN:185,(anonymous_15)
95 | FN:193,(anonymous_16)
96 | FN:224,(anonymous_17)
97 | FN:233,(anonymous_18)
98 | FNF:19
99 | FNH:19
100 | FNDA:13,(anonymous_0)
101 | FNDA:9,(anonymous_1)
102 | FNDA:3,(anonymous_2)
103 | FNDA:4,(anonymous_3)
104 | FNDA:2,(anonymous_4)
105 | FNDA:4,(anonymous_5)
106 | FNDA:7,(anonymous_6)
107 | FNDA:4,(anonymous_7)
108 | FNDA:7,(anonymous_8)
109 | FNDA:4,(anonymous_9)
110 | FNDA:3,(anonymous_10)
111 | FNDA:1,(anonymous_11)
112 | FNDA:1,(anonymous_12)
113 | FNDA:3,(anonymous_13)
114 | FNDA:15,(anonymous_14)
115 | FNDA:3,(anonymous_15)
116 | FNDA:15,(anonymous_16)
117 | FNDA:7,(anonymous_17)
118 | FNDA:6,(anonymous_18)
119 | DA:15,5
120 | DA:16,13
121 | DA:25,5
122 | DA:26,9
123 | DA:27,9
124 | DA:29,9
125 | DA:36,5
126 | DA:37,3
127 | DA:38,3
128 | DA:40,2
129 | DA:41,2
130 | DA:43,2
131 | DA:44,4
132 | DA:47,2
133 | DA:48,2
134 | DA:49,4
135 | DA:53,2
136 | DA:55,1
137 | DA:56,1
138 | DA:66,5
139 | DA:67,7
140 | DA:75,5
141 | DA:76,7
142 | DA:95,5
143 | DA:97,3
144 | DA:99,3
145 | DA:102,1
146 | DA:103,1
147 | DA:104,1
148 | DA:108,1
149 | DA:110,1
150 | DA:124,1
151 | DA:125,1
152 | DA:126,1
153 | DA:129,1
154 | DA:135,1
155 | DA:152,5
156 | DA:154,3
157 | DA:157,3
158 | DA:161,15
159 | DA:185,5
160 | DA:186,3
161 | DA:187,3
162 | DA:188,3
163 | DA:190,3
164 | DA:191,3
165 | DA:193,3
166 | DA:194,15
167 | DA:195,3
168 | DA:196,3
169 | DA:197,3
170 | DA:200,12
171 | DA:201,4
172 | DA:203,8
173 | DA:208,3
174 | DA:209,1
175 | DA:210,2
176 | DA:211,1
177 | DA:214,1
178 | DA:224,5
179 | DA:225,7
180 | DA:233,5
181 | DA:234,6
182 | DA:236,6
183 | DA:238,1
184 | DA:239,1
185 | DA:242,5
186 | LF:67
187 | LH:67
188 | BRDA:40,0,0,1
189 | BRDA:99,1,0,1
190 | BRDA:99,1,1,1
191 | BRDA:99,1,2,1
192 | BRDA:99,1,3,1
193 | BRDA:99,1,4,1
194 | BRDA:99,1,5,1
195 | BRDA:99,1,6,1
196 | BRDA:99,1,7,1
197 | BRDA:99,1,8,1
198 | BRDA:99,1,9,1
199 | BRDA:99,1,10,1
200 | BRDA:194,2,0,3
201 | BRDA:194,2,1,12
202 | BRDA:200,3,0,4
203 | BRDA:200,3,1,8
204 | BRDA:208,4,0,1
205 | BRDA:208,4,1,2
206 | BRDA:210,5,0,1
207 | BRDA:210,5,1,1
208 | BRDA:233,6,0,0
209 | BRDA:236,7,0,1
210 | BRDA:236,7,1,5
211 | BRF:23
212 | BRH:22
213 | end_of_record
214 |
--------------------------------------------------------------------------------
/dist/project/vue2/index.js:
--------------------------------------------------------------------------------
1 | const provideKey="$urvl";var componentInject={inject:[provideKey],mounted(){const o=this[provideKey].$refs;Object.keys(o).forEach(e=>{o[e].$v=void 0===o[e].$vm?o[e]:o[e].$vm})}};const s=Date.now();var pageProvide={provide(){return{[provideKey]:this[s]}},data(){return{[s]:{$refs:this.$refs}}}};export{componentInject as ComponentInjectMixin,pageProvide as PageProvideMixin};
2 |
--------------------------------------------------------------------------------
/dist/project/vue3/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from './provide/pageProvide';
2 | export * from './inject/componentInject';
3 |
--------------------------------------------------------------------------------
/dist/project/vue3/index.js:
--------------------------------------------------------------------------------
1 | import{provide,inject}from"vue";const provideKey="$urvl";var pageProvide=function(o){var n={};Object.keys(o).forEach(function(e){n[e]=function(){return o[e].value}}),provide(provideKey,n)},componentInject=function(){return inject(provideKey)};export{componentInject,pageProvide};
2 |
--------------------------------------------------------------------------------
/dist/project/vue3/inject/componentInject.d.ts:
--------------------------------------------------------------------------------
1 | declare type ComponentInjectRes = {
2 | [K in keyof T]: () => T[K];
3 | };
4 | export declare const componentInject: () => ComponentInjectRes;
5 | export {};
6 |
--------------------------------------------------------------------------------
/dist/project/vue3/provide/pageProvide.d.ts:
--------------------------------------------------------------------------------
1 | import { Ref } from 'vue';
2 | interface Opts {
3 | [key: string]: Ref;
4 | }
5 | export declare const pageProvide: (opts: Opts) => void;
6 | export {};
7 |
--------------------------------------------------------------------------------
/docs/.vuepress/clientAppEnhance.ts:
--------------------------------------------------------------------------------
1 | import { defineClientAppEnhance } from '@vuepress/client';
2 | import Modal from '../components/modal.vue';
3 | import Footer from '../components/footer.vue';
4 |
5 | export default defineClientAppEnhance(({ app, router, siteData }) => {
6 | app.component('Modal', Modal);
7 | app.component('Footer', Footer);
8 | });
9 |
--------------------------------------------------------------------------------
/docs/.vuepress/config.ts:
--------------------------------------------------------------------------------
1 | import { defineUserConfig } from 'vuepress';
2 | import type { DefaultThemeOptions } from 'vuepress';
3 | import type { ViteBundlerOptions } from '@vuepress/bundler-vite';
4 | import path from 'path';
5 | import LinksData from './data/links';
6 | import { version, name } from '../../package.json';
7 |
8 | export default defineUserConfig({
9 | // 站点配置
10 | lang: 'en-US',
11 | title: name + ' v' + version,
12 | description: 'Just playing around',
13 | base: '/uniapp-router-view-loader/',
14 |
15 | bundlerConfig: {
16 | viteOptions: {
17 | // base: './'
18 | plugins: []
19 | }
20 | },
21 |
22 | plugins: [
23 | // ['vuepress-plugin-vuepress2.x-code-copy', true]
24 | // ['vuepress-plugin-copy-code2yarn dev', {}],
25 | [
26 | '@vuepress/plugin-search',
27 | {
28 | locales: {
29 | '/': {
30 | placeholder: '搜索'
31 | }
32 | }
33 | }
34 | ]
35 | ],
36 |
37 | markdown: {
38 | extractHeaders: {
39 | level: [2, 3, 4]
40 | }
41 | },
42 |
43 | // theme: 'vuepress-theme-quicksand',
44 | theme: path.resolve(__dirname, './theme'),
45 |
46 | themeConfig: {
47 | contributors: false,
48 | // logo: '/images/logo.png',
49 | navbar: [
50 | { text: '首页', link: '/' },
51 | { text: '配置', link: '/md/configure' },
52 | { text: '插件市场', link: 'https://ext.dcloud.net.cn/plugin?id=7523' },
53 | // { text: 'Gitee', link: '' },
54 | {
55 | text: 'Github',
56 | link: 'https://github.com/2460392754/uniapp-router-view-loader'
57 | },
58 | {
59 | text: '友情链接',
60 | children: LinksData
61 | }
62 | ],
63 |
64 | sidebarDepth: 4,
65 | sidebar: [
66 | '/md/introduce',
67 | '/md/install',
68 | '/md/configure',
69 | '/md/use',
70 | '/md/precautions',
71 | '/md/changelog',
72 | '/md/followUpPlan',
73 | '/md/aboutMe'
74 |
75 | // {
76 | // text: '实现原理',
77 | // children: []
78 | // }
79 | ]
80 | }
81 | });
82 |
--------------------------------------------------------------------------------
/docs/.vuepress/data/links.ts:
--------------------------------------------------------------------------------
1 | import type { NavbarGroup, NavbarItem } from '@vuepress/theme-default/lib/shared/nav';
2 |
3 | const LinkDatas: (NavbarGroup | NavbarItem | string)[] = [
4 | {
5 | text: 'uview ui',
6 | link: 'https://www.uviewui.com/'
7 | }
8 | ];
9 |
10 | export default LinkDatas;
11 |
--------------------------------------------------------------------------------
/docs/.vuepress/public/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/docs/.vuepress/public/images/logo.png
--------------------------------------------------------------------------------
/docs/.vuepress/styles/index.scss:
--------------------------------------------------------------------------------
1 | :root {
2 | --content-width: 1000px;
3 | --homepage-width: 1050px;
4 | }
5 |
6 | // * {
7 | // margin: 0;
8 | // padding: 0;
9 | // }
10 | .page {
11 | transform: none !important;
12 | }
13 |
14 | .theme-container .navbar .logo {
15 | border-radius: 0 !important;
16 | }
17 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/index.ts:
--------------------------------------------------------------------------------
1 | import path from 'path';
2 |
3 | export default {
4 | name: 'vuepress-theme-my-custom-local',
5 | extends: 'vuepress-theme-quicksand',
6 | layouts: {
7 | Layout: path.resolve(__dirname, 'layouts/Layout.vue')
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/layouts/Layout.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
24 |
25 |
40 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: Layout
3 | home: true
4 | heroImage: /images/logo.png
5 | heroText: uniapp-router-view-loader
6 | tagline: 让你拥有的代码拥有 "路由模板"、"虚拟标签"
7 | actions:
8 | - text: 快速上手
9 | link: /md/introduce
10 | type: primary
11 | # - text: 查看原理
12 | # link: /reference/config.html#theme
13 | # type: secondary
14 | features:
15 | - title: 简洁至上
16 | details: 极简的配置,极致的享受
17 | - title: 奇思妙想
18 | details: 实现官方未实现的功能
19 | - title: 全面兼容
20 | details: 无需关心,专注开发
21 | - title: 微入侵
22 | details: 高内聚,低耦合
23 | - title: 低成本
24 | details: 类模版功能
25 | - title: 高效率
26 | details: 几行代码就可实现理想功能
27 | ---
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/docs/code/use/1/App.vue:
--------------------------------------------------------------------------------
1 |
2 | My Header1
3 | My Header2
4 |
5 | My Footer1
6 | My Footer2
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/docs/code/use/1/afterPageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | My Header1
4 | My Header2
5 | content
6 | My Footer1
7 | My Footer2
8 |
9 |
10 |
--------------------------------------------------------------------------------
/docs/code/use/1/beforePageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | content
4 |
5 |
6 |
--------------------------------------------------------------------------------
/docs/code/use/2/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/docs/code/use/2/customCopyright.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ content }}
3 |
4 |
5 |
14 |
--------------------------------------------------------------------------------
/docs/code/use/2/main.js:
--------------------------------------------------------------------------------
1 | import CustomCopyright from './customCopyright.vue';
2 | import Vue from 'vue';
3 |
4 | Vue.component('CustomCopyright', CustomCopyright);
--------------------------------------------------------------------------------
/docs/code/use/3/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/docs/code/use/3/main.js:
--------------------------------------------------------------------------------
1 | import uView from 'uview-ui'
2 | import Vue from 'vue';
3 |
4 | Vue.use(uView)
--------------------------------------------------------------------------------
/docs/code/use/3/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/docs/code/use/3/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "autoscan": true,
4 | "custom": {
5 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue",
6 | "^u--(.*)": "uview-ui/components/u--$1/u--$1.vue"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/docs/code/use/3/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/docs/code/use/4/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/docs/code/use/4/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Mixin from './mixin.js'
3 |
4 | Vue.mixin(Mixin)
--------------------------------------------------------------------------------
/docs/code/use/4/mixin.js:
--------------------------------------------------------------------------------
1 | export default {
2 | data() {
3 | return {
4 | navbarTitle: '日有所思'
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/docs/code/use/4/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | content
5 |
6 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/docs/code/use/4/pageB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | content
5 |
6 |
7 |
8 |
17 |
--------------------------------------------------------------------------------
/docs/code/use/5-1/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/docs/code/use/5-1/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/docs/code/use/5-1/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/docs/code/use/5-1/pageB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/docs/code/use/5/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/docs/code/use/5/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
23 |
--------------------------------------------------------------------------------
/docs/code/use/5/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/docs/code/use/5/pageB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/docs/code/use/6/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
16 |
--------------------------------------------------------------------------------
/docs/code/use/6/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Mixin from './mixin.js'
3 |
4 | Vue.mixin(Mixin)
--------------------------------------------------------------------------------
/docs/code/use/6/mixin.js:
--------------------------------------------------------------------------------
1 | export default {
2 | data() {
3 | return {
4 | skeletonVisible: true,
5 | loadingPageVisible: false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/docs/code/use/6/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 无骨架屏
4 |
5 |
6 |
7 |
18 |
--------------------------------------------------------------------------------
/docs/code/use/6/pageB.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 有骨架屏
4 |
5 |
6 |
7 |
18 |
--------------------------------------------------------------------------------
/docs/code/use/7/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/docs/code/use/7/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 提交成功
4 |
5 |
6 |
7 |
26 |
--------------------------------------------------------------------------------
/docs/code/use/7/main.ts:
--------------------------------------------------------------------------------
1 | import { createSSRApp } from 'vue';
2 | import App from './App.vue';
3 | import Toast from './toast.vue';
4 |
5 | export function createApp() {
6 | const app = createSSRApp(App);
7 |
8 | app.component('Toast', Toast);
9 |
10 | return {
11 | app
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/docs/code/use/7/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | btn
4 |
5 |
6 |
7 |
8 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docs/code/use/7/toast.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ title }}
3 |
4 |
5 |
38 |
39 |
57 |
--------------------------------------------------------------------------------
/docs/code/use/8/App.vue:
--------------------------------------------------------------------------------
1 |
2 | div to view label
3 | span to text label
4 |
5 | is u-text label
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/docs/code/use/8/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Mixin from './mixin.js'
3 |
4 | Vue.mixin(Mixin)
--------------------------------------------------------------------------------
/docs/code/use/8/pageA.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 |
14 |
--------------------------------------------------------------------------------
/docs/code/use/8/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import uni from '@dcloudio/vite-plugin-uni';
3 | import { vitePlugin } from 'uniapp-router-view-loader';
4 |
5 | export default defineConfig({
6 | plugins: [
7 | uni(),
8 | vitePlugin({
9 | vLabel: {
10 | div: 'view',
11 | span: 'text',
12 | 'u-text': 'u--text',
13 | // 'u-form': 'u--form',
14 | // 'u-input': 'u--input',
15 | // 'u-textarea': 'u--textarea'
16 | }
17 | })
18 | ]
19 | });
20 |
--------------------------------------------------------------------------------
/docs/components/footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
37 |
38 |
53 |
--------------------------------------------------------------------------------
/docs/components/modal.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
公告
5 |
19 |
20 |
21 |
22 | 全网首个专属于UniApp的编译工具插件,全面支持各平台、各环境、各语言、各类型文件、各编译工具。
23 |
24 |
QQ群: 424521214
25 |
29 | GitHub Issues
30 |
31 |
32 |
33 |
52 |
53 |
54 |
55 |
75 |
76 |
151 |
--------------------------------------------------------------------------------
/docs/md/aboutMe.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 关于我
4 | description: 页面的描述
5 | layout: Layout
6 | ---
7 |
8 | About Me
9 |
--------------------------------------------------------------------------------
/docs/md/changeLog.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 更新日志
4 | ---
5 |
6 | # 更新日志
7 |
8 | - 2022-04-14 - v1.1.2
9 |
10 | - bug: 修复 多 `template` 标签导致 “添加代码到尾部” 异常
11 |
12 | - 2022-04-11 - v1.1.1
13 |
14 | - bug: 修复 页面 `footer插槽` 解析匹配错误
15 |
16 | - 2022-03-10 - v1.1.0
17 |
18 | - feature: 新增 `虚拟标签`
19 |
20 | - 2022-03-04 - v1.0.3
21 |
22 | - feature: 优化插件配置
23 | - feature: 优化冗余文件
24 | - example: 更新 `demo` 项目配置
25 |
26 | - 2022-03-03 - v1.0.2
27 |
28 | - bug: 修复 `vue` 文件中存在多 `script` 标签导致 `vue-compile` 工具编译异常
29 |
30 | - 2022-03-02 - v1.0.1
31 |
32 | - bug: 修复 `window系统` 磁盘路径读取后正则匹配异常
33 | - example: 添加 nvue 项目
34 |
35 | - 2022-03-01 - v1.0.0
36 |
37 | - feature: 插件发布
38 |
--------------------------------------------------------------------------------
/docs/md/configure.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 配置
4 | description: 页面的描述
5 | ---
6 |
7 | # 配置
8 |
9 | ### Vue2
10 |
11 | `vue.config.js`文件(没有就创建)
12 |
13 | :::: code-group
14 | ::: code-group-item Vue-Cli
15 |
16 | ```js
17 | module.exports = {
18 | chainWebpack: (config) => {
19 | config.resolveLoader.alias.set(
20 | 'custom-uniapp-router-view-loader',
21 | 'uniapp-router-view-loader'
22 | );
23 |
24 | config.module
25 | .rule('vue')
26 | .use('custom-uniapp-router-view-loader')
27 | .loader('custom-uniapp-router-view-loader')
28 | .options({
29 | vLabel: {
30 | div: 'view',
31 | span: 'text'
32 | // 'u-text': 'u--text',
33 | // 'u-form': 'u--form',
34 | // 'u-input': 'u--input',
35 | // 'u-textarea': 'u--textarea'
36 | }
37 | })
38 | .end();
39 | }
40 | };
41 | ```
42 |
43 | :::
44 | ::: code-group-item HBuilderX
45 |
46 | ```js
47 | module.exports = {
48 | chainWebpack: (config) => {
49 | config.resolveLoader.alias.set(
50 | 'custom-uniapp-router-view-loader',
51 | __dirname + '/node_modules/uniapp-router-view-loader'
52 | );
53 |
54 | config.module
55 | .rule('vue')
56 | .use('custom-uniapp-router-view-loader')
57 | .loader('custom-uniapp-router-view-loader')
58 | .options({
59 | vLabel: {
60 | div: 'view',
61 | span: 'text'
62 | // 'u-text': 'u--text',
63 | // 'u-form': 'u--form',
64 | // 'u-input': 'u--input',
65 | // 'u-textarea': 'u--textarea'
66 | }
67 | })
68 | .end();
69 | }
70 | };
71 | ```
72 |
73 | :::
74 | ::::
75 |
76 | ### Vue3
77 |
78 | `vite.config.ts`文件(没有就创建)
79 |
80 | :::: code-group
81 | ::: code-group-item Vue-Cli
82 |
83 | ```ts
84 | import { defineConfig } from 'vite';
85 | import uni from '@dcloudio/vite-plugin-uni';
86 | import { vitePlugin } from 'uniapp-router-view-loader';
87 |
88 | export default defineConfig({
89 | plugins: [
90 | uni(),
91 | vitePlugin({
92 | vLabel: {
93 | div: 'view',
94 | span: 'text'
95 | // 'u-text': 'u--text',
96 | // 'u-form': 'u--form',
97 | // 'u-input': 'u--input',
98 | // 'u-textarea': 'u--textarea'
99 | }
100 | })
101 | ]
102 | });
103 | ```
104 |
105 | :::
106 | ::: code-group-item HBuilderX
107 |
108 | ```ts
109 | import { defineConfig } from 'vite';
110 | import uni from '@dcloudio/vite-plugin-uni';
111 | import { vitePlugin } from 'uniapp-router-view-loader';
112 |
113 | export default defineConfig({
114 | plugins: [
115 | uni(),
116 | vitePlugin({
117 | vLabel: {
118 | div: 'view',
119 | span: 'text'
120 | // 'u-text': 'u--text',
121 | // 'u-form': 'u--form',
122 | // 'u-input': 'u--input',
123 | // 'u-textarea': 'u--textarea'
124 | }
125 | })
126 | ]
127 | });
128 | ```
129 |
130 | :::
131 | ::::
132 |
133 | ### 配置参数
134 |
135 | | 属性名 | 说明 | 是否必填 | 默认值 |
136 | | ------ | --------------------------------------------------- | -------- | ------ |
137 | | vLabel | 虚拟标签替换,可以静态全局检索 `vue` 文件代码并进行替换 | 否 | - |
138 |
--------------------------------------------------------------------------------
/docs/md/followUpPlan.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 后续计划
4 | ---
5 |
6 | # 后续计划
7 |
8 | - 支持 `虚拟标签` ✅
9 | - 支持 `app-nvue`
10 | - 支持 `uni_modules`
11 | - 支持 `webpack hot` 和 `vite hot`
12 | - 重构 `TS`
13 | - 完善 `单元测试`
14 |
--------------------------------------------------------------------------------
/docs/md/install.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 安装
4 | description: 页面的描述
5 | ---
6 |
7 | # 安装
8 |
9 | :::: code-group
10 | ::: code-group-item NPM
11 |
12 | ```bash
13 | npm install uniapp-router-view-loader -D
14 | ```
15 |
16 | :::
17 | ::: code-group-item YARN
18 |
19 | ```bash
20 | yarn add uniapp-router-view-loader -D
21 | ```
22 |
23 | :::
24 | ::::
25 |
--------------------------------------------------------------------------------
/docs/md/introduce.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 介绍
4 | description: 页面的描述
5 | ---
6 |
7 | # 介绍
8 |
9 | ## 兼容性
10 |
11 | | vue-cli | HBuilderX |
12 | | ------- | --------- |
13 | | √ | √ |
14 |
15 | | vue2 | vue3 | nvue | ts | webpack | vite |
16 | | ---- | ---- | ---- | --- | ------- | ---- |
17 | | √ | √ | √ | √ | √ | √ |
18 |
19 | | H5 | 微信 | 支付宝 | 字节 | QQ | 百度 | 360 | 飞书 | 快手 | 华为 | 快应用 | App |
20 | | --- | ---- | ------ | ---- | --- | ---- | --- | ---- | ---- | ---- | ------ | --- |
21 | | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ | √ |
22 |
23 | ## 单元测试覆盖率
24 |
25 | | File | Statements | Branches | Functions | Lines |
26 | | -------- | ---------- | -------- | --------- | ----- |
27 | | utils.js | 100% | 95.45% | 100% | 100% |
28 |
29 | ## 开发初衷
30 |
31 | `执着` + `决心`
32 |
33 | ## 功能
34 |
35 | ### 路由模板
36 |
37 | 通过自动解析 `pages.json` 文件实现自动匹配页面文件,以此实现给每个页面都添加上对应的模版代码。
38 |
39 | ### 虚拟标签
40 |
41 | 虚拟标签替换,可以静态全局检索 `vue` 文件代码并进行替换。
42 | 例如把 `` 转换成 ``
43 |
44 |
45 | ## 描述
46 |
47 | 在 `uniapp` 项目中享受全局模版功能带来的全新开发体验,让冗余的代码无处遁形。
48 |
49 | ### 简洁至上
50 |
51 | - 只需要极少的配置,就能在 `App.vue` 文件里实现全局或非全局的数据注入
52 | - 自动解析 `pages.json` 文件中的路由配置(包括分包路由),无需手动配置路由文件
53 |
54 | ### 奇思妙想
55 |
56 | - 日有所思,夜有所梦。会在有限的框架内实现无限的可能。
57 |
58 | ### 全面兼容
59 |
60 | - 支持 `H5`、`App` 和 `其他各端小程序`
61 | - 支持 `Vue2`、`Vue3` 版本
62 | - 支持 `js`、`ts` 语言
63 | - 支持 `vue`、`nvue` 文件类型
64 | - 支持 `vue-cli`、`HBuilderX` 创建的项目
65 | - 支持 `webpack`、`vite` 构建工具
66 |
67 | ### 微入侵
68 |
69 | 可以以最小粒度实现对原有项目的改造。
70 |
71 | ### 低成本
72 |
73 | 与 `vue-route` 插件在 `App.vue` 文件中处理 `template` 标签功能类似。
74 |
75 | ### 高效率
76 |
77 | 短短几行的配置,就再也不用在写入相同的代码。
78 |
--------------------------------------------------------------------------------
/docs/md/precautions.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 注意事项
4 | description: 页面的描述
5 | ---
6 |
7 | # 注意事项
8 |
9 | ### App.vue 文件中的 template 标签是什么
10 |
11 | 是由插件额外扩展的功能,非官方提供的。若不使用此插件则请移除该标签,否则可能会对你的项目造成异常问题。
12 |
13 | ### 在 App.vue 中 template 标签里的内容修改后,页面内容没更新
14 |
15 | 插件是在构建阶段中注入数据的,遇到这种情况重新编译即可。
16 |
17 | ### 注入的代码会对项目的源代码进行修改吗
18 |
19 | 不会,插件会在构建阶段对项目的源代码进行解析并修改,并不会影响项目文件代码。
20 |
21 | ### 如何控制注入的组件或标签
22 |
23 | - 使用 `ref` 属性
24 | - 通过 `mixin` 进行全局数据混入
25 | - 使用 `v-if` + `mixin` 控制不同页面的组件显示和隐藏
26 |
--------------------------------------------------------------------------------
/docs/md/use.md:
--------------------------------------------------------------------------------
1 | ---
2 | lang: zh-CN
3 | title: 使用
4 | description: 页面的描述
5 | ---
6 |
7 | # 使用
8 |
9 | ::: tip
10 | 避免因为插件的处理规则对你产生困扰,请查看
11 | [注意事项](./precautions.md)
12 | :::
13 |
14 | ## 基本
15 |
16 | ### 注入
17 |
18 | :::: code-group
19 | ::: code-group-item App.vue
20 |
21 | @[code vue{1-7}](../code/use/1/App.vue)
22 |
23 | :::
24 | ::::
25 |
26 | ### 使用
27 |
28 | :::: code-group
29 | ::: code-group-item 运行前 pageA.vue 项目文件代码
30 |
31 | @[code vue](../code/use/1/beforePageA.vue)
32 |
33 | :::
34 | ::: code-group-item 插件修改后的代码
35 |
36 | @[code vue{3-4,6-7}](../code/use/1/afterPageA.vue)
37 |
38 | :::
39 | ::::
40 |
41 | ## 使用组件
42 |
43 | 支持使用 `easycom` 和 `Vue.component` 注册的全局组件
44 |
45 | ### Vue.component
46 |
47 | :::: code-group
48 | ::: code-group-item main.js
49 |
50 | @[code js{4}](../code/use/2/main.js)
51 |
52 | :::
53 | ::: code-group-item customCopyright.vue
54 |
55 | @[code vue](../code/use/2/customCopyright.vue)
56 |
57 | :::
58 | ::: code-group-item App.vue
59 |
60 | @[code vue{1-4}](../code/use/2/App.vue)
61 |
62 | :::
63 | ::::
64 |
65 | ### easycom
66 |
67 | 使用 [uView 2](https://www.uviewui.com) 框架为例
68 |
69 | :::: code-group
70 | ::: code-group-item pages.json
71 |
72 | @[code json](../code/use/3/pages.json)
73 |
74 | :::
75 | ::: code-group-item uni.scss
76 |
77 | @[code scss](../code/use/3/uni.scss)
78 |
79 | :::
80 | ::: code-group-item main.js
81 |
82 | @[code js](../code/use/3/main.js)
83 |
84 | :::
85 | ::: code-group-item App.vue
86 |
87 | @[code vue{1-4}](../code/use/3/App.vue)
88 |
89 | :::
90 | ::: code-group-item pageA.vue
91 |
92 | @[code vue{11-14}](../code/use/3/pageA.vue)
93 |
94 | :::
95 | ::::
96 |
97 | ## 设置组件属性
98 |
99 | 使用 `Vue.mixin` 注册文件进行混入全局默认属性
100 |
101 | 使用 [uView 2](https://www.uviewui.com) 框架为例
102 |
103 | :::: code-group
104 | ::: code-group-item mixin.js
105 | @[code js{4}](../code/use/4/mixin.js)
106 | :::
107 |
108 | ::: code-group-item main.js
109 | @[code js{4}](../code/use/4/main.js)
110 | :::
111 |
112 | ::: code-group-item App.vue
113 | @[code vue{1-4}](../code/use/4/app.vue)
114 | :::
115 |
116 | ::: code-group-item pageA.vue
117 | @[code vue{3}](../code/use/4/pageA.vue)
118 | :::
119 |
120 | ::: code-group-item pageB.vue
121 | @[code vue{3,12}](../code/use/4/pageB.vue)
122 | :::
123 | ::::
124 |
125 | ## 获取组件实例
126 |
127 | 给组件添加 `ref` 属性,就在页面渲染后的任意位置获取当前组件实例
128 |
129 | 使用 [uView 2](https://www.uviewui.com) 框架为例
130 |
131 | ### 页面级
132 |
133 | :::: code-group
134 | ::: code-group-item App.vue
135 | @[code vue{1-4}](../code/use/5-1/App.vue)
136 | :::
137 |
138 | ::: code-group-item pageA.vue
139 | @[code vue{11-15}](../code/use/5-1/pageA.vue)
140 | :::
141 | ::::
142 |
143 | ### 组件级
144 |
145 |
166 |
167 | #### vue2
168 |
169 | 在组件文件里使用 `this.$root.$refs` ,可以直接访问页面文件里的 `$refs`
170 |
171 | :::: code-group
172 | ::: code-group-item App.vue
173 | @[code vue{1-4}](../code/use/5-1/App.vue)
174 | :::
175 |
176 | ::: code-group-item pageB.vue
177 | @[code vue{8,12}](../code/use/5-1/pageB.vue)
178 | :::
179 |
180 | ::: code-group-item customSubmit.vue
181 | @[code vue{11-14}](../code/use/5-1/customSubmit.vue)
182 | :::
183 | ::::
184 |
185 | #### vue3
186 |
187 | 使用工具内部封装的 `pageProvide` 和 `componentInject` 工具,实现跨组件调用
188 |
189 | :::: code-group
190 | ::: code-group-item App.vue
191 | @[code vue{1-4,6}](../code/use/7/App.vue)
192 | :::
193 |
194 | ::: code-group-item toast.vue
195 | @[code vue](../code/use/7/toast.vue)
196 | :::
197 |
198 | ::: code-group-item main.ts
199 | @[code ts{3,8}](../code/use/7/main.ts)
200 | :::
201 |
202 | ::: code-group-item pageA.vue
203 | @[code vue{8,12,26}](../code/use/7/pageA.vue)
204 | :::
205 |
206 | ::: code-group-item customSubmit.vue
207 | @[code vue{7,10,14,17}](../code/use/7/customSubmit.vue)
208 | :::
209 | ::::
210 |
211 | ## 非全局注入
212 |
213 | 使用 `Vue.mixin` 注册文件进行混入全局默认属性
214 |
215 | 使用 [uView 2](https://www.uviewui.com) 框架为例
216 |
217 | :::: code-group
218 | ::: code-group-item mixin.js
219 | @[code js](../code/use/6/mixin.js)
220 | :::
221 |
222 | ::: code-group-item main.js
223 | @[code js{4}](../code/use/6/main.js)
224 | :::
225 |
226 | ::: code-group-item App.vue
227 | @[code vue{1-7}](../code/use/6/App.vue)
228 | :::
229 |
230 | ::: code-group-item pageA.vue
231 | @[code vue{9-15}](../code/use/6/pageA.vue)
232 | :::
233 |
234 | ::: code-group-item pageB.vue
235 | @[code vue{9-15}](../code/use/6/pageB.vue)
236 | :::
237 | ::::
238 |
239 | ## 虚拟标签
240 |
241 | 使用 `Vue.mixin` 注册文件进行混入全局默认属性
242 |
243 | 使用 [uView 2](https://www.uviewui.com) 框架为例
244 |
245 | :::: code-group
246 | ::: code-group-item vite.config.js
247 | @[code js](../code/use/8/vite.config.js)
248 | :::
249 |
250 | ::: code-group-item App.vue
251 | @[code vue](../code/use/8/App.vue)
252 | :::
253 |
254 | ::: code-group-item pageA.vue
255 | @[code vue](../code/use/8/pageA.vue)
256 | :::
257 | ::::
258 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | unpackage/
4 | dist/
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 |
15 | # Editor directories and files
16 | .project
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw*
24 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/README.md:
--------------------------------------------------------------------------------
1 | ## AST 解析
2 |
3 | /node_modules/@dcloudio/uni-template-compiler/lib/index.js:101
4 | /node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-template-compiler/build.js:2423
5 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/babel.config.js:
--------------------------------------------------------------------------------
1 | const plugins = []
2 |
3 | if (process.env.UNI_OPT_TREESHAKINGNG) {
4 | plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
5 | }
6 |
7 | if (
8 | (
9 | process.env.UNI_PLATFORM === 'app-plus' &&
10 | process.env.UNI_USING_V8
11 | ) ||
12 | (
13 | process.env.UNI_PLATFORM === 'h5' &&
14 | process.env.UNI_H5_BROWSER === 'builtin'
15 | )
16 | ) {
17 | const path = require('path')
18 |
19 | const isWin = /^win/.test(process.platform)
20 |
21 | const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
22 |
23 | const input = normalizePath(process.env.UNI_INPUT_DIR)
24 | try {
25 | plugins.push([
26 | require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
27 | {
28 | file (file) {
29 | file = normalizePath(file)
30 | if (file.indexOf(input) === 0) {
31 | return path.relative(input, file)
32 | }
33 | return false
34 | }
35 | }
36 | ])
37 | } catch (e) {}
38 | }
39 |
40 | process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
41 | process.UNI_LIBRARIES.forEach(libraryName => {
42 | plugins.push([
43 | 'import',
44 | {
45 | 'libraryName': libraryName,
46 | 'customName': (name) => {
47 | return `${libraryName}/lib/${name}/${name}`
48 | }
49 | }
50 | ])
51 | })
52 | module.exports = {
53 | presets: [
54 | [
55 | '@vue/app',
56 | {
57 | modules: 'commonjs',
58 | useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
59 | }
60 | ]
61 | ],
62 | plugins
63 | }
64 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": false,
4 | }
5 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uniapp-vue2",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "npm run dev:h5",
7 | "build": "npm run build:h5",
8 | "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
9 | "build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
10 | "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
11 | "build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
12 | "build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
13 | "build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
14 | "build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
15 | "build:mp-lark": "cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build",
16 | "build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
17 | "build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
18 | "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
19 | "build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
20 | "build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
21 | "build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
22 | "build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
23 | "dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
24 | "dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
25 | "dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
26 | "dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
27 | "dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
28 | "dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
29 | "dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
30 | "dev:mp-lark": "cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch",
31 | "dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
32 | "dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
33 | "dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
34 | "dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
35 | "dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch",
36 | "dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
37 | "dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
38 | "info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
39 | "serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
40 | "test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
41 | "test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
42 | "test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
43 | "test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
44 | "test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
45 | },
46 | "dependencies": {
47 | "@dcloudio/uni-app-plus": "^2.0.1-33520211229002",
48 | "@dcloudio/uni-h5": "^2.0.1-33520211229002",
49 | "@dcloudio/uni-helper-json": "*",
50 | "@dcloudio/uni-i18n": "^2.0.1-33520211229002",
51 | "@dcloudio/uni-mp-360": "^2.0.1-33520211229002",
52 | "@dcloudio/uni-mp-alipay": "^2.0.1-33520211229002",
53 | "@dcloudio/uni-mp-baidu": "^2.0.1-33520211229002",
54 | "@dcloudio/uni-mp-kuaishou": "^2.0.1-33520211229002",
55 | "@dcloudio/uni-mp-lark": "^2.0.1-33520211229002",
56 | "@dcloudio/uni-mp-qq": "^2.0.1-33520211229002",
57 | "@dcloudio/uni-mp-toutiao": "^2.0.1-33520211229002",
58 | "@dcloudio/uni-mp-vue": "^2.0.1-33520211229002",
59 | "@dcloudio/uni-mp-weixin": "^2.0.1-33520211229002",
60 | "@dcloudio/uni-quickapp-native": "^2.0.1-33520211229002",
61 | "@dcloudio/uni-quickapp-webview": "^2.0.1-33520211229002",
62 | "@dcloudio/uni-stat": "^2.0.1-33520211229002",
63 | "@vue/shared": "^3.0.0",
64 | "core-js": "^3.6.5",
65 | "flyio": "^0.6.2",
66 | "node-sass": "^7.0.1",
67 | "regenerator-runtime": "^0.12.1",
68 | "sass": "^1.49.0",
69 | "sass-loader": "^10.1.1",
70 | "uview-ui": "^2.0.23",
71 | "vue": "^2.6.11",
72 | "vuex": "^3.2.0"
73 | },
74 | "devDependencies": {
75 | "@babel/runtime": "~7.12.0",
76 | "@dcloudio/types": "*",
77 | "@dcloudio/uni-automator": "^2.0.1-33520211229002",
78 | "@dcloudio/uni-cli-i18n": "^2.0.1-33520211229002",
79 | "@dcloudio/uni-cli-shared": "^2.0.1-33520211229002",
80 | "@dcloudio/uni-migration": "^2.0.1-33520211229002",
81 | "@dcloudio/uni-template-compiler": "^2.0.1-33520211229002",
82 | "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.1-33520211229002",
83 | "@dcloudio/vue-cli-plugin-uni": "^2.0.1-33520211229002",
84 | "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.1-33520211229002",
85 | "@dcloudio/webpack-uni-mp-loader": "^2.0.1-33520211229002",
86 | "@dcloudio/webpack-uni-pages-loader": "^2.0.1-33520211229002",
87 | "@vue/cli-plugin-babel": "~4.5.0",
88 | "@vue/cli-service": "~4.5.0",
89 | "babel-plugin-import": "^1.11.0",
90 | "cross-env": "^7.0.2",
91 | "jest": "^25.4.0",
92 | "mini-types": "*",
93 | "miniprogram-api-typings": "*",
94 | "postcss-comment": "^2.0.0",
95 | "uniapp-router-view-loader": "1.1.2",
96 | "vue-template-compiler": "^2.6.11"
97 | },
98 | "browserslist": [
99 | "Android >= 4.4",
100 | "ios >= 9"
101 | ],
102 | "uni-app": {
103 | "scripts": {}
104 | }
105 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/postcss.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | module.exports = {
3 | parser: require('postcss-comment'),
4 | plugins: [
5 | require('postcss-import')({
6 | resolve (id, basedir, importOptions) {
7 | if (id.startsWith('~@/')) {
8 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
9 | } else if (id.startsWith('@/')) {
10 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
11 | } else if (id.startsWith('/') && !id.startsWith('//')) {
12 | return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
13 | }
14 | return id
15 | }
16 | }),
17 | require('autoprefixer')({
18 | remove: process.env.UNI_PLATFORM !== 'h5'
19 | }),
20 | require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
17 |
18 |
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | is div to view
4 | is span to text
5 | My Header1
6 | My Header2
7 |
8 | My Footer1
9 | My Footer2
10 |
11 |
12 |
13 |
14 |
18 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/components/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 | import uView from "uview-ui";
4 | // import './plugin/hack'
5 |
6 | Vue.config.productionTip = false
7 | Vue.use(uView)
8 |
9 | App.mpType = 'app'
10 |
11 | const app = new Vue({
12 | ...App
13 | })
14 | app.$mount()
15 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "appid": "",
4 | "description": "",
5 | "versionName": "1.0.0",
6 | "versionCode": "100",
7 | "transformPx": false,
8 | "app-plus": { /* 5+App特有相关 */
9 | "usingComponents": true,
10 | "splashscreen": {
11 | "alwaysShowBeforeRender": true,
12 | "waiting": true,
13 | "autoclose": true,
14 | "delay": 0
15 | },
16 | "modules": { /* 模块配置 */
17 |
18 | },
19 | "distribute": { /* 应用发布信息 */
20 | "android": { /* android打包配置 */
21 | "permissions": ["",
22 | "",
23 | "",
24 | "",
25 | "",
26 | "",
27 | "",
28 | "",
29 | "",
30 | "",
31 | "",
32 | "",
33 | "",
34 | "",
35 | "",
36 | "",
37 | "",
38 | "",
39 | "",
40 | "",
41 | "",
42 | ""
43 | ]
44 | },
45 | "ios": { /* ios打包配置 */
46 |
47 | },
48 | "sdkConfigs": { /* SDK配置 */
49 |
50 | }
51 | }
52 | },
53 | "quickapp": { /* 快应用特有相关 */
54 |
55 | },
56 | "mp-weixin": { /* 微信小程序特有相关 */
57 | "appid": "",
58 | "setting": {
59 | "urlCheck": false
60 | },
61 | "usingComponents": true
62 | },
63 | "mp-alipay" : {
64 | "usingComponents" : true
65 | },
66 | "mp-baidu" : {
67 | "usingComponents" : true
68 | },
69 | "mp-toutiao" : {
70 | "usingComponents" : true
71 | },
72 | "mp-qq" : {
73 | "usingComponents" : true
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
4 | },
5 |
6 | "pages": [
7 | //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
8 | {
9 | "path": "pages/index/index",
10 | "style": {
11 | "navigationBarTitleText": "uni-app"
12 | }
13 | }
14 | ],
15 | "globalStyle": {
16 | "navigationBarTextStyle": "black",
17 | "navigationBarTitleText": "uni-app",
18 | "navigationBarBackgroundColor": "#F8F8F8",
19 | "backgroundColor": "#F8F8F8"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/pages/index/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 首页
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/plugin/hack.h5.js:
--------------------------------------------------------------------------------
1 | export default function ({ h, originRender, CLASS_NAME }) {
2 | let _h = this._self._c || h;
3 |
4 | function _render(tagName, render, props) {
5 | console.log(tagName, render, props)
6 |
7 | !render.class.includes(CLASS_NAME) && render.class.push(CLASS_NAME)
8 | return _h(tagName, render, props)
9 | }
10 |
11 |
12 | this._self._c = _render
13 |
14 | return originRender.call(this, h)
15 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/plugin/hack.js:
--------------------------------------------------------------------------------
1 | import Demo from '../components/demo.vue'
2 | import HackH5 from './hack.h5';
3 | import HackWx from './hack.wx'
4 |
5 | const CLASS_NAME = 'WxStyles'
6 | const originRender = Demo.render;
7 |
8 | Demo.render = function (h) {
9 | const opts = { h, originRender, CLASS_NAME };
10 |
11 | // #ifdef H5
12 | return HackH5.call(this, opts)
13 | // #endif
14 |
15 | // #ifdef MP-WEIXIN
16 | return HackWx.call(this, opts)
17 | // #endif
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/plugin/hack.wx.js:
--------------------------------------------------------------------------------
1 | export default function ({ h, originRender, CLASS_NAME }) {
2 | let _h = this._self._c || h;
3 |
4 | function _render(tagName, render, props) {
5 | console.log(tagName, render, props)
6 |
7 | !render.class.includes(CLASS_NAME) && render.class.push(CLASS_NAME)
8 | return _h(tagName, render, props)
9 | }
10 |
11 |
12 | this._self._c = _render
13 |
14 | console.log('render')
15 |
16 | return originRender.call(this, h)
17 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue2-cli-loader/src/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/src/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "types": [
4 | "@dcloudio/types",
5 | "miniprogram-api-typings",
6 | "mini-types"
7 | ]
8 | }
9 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-cli-loader/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | publicPath: './',
3 |
4 | transpileDependencies: ['uview-ui'],
5 |
6 | css: {
7 | loaderOptions: {
8 | scss: {
9 | prependData: `@import "~@/uni.scss";`
10 | }
11 | }
12 | },
13 |
14 | devServer: {
15 | open: false
16 | },
17 |
18 | chainWebpack: (config) => {
19 | // console.log(config.module)
20 | // config.module
21 | // .rule('vue')
22 | // .use('vue-loader')[]
23 | // .tap((options) => {
24 | // // console.log(options.compiler.compile.toString())
25 | // // console.log(options.compiler.parseComponent.toString())
26 | // // console.log(options.compiler.compileToFunctions.toString())
27 | // // console.log(options.compiler.generateCodeFrame.toString())
28 | // // console.log(options.compilerOptions.modules[1].preTransformNode.toString())
29 | // options.compiler = require('./babel/index')(options.compiler)
30 | // return options
31 | // })
32 |
33 | config.resolveLoader.alias.set(
34 | 'custom-uniapp-router-view-loader',
35 | 'uniapp-router-view-loader'
36 | );
37 |
38 | config.module
39 | .rule('vue')
40 | .use('custom-uniapp-router-view-loader')
41 | .loader('custom-uniapp-router-view-loader')
42 | .options({
43 | vLabel: {
44 | div: 'view',
45 | span: 'text'
46 | // 'u-text': 'u--text',
47 | // 'u-form': 'u--form',
48 | // 'u-input': 'u--input',
49 | // 'u-textarea': 'u--textarea'
50 | }
51 | })
52 | .end();
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/.hbuilderx/launch.json:
--------------------------------------------------------------------------------
1 | { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
2 | // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
3 | "version": "0.0",
4 | "configurations": [{
5 | "default" :
6 | {
7 | "launchtype" : "local"
8 | },
9 | "mp-weixin" :
10 | {
11 | "launchtype" : "local"
12 | },
13 | "type" : "uniCloud"
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | is div to view
4 | is span to text
5 | My Header1
6 | My Header2
7 |
8 | My Footer1
9 | My Footer2
10 |
11 |
12 |
15 |
16 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/components/submit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/main.js:
--------------------------------------------------------------------------------
1 | import App from './App'
2 | import uView from 'uview-ui'
3 | // import Mixin from './mixins/index'
4 | import Vue from 'vue'
5 |
6 | console.log(Vue.Mixin)
7 | // Vue.options._base.mixin(Mixin)
8 | // Vue.Mixin(Mixin)
9 |
10 | Vue.use(uView);
11 | Vue.config.productionTip = false
12 | App.mpType = 'app'
13 |
14 | const app = new Vue({
15 | ...App
16 | })
17 | app.$mount()
18 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "vnue",
3 | "appid" : "__UNI__54EC230",
4 | "description" : "",
5 | "versionName" : "1.0.0",
6 | "versionCode" : "100",
7 | "transformPx" : false,
8 | /* 5+App特有相关 */
9 | "app-plus" : {
10 | "usingComponents" : true,
11 | "nvueStyleCompiler" : "uni-app",
12 | "compilerVersion" : 3,
13 | "splashscreen" : {
14 | "alwaysShowBeforeRender" : true,
15 | "waiting" : true,
16 | "autoclose" : true,
17 | "delay" : 0
18 | },
19 | /* 模块配置 */
20 | "modules" : {},
21 | /* 应用发布信息 */
22 | "distribute" : {
23 | /* android打包配置 */
24 | "android" : {
25 | "permissions" : [
26 | "",
27 | "",
28 | "",
29 | "",
30 | "",
31 | "",
32 | "",
33 | "",
34 | "",
35 | "",
36 | "",
37 | "",
38 | "",
39 | "",
40 | ""
41 | ]
42 | },
43 | /* ios打包配置 */
44 | "ios" : {},
45 | /* SDK配置 */
46 | "sdkConfigs" : {}
47 | },
48 | "nvueLaunchMode" : "",
49 | "renderer" : "native"
50 | },
51 | /* 快应用特有相关 */
52 | "quickapp" : {},
53 | /* 小程序特有相关 */
54 | "mp-weixin" : {
55 | "appid" : "",
56 | "setting" : {
57 | "urlCheck" : false
58 | },
59 | "usingComponents" : true
60 | },
61 | "mp-alipay" : {
62 | "usingComponents" : true
63 | },
64 | "mp-baidu" : {
65 | "usingComponents" : true
66 | },
67 | "mp-toutiao" : {
68 | "usingComponents" : true
69 | },
70 | "uniStatistics" : {
71 | "enable" : false
72 | },
73 | "vueVersion" : "2"
74 | }
75 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/mixins/index.js:
--------------------------------------------------------------------------------
1 | export default {
2 | data() {
3 | return {
4 | show: false
5 | }
6 | },
7 |
8 | created() {
9 | console.log("this is mixin data")
10 | }
11 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nvue",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "main.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "uview-ui": "^2.0.28"
14 | },
15 | "devDependencies": {
16 | "uniapp-router-view-loader": "1.1.2"
17 | }
18 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
4 | },
5 | "pages": [
6 | //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
7 | {
8 | "path": "pages/index/index"
9 | }
10 | ],
11 | "globalStyle": {
12 | "navigationBarTextStyle": "black",
13 | "navigationBarTitleText": "uniapp-vue2-hbuilder-nvue-loader",
14 | "navigationBarBackgroundColor": "#F8F8F8",
15 | "backgroundColor": "#F8F8F8"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/pages/index/index.nvue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue2-hbuilder-nvue-loader/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilder-nvue-loader/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // ...
3 |
4 | chainWebpack: (config) => {
5 | // === 使用 hbuilder 工具创建的项目,使用这行 ===
6 | config.resolveLoader.alias.set(
7 | 'custom-uniapp-router-view-loader',
8 | __dirname + '/node_modules/uniapp-router-view-loader'
9 | );
10 | // === 使用 hbuilder 工具创建的项目,使用这行 ===
11 |
12 | config.module
13 | .rule('vue')
14 | .use('custom-uniapp-router-view-loader')
15 | .loader('custom-uniapp-router-view-loader')
16 | .options({
17 | vLabel: {
18 | div: 'view',
19 | span: 'text'
20 | // 'u-text': 'u--text',
21 | // 'u-form': 'u--form',
22 | // 'u-input': 'u--input',
23 | // 'u-textarea': 'u--textarea'
24 | }
25 | })
26 | .end();
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/.hbuilderx/launch.json:
--------------------------------------------------------------------------------
1 | { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
2 | // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
3 | "version": "0.0",
4 | "configurations": [{
5 | "app-plus" :
6 | {
7 | "launchtype" : "local"
8 | },
9 | "default" :
10 | {
11 | "launchtype" : "local"
12 | },
13 | "mp-360" :
14 | {
15 | "launchtype" : "local"
16 | },
17 | "mp-alipay" :
18 | {
19 | "launchtype" : "local"
20 | },
21 | "mp-baidu" :
22 | {
23 | "launchtype" : "local"
24 | },
25 | "mp-feishu" :
26 | {
27 | "launchtype" : "local"
28 | },
29 | "mp-kuaishou" :
30 | {
31 | "launchtype" : "local"
32 | },
33 | "mp-toutiao" :
34 | {
35 | "launchtype" : "local"
36 | },
37 | "mp-weixin" :
38 | {
39 | "launchtype" : "local"
40 | },
41 | "quickapp-union" :
42 | {
43 | "launchtype" : "local"
44 | },
45 | "quickapp-webview-huawei" :
46 | {
47 | "launchtype" : "local"
48 | },
49 | "type" : "uniCloud"
50 | }
51 | ]
52 | }
53 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | is div to view
4 | is span to text
5 | My Header1
6 | My Header2
7 |
8 | My Footer1
9 | My Footer2
10 |
11 |
12 |
15 |
16 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/components/submit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/global.scss:
--------------------------------------------------------------------------------
1 | .u-transition {
2 | z-index: 9;
3 | }
4 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/main.js:
--------------------------------------------------------------------------------
1 | import App from './App'
2 | import Vue from 'vue'
3 | import uView from 'uview-ui'
4 |
5 | Vue.config.productionTip = false
6 | App.mpType = 'app'
7 |
8 | const app = new Vue({
9 | ...App
10 | })
11 | app.$mount()
12 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "uniapp-vue2-hbuilderx-loader",
3 | "appid" : "__UNI__D374408",
4 | "description" : "",
5 | "versionName" : "1.0.0",
6 | "versionCode" : "100",
7 | "transformPx" : false,
8 | /* 5+App特有相关 */
9 | "app-plus" : {
10 | "usingComponents" : true,
11 | "nvueStyleCompiler" : "uni-app",
12 | "compilerVersion" : 3,
13 | "splashscreen" : {
14 | "alwaysShowBeforeRender" : true,
15 | "waiting" : true,
16 | "autoclose" : true,
17 | "delay" : 0
18 | },
19 | /* 模块配置 */
20 | "modules" : {},
21 | /* 应用发布信息 */
22 | "distribute" : {
23 | /* android打包配置 */
24 | "android" : {
25 | "permissions" : [
26 | "",
27 | "",
28 | "",
29 | "",
30 | "",
31 | "",
32 | "",
33 | "",
34 | "",
35 | "",
36 | "",
37 | "",
38 | "",
39 | "",
40 | ""
41 | ]
42 | },
43 | /* ios打包配置 */
44 | "ios" : {},
45 | /* SDK配置 */
46 | "sdkConfigs" : {}
47 | },
48 | "nvueLaunchMode" : ""
49 | },
50 | /* 快应用特有相关 */
51 | "quickapp" : {},
52 | /* 小程序特有相关 */
53 | "mp-weixin" : {
54 | "appid" : "",
55 | "setting" : {
56 | "urlCheck" : false
57 | },
58 | "usingComponents" : true
59 | },
60 | "mp-alipay" : {
61 | "usingComponents" : true
62 | },
63 | "mp-baidu" : {
64 | "usingComponents" : true
65 | },
66 | "mp-toutiao" : {
67 | "usingComponents" : true
68 | },
69 | "uniStatistics" : {
70 | "enable" : false
71 | },
72 | "vueVersion" : "2",
73 | "h5" : {
74 | "optimization" : {
75 | "treeShaking" : {
76 | "enable" : true
77 | }
78 | }
79 | },
80 | "quickapp-webview" : {
81 | "icon" : "static/logo.png",
82 | "package" : "com.pocky.vue2HbuilderxLoader",
83 | "versionName" : "1.0",
84 | "versionCode" : 1
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uniapp-vue2-hbuilderx-loader",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "main.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "uview-ui": "^2.0.27"
14 | },
15 | "devDependencies": {
16 | "uniapp-router-view-loader": "1.1.2"
17 | }
18 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "autoscan": true,
4 | "custom": {
5 | // uview-ui
6 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
7 | }
8 | },
9 | "pages": [
10 | //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
11 | {
12 | "path": "pages/index/index"
13 | },
14 | {
15 | "path": "pages/index/other"
16 | }
17 | ],
18 | "globalStyle": {
19 | "navigationBarTextStyle": "black",
20 | "navigationBarTitleText": "",
21 | "navigationBarBackgroundColor": "#F8F8F8",
22 | "backgroundColor": "#f2f4f5",
23 | "navigationStyle": "custom",
24 | "transparentTitle": "always"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/pages/index/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/pages/index/other.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue2-hbuilderx-loader/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/examples/uniapp-vue2-hbuilderx-loader/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | chainWebpack: (config) => {
3 | config.resolveLoader.alias.set(
4 | 'custom-uniapp-router-view-loader',
5 | __dirname + '/node_modules/uniapp-router-view-loader'
6 | );
7 |
8 | config.module
9 | .rule('vue')
10 | .use('custom-uniapp-router-view-loader')
11 | .loader('custom-uniapp-router-view-loader')
12 | .options({
13 | vLabel: {
14 | div: 'view',
15 | span: 'text'
16 | // 'u-text': 'u--text',
17 | // 'u-form': 'u--form',
18 | // 'u-input': 'u--input',
19 | // 'u-textarea': 'u--textarea'
20 | }
21 | })
22 | .end();
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | .idea/
3 | node_modules/
4 |
5 | /dist
6 | /.idea
7 | /node_modules
8 | .DS_Store
9 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "i18n-ally.localesPaths": []
3 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue3-cli-vite-ts-plugin/README.md
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uni-preset-vue",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "dev:app": "uni -p app",
6 | "dev:custom": "uni -p",
7 | "dev:h5": "uni",
8 | "dev:h5:ssr": "uni --ssr",
9 | "dev:mp-alipay": "uni -p mp-alipay",
10 | "dev:mp-baidu": "uni -p mp-baidu",
11 | "dev:mp-kuaishou": "uni -p mp-kuaishou",
12 | "dev:mp-lark": "uni -p mp-lark",
13 | "dev:mp-qq": "uni -p mp-qq",
14 | "dev:mp-toutiao": "uni -p mp-toutiao",
15 | "dev:mp-weixin": "uni -p mp-weixin",
16 | "dev:quickapp-webview": "uni -p quickapp-webview",
17 | "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
18 | "dev:quickapp-webview-union": "uni -p quickapp-webview-union",
19 | "build:app": "uni build -p app",
20 | "build:custom": "uni build -p",
21 | "build:h5": "uni build",
22 | "build:h5:ssr": "uni build --ssr",
23 | "build:mp-alipay": "uni build -p mp-alipay",
24 | "build:mp-baidu": "uni build -p mp-baidu",
25 | "build:mp-kuaishou": "uni build -p mp-kuaishou",
26 | "build:mp-lark": "uni build -p mp-lark",
27 | "build:mp-qq": "uni build -p mp-qq",
28 | "build:mp-toutiao": "uni build -p mp-toutiao",
29 | "build:mp-weixin": "uni build -p mp-weixin",
30 | "build:quickapp-webview": "uni build -p quickapp-webview",
31 | "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
32 | "build:quickapp-webview-union": "uni build -p quickapp-webview-union"
33 | },
34 | "dependencies": {
35 | "@dcloudio/uni-app": "^3.0.0-alpha-3030820220114004",
36 | "@dcloudio/uni-app-plus": "^3.0.0-alpha-3030820220114004",
37 | "@dcloudio/uni-components": "^3.0.0-alpha-3030820220114004",
38 | "@dcloudio/uni-h5": "^3.0.0-alpha-3030820220114004",
39 | "@dcloudio/uni-mp-alipay": "^3.0.0-alpha-3030820220114004",
40 | "@dcloudio/uni-mp-baidu": "^3.0.0-alpha-3030820220114004",
41 | "@dcloudio/uni-mp-kuaishou": "^3.0.0-alpha-3030820220114004",
42 | "@dcloudio/uni-mp-lark": "^3.0.0-alpha-3030820220114004",
43 | "@dcloudio/uni-mp-qq": "^3.0.0-alpha-3030820220114004",
44 | "@dcloudio/uni-mp-toutiao": "^3.0.0-alpha-3030820220114004",
45 | "@dcloudio/uni-mp-weixin": "^3.0.0-alpha-3030820220114004",
46 | "@dcloudio/uni-quickapp-webview": "^3.0.0-alpha-3030820220114004",
47 | "@dcloudio/uni-ui": "^1.4.11",
48 | "node-sass": "7",
49 | "sass": "^1.49.0",
50 | "sass-loader": "10",
51 | "uview-ui": "^2.0.24",
52 | "vue": "^3.2.27",
53 | "vue-i18n": "^9.1.9",
54 | "vuex": "^4.0.2"
55 | },
56 | "devDependencies": {
57 | "@dcloudio/types": "^2.5.16",
58 | "@dcloudio/uni-automator": "^3.0.0-alpha-3030820220114004",
59 | "@dcloudio/uni-cli-shared": "^3.0.0-alpha-3030820220114004",
60 | "@dcloudio/vite-plugin-uni": "^3.0.0-alpha-3030820220114004",
61 | "@vitejs/plugin-vue": "^2.2.0",
62 | "autoprefixer": "^10.4.2",
63 | "typescript": "^4.5.2",
64 | "uniapp-router-view-loader": "1.1.2",
65 | "vite": "^2.7.13"
66 | }
67 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/plugin.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * vite
4 | * @returns
5 | */
6 | export function vitePlugin(opts) {
7 | console.log('vitePlugin', opts)
8 | return {
9 | name: 'asd',
10 |
11 | // 插件排序(执行顺序)
12 | enforce: 'pre',
13 |
14 | config(config) {
15 | console.log('config', config);
16 | return {}
17 | },
18 |
19 | transform(code, path) {
20 |
21 | if (path === '/Users/pocky/code/demo/uniapp-ts-vue3-vite-plugin/src/App.vue') {
22 | console.log(code);
23 | return {
24 | code: `
27 |
28 |
29 | `
30 | }
31 | }
32 |
33 | if (path === '/Users/pocky/code/demo/uniapp-ts-vue3-vite-plugin/src/pages/home/index.vue') {
34 | return {
35 | code: `
36 |
37 | AAA
38 |
39 |
40 |
41 |
42 |
58 |
59 |
60 | `
61 | }
62 | }
63 |
64 | return { code }
65 | },
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/postcss.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | uniPostcssPlugin
3 | } = require('@dcloudio/uni-cli-shared')
4 |
5 | module.exports = {
6 | plugins: [
7 | uniPostcssPlugin(),
8 | require('autoprefixer')()
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "bundle": false,
8 | "userConfirmedBundleSwitch": false,
9 | "urlCheck": true,
10 | "scopeDataCheck": false,
11 | "coverView": true,
12 | "es6": true,
13 | "postcss": true,
14 | "compileHotReLoad": false,
15 | "lazyloadPlaceholderEnable": false,
16 | "preloadBackgroundData": false,
17 | "minified": true,
18 | "autoAudits": false,
19 | "newFeature": false,
20 | "uglifyFileName": false,
21 | "uploadWithSourceMap": true,
22 | "useIsolateContext": true,
23 | "nodeModules": false,
24 | "enhance": true,
25 | "useMultiFrameRuntime": true,
26 | "useApiHook": true,
27 | "useApiHostProcess": true,
28 | "showShadowRootInWxmlPanel": true,
29 | "packNpmManually": false,
30 | "enableEngineNative": false,
31 | "packNpmRelationList": [],
32 | "minifyWXSS": true,
33 | "showES6CompileOption": false,
34 | "minifyWXML": true
35 | },
36 | "compileType": "miniprogram",
37 | "libVersion": "2.22.0",
38 | "appid": "wx3ab7ee3140af98c8",
39 | "projectname": "miniprogram-1",
40 | "debugOptions": {
41 | "hidedInDevtools": []
42 | },
43 | "scripts": {},
44 | "staticServerOptions": {
45 | "baseURL": "",
46 | "servePath": ""
47 | },
48 | "isGameTourist": false,
49 | "condition": {
50 | "search": {
51 | "list": []
52 | },
53 | "conversation": {
54 | "list": []
55 | },
56 | "game": {
57 | "list": []
58 | },
59 | "plugin": {
60 | "list": []
61 | },
62 | "gamePlugin": {
63 | "list": []
64 | },
65 | "miniprogram": {
66 | "list": []
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | is div to view
4 | is span to text
5 | My Header1
6 | My Header2
7 |
8 | My Footer1
9 | My Footer2
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/components/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 提交成功
4 |
5 |
6 |
7 |
26 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/components/demo.vue:
--------------------------------------------------------------------------------
1 |
2 | 123
3 |
4 |
5 |
23 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/components/toast.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ title }}
3 |
4 |
5 |
38 |
39 |
57 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import { DefineComponent } from 'vue'
5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6 | const component: DefineComponent<{}, {}, any>
7 | export default component
8 | }
9 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/main.ts:
--------------------------------------------------------------------------------
1 | import { createSSRApp } from 'vue';
2 | import App from './App.vue';
3 | import Toast from './components/toast.vue';
4 |
5 | export function createApp() {
6 | const app = createSSRApp(App);
7 |
8 | app.component('Toast', Toast);
9 |
10 | return {
11 | app
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "hello",
3 | "appid" : "__UNI__4DCD124",
4 | "description" : "",
5 | "versionName" : "1.0.0",
6 | "versionCode" : "100",
7 | "transformPx" : false,
8 | /* 5+App特有相关 */
9 | "app-plus" : {
10 | "usingComponents" : true,
11 | "nvueStyleCompiler" : "uni-app",
12 | "compilerVersion" : 3,
13 | "splashscreen" : {
14 | "alwaysShowBeforeRender" : true,
15 | "waiting" : true,
16 | "autoclose" : true,
17 | "delay" : 0
18 | },
19 | /* 模块配置 */
20 | "modules" : {},
21 | /* 应用发布信息 */
22 | "distribute" : {
23 | /* android打包配置 */
24 | "android" : {
25 | "permissions" : [
26 | "",
27 | "",
28 | "",
29 | "",
30 | "",
31 | "",
32 | "",
33 | "",
34 | "",
35 | "",
36 | "",
37 | "",
38 | "",
39 | "",
40 | ""
41 | ]
42 | },
43 | /* ios打包配置 */
44 | "ios" : {},
45 | /* SDK配置 */
46 | "sdkConfigs" : {}
47 | }
48 | },
49 | /* 快应用特有相关 */
50 | "quickapp" : {},
51 | /* 小程序特有相关 */
52 | "mp-weixin" : {
53 | "appid" : "",
54 | "setting" : {
55 | "urlCheck" : false
56 | },
57 | "usingComponents" : true
58 | },
59 | "mp-alipay" : {
60 | "usingComponents" : true
61 | },
62 | "mp-baidu" : {
63 | "usingComponents" : true
64 | },
65 | "mp-toutiao" : {
66 | "usingComponents" : true
67 | },
68 | "uniStatistics": {
69 | "enable": false
70 | },
71 | "vueVersion" : "3"
72 | }
73 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "autoscan": true,
4 | "custom": {
5 | "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
6 | }
7 | },
8 |
9 | "pages": [
10 | {
11 | "path": "pages/home/index",
12 | "style": {
13 | "navigationBarTitleText": "首页"
14 | }
15 | },
16 | {
17 | "path": "pages/mine/index/index",
18 | "style": {
19 | "navigationBarTitleText": "个人中心"
20 | }
21 | }
22 | ],
23 |
24 | "globalStyle": {
25 | "navigationBarTextStyle": "black",
26 | "navigationBarTitleText": "uni-app",
27 | "navigationBarBackgroundColor": "#F8F8F8",
28 | "backgroundColor": "#F8F8F8"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/pages/home/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | btn
4 |
5 |
6 |
7 |
8 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/pages/mine/index/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue3-cli-vite-ts-plugin/src/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/src/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "preserve",
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "esModuleInterop": true,
12 | "lib": [
13 | "esnext",
14 | "dom"
15 | ],
16 | "types": [
17 | "@dcloudio/types"
18 | ]
19 | },
20 | "include": [
21 | "src/**/*.ts",
22 | "src/**/*.d.ts",
23 | "src/**/*.tsx",
24 | "src/**/*.vue"
25 | ]
26 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue3-cli-vite-ts-plugin/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import uni from '@dcloudio/vite-plugin-uni';
3 | import { vitePlugin } from 'uniapp-router-view-loader';
4 |
5 | export default defineConfig({
6 | plugins: [
7 | uni(),
8 | vitePlugin({
9 | vLabel: {
10 | div: 'view',
11 | span: 'text'
12 | // 'u-text': 'u--text',
13 | // 'u-form': 'u--form',
14 | // 'u-input': 'u--input',
15 | // 'u-textarea': 'u--textarea'
16 | }
17 | })
18 | ]
19 | });
20 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/.hbuilderx/launch.json:
--------------------------------------------------------------------------------
1 | { // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
2 | // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
3 | "version": "0.0",
4 | "configurations": [{
5 | "app-plus" :
6 | {
7 | "launchtype" : "local"
8 | },
9 | "default" :
10 | {
11 | "launchtype" : "local"
12 | },
13 | "mp-360" :
14 | {
15 | "launchtype" : "local"
16 | },
17 | "mp-alipay" :
18 | {
19 | "launchtype" : "local"
20 | },
21 | "mp-baidu" :
22 | {
23 | "launchtype" : "local"
24 | },
25 | "mp-feishu" :
26 | {
27 | "launchtype" : "local"
28 | },
29 | "mp-kuaishou" :
30 | {
31 | "launchtype" : "local"
32 | },
33 | "mp-toutiao" :
34 | {
35 | "launchtype" : "local"
36 | },
37 | "mp-weixin" :
38 | {
39 | "launchtype" : "local"
40 | },
41 | "quickapp-union" :
42 | {
43 | "launchtype" : "local"
44 | },
45 | "quickapp-webview-huawei" :
46 | {
47 | "launchtype" : "local"
48 | },
49 | "type" : "uniCloud"
50 | }
51 | ]
52 | }
53 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | is div to view
4 | is span to text
5 | My Header1
6 | My Header2
7 |
8 | My Footer1
9 | My Footer2
10 |
11 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/components/customSubmit.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | 提交成功
4 |
5 |
6 |
7 |
28 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/components/toast.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ title }}
3 |
4 |
5 |
28 |
29 |
47 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/global.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue3-hbuilderx-plugin/global.scss
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/main.js:
--------------------------------------------------------------------------------
1 | import App from './App'
2 | import { createSSRApp } from 'vue'
3 | import Toast from './components/toast.vue'
4 |
5 | export function createApp() {
6 | const app = createSSRApp(App)
7 |
8 | app.component('Toast', Toast)
9 |
10 | return {
11 | app
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "uniapp-vue2-hbuilderx-loader",
3 | "appid" : "__UNI__D374408",
4 | "description" : "",
5 | "versionName" : "1.0.0",
6 | "versionCode" : "100",
7 | "transformPx" : false,
8 | /* 5+App特有相关 */
9 | "app-plus" : {
10 | "usingComponents" : true,
11 | "nvueStyleCompiler" : "uni-app",
12 | "compilerVersion" : 3,
13 | "splashscreen" : {
14 | "alwaysShowBeforeRender" : true,
15 | "waiting" : true,
16 | "autoclose" : true,
17 | "delay" : 0
18 | },
19 | /* 模块配置 */
20 | "modules" : {},
21 | /* 应用发布信息 */
22 | "distribute" : {
23 | /* android打包配置 */
24 | "android" : {
25 | "permissions" : [
26 | "",
27 | "",
28 | "",
29 | "",
30 | "",
31 | "",
32 | "",
33 | "",
34 | "",
35 | "",
36 | "",
37 | "",
38 | "",
39 | "",
40 | ""
41 | ]
42 | },
43 | /* ios打包配置 */
44 | "ios" : {},
45 | /* SDK配置 */
46 | "sdkConfigs" : {}
47 | },
48 | "nvueLaunchMode" : ""
49 | },
50 | /* 快应用特有相关 */
51 | "quickapp" : {},
52 | /* 小程序特有相关 */
53 | "mp-weixin" : {
54 | "appid" : "",
55 | "setting" : {
56 | "urlCheck" : false
57 | },
58 | "usingComponents" : true
59 | },
60 | "mp-alipay" : {
61 | "usingComponents" : true
62 | },
63 | "mp-baidu" : {
64 | "usingComponents" : true
65 | },
66 | "mp-toutiao" : {
67 | "usingComponents" : true
68 | },
69 | "uniStatistics" : {
70 | "enable" : false
71 | },
72 | "vueVersion" : "3",
73 | "h5" : {
74 | "optimization" : {
75 | "treeShaking" : {
76 | "enable" : true
77 | }
78 | }
79 | },
80 | "quickapp-webview" : {
81 | "icon" : "static/logo.png",
82 | "package" : "com.pocky.vue3HbuilderxPlugin",
83 | "versionName" : "1.0",
84 | "versionCode" : 1
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uniapp-vue2-hbuilderx-loader",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "main.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {},
13 | "devDependencies": {
14 | "@vitejs/plugin-vue": "^2.2.0",
15 | "lib-flexible": "^0.3.2",
16 | "uniapp-router-view-loader": "1.1.2",
17 | "vite": "^2.8.2"
18 | }
19 | }
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "easycom": {
3 | "autoscan": true,
4 | "custom": {
5 | // uview-ui
6 | "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
7 | }
8 | },
9 | "pages": [
10 | //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
11 | {
12 | "path": "pages/index/index"
13 | },
14 | {
15 | "path": "pages/index/other"
16 | }
17 | ],
18 | "globalStyle": {
19 | "navigationBarTextStyle": "black",
20 | "navigationBarTitleText": "",
21 | "navigationBarBackgroundColor": "#F8F8F8",
22 | "backgroundColor": "#f2f4f5",
23 | "navigationStyle": "custom",
24 | "transparentTitle": "always"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/pages/index/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | btn
4 |
5 |
6 |
7 |
8 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/pages/index/other.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/plugin.js:
--------------------------------------------------------------------------------
1 | module.exports = function () {
2 | return {}
3 | }
4 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/static/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/examples/uniapp-vue3-hbuilderx-plugin/static/logo.png
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/uni.scss:
--------------------------------------------------------------------------------
1 | @import 'uview-ui/theme.scss';
2 |
--------------------------------------------------------------------------------
/examples/uniapp-vue3-hbuilderx-plugin/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import { vitePlugin } from 'uniapp-router-view-loader';
3 | import uni from '@dcloudio/vite-plugin-uni';
4 |
5 | export default defineConfig({
6 | plugins: [
7 | uni(),
8 | vitePlugin({
9 | vLabel: {
10 | div: 'view',
11 | span: 'text'
12 | // 'u-text': 'u--text',
13 | // 'u-form': 'u--form',
14 | // 'u-input': 'u--input',
15 | // 'u-textarea': 'u--textarea'
16 | }
17 | })
18 | ]
19 | });
20 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | collectCoverageFrom: [
3 | './src/**/*.js',
4 | '!**/node_modules/**',
5 | '!./src/errorId.js',
6 | ],
7 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "uniapp-router-view-loader",
3 | "version": "1.1.3",
4 | "description": "打造uniapp的专属插件",
5 | "main": "./dist/plugins/index.js",
6 | "scripts": {
7 | "dev": "rimraf ./dist && rollup --config --environment NODE_ENV:development && npm run local:test",
8 | "dev:watch": "node ./scripts/chokidar.js",
9 | "build": "rimraf ./dist && rollup --config --environment NODE_ENV:production",
10 | "addV": "npm --no-git-tag-version version patch",
11 | "test": "jest",
12 | "test:coverage": "jest --coverage",
13 | "docs:dev": "node ./scripts/copyChangelog.js && vuepress dev docs",
14 | "docs:build": "node ./scripts/copyChangelog.js && vuepress build docs && node ./scripts/addBaiduStatistics.js && gzip ./docs/.vuepress/dist/**/*.{html,css,js,svg}",
15 | "zip:example": "node ./scripts/compressZipExample.js",
16 | "zip:src": "node ./scripts/compressZipSrc.js",
17 | "local:test": "node ./scripts/localTest.js",
18 | "local:publish": "node ./scripts/localPublish.js"
19 | },
20 | "author": "fty2460392754@gmail.com",
21 | "keywords": [
22 | "uniapp",
23 | "router-view"
24 | ],
25 | "repository": {
26 | "type": "git",
27 | "url": "https://github.com/2460392754/uniapp-router-view-loader.git"
28 | },
29 | "bugs": {
30 | "url": "https://github.com/2460392754/uniapp-router-view-loader/issues"
31 | },
32 | "homepage": "https://github.com/2460392754/uniapp-router-view-loader",
33 | "license": "MIT",
34 | "devDependencies": {
35 | "@babel/core": "^7.17.2",
36 | "@babel/node": "^7.16.8",
37 | "@babel/preset-env": "^7.16.11",
38 | "@rollup/plugin-json": "^4.1.0",
39 | "@types/jest": "^27.4.0",
40 | "@vuepress/plugin-search": "^2.0.0-beta.35",
41 | "chalk": "4",
42 | "chokidar": "^3.5.3",
43 | "compressing": "^1.5.1",
44 | "dayjs": "^1.10.8",
45 | "gzip-cli": "^1.2.0",
46 | "jest": "^27.5.1",
47 | "rollup": "^2.67.2",
48 | "rollup-plugin-ts": "^2.0.5",
49 | "rollup-plugin-typescript2": "^0.31.2",
50 | "rollup-plugin-uglify": "^6.0.4",
51 | "shelljs": "^0.8.5",
52 | "typescript": "^4.5.5",
53 | "vue": "^3.2.31",
54 | "vuepress": "^2.0.0-beta.35",
55 | "vuepress-plugin-copy-code2": "^2.0.0-alpha.23",
56 | "vuepress-plugin-vuepress2.x-code-copy": "^1.0.0",
57 | "vuepress-theme-quicksand": "^1.0.4"
58 | },
59 | "dependencies": {
60 | "node-html-parser": "^5.2.0"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/package.uniModules.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import json from '@rollup/plugin-json'
2 | import { uglify } from 'rollup-plugin-uglify'
3 | import typescript from 'rollup-plugin-typescript2';
4 |
5 | const plugins = [json()]
6 |
7 | // 生产环节开启压缩
8 | if (process.env.NODE_ENV === 'production') {
9 | plugins.push(uglify())
10 | }
11 |
12 | export default [
13 | {
14 | plugins,
15 | input: './src/plugins/index.js', //入口文件
16 | output: {
17 | file: './dist/plugins/index.js', //打包后的存放文件
18 | format: 'cjs', //输出格式 amd es6 iife umd cjs
19 | name: 'bundleName' //如果iife,umd需要指定一个全局变量
20 | }
21 | },
22 | {
23 | plugins: [
24 | json(),
25 | uglify()
26 | ],
27 | input: './src/project/vue2/index.js', //入口文件
28 | output: {
29 | file: './dist/project/vue2/index.js', //打包后的存放文件
30 | format: 'esm', //输出格式 amd es6 iife umd cjs
31 | name: 'bundleName' //如果iife,umd需要指定一个全局变量
32 | },
33 | },
34 | {
35 | plugins: [
36 | json(),
37 | uglify(),
38 | typescript({
39 | tsconfigOverride: {
40 | compilerOptions: { declaration: true }, // 生成.d.ts的文件
41 | // exclude: ["tests/**/*.ts", "tests/**/*.tsx"]
42 | include: ['src/**/*.ts']
43 | }
44 | }),
45 | ],
46 | external: ['vue'],
47 | input: './src/project/vue3/index.ts', //入口文件
48 | output: {
49 | file: './dist/project/vue3/index.js', //打包后的存放文件
50 | format: 'esm', //输出格式 amd es6 iife umd cjs
51 | name: 'bundleName' //如果iife,umd需要指定一个全局变量
52 | },
53 | },
54 | ]
55 |
--------------------------------------------------------------------------------
/scripts/addBaiduStatistics.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-01 14:41:14
4 | * @LastEditTime: 2022-03-02 00:47:51
5 | * @Description: 添加百度统计到 `index.html`
6 | * @FilePath: /uniapp-router-view-loader/scripts/addBaiduStatistics.js
7 | */
8 |
9 | const Fs = require('fs');
10 | const Path = require('path')
11 |
12 | const scriptsStr = ``
13 | const htmlPath = Path.join(__dirname, '../', './docs/.vuepress/dist/index.html');
14 | const html = Fs.readFileSync(htmlPath, 'utf8')
15 | const tempHtml = html.replace(//, s => s + scriptsStr)
16 |
17 | Fs.writeFileSync(htmlPath, tempHtml)
--------------------------------------------------------------------------------
/scripts/chokidar.js:
--------------------------------------------------------------------------------
1 | const chokidar = require('chokidar');
2 | const chalk = require("chalk");
3 | const shell = require('shelljs');
4 |
5 | console.log(chalk.green(`Tip: 开始监听`));
6 |
7 | chokidar.watch('./src').on('all', (event, path) => {
8 | // 文件更新
9 | if (event === 'change') {
10 | console.log(chalk.green(`Tip: 文件更新[${path}]`));
11 | shell.exec('npm run dev')
12 | }
13 | });
14 |
--------------------------------------------------------------------------------
/scripts/compressZipExample.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-01 18:58:45
4 | * @LastEditTime: 2022-03-02 11:51:15
5 | * @Description: 压缩 `examples` 文件夹
6 | * @FilePath: /uniapp-router-view-loader/scripts/compressZipExample.js
7 | */
8 |
9 | const { version } = require('../package.json')
10 | const path = require("path");
11 | const fs = require("fs");
12 | const chalk = require("chalk");
13 | const compressing = require("compressing");
14 | const dayjs = require("dayjs");
15 | const fse = require('fs-extra');
16 |
17 | const getPath = (s) => path.join(__dirname, '../', s)
18 |
19 | const exampleDir = getPath('./examples')
20 | const zipDir = getPath('./zip')
21 | const tempDir = getPath('./temp')
22 | const fileName = getPath('./zip' + `/example_${version.replace(/\./g, '-')}_${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.zip`);
23 |
24 | // 创建 zip 文件夹
25 | if (!fs.existsSync(zipDir)) {
26 | fs.mkdirSync(zipDir);
27 | }
28 |
29 | // 删除 temp 临时文件夹
30 | if (fs.existsSync(tempDir)) {
31 | fs.rmdirSync(tempDir, { recursive: true })
32 | }
33 |
34 | // 复制 examples 文件夹中的部分文件到 temp 临时文件夹中
35 | fse.copySync(exampleDir, tempDir, {
36 | filter: (src, dest) => {
37 | return !/\.git|node_modules|dist|unpackage|yarn.*/.test(src)
38 | }
39 | }, (err) => {
40 | console.log(chalk.red("Tip: 复制错误"));
41 | console.error(err);
42 | })
43 |
44 | compressing.zip
45 | .compressDir(getPath("./temp"), fileName)
46 | .then(() => {
47 | console.log(chalk.yellow(`Tip: 文件压缩成功,已压缩至【${fileName}】`));
48 | })
49 | .catch(err => {
50 | console.log(chalk.red("Tip: 压缩报错"));
51 | console.error(err);
52 | }).finally(() => {
53 | fs.rmdirSync(tempDir, { recursive: true })
54 | })
--------------------------------------------------------------------------------
/scripts/compressZipSrc.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-02 11:52:38
4 | * @LastEditTime: 2022-03-02 11:55:45
5 | * @Description: 压缩 `src` 文件夹
6 | * @FilePath: /uniapp-router-view-loader/scripts/comporessZipSrc.js
7 | */
8 |
9 | const { version } = require('../package.json')
10 | const path = require("path");
11 | const fs = require("fs");
12 | const chalk = require("chalk");
13 | const compressing = require("compressing");
14 | const dayjs = require("dayjs");
15 |
16 | const getPath = (s) => path.join(__dirname, '../', s)
17 |
18 | const srcDir = getPath('./src')
19 | const zipDir = getPath('./zip')
20 | const fileName = getPath('./zip' + `/src_${version.replace(/\./g, '-')}_${dayjs().format("YYYY-MM-DD_HH-mm-ss")}.zip`);
21 |
22 | // 创建 zip 文件夹
23 | if (!fs.existsSync(zipDir)) {
24 | fs.mkdirSync(zipDir);
25 | }
26 |
27 | compressing.zip
28 | .compressDir(srcDir, fileName)
29 | .then(() => {
30 | console.log(chalk.yellow(`Tip: 文件压缩成功,已压缩至【${fileName}】`));
31 | })
32 | .catch(err => {
33 | console.log(chalk.red("Tip: 压缩报错"));
34 | console.error(err);
35 | })
--------------------------------------------------------------------------------
/scripts/copyChangelog.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-01 19:16:21
4 | * @LastEditTime: 2022-03-02 00:47:19
5 | * @Description: 复制 `changelog.md` 文件到 `docs/md` 位置
6 | * @FilePath: /uniapp-router-view-loader/scripts/copyChangelog.js
7 | */
8 |
9 | const fs = require('fs');
10 |
11 | fs.copyFile('./changelog.md', './docs/md/changelog.md', (err) => {
12 | if (err) throw err;
13 | });
--------------------------------------------------------------------------------
/scripts/localPublish.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-02 00:43:54
4 | * @LastEditTime: 2022-03-03 16:13:54
5 | * @Description: 测试文件同步插件版本号
6 | * @FilePath: /uniapp-router-view-loader/scripts/localPublish.js
7 | */
8 |
9 | const fs = require('fs');
10 | const path = require('path')
11 | const chalk = require("chalk");
12 | const { name, version } = require('../package.json')
13 |
14 | const dirPath = './examples'
15 | const dirChildrenPathAll = fs.readdirSync(dirPath)
16 |
17 | console.log(chalk.green(`Tip: 测试项目本地部署版本号开始`));
18 |
19 | // 修改版本号, 并锁定
20 | for (const childPath of dirChildrenPathAll) {
21 | const toDirPath = './' + path.join(dirPath, childPath)
22 | const toPackageJsonPath = './' + path.join(dirPath, childPath, 'package.json')
23 |
24 |
25 | if (fs.lstatSync(toDirPath).isDirectory()) {
26 | const content = JSON.parse(fs.readFileSync(toPackageJsonPath, 'utf8'));
27 |
28 | content.devDependencies[name] = version;
29 |
30 | try {
31 | fs.writeFileSync(toPackageJsonPath, JSON.stringify(content, null, 4), 'utf8')
32 | console.log(chalk.yellow(`Tip: 测试项目本地部署版本号成功【${toPackageJsonPath}】`));
33 | } catch (err) {
34 | console.error(err)
35 | }
36 | }
37 | }
38 |
39 | console.log(chalk.green(`Tip: 测试项目本地部署版本号结束`));
--------------------------------------------------------------------------------
/scripts/localTest.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: 2460392754@qq.com
3 | * @Date: 2022-03-02 00:43:54
4 | * @LastEditTime: 2022-03-04 16:43:14
5 | * @Description: 本地部署测试文件,替换 `examples` 里各项目的 `node_modules/**\/dist` 文件内容
6 | * @FilePath: /uniapp-router-view-loader/scripts/localTest.js
7 | */
8 |
9 | const fs = require('fs');
10 | const fse = require('fs-extra');
11 | const path = require('path')
12 | const chalk = require("chalk");
13 | const { name } = require('../package.json')
14 |
15 | const dirPath = './examples'
16 | const dirChildrenPathAll = fs.readdirSync(dirPath)
17 |
18 | console.log(chalk.green(`Tip: 测试项目本地部署测试文件开始`));
19 |
20 | for (const childPath of dirChildrenPathAll) {
21 | const toDir = './' + path.join(dirPath, childPath, 'node_modules', name, 'dist')
22 |
23 | // 判断 `./examples/xxx` 文件目录
24 | if (!fs.lstatSync('./' + path.join(dirPath, childPath)).isDirectory()) {
25 | continue;
26 | }
27 |
28 | // 判断 `./examples/xxx/node_modules/uniapp-router-view-loader/dist` 文件目录
29 | if (!fs.lstatSync(toDir).isDirectory()) {
30 | continue;
31 | }
32 |
33 | try {
34 | fse.copySync('./dist', toDir)
35 | console.log(chalk.yellow(`Tip: 测试项目本地部署成功【${toDir}】`));
36 | } catch (err) {
37 | console.error(err)
38 | }
39 | }
40 |
41 | console.log(chalk.green(`Tip: 测试项目本地部署测试文件结束`));
--------------------------------------------------------------------------------
/src/config.d.ts:
--------------------------------------------------------------------------------
1 | export { name, version } from '../package.json';
2 |
3 | export const publicPath: string;
4 | export const provideKey: string;
5 |
--------------------------------------------------------------------------------
/src/config.js:
--------------------------------------------------------------------------------
1 | export { name, version } from '../package.json'
2 |
3 | /**
4 | * pages.json 在项目中的相对路径
5 | */
6 | // export const publicPath = '../../../'
7 |
8 | /**
9 | * vnode 节点
10 | */
11 | // export const VNode = {
12 | // 'VNode-Navbar': '/src/template/navbar',
13 | // 'VNode-Copyright': '/src/template/copyright',
14 | // }
15 |
16 | export const provideKey = '$urvl'
--------------------------------------------------------------------------------
/src/plugins/errorId.js:
--------------------------------------------------------------------------------
1 | export default {
2 | 10001: 'pages.json文件解析异常, 请查看抛出的异常信息',
3 | 10101: 'App.vue文件中未找到标签',
4 | 10102: 'App.vue文件中标签数量超过1个以上',
5 | 10201: '运行环境异常'
6 | }
--------------------------------------------------------------------------------
/src/plugins/index.js:
--------------------------------------------------------------------------------
1 | import * as Utils from './utils';
2 | import * as Config from '../config';
3 | import { join } from 'path';
4 |
5 | let addLabel = {
6 | header: [],
7 | footer: []
8 | };
9 |
10 | /**
11 | * 获取 配置
12 | * @param {*} opts
13 | * @returns
14 | */
15 | function getConfigure(opts) {
16 | const config = Object.assign({}, Config, opts);
17 | const routeFilePathRegList = Utils.getRouteFileMatchRegAll(config);
18 |
19 | return {
20 | config,
21 | routeFilePathRegList
22 | };
23 | }
24 |
25 | /**
26 | * 处理 App.vue文件
27 | * @param {string} source
28 | * @returns
29 | */
30 | function handleAppVue(source) {
31 | Utils.print('App.vue file match, process: ', process.env.UNI_PLATFORM);
32 |
33 | const handleAppRes = Utils.handleAppTemplateAddCode(source);
34 | const labelList = Utils.handleGetTemplateRowCode(handleAppRes.addCode);
35 | const handleLabelList = Utils.handleGetTemplateHeaderOrFooterLabelCode(labelList);
36 |
37 | source = handleAppRes.source;
38 | source = source.replace(/
123 |
124 | `
125 | const AddCodeList = {
126 | header: ['Header1'],
127 | footer: ['Footer1'],
128 | }
129 |
130 | const PageTemplateAfter = `
131 |
132 |
133 | Header1
134 | 234
135 | Footer1
136 |
137 |
138 |
139 |
140 | `.replace(/\s+/g, '');
141 |
142 | const handlerPageTemp = handlePageCode(PageTemplate, AddCodeList)
143 |
144 | expect(handlerPageTemp).toBe(PageTemplateAfter)
145 | })
146 |
147 | test('向路由文件注入代码, 但文件内容是空', () => {
148 | const PageTemplate = ``
149 | const AddCodeList = {
150 | header: ['Header1'],
151 | footer: ['Footer1'],
152 | }
153 |
154 | const PageTemplateAfter = ``.replace(/\s+/g, '');
155 | const handlerPageTemp = handlePageCode(PageTemplate, AddCodeList)
156 |
157 | expect(handlerPageTemp).toBe(PageTemplateAfter)
158 | })
159 |
160 | test('向路由文件注入代码, 但缺少标签', () => {
161 | const PageTemplate = `
162 |
163 |
164 | `
165 | const AddCodeList = {
166 | header: ['Header1'],
167 | footer: ['Footer1'],
168 | }
169 |
170 | const PageTemplateAfter = `
171 |
172 |
173 | `.replace(/\s+/g, '');
174 |
175 | const handlerPageTemp = handlePageCode(PageTemplate, AddCodeList)
176 |
177 | expect(handlerPageTemp).toBe(PageTemplateAfter)
178 | })
--------------------------------------------------------------------------------
/test/appVueTemplate/index.test.js:
--------------------------------------------------------------------------------
1 | import { handleAppTemplateAddCode } from '../../src/utils'
2 | import ErorrId from '../../src/errorId'
3 |
4 | // 假设已修改的App.vue代码
5 | const AppVueAddCode = `
6 |
7 | Header1'
8 |
9 | Footer1
10 |
11 | `
12 |
13 | // h5环境中App.vue源代码
14 | const AppVueIsH5EnvOriginalCode = `
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 | `
25 |
26 | // h5环境中处理后的App.vue源代码
27 | const AppVueIsH5EnvHandleOriginalCode = `
28 |
29 |
30 |
31 | ${AppVueAddCode}
32 |
33 |
36 |
37 |
38 | `
39 |
40 | // 非h5环境中App.vue源代码
41 | const AppVueIsNotH5EnvOriginalCode = `
42 | ${AppVueAddCode}
43 |
44 |
47 |
48 |
49 | `
50 |
51 | test('处理H5环境的App.vue代码解析', () => {
52 | process.env.UNI_PLATFORM = 'h5'
53 |
54 | const { source, addCode } = handleAppTemplateAddCode(AppVueIsH5EnvHandleOriginalCode)
55 |
56 | // App.vue文件中添加的代码移除后进行对比
57 | const sourceCodeIsSame = AppVueIsH5EnvOriginalCode.replace(/\s+/, '') === source.replace(/\s+/, '')
58 |
59 | // 向App.vue文件中添加的代码进行对比
60 | const addCodeIsSame = addCode.replace(/\s+/, '') === AppVueAddCode.replace(/\s+/, '')
61 |
62 | expect(sourceCodeIsSame).toBeFalsy()
63 | expect(addCodeIsSame).toBeFalsy()
64 | })
65 |
66 | test('处理非H5环境的App.vue代码解析', () => {
67 | process.env.UNI_PLATFORM = 'mp-weixin'
68 |
69 | const { source, addCode } = handleAppTemplateAddCode(AppVueIsNotH5EnvOriginalCode)
70 |
71 | // App.vue文件中添加的代码移除后进行对比
72 | const sourceCodeIsSame = AppVueIsNotH5EnvOriginalCode.replace(/\s+/, '') === source.replace(/\s+/, '')
73 |
74 | // 向App.vue文件中添加的代码进行对比
75 | const addCodeIsSame = addCode.replace(/\s+/, '') === AppVueAddCode.replace(/\s+/, '')
76 |
77 | expect(sourceCodeIsSame).toBeFalsy()
78 | expect(addCodeIsSame).toBeFalsy()
79 | })
80 |
81 | test('处理异常环境代码解析', () => {
82 | process.env.UNI_PLATFORM = 'xxxx'
83 |
84 | expect(() => {
85 | handleAppTemplateAddCode(AppVueIsNotH5EnvOriginalCode)
86 | }).toThrow(ErorrId[10201])
87 | })
--------------------------------------------------------------------------------
/test/getRouterFile/data/1/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [{ "path": "src/pages/A" }, { "path": "src/pages/B/B1" }]
3 | }
4 |
--------------------------------------------------------------------------------
/test/getRouterFile/data/2/pages.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [{ "path": "src/pages/A" }, { "path": "src/pages/B/B1" }],
3 | "subPackages": [
4 | {
5 | "root": "src/packages/C",
6 | "pages": [
7 | {
8 | "path": "views/C1"
9 | }
10 | ]
11 | },
12 | {
13 | "root": "src/packages/D",
14 | "pages": [
15 | {
16 | "path": "views/D1"
17 | },
18 | {
19 | "path": "views/D2"
20 | },
21 | {
22 | "path": "views/D3/D31"
23 | }
24 | ]
25 | }
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/test/getRouterFile/index.test.js:
--------------------------------------------------------------------------------
1 | import { getPath, getFileMatchReg, getRouteFileMatchRegAll } from '../../src/utils'
2 | import ErorrId from '../../src/errorId'
3 |
4 | const redirectPath = './test/getRouterFile'
5 |
6 | /**
7 | * 处理 路由文件正则匹配(vue和nvue文件)
8 | * @param {*} routerFileList
9 | * @param {*} filePath
10 | * @param {*} routeFilePathRegList
11 | * @returns
12 | */
13 | function handleRouteFileRegMatch(routerFileList, filePath, routeFilePathRegList) {
14 | return routerFileList.every(s => {
15 | const path = __dirname + filePath + s;
16 | const vuePath = path + '.vue'
17 | const nvuePath = path + '.nvue'
18 |
19 | return routeFilePathRegList.some(reg => reg.test(vuePath)) && routeFilePathRegList.some(reg => reg.test(nvuePath))
20 | })
21 | }
22 |
23 | test('获取相对路径', () => {
24 | expect(getPath([redirectPath])).toBe(__dirname)
25 | })
26 |
27 | test('匹配vue和nvue文件', () => {
28 | const pathReg = getFileMatchReg(redirectPath, 'demo')
29 | const vuePath = __dirname + '/demo.vue'
30 | const nvuePath = __dirname + '/demo.nvue'
31 |
32 | expect(pathReg.test(vuePath)).toBeTruthy()
33 | expect(pathReg.test(nvuePath)).toBeTruthy()
34 | })
35 |
36 | test('解析pages.json文件中对应路径的vue或nvue文件', () => {
37 | const filePath = '/data/1';
38 | const routeFilePathRegList = getRouteFileMatchRegAll({
39 | publicPath: redirectPath + filePath
40 | })
41 | const routerFileList = [
42 | '/src/pages/A',
43 | '/src/pages/B/B1',
44 | ]
45 | const flag = handleRouteFileRegMatch(routerFileList, filePath, routeFilePathRegList);
46 |
47 | expect(flag).toBeTruthy()
48 | })
49 |
50 | test('解析pages.json文件中对应路径的vue或nvue文件(分包)', () => {
51 | const filePath = '/data/2';
52 | const routeFilePathRegList = getRouteFileMatchRegAll({
53 | publicPath: redirectPath + filePath
54 | })
55 | const routerFileList = [
56 | '/src/pages/A',
57 | '/src/pages/B/B1',
58 | '/src/packages/C/views/C1',
59 | '/src/packages/D/views/D1',
60 | '/src/packages/D/views/D2',
61 | '/src/packages/D/views/D3/D31',
62 | ]
63 | const flag = handleRouteFileRegMatch(routerFileList, filePath, routeFilePathRegList);
64 |
65 | expect(flag).toBeTruthy()
66 | })
67 |
68 | test('pages.json文件路径匹配错误,未找到该文件', () => {
69 | console.log = () => { };
70 |
71 | expect(() => {
72 | const filePath = '/data/xxxx';
73 | getRouteFileMatchRegAll({
74 | publicPath: redirectPath + filePath
75 | })
76 | }).toThrow(ErorrId[10001])
77 | })
78 |
79 |
--------------------------------------------------------------------------------
/test/parse/vite.spec.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/test/parse/vite.spec.js
--------------------------------------------------------------------------------
/test/parse/webpack.spec.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2460392754/uniapp-router-view-loader/aeff206c59c32c801a1d48365da28000d21ac634/test/parse/webpack.spec.js
--------------------------------------------------------------------------------
/test/parseHtml/index.test.js:
--------------------------------------------------------------------------------
1 | import { handleGetTemplateRowCode, handleGetTemplateHeaderOrFooterLabelCode } from '../../src/utils'
2 | import ErorrId from '../../src/errorId'
3 |
4 | test('解析App.vue文件正常', () => {
5 | const AppVueTemplate = `
6 |
7 | My Header1
8 | My Header2
9 | My Header3
10 |
11 | My Header4
12 |
13 |
14 |
15 | My Header5
16 |
17 |
18 |
19 |
20 |
21 | My Footer1
22 | My Footer2
23 |
24 | `
25 | const formatList = {
26 | header: [
27 | 'My Header1',
28 | 'My Header2',
29 | 'My Header3',
30 | 'My Header4',
31 | 'My Header5'
32 | ],
33 | footer: [
34 | 'My Footer1',
35 | 'My Footer2'
36 | ]
37 | }
38 |
39 | const formatCode = handleGetTemplateRowCode(AppVueTemplate);
40 | const labelListCode = handleGetTemplateHeaderOrFooterLabelCode(formatCode);
41 |
42 | expect(labelListCode).toEqual(formatList)
43 | })
44 |
45 | test('解析App.vue文件异常:缺少标签', () => {
46 | const AppVueTemplate = `
47 |
48 | My Header1
49 | My Footer1
50 |
51 | `
52 | const formatList = {
53 | header: ['My Header1'],
54 | footer: ['My Footer1']
55 | }
56 |
57 | const fun = () => {
58 | const formatCode = handleGetTemplateRowCode(AppVueTemplate);
59 | const labelListCode = handleGetTemplateHeaderOrFooterLabelCode(formatCode);
60 |
61 | expect(labelListCode).toEqual(formatList)
62 | }
63 |
64 | expect(fun).toThrow(ErorrId[10101])
65 | })
66 |
67 | test('解析App.vue文件异常:标签数量大于1', () => {
68 | const AppVueTemplate = `
69 |
70 | My Header1
71 |
72 |
73 | My Footer1
74 | My Footer2
75 |
76 | `
77 | const formatList = {
78 | header: ['My Header1'],
79 | footer: [
80 | 'My Footer1',
81 | 'My Footer1'
82 | ]
83 | }
84 |
85 | const fun = () => {
86 | const formatCode = handleGetTemplateRowCode(AppVueTemplate);
87 | const labelListCode = handleGetTemplateHeaderOrFooterLabelCode(formatCode);
88 |
89 | expect(labelListCode).toEqual(formatList)
90 | }
91 |
92 | expect(fun).toThrow(ErorrId[10102])
93 | })
94 |
--------------------------------------------------------------------------------
/test/print/index.test.js:
--------------------------------------------------------------------------------
1 | import { getPrintID, print } from '../../src/utils'
2 | import ErorrId from '../../src/errorId'
3 |
4 | test('打印log类型', () => {
5 | let printMsg = ''
6 |
7 | console.log = (msg) => {
8 | printMsg = msg;
9 | };
10 |
11 | const msg = 'is test'
12 | print('log', msg)
13 |
14 | expect(printMsg).toBe(getPrintID() + msg)
15 | })
16 |
17 | test('打印error类型', () => {
18 | expect(() => {
19 | print('error', ErorrId[10001])
20 | }).toThrow(ErorrId[10001])
21 | })
--------------------------------------------------------------------------------
/tsconfig.xx.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "useDefineForClassFields": true,
5 | "module": "esnext",
6 | "moduleResolution": "node",
7 | "strict": true,
8 | "jsx": "preserve",
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "esModuleInterop": true,
12 | "declaration": true,
13 | // "declarationDir": "./types",
14 | "lib": [
15 | "esnext",
16 | "dom"
17 | ],
18 | }
19 | }
--------------------------------------------------------------------------------