vue2-client 1.8.394 → 1.8.395

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.394",
3
+ "version": "1.8.395",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
package/src/main.js CHANGED
@@ -4,10 +4,12 @@ import Router from 'vue-router'
4
4
  import Vuex from 'vuex'
5
5
  import { routerOptions, modules, i18n, message, bootstrap } from '../index'
6
6
  import eventLogPlugin from '@/plugins/EventLogPlugin'
7
+ import findParentData from '@/plugins/FindParentsData'
7
8
 
8
9
  Vue.use(Router)
9
10
  Vue.use(Vuex)
10
11
  Vue.use(eventLogPlugin)
12
+ Vue.use(findParentData)
11
13
 
12
14
  // 创建router store
13
15
  const store = new Vuex.Store({ modules })
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <div>
3
+ <button @click="useExampleMethod">Click Me</button>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ methods: {
10
+ useExampleMethod () {
11
+ console.log(this.$findParentData('experimentData'))
12
+ }
13
+ }
14
+ }
15
+ </script>
@@ -1,9 +1,27 @@
1
1
  <template>
2
- <router-view />
2
+ <div>
3
+ <router-view />
4
+ <child-index /> <!-- 添加 childIndex 组件 -->
5
+ </div>
3
6
  </template>
4
7
 
5
8
  <script>
9
+ import ChildIndex from './childIndex.vue' // 引入 ChildIndex 组件
10
+
6
11
  export default {
7
12
  name: 'Example',
13
+ components: {
14
+ ChildIndex, // 注册 ChildIndex 组件
15
+ },
16
+ data () {
17
+ return {
18
+ // 实验数据
19
+ experimentData: {
20
+ // 在这里添加您的实验数据
21
+ key1: 'value1',
22
+ key2: 'value2',
23
+ },
24
+ }
25
+ },
8
26
  }
9
27
  </script>
@@ -0,0 +1,17 @@
1
+ export default {
2
+ install (Vue) {
3
+ // 添加公共方法到 Vue 原型上
4
+ Vue.prototype.$findParentData = function (dataName) {
5
+ // 尝试从父组件获取数据
6
+ let parent = this.$parent
7
+ while (parent) {
8
+ const parentData = parent[dataName]
9
+ if (parentData !== undefined) {
10
+ return parentData // 找到返回数据
11
+ }
12
+ parent = parent.$parent // 继续向上寻找
13
+ }
14
+ return null // 如果没有找到,返回空
15
+ }
16
+ }
17
+ }
@@ -169,7 +169,8 @@ const loginGuard = (to, from, next, options) => {
169
169
  r: v4LoginData.r
170
170
  }
171
171
  Vue.$store.commit('account/setLogin', login)
172
- if (!Vue.$store.state?.setting?.menuData) {
172
+ console.log('Vue.$store.state?.setting?.menuData', JSON.stringify(Vue.$store.state?.setting?.menuData))
173
+ if (!Vue.$store.state?.setting?.menuData || Vue.$store.state?.setting?.menuData?.length === 0) {
173
174
  loadRoutes(funcToRouter(v4LoginData.functions))
174
175
  }
175
176
  next()