Skip to content

Commit b320482

Browse files
authored
Merge pull request #43 from CurryPaste/main
npm update
2 parents 05d6594 + 5ca0a08 commit b320482

18 files changed

Lines changed: 478 additions & 73 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
/dist
4+
/.github
45

56

67
# local env files
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template lang="pug">
2+
div
3+
//- breadcrumb(seprator="/")
4+
breadcrumb-item(v-for="(route,index) in breadList",:key="route.breadcrumbName")
5+
router-link(:to="route.path",@click.native="handleClick(route,index)") {{route.breadcrumbName}}
6+
</template>
7+
8+
<script lang="ts">
9+
import {
10+
computed, defineComponent, onMounted, toRaw,
11+
} from 'vue';
12+
import { useStore, mapActions } from 'vuex';
13+
import { Breadcrumb } from 'ant-design-vue';
14+
import { useRoute } from 'vue-router';
15+
import getDefaultRoutes from '@/router/defaultRoutes';
16+
import { Bread } from '@/types/base';
17+
import { UserRole } from '@/types/user';
18+
19+
export default defineComponent({
20+
components: {
21+
breadcrumb: Breadcrumb,
22+
'breadcrumb-item': Breadcrumb.Item,
23+
},
24+
25+
setup() {
26+
const route = useRoute();
27+
const store = useStore();
28+
const { init, splice, clear } = mapActions('breadcrumb', ['init', 'splice', 'clear']);
29+
const breadList = computed(() => store.state.breadcrumb.breadList);
30+
const role = sessionStorage.getItem('role') as UserRole | null;
31+
32+
function handleClick(r: Bread, bIndex: number) {
33+
if (bIndex < breadList.value.length - 1) {
34+
// splice(bIndex + 1);
35+
store.dispatch('breadcrumb/splice', bIndex + 1);
36+
}
37+
}
38+
39+
const selfMounted = async () => {
40+
// await init();
41+
store.dispatch('breadcrumb/init');
42+
const list = getDefaultRoutes(role);
43+
if (list.find((r) => r.path === route.path)) {
44+
// clear();
45+
store.dispatch('breadcrumb/clear');
46+
}
47+
48+
// 未点击面包屑时,自动删除不需要的 面包屑
49+
const { path } = route;
50+
const index = breadList.value.findIndex((p) => p.path.includes(path));
51+
if (index > -1) {
52+
// splice(index + 1);
53+
store.dispatch('breadcrumb/splice', index + 1);
54+
}
55+
};
56+
57+
onMounted(() => {
58+
console.log(getDefaultRoutes(role), 'list', role, 'role');
59+
selfMounted();
60+
console.log(toRaw(breadList.value));
61+
});
62+
63+
return {
64+
breadList,
65+
handleClick,
66+
};
67+
},
68+
});
69+
</script>
70+
71+
<style lang="stylus" scoped>
72+
.bcr-wrap
73+
font-size 14px
74+
</style>

generator/template/src/components/Breadcrumb.vue

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ div
66
</template>
77

88
<script lang="ts">
9-
import { computed, defineComponent } from 'vue';
9+
import { computed, defineComponent, onMounted } from 'vue';
1010
import { useStore, mapActions } from 'vuex';
1111
import { Breadcrumb } from 'ant-design-vue';
1212
import { useRoute } from 'vue-router';
@@ -16,8 +16,8 @@ import { UserRole } from '@/types/user';
1616
1717
export default defineComponent({
1818
components: {
19-
breadcrumb: Breadcrumb,
20-
'breadcrumb-item': Breadcrumb.Item,
19+
aBreadcrumb: Breadcrumb,
20+
aBreadcrumbItem: Breadcrumb.Item,
2121
},
2222
2323
setup() {
@@ -29,22 +29,36 @@ export default defineComponent({
2929
3030
function handleClick(r: Bread, bIndex: number) {
3131
if (bIndex < breadList.value.length - 1) {
32-
splice(bIndex + 1);
32+
// splice(bIndex + 1);
33+
store.dispatch('breadcrumb/splice', bIndex + 1);
3334
}
3435
}
3536
36-
init();
37-
const list = getDefaultRoutes(role);
38-
if (list.find((r) => r.path === route.path)) {
39-
clear();
40-
}
37+
const selfMounted = () => {
38+
// init();
39+
store.dispatch('breadcrumb/init');
40+
const list = getDefaultRoutes(role);
41+
if (list.find((r) => r.path === route.path)) {
42+
// clear();
43+
store.dispatch('breadcrumb/clear');
44+
}
4145
42-
// 未点击面包屑时,自动删除不需要的 面包屑
43-
const { path } = route;
44-
const index = breadList.value.findIndex((p) => p.path.includes(path));
45-
if (index > -1) {
46-
splice(index + 1);
47-
}
46+
// 未点击面包屑时,自动删除不需要的 面包屑
47+
const { path } = route;
48+
const index = breadList.value.findIndex((p) => p.path.includes(path));
49+
if (index > -1) {
50+
// splice(index + 1);
51+
store.dispatch('breadcrumb/splice', index + 1);
52+
}
53+
};
54+
onMounted(() => {
55+
selfMounted();
56+
});
57+
58+
return {
59+
handleClick,
60+
breadList,
61+
};
4862
},
4963
});
5064
</script>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<template lang="pug">
2+
div
3+
a-breadcrumb(seprator="/")
4+
a-breadcrumb-item(v-for="(route,index) in breadList",:key="route.breadcrumbName")
5+
router-link(:to="route.path",@click.native="handleClick(route,index)") {{route.breadcrumbName}}
6+
</template>
7+
8+
<script lang="ts">
9+
/**
10+
* 方案
11+
* 1、通过路由文件的子父级关系确定面包屑的显示。即通过路由地址在路由文件中获得到子父关系
12+
* 2、面包屑的层级关系,直接手动操作。
13+
* ——面包屑显示的时候,只需要根据list直接显示就可以,不需要考虑路由的层级关系
14+
* # 每次加载从storage里取,然后再渲染——init——为了处理刷新情况
15+
* # 在组件调用时,向list中添加
16+
* # 点击时,删除后面的
17+
*/
18+
import {
19+
computed, defineComponent, onMounted,
20+
} from 'vue';
21+
import { useStore } from 'vuex';
22+
import { Breadcrumb } from 'ant-design-vue';
23+
import { useRoute } from 'vue-router';
24+
// import getDefaultRoutes from '@/router/defaultRoutes';
25+
import { Bread } from '@/types/base';
26+
// import { UserRole } from '@/types/user';
27+
28+
export default defineComponent({
29+
components: {
30+
aBreadcrumb: Breadcrumb,
31+
aBreadcrumbItem: Breadcrumb.Item,
32+
},
33+
34+
setup() {
35+
const route = useRoute();
36+
const store = useStore();
37+
const breadList = computed(() => store.state.breadcrumb.breadList);
38+
// const role = sessionStorage.getItem('role') as UserRole | null;
39+
40+
function handleClick(r: Bread, bIndex: number) {
41+
if (bIndex < breadList.value.length - 1) {
42+
// splice(bIndex + 1);
43+
store.dispatch('breadcrumb/splice', bIndex);
44+
}
45+
}
46+
47+
const selfMounted = async () => {
48+
// await init();
49+
store.dispatch('breadcrumb/init');
50+
// console.log('init', toRaw(breadList.value));
51+
// const list = getDefaultRoutes(role);
52+
// if (list.find((r) => r.path === route.path)) {
53+
// // clear();
54+
// store.dispatch('breadcrumb/clear');
55+
// }
56+
// console.log('clear', toRaw(breadList.value));
57+
58+
// 未点击面包屑时,自动删除不需要的 面包屑
59+
const { path } = route;
60+
const index = breadList.value.findIndex((p) => p.path.includes(path));
61+
if (index > -1) {
62+
// splice(index + 1);
63+
store.dispatch('breadcrumb/splice', index);
64+
}
65+
66+
/** 开始处理面包值 */
67+
store.dispatch('breadcrumb/push', {
68+
breadcrumbName: '实验管理',
69+
path: route.path,
70+
});
71+
// console.log('splice', toRaw(breadList.value));
72+
};
73+
onMounted(() => {
74+
selfMounted();
75+
});
76+
77+
return {
78+
handleClick,
79+
breadList,
80+
};
81+
},
82+
});
83+
</script>
84+
85+
<style lang="stylus" scoped>
86+
.bcr-wrap
87+
font-size 14px
88+
</style>

generator/template/src/components/Fluctuation.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
)
1010
span.unit-box {{ unit }}
1111
transition(name='lotus')
12-
p.fluctuating-animate(v-show="isShow") {{ changeValue }}
12+
p.fluctuating-animate(v-show="isShow" :style='{color: `${changeValue > 0 ? plusColor : reduceColor}`}') {{ changeValue }}
1313
</template>
1414

1515
<script lang="ts">
@@ -40,6 +40,14 @@ export default defineComponent({
4040
type: Number,
4141
default: 500,
4242
},
43+
plusColor: {
44+
type: String,
45+
default: 'red',
46+
},
47+
reduceColor: {
48+
typp: String,
49+
default: 'limegreen',
50+
},
4351
},
4452
setup(props) {
4553
/** var */

generator/template/src/components/Public/DigitalTransform/DigitalTransfromScroll.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default defineComponent({
3535
setup(props) {
3636
/** var */
3737
const listRef = ref(null);
38-
const digitals = ref([',', '.', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0']);
38+
const digitals = ref(['-', ',', '.', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0']);
3939
const listHeight = ref(0);
4040
const spacing = ref(1);
4141
const listStyle = computed(() => ({

generator/template/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
declare module '@findsoft/vue-fluctuation';
22
declare module 'to-top-vue';
3+
declare module 'vue-cropperjs';
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
/* eslint-disable no-console */
1+
// /* eslint-disable no-console */
22

3-
import { register } from 'register-service-worker';
3+
// import { register } from 'register-service-worker';
44

5-
if (process.env.NODE_ENV === 'production') {
6-
register(`${process.env.BASE_URL}service-worker.js`, {
7-
ready() {
8-
console.log(
9-
'App is being served from cache by a service worker.\n'
10-
+ 'For more details, visit https://goo.gl/AFskqB',
11-
);
12-
},
13-
registered() {
14-
console.log('Service worker has been registered.');
15-
},
16-
cached() {
17-
console.log('Content has been cached for offline use.');
18-
},
19-
updatefound() {
20-
console.log('New content is downloading.');
21-
},
22-
updated() {
23-
console.log('New content is available; please refresh.');
24-
},
25-
offline() {
26-
console.log('No internet connection found. App is running in offline mode.');
27-
},
28-
error(error) {
29-
console.error('Error during service worker registration:', error);
30-
},
31-
});
32-
}
5+
// if (process.env.NODE_ENV === 'production') {
6+
// register(`${process.env.BASE_URL}service-worker.js`, {
7+
// ready() {
8+
// console.log(
9+
// 'App is being served from cache by a service worker.\n'
10+
// + 'For more details, visit https://goo.gl/AFskqB',
11+
// );
12+
// },
13+
// registered() {
14+
// console.log('Service worker has been registered.');
15+
// },
16+
// cached() {
17+
// console.log('Content has been cached for offline use.');
18+
// },
19+
// updatefound() {
20+
// console.log('New content is downloading.');
21+
// },
22+
// updated() {
23+
// console.log('New content is available; please refresh.');
24+
// },
25+
// offline() {
26+
// console.log('No internet connection found. App is running in offline mode.');
27+
// },
28+
// error(error) {
29+
// console.error('Error during service worker registration:', error);
30+
// },
31+
// });
32+
// }

generator/template/src/router/defaultRoutes.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const routes = {
1212
},
1313
{
1414
name: '实验管理',
15-
path: '/Teacher/distributecase',
15+
path: '/Teacher/experimentlist',
1616
},
1717
{
1818
name: '报告管理',
@@ -26,6 +26,10 @@ const routes = {
2626
name: '自定义',
2727
path: '/Teacher/customcase',
2828
},
29+
// {
30+
// name: '组件展示',
31+
// path: '/Teacher/exhibition',
32+
// },
2933
],
3034
teacher: [
3135
{
@@ -38,7 +42,7 @@ const routes = {
3842
},
3943
{
4044
name: '实验管理',
41-
path: '/Teacher/distributecase',
45+
path: '/Teacher/experimentlist',
4246
},
4347
{
4448
name: '报告管理',
@@ -52,8 +56,17 @@ const routes = {
5256
name: '自定义',
5357
path: '/Teacher/customcase',
5458
},
59+
// {
60+
// name: '组件展示',
61+
// path: '/Teacher/exhibition',
62+
// },
63+
],
64+
student: [
65+
{
66+
name: '组件展示',
67+
path: '/Teacher/exhibition',
68+
},
5569
],
56-
student: [],
5770
};
5871

5972
const getDefaultRoutes = (role: UserRole | null) => {

0 commit comments

Comments
 (0)