Skip to content

Commit 2a3f9a4

Browse files
committed
fix(用户模板): 未登录校验
1 parent dbf78ab commit 2a3f9a4

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/components/myMaterial/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: 秦少卫
33
* @Date: 2024-04-25 15:30:54
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2024-05-11 15:50:32
5+
* @LastEditTime: 2024-05-11 17:12:21
66
* @Description: 我的素材
77
-->
88

@@ -30,7 +30,7 @@ const isLogin = ref(false);
3030
const getFileListHandle = () => {
3131
// 获取素材列表
3232
getFileList()
33-
.then((res) => {
33+
.then(() => {
3434
isLogin.value = true;
3535
})
3636
.catch(() => {

src/components/myTemplName.vue

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: 秦少卫
33
* @Date: 2024-05-11 13:23:48
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2024-05-11 16:51:47
5+
* @LastEditTime: 2024-05-11 17:33:56
66
* @Description: 文件名称
77
-->
88

@@ -27,8 +27,11 @@
2727
import { debounce } from 'lodash-es';
2828
import useMaterial from '@/hooks/useMaterial';
2929
import { useRoute } from 'vue-router';
30+
import useSelect from '@/hooks/select';
3031
const { getTemplInfo, updataTemplInfo } = useMaterial();
3132

33+
const { canvasEditor } = useSelect();
34+
3235
const fileName = ref('');
3336
const route = useRoute();
3437
const loading = ref(false);
@@ -46,6 +49,18 @@ watch(
4649
}
4750
);
4851

52+
onMounted(() => {
53+
if (route?.query?.id) {
54+
getTemplInfo(route?.query?.id)
55+
.then((res) => {
56+
fileName.value = res?.data?.attributes?.name;
57+
canvasEditor.loadJSON(JSON.stringify(res?.data?.attributes?.json));
58+
})
59+
.catch(() => {
60+
window.location.href = '/';
61+
});
62+
}
63+
});
4964
const saveTempl = () => {
5065
loading.value = true;
5166
updataTemplInfo(route.query.id, fileName.value)

0 commit comments

Comments
 (0)