完成公共模板管理员的解决方案
This commit is contained in:
parent
be5232f7a5
commit
063c5dd568
@ -5,6 +5,7 @@ import request from '@/utils/request.js';
|
||||
*/
|
||||
export async function getPosterTemplateList() {
|
||||
const res = await request.get('/barmgr/poster/posterTemplateList');
|
||||
// const res = await request.get('/barmgr/poster/fixUserToken');
|
||||
if (res.data.code === 200) {
|
||||
return res.data;
|
||||
}
|
||||
@ -32,3 +33,14 @@ export async function delPosterTemplate(id) {
|
||||
}
|
||||
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">
|
||||
<ele-card shadow="always" class="login-card">
|
||||
<div class="login-cover">
|
||||
<h1 class="login-title">啤啤星球</h1>
|
||||
<h1 class="login-title">啤啤猩球</h1>
|
||||
<h4 class="login-subtitle"
|
||||
>为酒吧提供一整套全面解决方案涵盖酒水供应、运营支持、
|
||||
营销推广及产品创新</h4
|
||||
>高效制作专属酒单·就在BeerApe</h4
|
||||
>
|
||||
</div>
|
||||
<div class="login-body">
|
||||
|
||||
@ -67,23 +67,24 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
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' });
|
||||
// 类型声明放在setup顶部
|
||||
interface Item {
|
||||
id: number;
|
||||
uid: number;
|
||||
name: string;
|
||||
uuid: 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[]>([]);
|
||||
@ -101,20 +102,41 @@
|
||||
const fastUrl = VITE_API_STORE_URL;
|
||||
|
||||
/** 打开新建 */
|
||||
const openEdit = () => {
|
||||
console.log('打开新建:', fastUrl);
|
||||
// 构建编辑器URL
|
||||
const editorUrl = `${fastUrl}?token=${token}`;
|
||||
// 在当前窗口中打开编辑器
|
||||
window.location.href = editorUrl;
|
||||
|
||||
const openEdit = async () => {
|
||||
try {
|
||||
const res = await getEditorToken({ purpose: 'create' });
|
||||
console.log('[openEdit] getEditorToken返回:', res);
|
||||
if (res && res.fastPosterUrl && res.editorToken) {
|
||||
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) => {
|
||||
// 构建编辑器URL,使用模板的ID
|
||||
const editorUrl = `${fastUrl}?token=${token}&posterId=${item.id}`;
|
||||
window.open(editorUrl, '_blank', `fullscreen=yes,width=${screenWidth},height=${screenHeight},top=0,left=0,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,status=no`);
|
||||
const editTemplate = async (item: Item) => {
|
||||
try {
|
||||
const res = await getEditorToken({ templateId: item.uuid, purpose: 'edit' });
|
||||
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