完成公共模板管理员的解决方案
This commit is contained in:
parent
be5232f7a5
commit
063c5dd568
@ -5,6 +5,7 @@ import request from '@/utils/request.js';
|
|||||||
*/
|
*/
|
||||||
export async function getPosterTemplateList() {
|
export async function getPosterTemplateList() {
|
||||||
const res = await request.get('/barmgr/poster/posterTemplateList');
|
const res = await request.get('/barmgr/poster/posterTemplateList');
|
||||||
|
// const res = await request.get('/barmgr/poster/fixUserToken');
|
||||||
if (res.data.code === 200) {
|
if (res.data.code === 200) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
@ -32,3 +33,14 @@ export async function delPosterTemplate(id) {
|
|||||||
}
|
}
|
||||||
return Promise.reject(new Error(res.data.msg));
|
return Promise.reject(new Error(res.data.msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取编辑器访问令牌
|
||||||
|
*/
|
||||||
|
export async function getEditorToken(data) {
|
||||||
|
const res = await request.post('/barmgr/editor/getToken', data);
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.msg));
|
||||||
|
}
|
||||||
|
|||||||
@ -3,10 +3,9 @@
|
|||||||
<div class="login-main">
|
<div class="login-main">
|
||||||
<ele-card shadow="always" class="login-card">
|
<ele-card shadow="always" class="login-card">
|
||||||
<div class="login-cover">
|
<div class="login-cover">
|
||||||
<h1 class="login-title">啤啤星球</h1>
|
<h1 class="login-title">啤啤猩球</h1>
|
||||||
<h4 class="login-subtitle"
|
<h4 class="login-subtitle"
|
||||||
>为酒吧提供一整套全面解决方案涵盖酒水供应、运营支持、
|
>高效制作专属酒单·就在BeerApe</h4
|
||||||
营销推广及产品创新</h4
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="login-body">
|
<div class="login-body">
|
||||||
|
|||||||
@ -67,23 +67,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
// 类型声明放在setup顶部
|
||||||
import { PlusOutlined } from 'ele-admin-plus/es/icons';
|
|
||||||
import { getPosterTemplateList, copyPosterTemplate, delPosterTemplate } from '@/api/barmgr/poster';
|
|
||||||
import { Delete, DocumentCopy, Edit } from '@element-plus/icons-vue';
|
|
||||||
import { EleMessage } from 'ele-admin-plus';
|
|
||||||
import { getFastToken } from '@/utils/token-util.js';
|
|
||||||
import { VITE_API_STORE_URL } from '@/config/setting';
|
|
||||||
|
|
||||||
defineOptions({ name: 'ListCardProject' });
|
|
||||||
interface Item {
|
interface Item {
|
||||||
id: number;
|
id: number;
|
||||||
uid: number;
|
uid: number;
|
||||||
name: string;
|
name: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
createTime: string;
|
createTime: string;
|
||||||
preview : string;
|
preview: string;
|
||||||
}
|
}
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { PlusOutlined } from 'ele-admin-plus/es/icons';
|
||||||
|
import { getPosterTemplateList, copyPosterTemplate, delPosterTemplate, getEditorToken } from '@/api/barmgr/poster';
|
||||||
|
import { Delete, DocumentCopy, Edit } from '@element-plus/icons-vue';
|
||||||
|
import { EleMessage } from 'ele-admin-plus';
|
||||||
|
import { getFastToken } from '@/utils/token-util.js';
|
||||||
|
import { VITE_API_STORE_URL } from '@/config/setting';
|
||||||
|
|
||||||
|
defineOptions({ name: 'ListCardProject' });
|
||||||
|
|
||||||
/** 数据 */
|
/** 数据 */
|
||||||
const data = ref<Item[]>([]);
|
const data = ref<Item[]>([]);
|
||||||
@ -101,20 +102,41 @@
|
|||||||
const fastUrl = VITE_API_STORE_URL;
|
const fastUrl = VITE_API_STORE_URL;
|
||||||
|
|
||||||
/** 打开新建 */
|
/** 打开新建 */
|
||||||
const openEdit = () => {
|
const openEdit = async () => {
|
||||||
console.log('打开新建:', fastUrl);
|
try {
|
||||||
// 构建编辑器URL
|
const res = await getEditorToken({ purpose: 'create' });
|
||||||
const editorUrl = `${fastUrl}?token=${token}`;
|
console.log('[openEdit] getEditorToken返回:', res);
|
||||||
// 在当前窗口中打开编辑器
|
if (res && res.fastPosterUrl && res.editorToken) {
|
||||||
window.location.href = editorUrl;
|
const url = `${res.fastPosterUrl}?editorToken=${res.editorToken}`;
|
||||||
|
console.log('[openEdit] 跳转URL:', url);
|
||||||
|
window.location.href = url;
|
||||||
|
} else {
|
||||||
|
console.error('[openEdit] 获取编辑器令牌失败:', res);
|
||||||
|
EleMessage.error(res.msg || '获取编辑器令牌失败');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[openEdit] 网络异常:', e);
|
||||||
|
EleMessage.error(e.message || '网络异常,无法打开编辑器');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// 获取token
|
|
||||||
/** 编辑模板 */
|
/** 编辑模板 */
|
||||||
const editTemplate = (item: Item) => {
|
const editTemplate = async (item: Item) => {
|
||||||
// 构建编辑器URL,使用模板的ID
|
try {
|
||||||
const editorUrl = `${fastUrl}?token=${token}&posterId=${item.id}`;
|
const res = await getEditorToken({ templateId: item.uuid, purpose: 'edit' });
|
||||||
window.open(editorUrl, '_blank', `fullscreen=yes,width=${screenWidth},height=${screenHeight},top=0,left=0,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no`);
|
console.log('[editTemplate] getEditorToken返回:', res);
|
||||||
|
if (res && res.fastPosterUrl && res.editorToken) {
|
||||||
|
const url = `${res.fastPosterUrl}?editorToken=${res.editorToken}`;
|
||||||
|
console.log('[editTemplate] 跳转URL:', url);
|
||||||
|
window.location.href = url;
|
||||||
|
} else {
|
||||||
|
console.error('[editTemplate] 获取编辑器令牌失败:', res);
|
||||||
|
EleMessage.error(res.msg || '获取编辑器令牌失败');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[editTemplate] 网络异常:', e);
|
||||||
|
EleMessage.error(e.message || '网络异常,无法打开编辑器');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 删除模板 */
|
/** 删除模板 */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user