Skip to content

Commit

Permalink
feat(目录迁移): 新增目录迁移功能
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed May 31, 2024
1 parent a870913 commit 5c997b3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2024-04-24 14:07:06
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-30 17:54:26
* @LastEditTime: 2024-05-31 15:52:01
* @Description: 用户接口登录
*/

Expand Down Expand Up @@ -70,6 +70,9 @@ export const getTmplList = (data: any) => instance.get(`/api/user-templs?${data}
// 查询素材列表
export const getTmplInfo = (data: any) => instance.get(`/api/user-templs/${data}`);

// 获取用户树菜单
export const getUserFileTypeTree = () => instance.get(`/api/user-templ/getUerFileTypeTree`);

// 获取菜单树
export const getFileTypeTree = (data: any) =>
instance.get(`/api/custom/getUerFileTypeTree`, {
Expand Down
8 changes: 4 additions & 4 deletions src/components/importJSON.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2022-09-03 19:16:55
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-30 14:14:02
* @LastEditTime: 2024-05-31 16:58:12
* @Description: 导入JSON文件
-->

Expand Down Expand Up @@ -54,9 +54,9 @@ const clickHandler = (type) => {
createDesign,
// psd
psd: () => {
Spin.show({
render: (h) => h('div', t('alert.loading_data')),
});
// Spin.show({
// render: (h) => h('div', t('alert.loading_data')),
// });
canvasEditor.insertPSD().finally(Spin.hide);
},
};
Expand Down
32 changes: 31 additions & 1 deletion src/components/myMaterial/components/file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2024-05-30 10:48:00
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-30 14:47:39
* @LastEditTime: 2024-05-31 16:38:14
* @Description: 模板文件
-->
<template>
Expand All @@ -26,18 +26,25 @@
<DropdownMenu>
<DropdownItem name="reName">重命名</DropdownItem>
<DropdownItem name="delete">删除</DropdownItem>
<DropdownItem name="transfer">迁移目录</DropdownItem>
</DropdownMenu>
</template>
</Dropdown>
</div>
</div>
</Tooltip>
<!-- 迁移文件夹 -->
<Modal v-model="modalVisable" title="请选择迁移目录" @on-ok="transferRequest">
<TreeSelect v-model="fileTypeId" :data="treeData" v-width="200" />
</Modal>
<!-- -->
</template>

<script setup name="ImportTmpl">
import useMaterial from '@/hooks/useMaterial';
import { useI18n } from 'vue-i18n';
import useSelect from '@/hooks/select';
import { getUserFileTypeTree, updataTempl } from '@/api/user';
const { t } = useI18n();
const { canvasEditor } = useSelect();
const { reNameFileType, removeTemplInfo, routerToId } = useMaterial();
Expand Down Expand Up @@ -73,6 +80,7 @@ const operation = (value) => {
const mapActions = {
reName: reNameFile,
delete: deleteFile,
transfer: transfer,
};
mapActions[value]();
};
Expand Down Expand Up @@ -124,6 +132,28 @@ const getTempData = () => {
routerToId(props.itemId);
canvasEditor.loadJSON(JSON.stringify(props.json), Spin.hide);
};

const modalVisable = ref(false);
const fileTypeId = ref('');
const treeData = ref([]);

const transfer = async () => {
treeData.value = [];
fileTypeId.value = '';
const res = await getUserFileTypeTree();
treeData.value = [res.data.data];
modalVisable.value = true;
};

const transferRequest = async () => {
const parentId = fileTypeId.value === 'root' ? '' : fileTypeId.value;
await updataTempl(props.itemId, {
data: {
parentId: String(parentId),
},
});
emit('change');
};
</script>

<style scoped lang="less">
Expand Down
6 changes: 5 additions & 1 deletion src/router/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';

import { setToken, autoLogin } from '@/api/user';
import { setToken, autoLogin, logout } from '@/api/user';

const routes: RouteRecordRaw[] = [
{
Expand All @@ -14,6 +14,10 @@ const routes: RouteRecordRaw[] = [
});
if (res.data.jwt) {
setToken(res.data.jwt);
} else {
logout();
alert('签名失败');
window.location.href = '/';
}
}
return true;
Expand Down
11 changes: 10 additions & 1 deletion src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 秦少卫
* @Date: 2024-05-17 15:30:21
* @LastEditors: 秦少卫
* @LastEditTime: 2024-05-30 14:11:31
* @LastEditTime: 2024-05-31 14:26:41
* @Description: file content
-->
<template>
Expand Down Expand Up @@ -160,6 +160,9 @@
// 导入元素
import importJson from '@/components/importJSON.vue';
import importFile from '@/components/importFile.vue';
// 路由
import { useRoute } from 'vue-router';

// import fontTmpl from '@/components/fontTmpl.vue';

// 顶部组件
Expand Down Expand Up @@ -351,6 +354,12 @@ onMounted(() => {
if (state.ruler) {
canvasEditor.rulerEnable();
}

// 有ID时,打开作品面板
const route = useRoute();
if (route?.query?.id) {
menuActive.value = 'myMaterial';
}
});

onUnmounted(() => canvasEditor.destory());
Expand Down

0 comments on commit 5c997b3

Please sign in to comment.