Skip to content

Commit 05d6594

Browse files
authored
Merge pull request #42 from CurryPaste/main
pr
2 parents af0f50d + b0599cc commit 05d6594

67 files changed

Lines changed: 2460 additions & 199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
node_modules
33
/dist
44
/docs
5+
src/components/Breadcrumb copy.vue
6+
src/store/modules/breadcrumb copy.ts
57

68

79
# local env files

example/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>

example/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 */

example/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(() => ({

example/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+
// }

example/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) => {

example/src/router/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,21 @@ const routes: Array<RouteRecordRaw> = [
5656
},
5757
},
5858
{
59-
path: '/Teacher/userInfo',
60-
name: 'Teacher/UserInfo',
61-
component: () => import('../views/Public/UserInfo.vue'),
59+
path: '/Teacher/experimentlist',
60+
name: 'Teacher/Experimentlist',
61+
component: () => import('../views/Teacher/experiment/index.vue'),
6262
meta: {
63-
title: '个人中心',
63+
title: '实验管理',
64+
icon: '',
65+
role: ['admin', 'teacher'],
66+
},
67+
},
68+
{
69+
path: '/Teacher/experimentinfo',
70+
name: 'Teacher/Experimentinfo',
71+
component: () => import('../views/Teacher/experiment/info.vue'),
72+
meta: {
73+
title: '实验详情',
6474
icon: '',
6575
role: ['admin', 'teacher', 'student'],
6676
},
@@ -108,7 +118,7 @@ router.beforeEach((to, from, next) => {
108118
next(); // 判断白名单
109119
} else if (!role || !code) {
110120
next({ path: '/' }); // 判断登录
111-
} else if (to.meta.role && to.meta.role.includes(role)) {
121+
} else if (to.meta.role && (to.meta.role as []).includes((role as never))) {
112122
next(); // 判断页面、角色权限
113123
} else {
114124
next({ path: '/404' });

0 commit comments

Comments
 (0)