@focus-teach/ui 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/.history/package_20230626120806.json +45 -0
  2. package/.history/package_20230626120808.json +46 -0
  3. package/.history/package_20230626120809.json +45 -0
  4. package/.history/package_20230626133910.json +46 -0
  5. package/.history/package_20230626133912.json +46 -0
  6. package/.history/package_20230626133915.json +46 -0
  7. package/.history/package_20230626133917.json +46 -0
  8. package/.history/package_20230626133923.json +46 -0
  9. package/.history/package_20230626133927.json +46 -0
  10. package/.history/package_20230626134037.json +46 -0
  11. package/.history/package_20230626134121.json +46 -0
  12. package/.history/package_20230626134122.json +46 -0
  13. package/.history/package_20230626134126.json +45 -0
  14. package/.history/vue.config_20230626131835.js +132 -0
  15. package/.history/vue.config_20230626132308.js +132 -0
  16. package/.history/vue.config_20230626132415.js +132 -0
  17. package/.history/vue.config_20230626132534.js +132 -0
  18. package/.history/vue.config_20230626132823.js +133 -0
  19. package/.history/vue.config_20230626132826.js +133 -0
  20. package/.history/vue.config_20230626132829.js +133 -0
  21. package/.history/vue.config_20230626132832.js +133 -0
  22. package/.history/vue.config_20230626132836.js +132 -0
  23. package/.history/vue.config_20230626132838.js +132 -0
  24. package/.history/vue.config_20230626132940.js +132 -0
  25. package/.history/vue.config_20230626133032.js +131 -0
  26. package/.history/vue.config_20230626133106.js +132 -0
  27. package/.history/vue.config_20230626133113.js +132 -0
  28. package/.history/vue.config_20230626133122.js +132 -0
  29. package/.history/vue.config_20230626133252.js +132 -0
  30. package/.history/vue.config_20230626133258.js +133 -0
  31. package/.history/vue.config_20230626133300.js +133 -0
  32. package/.history/vue.config_20230626133302.js +133 -0
  33. package/.history/vue.config_20230626133303.js +133 -0
  34. package/.history/vue.config_20230626133305.js +133 -0
  35. package/.history/vue.config_20230626133312.js +132 -0
  36. package/.history/vue.config_20230626133314.js +132 -0
  37. package/.history/vue.config_20230626133316.js +133 -0
  38. package/.history/vue.config_20230626133319.js +132 -0
  39. package/.history/vue.config_20230626133326.js +132 -0
  40. package/.history/vue.config_20230626133336.js +132 -0
  41. package/.history/vue.config_20230626133428.js +132 -0
  42. package/.history/vue.config_20230626133623.js +132 -0
  43. package/.history/vue.config_20230626133736.js +132 -0
  44. package/lib/demo.html +4 -4
  45. package/lib/fonts/icomoon.356dc15f.woff +0 -0
  46. package/lib/fonts/icomoon.71d64f31.woff +0 -0
  47. package/lib/fonts/icomoon.7c9a60d9.eot +0 -0
  48. package/lib/fonts/icomoon.ba18ad87.eot +0 -0
  49. package/lib/fonts/icomoon.de76432e.ttf +0 -0
  50. package/lib/fonts/icomoon.ec37e716.ttf +0 -0
  51. package/lib/img/cloud_txt_24.87b9d2ae.svg +1 -0
  52. package/lib/img/icomoon.428f3063.svg +346 -0
  53. package/lib/img/icomoon.532b3795.svg +345 -0
  54. package/lib/img/icon_question.e931b16c.svg +14 -0
  55. package/lib/{@focus-teach/ui.common.js → ui.common.js} +1 -1
  56. package/lib/ui.css +1 -0
  57. package/lib/{@focus-teach/ui.umd.js → ui.umd.js} +3 -3
  58. package/lib/{@focus-teach/ui.umd.min.js → ui.umd.min.js} +2 -2
  59. package/package.json +2 -2
  60. package/lib/@focus-teach/ui.css +0 -1
  61. /package/{lib/@focus-teach/fonts → fonts}/icomoon.356dc15f.woff +0 -0
  62. /package/{lib/@focus-teach/fonts → fonts}/icomoon.71d64f31.woff +0 -0
  63. /package/{lib/@focus-teach/fonts → fonts}/icomoon.7c9a60d9.eot +0 -0
  64. /package/{lib/@focus-teach/fonts → fonts}/icomoon.ba18ad87.eot +0 -0
  65. /package/{lib/@focus-teach/fonts → fonts}/icomoon.de76432e.ttf +0 -0
  66. /package/{lib/@focus-teach/fonts → fonts}/icomoon.ec37e716.ttf +0 -0
  67. /package/{lib/@focus-teach/img → img}/cloud_txt_24.87b9d2ae.svg +0 -0
  68. /package/{lib/@focus-teach/img → img}/icomoon.428f3063.svg +0 -0
  69. /package/{lib/@focus-teach/img → img}/icomoon.532b3795.svg +0 -0
  70. /package/{lib/@focus-teach/img → img}/icon_question.e931b16c.svg +0 -0
@@ -0,0 +1,133 @@
1
+ const path = require("path");
2
+ // const PrerenderSpaPlugin = require("prerender-spa-plugin");
3
+ const MarkdownItContainer = require("markdown-it-container");
4
+
5
+ const cheerio = require('cheerio');
6
+ const striptags = (str, tags) => {
7
+ const $ = cheerio.load(str, { decodeEntities: false })
8
+
9
+ if (!tags || tags.length === 0) {
10
+ return str
11
+ }
12
+
13
+ tags = !Array.isArray(tags) ? [tags] : tags;
14
+ let len = tags.length;
15
+
16
+ while (len--) {
17
+ $(tags[len]).remove()
18
+ }
19
+
20
+ return $.html()
21
+ };
22
+ const convertHtml = function (str) {
23
+ return str.replace(/(&#x)(\w{4});/gi, $0 => String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)))
24
+ };
25
+ const wrapCustomClass = function (render) {
26
+ return function (...args) {
27
+ return render(...args)
28
+ .replace('<code class="', '<code class="hljs ')
29
+ .replace('<code>', '<code class="hljs">')
30
+ }
31
+ };
32
+ const vueMarkdown = {
33
+ raw: true,
34
+ preprocess: (MarkdownIt, source) => {
35
+ MarkdownIt.renderer.rules.table_open = function () {
36
+ return '<table class="table">'
37
+ };
38
+ MarkdownIt.renderer.rules.fence = wrapCustomClass(MarkdownIt.renderer.rules.fence);
39
+
40
+ // ```code`` 给这种样式加个class code_inline
41
+ const code_inline = MarkdownIt.renderer.rules.code_inline;
42
+ MarkdownIt.renderer.rules.code_inline = function(...args){
43
+ args[0][args[1]].attrJoin('class', 'code_inline');
44
+ return code_inline(...args)
45
+ };
46
+ return source
47
+ },
48
+ use: [
49
+ [MarkdownItContainer, 'demo', {
50
+ validate: params => params.trim().match(/^demo\s*(.*)$/),
51
+ render: function(tokens, idx) {
52
+ if (tokens[idx].nesting === 1) {
53
+ const html = convertHtml(striptags(tokens[idx + 1].content, 'script'));
54
+ // 移除描述,防止被添加到代码块
55
+ tokens[idx + 2].children = [];
56
+
57
+ return `<demo-block>
58
+ <div slot="desc">${html}</div>
59
+ <div slot="highlight">`;
60
+ }
61
+ return '</div></demo-block>\n';
62
+ }
63
+ }]
64
+ ]
65
+ };
66
+ const resolve = dir => path.join(__dirname, dir);
67
+ const packagesDir = resolve('packages');
68
+ module.exports = {
69
+ runtimeCompiler: true,
70
+ devServer: {
71
+ proxy: {
72
+ '/backend': {
73
+ target: 'http://10.10.14.64:8085',
74
+ changeOrigin: true,
75
+ pathRewrite: {
76
+ '^/backend': '/'
77
+ }
78
+ }
79
+ }
80
+ },
81
+ pages: {
82
+ index: {
83
+ entry: "examples/main.js",
84
+ template: "public/index.html",
85
+ filename: "index.html"
86
+ }
87
+ },
88
+ publicPath: process.env.NODE_ENV === 'production' ? '/vue-ui-demo/' : '/',
89
+ chainWebpack: config => {
90
+ config.resolve.alias
91
+ .set("@", path.resolve("examples"))
92
+ .set("~", path.resolve("packages"));
93
+ config.module
94
+ .rule("js")
95
+ .include.add("/packages")
96
+ .end()
97
+ .include.add("/examples")
98
+ .end()
99
+ .include.add("/api")
100
+ .end()
101
+ .use("babel")
102
+ .loader("babel-loader")
103
+ .end()
104
+ .use("vue-loader")
105
+ .loader("vue-loader")
106
+ .end()
107
+ config.module.rule("md")
108
+ .test(/\.md/)
109
+ .use("vue-loader")
110
+ .loader("vue-loader")
111
+ .end()
112
+ .use("vue-markdown-loader")
113
+ .loader("vue-markdown-loader/lib/markdown-compiler")
114
+ .options(vueMarkdown);
115
+ config.module.rule("vue")
116
+ .test(/\.vue/)
117
+ .use("vue-loader")
118
+ .loader("vue-loader")
119
+ },
120
+ outputDir:path.resolve(__dirname, 'lib'),
121
+ assetsDir: './',
122
+ publicPath
123
+ configureWebpack: {
124
+ entry: {
125
+ index: path.resolve(packagesDir, 'index.js'),
126
+ exam: path.resolve(packagesDir, 'exam/index.js'),
127
+ 'exam-drawer': path.resolve(packagesDir, 'exam-drawer/index.js'),
128
+ },
129
+ output: {
130
+ filename: 'packages/[name]/[name].js',
131
+ }
132
+ }
133
+ };
@@ -0,0 +1,133 @@
1
+ const path = require("path");
2
+ // const PrerenderSpaPlugin = require("prerender-spa-plugin");
3
+ const MarkdownItContainer = require("markdown-it-container");
4
+
5
+ const cheerio = require('cheerio');
6
+ const striptags = (str, tags) => {
7
+ const $ = cheerio.load(str, { decodeEntities: false })
8
+
9
+ if (!tags || tags.length === 0) {
10
+ return str
11
+ }
12
+
13
+ tags = !Array.isArray(tags) ? [tags] : tags;
14
+ let len = tags.length;
15
+
16
+ while (len--) {
17
+ $(tags[len]).remove()
18
+ }
19
+
20
+ return $.html()
21
+ };
22
+ const convertHtml = function (str) {
23
+ return str.replace(/(&#x)(\w{4});/gi, $0 => String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)))
24
+ };
25
+ const wrapCustomClass = function (render) {
26
+ return function (...args) {
27
+ return render(...args)
28
+ .replace('<code class="', '<code class="hljs ')
29
+ .replace('<code>', '<code class="hljs">')
30
+ }
31
+ };
32
+ const vueMarkdown = {
33
+ raw: true,
34
+ preprocess: (MarkdownIt, source) => {
35
+ MarkdownIt.renderer.rules.table_open = function () {
36
+ return '<table class="table">'
37
+ };
38
+ MarkdownIt.renderer.rules.fence = wrapCustomClass(MarkdownIt.renderer.rules.fence);
39
+
40
+ // ```code`` 给这种样式加个class code_inline
41
+ const code_inline = MarkdownIt.renderer.rules.code_inline;
42
+ MarkdownIt.renderer.rules.code_inline = function(...args){
43
+ args[0][args[1]].attrJoin('class', 'code_inline');
44
+ return code_inline(...args)
45
+ };
46
+ return source
47
+ },
48
+ use: [
49
+ [MarkdownItContainer, 'demo', {
50
+ validate: params => params.trim().match(/^demo\s*(.*)$/),
51
+ render: function(tokens, idx) {
52
+ if (tokens[idx].nesting === 1) {
53
+ const html = convertHtml(striptags(tokens[idx + 1].content, 'script'));
54
+ // 移除描述,防止被添加到代码块
55
+ tokens[idx + 2].children = [];
56
+
57
+ return `<demo-block>
58
+ <div slot="desc">${html}</div>
59
+ <div slot="highlight">`;
60
+ }
61
+ return '</div></demo-block>\n';
62
+ }
63
+ }]
64
+ ]
65
+ };
66
+ const resolve = dir => path.join(__dirname, dir);
67
+ const packagesDir = resolve('packages');
68
+ module.exports = {
69
+ runtimeCompiler: true,
70
+ devServer: {
71
+ proxy: {
72
+ '/backend': {
73
+ target: 'http://10.10.14.64:8085',
74
+ changeOrigin: true,
75
+ pathRewrite: {
76
+ '^/backend': '/'
77
+ }
78
+ }
79
+ }
80
+ },
81
+ pages: {
82
+ index: {
83
+ entry: "examples/main.js",
84
+ template: "public/index.html",
85
+ filename: "index.html"
86
+ }
87
+ },
88
+ publicPath: process.env.NODE_ENV === 'production' ? '/vue-ui-demo/' : '/',
89
+ chainWebpack: config => {
90
+ config.resolve.alias
91
+ .set("@", path.resolve("examples"))
92
+ .set("~", path.resolve("packages"));
93
+ config.module
94
+ .rule("js")
95
+ .include.add("/packages")
96
+ .end()
97
+ .include.add("/examples")
98
+ .end()
99
+ .include.add("/api")
100
+ .end()
101
+ .use("babel")
102
+ .loader("babel-loader")
103
+ .end()
104
+ .use("vue-loader")
105
+ .loader("vue-loader")
106
+ .end()
107
+ config.module.rule("md")
108
+ .test(/\.md/)
109
+ .use("vue-loader")
110
+ .loader("vue-loader")
111
+ .end()
112
+ .use("vue-markdown-loader")
113
+ .loader("vue-markdown-loader/lib/markdown-compiler")
114
+ .options(vueMarkdown);
115
+ config.module.rule("vue")
116
+ .test(/\.vue/)
117
+ .use("vue-loader")
118
+ .loader("vue-loader")
119
+ },
120
+ outputDir:path.resolve(__dirname, 'lib'),
121
+ assetsDir: './',
122
+ publicPath:''
123
+ configureWebpack: {
124
+ entry: {
125
+ index: path.resolve(packagesDir, 'index.js'),
126
+ exam: path.resolve(packagesDir, 'exam/index.js'),
127
+ 'exam-drawer': path.resolve(packagesDir, 'exam-drawer/index.js'),
128
+ },
129
+ output: {
130
+ filename: 'packages/[name]/[name].js',
131
+ }
132
+ }
133
+ };
@@ -0,0 +1,133 @@
1
+ const path = require("path");
2
+ // const PrerenderSpaPlugin = require("prerender-spa-plugin");
3
+ const MarkdownItContainer = require("markdown-it-container");
4
+
5
+ const cheerio = require('cheerio');
6
+ const striptags = (str, tags) => {
7
+ const $ = cheerio.load(str, { decodeEntities: false })
8
+
9
+ if (!tags || tags.length === 0) {
10
+ return str
11
+ }
12
+
13
+ tags = !Array.isArray(tags) ? [tags] : tags;
14
+ let len = tags.length;
15
+
16
+ while (len--) {
17
+ $(tags[len]).remove()
18
+ }
19
+
20
+ return $.html()
21
+ };
22
+ const convertHtml = function (str) {
23
+ return str.replace(/(&#x)(\w{4});/gi, $0 => String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)))
24
+ };
25
+ const wrapCustomClass = function (render) {
26
+ return function (...args) {
27
+ return render(...args)
28
+ .replace('<code class="', '<code class="hljs ')
29
+ .replace('<code>', '<code class="hljs">')
30
+ }
31
+ };
32
+ const vueMarkdown = {
33
+ raw: true,
34
+ preprocess: (MarkdownIt, source) => {
35
+ MarkdownIt.renderer.rules.table_open = function () {
36
+ return '<table class="table">'
37
+ };
38
+ MarkdownIt.renderer.rules.fence = wrapCustomClass(MarkdownIt.renderer.rules.fence);
39
+
40
+ // ```code`` 给这种样式加个class code_inline
41
+ const code_inline = MarkdownIt.renderer.rules.code_inline;
42
+ MarkdownIt.renderer.rules.code_inline = function(...args){
43
+ args[0][args[1]].attrJoin('class', 'code_inline');
44
+ return code_inline(...args)
45
+ };
46
+ return source
47
+ },
48
+ use: [
49
+ [MarkdownItContainer, 'demo', {
50
+ validate: params => params.trim().match(/^demo\s*(.*)$/),
51
+ render: function(tokens, idx) {
52
+ if (tokens[idx].nesting === 1) {
53
+ const html = convertHtml(striptags(tokens[idx + 1].content, 'script'));
54
+ // 移除描述,防止被添加到代码块
55
+ tokens[idx + 2].children = [];
56
+
57
+ return `<demo-block>
58
+ <div slot="desc">${html}</div>
59
+ <div slot="highlight">`;
60
+ }
61
+ return '</div></demo-block>\n';
62
+ }
63
+ }]
64
+ ]
65
+ };
66
+ const resolve = dir => path.join(__dirname, dir);
67
+ const packagesDir = resolve('packages');
68
+ module.exports = {
69
+ runtimeCompiler: true,
70
+ devServer: {
71
+ proxy: {
72
+ '/backend': {
73
+ target: 'http://10.10.14.64:8085',
74
+ changeOrigin: true,
75
+ pathRewrite: {
76
+ '^/backend': '/'
77
+ }
78
+ }
79
+ }
80
+ },
81
+ pages: {
82
+ index: {
83
+ entry: "examples/main.js",
84
+ template: "public/index.html",
85
+ filename: "index.html"
86
+ }
87
+ },
88
+ publicPath: process.env.NODE_ENV === 'production' ? '/vue-ui-demo/' : '/',
89
+ chainWebpack: config => {
90
+ config.resolve.alias
91
+ .set("@", path.resolve("examples"))
92
+ .set("~", path.resolve("packages"));
93
+ config.module
94
+ .rule("js")
95
+ .include.add("/packages")
96
+ .end()
97
+ .include.add("/examples")
98
+ .end()
99
+ .include.add("/api")
100
+ .end()
101
+ .use("babel")
102
+ .loader("babel-loader")
103
+ .end()
104
+ .use("vue-loader")
105
+ .loader("vue-loader")
106
+ .end()
107
+ config.module.rule("md")
108
+ .test(/\.md/)
109
+ .use("vue-loader")
110
+ .loader("vue-loader")
111
+ .end()
112
+ .use("vue-markdown-loader")
113
+ .loader("vue-markdown-loader/lib/markdown-compiler")
114
+ .options(vueMarkdown);
115
+ config.module.rule("vue")
116
+ .test(/\.vue/)
117
+ .use("vue-loader")
118
+ .loader("vue-loader")
119
+ },
120
+ outputDir:path.resolve(__dirname, 'lib'),
121
+ assetsDir: './',
122
+ publicPath:'../'
123
+ configureWebpack: {
124
+ entry: {
125
+ index: path.resolve(packagesDir, 'index.js'),
126
+ exam: path.resolve(packagesDir, 'exam/index.js'),
127
+ 'exam-drawer': path.resolve(packagesDir, 'exam-drawer/index.js'),
128
+ },
129
+ output: {
130
+ filename: 'packages/[name]/[name].js',
131
+ }
132
+ }
133
+ };
@@ -0,0 +1,132 @@
1
+ const path = require("path");
2
+ // const PrerenderSpaPlugin = require("prerender-spa-plugin");
3
+ const MarkdownItContainer = require("markdown-it-container");
4
+
5
+ const cheerio = require('cheerio');
6
+ const striptags = (str, tags) => {
7
+ const $ = cheerio.load(str, { decodeEntities: false })
8
+
9
+ if (!tags || tags.length === 0) {
10
+ return str
11
+ }
12
+
13
+ tags = !Array.isArray(tags) ? [tags] : tags;
14
+ let len = tags.length;
15
+
16
+ while (len--) {
17
+ $(tags[len]).remove()
18
+ }
19
+
20
+ return $.html()
21
+ };
22
+ const convertHtml = function (str) {
23
+ return str.replace(/(&#x)(\w{4});/gi, $0 => String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)))
24
+ };
25
+ const wrapCustomClass = function (render) {
26
+ return function (...args) {
27
+ return render(...args)
28
+ .replace('<code class="', '<code class="hljs ')
29
+ .replace('<code>', '<code class="hljs">')
30
+ }
31
+ };
32
+ const vueMarkdown = {
33
+ raw: true,
34
+ preprocess: (MarkdownIt, source) => {
35
+ MarkdownIt.renderer.rules.table_open = function () {
36
+ return '<table class="table">'
37
+ };
38
+ MarkdownIt.renderer.rules.fence = wrapCustomClass(MarkdownIt.renderer.rules.fence);
39
+
40
+ // ```code`` 给这种样式加个class code_inline
41
+ const code_inline = MarkdownIt.renderer.rules.code_inline;
42
+ MarkdownIt.renderer.rules.code_inline = function(...args){
43
+ args[0][args[1]].attrJoin('class', 'code_inline');
44
+ return code_inline(...args)
45
+ };
46
+ return source
47
+ },
48
+ use: [
49
+ [MarkdownItContainer, 'demo', {
50
+ validate: params => params.trim().match(/^demo\s*(.*)$/),
51
+ render: function(tokens, idx) {
52
+ if (tokens[idx].nesting === 1) {
53
+ const html = convertHtml(striptags(tokens[idx + 1].content, 'script'));
54
+ // 移除描述,防止被添加到代码块
55
+ tokens[idx + 2].children = [];
56
+
57
+ return `<demo-block>
58
+ <div slot="desc">${html}</div>
59
+ <div slot="highlight">`;
60
+ }
61
+ return '</div></demo-block>\n';
62
+ }
63
+ }]
64
+ ]
65
+ };
66
+ const resolve = dir => path.join(__dirname, dir);
67
+ const packagesDir = resolve('packages');
68
+ module.exports = {
69
+ runtimeCompiler: true,
70
+ devServer: {
71
+ proxy: {
72
+ '/backend': {
73
+ target: 'http://10.10.14.64:8085',
74
+ changeOrigin: true,
75
+ pathRewrite: {
76
+ '^/backend': '/'
77
+ }
78
+ }
79
+ }
80
+ },
81
+ pages: {
82
+ index: {
83
+ entry: "examples/main.js",
84
+ template: "public/index.html",
85
+ filename: "index.html"
86
+ }
87
+ },
88
+ publicPath: process.env.NODE_ENV === 'production' ? '/vue-ui-demo/' : '/',
89
+ chainWebpack: config => {
90
+ config.resolve.alias
91
+ .set("@", path.resolve("examples"))
92
+ .set("~", path.resolve("packages"));
93
+ config.module
94
+ .rule("js")
95
+ .include.add("/packages")
96
+ .end()
97
+ .include.add("/examples")
98
+ .end()
99
+ .include.add("/api")
100
+ .end()
101
+ .use("babel")
102
+ .loader("babel-loader")
103
+ .end()
104
+ .use("vue-loader")
105
+ .loader("vue-loader")
106
+ .end()
107
+ config.module.rule("md")
108
+ .test(/\.md/)
109
+ .use("vue-loader")
110
+ .loader("vue-loader")
111
+ .end()
112
+ .use("vue-markdown-loader")
113
+ .loader("vue-markdown-loader/lib/markdown-compiler")
114
+ .options(vueMarkdown);
115
+ config.module.rule("vue")
116
+ .test(/\.vue/)
117
+ .use("vue-loader")
118
+ .loader("vue-loader")
119
+ },
120
+ outputDir:path.resolve(__dirname, 'lib'),
121
+ publicPath:'../'
122
+ configureWebpack: {
123
+ entry: {
124
+ index: path.resolve(packagesDir, 'index.js'),
125
+ exam: path.resolve(packagesDir, 'exam/index.js'),
126
+ 'exam-drawer': path.resolve(packagesDir, 'exam-drawer/index.js'),
127
+ },
128
+ output: {
129
+ filename: 'packages/[name]/[name].js',
130
+ }
131
+ }
132
+ };
@@ -0,0 +1,132 @@
1
+ const path = require("path");
2
+ // const PrerenderSpaPlugin = require("prerender-spa-plugin");
3
+ const MarkdownItContainer = require("markdown-it-container");
4
+
5
+ const cheerio = require('cheerio');
6
+ const striptags = (str, tags) => {
7
+ const $ = cheerio.load(str, { decodeEntities: false })
8
+
9
+ if (!tags || tags.length === 0) {
10
+ return str
11
+ }
12
+
13
+ tags = !Array.isArray(tags) ? [tags] : tags;
14
+ let len = tags.length;
15
+
16
+ while (len--) {
17
+ $(tags[len]).remove()
18
+ }
19
+
20
+ return $.html()
21
+ };
22
+ const convertHtml = function (str) {
23
+ return str.replace(/(&#x)(\w{4});/gi, $0 => String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16)))
24
+ };
25
+ const wrapCustomClass = function (render) {
26
+ return function (...args) {
27
+ return render(...args)
28
+ .replace('<code class="', '<code class="hljs ')
29
+ .replace('<code>', '<code class="hljs">')
30
+ }
31
+ };
32
+ const vueMarkdown = {
33
+ raw: true,
34
+ preprocess: (MarkdownIt, source) => {
35
+ MarkdownIt.renderer.rules.table_open = function () {
36
+ return '<table class="table">'
37
+ };
38
+ MarkdownIt.renderer.rules.fence = wrapCustomClass(MarkdownIt.renderer.rules.fence);
39
+
40
+ // ```code`` 给这种样式加个class code_inline
41
+ const code_inline = MarkdownIt.renderer.rules.code_inline;
42
+ MarkdownIt.renderer.rules.code_inline = function(...args){
43
+ args[0][args[1]].attrJoin('class', 'code_inline');
44
+ return code_inline(...args)
45
+ };
46
+ return source
47
+ },
48
+ use: [
49
+ [MarkdownItContainer, 'demo', {
50
+ validate: params => params.trim().match(/^demo\s*(.*)$/),
51
+ render: function(tokens, idx) {
52
+ if (tokens[idx].nesting === 1) {
53
+ const html = convertHtml(striptags(tokens[idx + 1].content, 'script'));
54
+ // 移除描述,防止被添加到代码块
55
+ tokens[idx + 2].children = [];
56
+
57
+ return `<demo-block>
58
+ <div slot="desc">${html}</div>
59
+ <div slot="highlight">`;
60
+ }
61
+ return '</div></demo-block>\n';
62
+ }
63
+ }]
64
+ ]
65
+ };
66
+ const resolve = dir => path.join(__dirname, dir);
67
+ const packagesDir = resolve('packages');
68
+ module.exports = {
69
+ runtimeCompiler: true,
70
+ devServer: {
71
+ proxy: {
72
+ '/backend': {
73
+ target: 'http://10.10.14.64:8085',
74
+ changeOrigin: true,
75
+ pathRewrite: {
76
+ '^/backend': '/'
77
+ }
78
+ }
79
+ }
80
+ },
81
+ pages: {
82
+ index: {
83
+ entry: "examples/main.js",
84
+ template: "public/index.html",
85
+ filename: "index.html"
86
+ }
87
+ },
88
+ publicPath: process.env.NODE_ENV === 'production' ? '/vue-ui-demo/' : '/',
89
+ chainWebpack: config => {
90
+ config.resolve.alias
91
+ .set("@", path.resolve("examples"))
92
+ .set("~", path.resolve("packages"));
93
+ config.module
94
+ .rule("js")
95
+ .include.add("/packages")
96
+ .end()
97
+ .include.add("/examples")
98
+ .end()
99
+ .include.add("/api")
100
+ .end()
101
+ .use("babel")
102
+ .loader("babel-loader")
103
+ .end()
104
+ .use("vue-loader")
105
+ .loader("vue-loader")
106
+ .end()
107
+ config.module.rule("md")
108
+ .test(/\.md/)
109
+ .use("vue-loader")
110
+ .loader("vue-loader")
111
+ .end()
112
+ .use("vue-markdown-loader")
113
+ .loader("vue-markdown-loader/lib/markdown-compiler")
114
+ .options(vueMarkdown);
115
+ config.module.rule("vue")
116
+ .test(/\.vue/)
117
+ .use("vue-loader")
118
+ .loader("vue-loader")
119
+ },
120
+ outputDir:path.resolve(__dirname, 'lib'),
121
+ publicPath:'../',
122
+ configureWebpack: {
123
+ entry: {
124
+ index: path.resolve(packagesDir, 'index.js'),
125
+ exam: path.resolve(packagesDir, 'exam/index.js'),
126
+ 'exam-drawer': path.resolve(packagesDir, 'exam-drawer/index.js'),
127
+ },
128
+ output: {
129
+ filename: 'packages/[name]/[name].js',
130
+ }
131
+ }
132
+ };