w-flow-vue 1.0.0

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 (144) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/AGENT.md +223 -0
  6. package/LICENSE +21 -0
  7. package/README.md +37 -0
  8. package/SECURITY.md +5 -0
  9. package/babel.config.js +16 -0
  10. package/dist/w-flow-vue.umd.js +15 -0
  11. package/dist/w-flow-vue.umd.js.map +1 -0
  12. package/docs/components_WFlowVue.vue.html +1214 -0
  13. package/docs/examples/app.html +62 -0
  14. package/docs/examples/app.umd.js +20 -0
  15. package/docs/examples/app.umd.js.map +1 -0
  16. package/docs/examples/ex-AppBasic.html +440 -0
  17. package/docs/examples/ex-AppConnectivity.html +131 -0
  18. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  21. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  22. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  23. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  24. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  25. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  31. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  32. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  36. package/docs/global.html +1919 -0
  37. package/docs/index.html +84 -0
  38. package/docs/js_defaults.mjs.html +105 -0
  39. package/docs/js_edge-path.mjs.html +237 -0
  40. package/docs/js_geometry.mjs.html +298 -0
  41. package/docs/js_graph.mjs.html +103 -0
  42. package/docs/js_step-routing.mjs.html +346 -0
  43. package/docs/module-WFlowVue.html +2790 -0
  44. package/docs/scripts/collapse.js +39 -0
  45. package/docs/scripts/commonNav.js +28 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +99 -0
  53. package/docs/styles/jsdoc.css +776 -0
  54. package/docs/styles/prettify.css +80 -0
  55. package/jest.config.js +20 -0
  56. package/package.json +80 -0
  57. package/public/index.html +38 -0
  58. package/script.txt +22 -0
  59. package/src/App.vue +326 -0
  60. package/src/AppBasic.vue +125 -0
  61. package/src/AppConnectivity.vue +186 -0
  62. package/src/components/WFlowVue.vue +1142 -0
  63. package/src/components/canvas/BackgroundLayer.vue +78 -0
  64. package/src/components/canvas/FlowCanvas.vue +64 -0
  65. package/src/components/canvas/SelectionBox.vue +36 -0
  66. package/src/components/canvas/ViewportTransform.vue +35 -0
  67. package/src/components/edges/ConnectionLine.vue +65 -0
  68. package/src/components/edges/EdgeMarkerDefs.vue +76 -0
  69. package/src/components/edges/EdgeRenderer.vue +120 -0
  70. package/src/components/edges/EdgeWrapper.vue +379 -0
  71. package/src/components/nodes/DefaultNode.vue +276 -0
  72. package/src/components/nodes/Handle.vue +101 -0
  73. package/src/components/nodes/InputNode.vue +47 -0
  74. package/src/components/nodes/NodeBody.vue +103 -0
  75. package/src/components/nodes/NodeFace.vue +128 -0
  76. package/src/components/nodes/NodeRenderer.vue +95 -0
  77. package/src/components/nodes/NodeWrapper.vue +475 -0
  78. package/src/components/nodes/OutputNode.vue +47 -0
  79. package/src/components/ui/ConnSettingsForm.vue +158 -0
  80. package/src/components/ui/Controls.vue +83 -0
  81. package/src/components/ui/NodeSettingsForm.vue +185 -0
  82. package/src/js/defaults.mjs +33 -0
  83. package/src/js/edge-path.mjs +165 -0
  84. package/src/js/geometry.mjs +226 -0
  85. package/src/js/graph.mjs +31 -0
  86. package/src/js/step-routing.mjs +274 -0
  87. package/src/main.js +22 -0
  88. package/test/WFlowVue-features.test.mjs +760 -0
  89. package/test/WFlowVue.test.mjs +421 -0
  90. package/test/components-canvas.test.mjs +102 -0
  91. package/test/components-edge.test.mjs +147 -0
  92. package/test/components-node.test.mjs +174 -0
  93. package/test/components-ui.test.mjs +69 -0
  94. package/test/defaults.test.mjs +86 -0
  95. package/test/edge-path.test.mjs +102 -0
  96. package/test/generate-routing-snapshots.mjs +77 -0
  97. package/test/generate-visual-baselines.mjs +206 -0
  98. package/test/geometry.test.mjs +236 -0
  99. package/test/graph.test.mjs +72 -0
  100. package/test/jsons/routing-snapshots.json +24994 -0
  101. package/test/pics/_check2.png +0 -0
  102. package/test/pics/_check3.png +0 -0
  103. package/test/pics/_check4.png +0 -0
  104. package/test/pics/_check5.png +0 -0
  105. package/test/pics/_v1.png +0 -0
  106. package/test/pics/_v2.png +0 -0
  107. package/test/pics/_v3.png +0 -0
  108. package/test/pics/_v4.png +0 -0
  109. package/test/pics/_v5.png +0 -0
  110. package/test/pics/_v6.png +0 -0
  111. package/test/pics/_v7.png +0 -0
  112. package/test/pics/vb-edge-hovered.png +0 -0
  113. package/test/pics/vb-edges-normal.png +0 -0
  114. package/test/pics/vb-locked-edge-hovered.png +0 -0
  115. package/test/pics/vb-locked-node-hovered.png +0 -0
  116. package/test/pics/vb-locked-node-selected.png +0 -0
  117. package/test/pics/vb-locked-overview.png +0 -0
  118. package/test/pics/vb-node-1.png +0 -0
  119. package/test/pics/vb-node-10.png +0 -0
  120. package/test/pics/vb-node-11.png +0 -0
  121. package/test/pics/vb-node-12.png +0 -0
  122. package/test/pics/vb-node-2.png +0 -0
  123. package/test/pics/vb-node-3.png +0 -0
  124. package/test/pics/vb-node-4.png +0 -0
  125. package/test/pics/vb-node-5.png +0 -0
  126. package/test/pics/vb-node-6.png +0 -0
  127. package/test/pics/vb-node-7.png +0 -0
  128. package/test/pics/vb-node-8.png +0 -0
  129. package/test/pics/vb-node-9.png +0 -0
  130. package/test/pics/vb-node-hovered.png +0 -0
  131. package/test/pics/vb-node-selected.png +0 -0
  132. package/test/pics/vb-overview.png +0 -0
  133. package/test/step-routing-connectivity.test.mjs +78 -0
  134. package/test/step-routing.test.mjs +88 -0
  135. package/test/visual-regression.test.mjs +274 -0
  136. package/toolg/addVersion.mjs +4 -0
  137. package/toolg/cleanFolder.mjs +4 -0
  138. package/toolg/gDistApp.mjs +34 -0
  139. package/toolg/gDistRollupComps.mjs +22 -0
  140. package/toolg/gDocExams.mjs +47 -0
  141. package/toolg/gExtractHtml.mjs +179 -0
  142. package/toolg/modifyReadme.mjs +4 -0
  143. package/vue.config.js +9 -0
  144. package/vue2/344/271/213foreignObject/345/205/247/346/270/262/346/237/223/345/225/217/351/241/214/350/210/207/344/277/256/346/255/243.md +151 -0
@@ -0,0 +1,80 @@
1
+ .pln {
2
+ color: #ddd;
3
+ }
4
+
5
+ /* string content */
6
+ .str {
7
+ color: #61ce3c;
8
+ }
9
+
10
+ /* a keyword */
11
+ .kwd {
12
+ color: #fbde2d;
13
+ }
14
+
15
+ /* a comment */
16
+ .com {
17
+ color: #aeaeae;
18
+ }
19
+
20
+ /* a type name */
21
+ .typ {
22
+ color: #8da6ce;
23
+ }
24
+
25
+ /* a literal value */
26
+ .lit {
27
+ color: #fbde2d;
28
+ }
29
+
30
+ /* punctuation */
31
+ .pun {
32
+ color: #ddd;
33
+ }
34
+
35
+ /* lisp open bracket */
36
+ .opn {
37
+ color: #000000;
38
+ }
39
+
40
+ /* lisp close bracket */
41
+ .clo {
42
+ color: #000000;
43
+ }
44
+
45
+ /* a markup tag name */
46
+ .tag {
47
+ color: #8da6ce;
48
+ }
49
+
50
+ /* a markup attribute name */
51
+ .atn {
52
+ color: #fbde2d;
53
+ }
54
+
55
+ /* a markup attribute value */
56
+ .atv {
57
+ color: #ddd;
58
+ }
59
+
60
+ /* a declaration */
61
+ .dec {
62
+ color: #EF5050;
63
+ }
64
+
65
+ /* a variable name */
66
+ .var {
67
+ color: #c82829;
68
+ }
69
+
70
+ /* a function name */
71
+ .fun {
72
+ color: #4271ae;
73
+ }
74
+
75
+ /* Specify class=linenums on a pre to get line numbering */
76
+ ol.linenums {
77
+ margin-top: 0;
78
+ margin-bottom: 0;
79
+ padding-bottom: 2px;
80
+ }
package/jest.config.js ADDED
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ testEnvironment: 'jsdom',
3
+ roots: ['<rootDir>/test'],
4
+ testMatch: ['**/*.test.mjs'],
5
+ testPathIgnorePatterns: ['/node_modules/', 'visual-regression\\.test\\.mjs', 'generate-visual-baselines\\.mjs'],
6
+ moduleFileExtensions: ['mjs', 'js', 'json', 'vue'],
7
+ transform: {
8
+ '^.+\\.vue$': '@vue/vue2-jest',
9
+ '^.+\\.m?js$': 'babel-jest',
10
+ },
11
+ transformIgnorePatterns: [
12
+ 'node_modules/(?!(w-component-vue|wsemi|w-jsonview-tree|lodash-es|@popperjs|@mdi)/)',
13
+ ],
14
+ moduleNameMapper: {
15
+ '^@/(.*)$': '<rootDir>/src/$1',
16
+ },
17
+ collectCoverageFrom: [
18
+ 'src/**/*.{mjs,vue}',
19
+ ],
20
+ }
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "w-flow-vue",
3
+ "version": "1.0.0",
4
+ "main": "dist/w-flow-vue.umd.js",
5
+ "dependencies": {
6
+ "@mdi/js": "^7.4.47",
7
+ "lodash-es": "^4.18.1",
8
+ "w-component-vue": "^2.4.49",
9
+ "w-jsonview-tree": "^1.0.31",
10
+ "wsemi": "^1.8.45"
11
+ },
12
+ "devDependencies": {
13
+ "@vue/cli-plugin-babel": "^5.0.8",
14
+ "@vue/cli-plugin-eslint": "^5.0.8",
15
+ "@vue/cli-service": "^5.0.8",
16
+ "@vue/test-utils": "^1.3.6",
17
+ "@vue/vue2-jest": "^29.2.6",
18
+ "babel-jest": "^29.7.0",
19
+ "cheerio": "^1.2.0",
20
+ "eslint": "^8.37.0",
21
+ "eslint-config-standard": "^17.1.0",
22
+ "eslint-friendly-formatter": "^4.0.1",
23
+ "eslint-plugin-import": "^2.27.5",
24
+ "eslint-plugin-n": "^16.6.2",
25
+ "eslint-plugin-promise": "^6.1.1",
26
+ "eslint-plugin-vue": "^9.10.0",
27
+ "jest": "^29.7.0",
28
+ "jest-environment-jsdom": "^29.7.0",
29
+ "playwright": "^1.59.1",
30
+ "pngjs": "^7.0.0",
31
+ "vue": "^2.6.14",
32
+ "w-package-tools": "^1.1.5"
33
+ },
34
+ "scripts": {
35
+ "serve": "vue-cli-service serve",
36
+ "build": "vue-cli-service build",
37
+ "test": "jest",
38
+ "test:visual": "node test/visual-regression.test.mjs",
39
+ "test:visual:update": "node test/generate-visual-baselines.mjs",
40
+ "lint": "vue-cli-service lint",
41
+ "deploy": "gh-pages -d docs"
42
+ },
43
+ "eslintConfig": {
44
+ "root": true,
45
+ "env": {
46
+ "node": true
47
+ },
48
+ "extends": [
49
+ "plugin:vue/essential",
50
+ "eslint:recommended"
51
+ ],
52
+ "rules": {},
53
+ "parserOptions": {
54
+ "parser": "babel-eslint"
55
+ }
56
+ },
57
+ "postcss": {
58
+ "plugins": {
59
+ "autoprefixer": {}
60
+ }
61
+ },
62
+ "browserslist": [
63
+ "> 1%",
64
+ "last 2 versions"
65
+ ],
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/yuda-lyu/w-flow-vue.git"
69
+ },
70
+ "keywords": [
71
+ "component",
72
+ "vue",
73
+ "three.js",
74
+ "model",
75
+ "stl",
76
+ "3d"
77
+ ],
78
+ "author": "yuda-lyu(semisphere)",
79
+ "license": "MIT"
80
+ }
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <title>w-flow-vue</title>
8
+
9
+ <!-- @vue-cli動添加@babel/polyfill與vue -->
10
+
11
+ <!-- fontawesome -->
12
+ <link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css" rel="stylesheet">
13
+
14
+ <!-- mdi, 各組件使用mdi/js會於轉單頁時改為mdi icon, 故需引用mdi/css -->
15
+ <link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
16
+
17
+ <!-- google font -->
18
+ <link _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
19
+ <link _href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
20
+
21
+ <!-- lodash -->
22
+ <script src="https://cdn.jsdelivr.net/npm/lodash/lodash.min.js"></script>
23
+
24
+ <!-- wsemi -->
25
+ <script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.min.js"></script>
26
+
27
+ </head>
28
+ <body style="font-family:'Microsoft JhengHei','Avenir','Helvetica'; padding:0px; margin:0px;">
29
+ <noscript>
30
+ <strong
31
+ >We're sorry but w-flow-vue doesn't work properly without
32
+ JavaScript enabled. Please enable it to continue.</strong
33
+ >
34
+ </noscript>
35
+ <div id="app"></div>
36
+ <!-- built files will be auto injected -->
37
+ </body>
38
+ </html>
package/script.txt ADDED
@@ -0,0 +1,22 @@
1
+ #node toolg/addVersion.mjs
2
+ node toolg/modifyReadme.mjs
3
+
4
+ node toolg/cleanFolder.mjs
5
+ ./node_modules/.bin/jsdoc -c .jsdoc
6
+
7
+ node toolg/gDistApp.mjs
8
+
9
+ node toolg/gExtractHtml.mjs
10
+ node toolg/gDocExams.mjs
11
+
12
+ node toolg/gDistRollupComps.mjs
13
+
14
+ git add . -A
15
+ git commit -m 'modify: '
16
+ git push origin master:master
17
+
18
+ npm run deploy
19
+
20
+ #npm test
21
+
22
+ #npm publish
package/src/App.vue ADDED
@@ -0,0 +1,326 @@
1
+ <template>
2
+ <div
3
+ style=""
4
+ :changeMenus="changeMenus"
5
+ >
6
+
7
+
8
+ <template v-if="!isNarrow">
9
+ <a href="https://github.com/yuda-lyu/w-flow-vue" class="github-corner" style="position:fixed; top:0; right:0; border:0; z-index:10000;" aria-label="View source on GitHub" target="_blank" rel="noreferrer noopener">
10
+ <svg width="80" height="80" viewBox="0 0 250 250" style="fill:rgba(0,0,0,0.25); color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg>
11
+ </a>
12
+ </template>
13
+
14
+
15
+ <div style="background:#f5f5f5;">
16
+
17
+ <div style="width:calc( 100vw - 20px ); overflow-x:auto;" v-if="cmpsL1 && cmpsL1.length>0">
18
+ <WListHorizontal
19
+ :items="cmpsL1"
20
+ :itemActive.sync="cmpP1"
21
+ :itemBackgroundColor="'transparent'"
22
+ :itemBackgroundColorHover="'#eee'"
23
+ :itemBackgroundColorActive="'#eee'"
24
+ :keyText="'name'"
25
+ :paddingStyle="{v:12,h:20}"
26
+ @update:itemActive="(v)=>{indP3=0;indP2=0;indP1=getInd(v,cmpsL1)}"
27
+ >
28
+ <template v-slot:item="props">
29
+ <div style="">
30
+ {{props.item.name}}
31
+ </div>
32
+ </template>
33
+ </WListHorizontal>
34
+ <div style="height:1px; background:#ddd;"></div>
35
+ </div>
36
+
37
+
38
+ <div style="width:calc( 100vw - 20px ); overflow-x:auto;" v-if="cmpsL2 && cmpsL2.length>0">
39
+ <div style="height:3px; background:#fff;"></div>
40
+ <WListHorizontal
41
+ :items="cmpsL2"
42
+ :itemActive.sync="cmpP2"
43
+ :itemBackgroundColor="'transparent'"
44
+ :itemBackgroundColorHover="'#eee'"
45
+ :itemBackgroundColorActive="'#eee'"
46
+ :keyText="'name'"
47
+ :paddingStyle="{v:12,h:20}"
48
+ @update:itemActive="(v)=>{indP3=0;indP2=getInd(v,cmpsL2)}"
49
+ >
50
+ <template v-slot:item="props">
51
+ <div style="">
52
+ {{props.item.name}}
53
+ </div>
54
+ </template>
55
+ </WListHorizontal>
56
+ <div style="height:1px; background:#ddd;"></div>
57
+ </div>
58
+
59
+ <div style="width:calc( 100vw - 20px ); overflow-x:auto;" v-if="cmpsL3 && cmpsL3.length>0">
60
+ <div style="height:3px; background:#fff;"></div>
61
+ <WListHorizontal
62
+ :items="cmpsL3"
63
+ :itemActive.sync="cmpP3"
64
+ :itemBackgroundColor="'transparent'"
65
+ :itemBackgroundColorHover="'#eee'"
66
+ :itemBackgroundColorActive="'#eee'"
67
+ :keyText="'name'"
68
+ :paddingStyle="{v:12,h:20}"
69
+ @update:itemActive="(v)=>{indP3=getInd(v,cmpsL3)}"
70
+ >
71
+ <template v-slot:item="props">
72
+ <div style="">
73
+ {{props.item.name}}
74
+ </div>
75
+ </template>
76
+ </WListHorizontal>
77
+ <div style="height:1px; background:#ddd;"></div>
78
+ </div>
79
+
80
+ </div>
81
+
82
+
83
+ <div class="bkh">
84
+
85
+ <AppBasic v-if="cmpPick==='size'"></AppBasic>
86
+ <AppConnectivity v-if="cmpPick==='connectivity'"></AppConnectivity>
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+ </template>
93
+
94
+ <script>
95
+ import get from 'lodash-es/get.js'
96
+ import each from 'lodash-es/each.js'
97
+ // import cloneDeep from 'lodash-es/cloneDeep.js'
98
+ import urlParse from 'wsemi/src/urlParse.mjs'
99
+ import WListHorizontal from 'w-component-vue/src/components/WListHorizontal.vue'
100
+ import AppBasic from './AppBasic.vue'
101
+ import AppConnectivity from './AppConnectivity.vue'
102
+
103
+
104
+ export default {
105
+ components: {
106
+ WListHorizontal,
107
+ AppBasic,
108
+ AppConnectivity,
109
+ },
110
+ data: function() {
111
+ let cmps = [
112
+ {
113
+ name: 'basic',
114
+ cmps: [
115
+ { name: 'size' },
116
+ { name: 'connectivity' },
117
+ ],
118
+ },
119
+ ]
120
+ return {
121
+
122
+ cmpsL1: cmps,
123
+ indP1: null,
124
+ cmpP1: null,
125
+
126
+ cmpsL2: null,
127
+ indP2: null,
128
+ cmpP2: null,
129
+
130
+ cmpsL3: null,
131
+ indP3: null,
132
+ cmpP3: null,
133
+
134
+ cmpsL4: null,
135
+
136
+ cmpPick: '',
137
+
138
+ }
139
+ },
140
+ mounted: function() {
141
+ let vo = this
142
+
143
+ //default
144
+ vo.indP1 = 0
145
+ vo.indP2 = 0
146
+ vo.indP3 = 0
147
+
148
+ //urlParse, http://localhost:8080/?cmp=w-set-multi
149
+ let p = urlParse(location.href)
150
+ // console.log('p', p)
151
+
152
+ //viewPick
153
+ vo.viewPick(get(p, 'cmp', ''))
154
+
155
+ },
156
+ computed: {
157
+
158
+ changeMenus: function() {
159
+ let vo = this
160
+ vo.modifyMenus(vo.indP1, vo.indP2, vo.indP3)
161
+ return ''
162
+ },
163
+
164
+ isNarrow: function() {
165
+ return window.innerWidth < 1000
166
+ },
167
+
168
+ },
169
+ methods: {
170
+
171
+ modifyMenus: function() {
172
+ let vo = this
173
+
174
+ let cmpPick = ''
175
+
176
+ setTimeout(() => {
177
+
178
+ // console.log('call P1')
179
+ vo.cmpP1 = get(vo.cmpsL1, vo.indP1, {})
180
+ vo.cmpsL2 = get(vo.cmpP1, `cmps`, [])
181
+ let _cmpPick = get(vo.cmpP1, `name`, '')
182
+ if (_cmpPick) {
183
+ cmpPick = _cmpPick
184
+ }
185
+ // console.log('vo.cmpP1', cloneDeep(vo.cmpP1))
186
+ // console.log('vo.cmpsL2', cloneDeep(vo.cmpsL2))
187
+
188
+ }, 50)
189
+
190
+ setTimeout(() => {
191
+
192
+ // console.log('call P2')
193
+ let cmps = get(vo.cmpP1, `cmps`, [])
194
+ vo.cmpP2 = get(cmps, vo.indP2, {})
195
+ vo.cmpsL3 = get(vo.cmpP2, `cmps`, [])
196
+ let _cmpPick = get(vo.cmpP2, `name`, '')
197
+ if (_cmpPick) {
198
+ cmpPick = _cmpPick
199
+ }
200
+ // console.log('vo.cmpP2', cloneDeep(vo.cmpP2))
201
+ // console.log('vo.cmpsL3', cloneDeep(vo.cmpsL3))
202
+
203
+ }, 100)
204
+
205
+ setTimeout(() => {
206
+
207
+ // console.log('call P3')
208
+ let cmps = get(vo.cmpP2, `cmps`, [])
209
+ vo.cmpP3 = get(cmps, vo.indP3, {})
210
+ vo.cmpsL4 = get(vo.cmpP3, `cmps`, [])
211
+ let _cmpPick = get(vo.cmpP3, `name`, '')
212
+ if (_cmpPick) {
213
+ cmpPick = _cmpPick
214
+ }
215
+ // console.log('vo.cmpP3', cloneDeep(vo.cmpP3))
216
+ // console.log('vo.cmpsL4', cloneDeep(vo.cmpsL4))
217
+
218
+ //update
219
+ vo.cmpPick = cmpPick
220
+ // console.log('cmpPick', cmpPick)
221
+
222
+ }, 150)
223
+
224
+ },
225
+
226
+ getInd: function(item, items) {
227
+ // let vo = this
228
+ let ind = -1
229
+ each(items, (v, k) => {
230
+ if (item.name === v.name) {
231
+ ind = k
232
+ return false //跳出
233
+ }
234
+ })
235
+ return ind
236
+ },
237
+
238
+ viewPick: function(cmpPick) {
239
+ let vo = this
240
+ let _cmpPick = cmpPick
241
+ let r = ''
242
+ let rs = []
243
+ let ls = []
244
+ let pv = (ts) => {
245
+ each(ts, (v, k) => {
246
+ ls.push(k)
247
+
248
+ //name, _name
249
+ let name = get(v, `name`, '')
250
+ let _name = name
251
+
252
+ //cmps
253
+ let cmps = get(v, `cmps`, [])
254
+
255
+ //push
256
+ let cls = ls.join('.')
257
+ let b = _name === _cmpPick
258
+ rs.push({
259
+ cls,
260
+ name,
261
+ b,
262
+ })
263
+
264
+ //save
265
+ if (b) {
266
+ r = JSON.parse(JSON.stringify(ls))
267
+ }
268
+
269
+ //遞迴pv
270
+ if (cmps.length > 0) {
271
+ pv(cmps)
272
+ }
273
+
274
+ ls.pop()
275
+ })
276
+ }
277
+ pv(vo.cmpsL1)
278
+ // console.log('rs', rs)
279
+ // console.log('r', r)
280
+ vo.indP1 = get(r, 0, 0)
281
+ vo.indP2 = get(r, 1, 0)
282
+ vo.indP3 = get(r, 2, 0)
283
+ },
284
+
285
+ },
286
+ }
287
+ </script>
288
+
289
+ <style>
290
+ .item-link {
291
+ display: inline-block;
292
+ margin: 10px 10px 0px 0px;
293
+ padding: 5px 10px;
294
+ font-size: 0.8rem;
295
+ color: #fff;
296
+ background-color: #443a65;
297
+ cursor: pointer;
298
+ text-decoration: none;
299
+ }
300
+ .bkh { /* 寬 */
301
+ padding:20px;
302
+ }
303
+ @media screen and (max-width:800px){ /* 中 */
304
+ .bkh {
305
+ padding:10px;
306
+ }
307
+ }
308
+ @media screen and (max-width:400px){ /* 窄 */
309
+ .bkh {
310
+ padding:5px;
311
+ }
312
+ }
313
+ .bkp { /* 寬 */
314
+ padding:0px 20px;
315
+ }
316
+ @media screen and (max-width:800px){ /* 中 */
317
+ .bkp {
318
+ padding:0px 10px;
319
+ }
320
+ }
321
+ @media screen and (max-width:400px){ /* 窄 */
322
+ .bkp {
323
+ padding:0px 5px;
324
+ }
325
+ }
326
+ </style>