225 lines
11 KiB
JavaScript
225 lines
11 KiB
JavaScript
import { nextTick} from "vue";
|
|
import { driver } from "driver.js";
|
|
import { setCookie, getCookie, WriteCookie } from "@/tool/cookie";
|
|
import "driver.js/dist/driver.css";
|
|
import { useStore } from "vuex";
|
|
//版本一
|
|
let driverIndex__ = 0
|
|
let store
|
|
let element
|
|
let data = {
|
|
index:driverIndex__,
|
|
driver:true,
|
|
}
|
|
const driverObj__ = driver({
|
|
steps: [
|
|
{ element: '.Guide_1_1_1', popover: { title: 'Title', description: 'Description' } },
|
|
{ element: '.Guide_1_27', popover: { title: '', description: "You can personalize your design settings right here in the <strong>Workspace</strong>, including choosing to design for men's or women's wear, as well as selecting the mannequin to use for your creations." } },
|
|
{ element: '.Guide_1_28', popover: { title: '', description: "Select the apparel type you'd like to work on.", side: "right",align: 'center' } },
|
|
{ element: '.Guide_1_28', popover: { title: '', description: 'Change the mannequin here.', side: "right",align: 'end' } },
|
|
{ element: '.Guide_1_29', popover: { title: '', description: 'You can currently select a mannequin from our system library. Later, you can also choose from the user library after registering your own mannequin.' } },
|
|
|
|
|
|
{ element: '.Guide_1_1', popover: { title: '', description: 'Begin your creative journey here. ' } },
|
|
{ element: '.Guide_1_1_2', popover: { title: '', description: 'For the Moodboard, Printboard, or Sketchboard, we provide three different sourcing methods to add images. The first option, as displayed on this page, is to upload directly from your local device. ' } },
|
|
{ element: '.Guide_1_1_2', popover: { title: '', description: "The second method is to select from your library. <br> You might notice that your library page is currently empty; there's no need to worry. All the images you upload will be automatically added to your library. In the future, you won't have to upload each time—you can simply choose from your library instead." } },
|
|
// { element: '.Guide_1_1_2', popover: { title: '', description: 'Begin your creative journey here. ' } },
|
|
// { element: '.Guide_1_3', popover: { title: '', description: 'Description' } },
|
|
// { element: '.Guide_1_2', popover: { title: '', description: 'Description' } },
|
|
{ element: '.Guide_1_4', popover: { title: '', description: 'The third method is to generate images using the latest Image Generation technology.' } },
|
|
{ element: '.Guide_1_5', popover: { title: '', description: "Enter keywords that capture the mood you wish to express and then click the 'Generate' button." } },
|
|
{ element: '.Guide_1_6', popover: { title: '', description: 'Select two images for your moodboard.' } },
|
|
{ element: '.Guide_1_7', popover: { title: '', description: 'Click here to layout your moodboard.' } },
|
|
{ element: '.Guide_1_8', popover: { title: '', description: 'Click here for next step.' } },
|
|
//以上moodboard
|
|
{ element: '.Guide_1_2_1', popover: { title: '', description: 'Click here to generate print images.' } },
|
|
{ element: '.Guide_1_2_2', popover: { title: '', description: 'We provide three input options for generating images: Image Only, Text Only, and Text-Image.' } },
|
|
{ element: '.Guide_1_2_3', popover: { title: '', description: 'Select this option and we will generate four print images using both the picture you upload and the text you enter.' } },
|
|
{ element: '.Guide_1_2_4', popover: { title: '', description: 'Choose a generation model here; different models will generate images in various styles.' } },
|
|
{ element: '.Guide_1_2_5', popover: { title: '', description: 'Choose a generation model here; different models will generate images in various styles.' } },
|
|
{ element: '.Guide_1_2_6', popover: { title: '', description: 'Upload the input picture here.' } },
|
|
{ element: '.Guide_1_2_7', popover: { title: '', description: "Click on this image to select it." } },
|
|
{ element: '.Guide_1_2_8', popover: { title: '', description: "Enter keywords about the print you wish to create and then click the 'Generate' button." } },
|
|
{ element: '.Guide_1_2_9', popover: { title: '', description: 'Select the generated prints you like best.' } },
|
|
{ element: '.Guide_1_8', popover: { title: '', description: 'Click here for next step.' } },
|
|
{ element: '.Guide_1_10', popover: { title: '', description: 'Click here to extract primary colors from image.' } },
|
|
{ element: '.Guide_1_11', popover: { title: '', description: 'Select the color you want from these color blocks as the first color.' } },
|
|
|
|
{ element: '.Guide_1_11_1', popover: { title: '', description: 'Click on this block to select the second color.' } },
|
|
{ element: '.Guide_1_11_2', popover: { title: '', description: 'Choose the color you want from these color blocks.' } },
|
|
|
|
{ element: '.Guide_1_8', popover: { title: '', description: 'Click here for next step.' } },
|
|
{ element: '.Guide_1_9', popover: { title: '', description: 'Click here to generate clothing sketches.' } },
|
|
{ element: '.Guide_1_9_1', popover: { title: '', description: 'Using text only option for generation.' } },
|
|
{ element: '.Guide_1_9_2', popover: { title: '', description: "Enter keywords about the sketch you wish to create and then click the 'Generate' button." } },
|
|
|
|
{ element: '.Guide_1_13', popover: { title: '', description: 'Click here to choose a category for the generated sketch.' } },
|
|
{ element: '.Guide_1_13_1', popover: { title: '', description: 'Choose correct category for the sketch.' } },
|
|
{ element: '.Guide_1_13_2', popover: { title: '', description: 'Select the generated sketches you like best.' } },
|
|
{ element: '.Guide_1_14', popover: { title: '', description: 'Cick here to complete the uploading process.' } },
|
|
//开始design
|
|
{ element: '.Guide_1_15', popover: { title: '', description: 'Click here to let AI generate design illustrations.' } },
|
|
{ element: '.Guide_1_16', popover: { title: '', description: 'Please wait a few seconds.' } },
|
|
{ element: '.Guide_1_17', popover: { title: '', description: 'Click on any design image you are interested in to modify the details.' } },
|
|
// { element: '.Guide_1_18', popover: { title: '', description: 'Description' } },
|
|
{ element: '.Guide_1_30', popover: { title: '', description: "Click the 'Redesign' button to generate new results using the selected mannequin." } },
|
|
{ element: '.Guide_1_16', popover: { title: '', description: 'Click here to let AI generate design illustrations.' } },
|
|
{ element: '.Guide_1_17', popover: { title: '', description: 'Click on any design image you are interested in to modify the details.' } },
|
|
{ element: '.Guide_1_19', popover: { title: '', description: 'Click on the clothes to modify its details.' } },
|
|
{ element: '.Guide_1_20', popover: { title: '', description: 'Click here to add or change the print.' } },
|
|
{ element: '.Guide_1_21', popover: { title: '', description: 'You can find the print you uploaded earlier in your Library.' } },
|
|
{ element: '.Guide_1_22', popover: { title: '', description: 'Select a print for this sketch.' } },
|
|
{ element: '.Guide_1_23', popover: { title: '', description: 'Click here to layout the selected print' } },
|
|
// { element: '.Guide_1_24', popover: { title: '', description: 'Description' } },
|
|
{ element: '.Guide_1_25', popover: { title: '', description: 'Preview printed design here.' ,side: "right",align: 'end' } },
|
|
{ element: '.Guide_1_26', popover: { title: '', description: 'Click here to finalize your modification.' } },
|
|
{ element: '.Guide_1_99', popover: { title: 'Begin Your Design', description: 'Your guide is complete, and now the canvas is yours to create freely. For more insights and details, check out our demo video on the homepage at <a href="https://code-create.com.hk/aida/" style="pointer-events: auto;" target="_blank">https://code-create.com.hk/aida/</a>' } },
|
|
],
|
|
// showProgress: true,//控制总页数和当前页数是否显示
|
|
allowClose:false,
|
|
showButtons:false,
|
|
stagePadding:10,//切口到元素的距离
|
|
stageRadius:5,//切口圆弧度
|
|
allowKeyboardControl:true,//控制是否可以键盘控制下一步
|
|
disableActiveInteraction:false,//是否禁用显示元素的交互
|
|
overlayOpacity:.4,
|
|
overlay: true,
|
|
// nextBtnText: '—›',
|
|
// prevBtnText: '‹—',
|
|
doneBtnText: '✕',
|
|
onPopoverRender: (popover, options) => {//每个步骤的元素和所有信息
|
|
// console.log(popover,options,element);
|
|
popover.previousButton.style.display = 'none'
|
|
// let driver = document.querySelector('body')
|
|
driverIndex__ = driverObj__.getState().activeIndex
|
|
data = {
|
|
index : driverIndex__,
|
|
driver : true,
|
|
}
|
|
store?.commit("setGuide", data);
|
|
if(options.state.activeIndex == 0){
|
|
popover.wrapper.style.display = 'none'
|
|
}else{
|
|
popover.wrapper.style.display = 'block'
|
|
}
|
|
|
|
//判断是不是generate 如果是就吧边距设为0
|
|
// if(options.state.activeIndex >= 2 && options.state.activeIndex < 3){
|
|
// options.config.stagePadding = 0
|
|
// }else{
|
|
// options.config.stagePadding = 10
|
|
// }
|
|
if(
|
|
// options.state.activeIndex >= 2 && options.state.activeIndex < 3 ||
|
|
options.state.activeIndex >= 6 && options.state.activeIndex < 9 ||
|
|
options.state.activeIndex >= 14 && options.state.activeIndex < 15 ||
|
|
// options.state.activeIndex >= 24 && options.state.activeIndex < 25 ||
|
|
driverObj__.isLastStep()
|
|
){
|
|
popover.footer.style.display = 'block'
|
|
// popover.previousButton.style.display = 'block'
|
|
popover.footerButtons.style.pointerEvents = 'auto';
|
|
// driver.classList.add('showEvents')
|
|
// addDiv(options.state.activeElement)
|
|
}else{
|
|
popover.footer.style.display = 'none'
|
|
// popover.previousButton.style.display = 'none'
|
|
// removeDiv(options.state.activeElement)
|
|
popover.footerButtons.style.pointerEvents = 'none';
|
|
// driver.classList.remove('showEvents')
|
|
}
|
|
nextTick().then(()=>{
|
|
if(element){
|
|
element.classList.remove('Guide_')
|
|
}
|
|
element = options.state.activeElement
|
|
element.classList.add('Guide_')
|
|
})
|
|
|
|
|
|
},
|
|
//销毁前
|
|
onDestroyStarted:()=>{
|
|
data = {
|
|
index : driverIndex__,
|
|
driver : false,
|
|
}
|
|
store?.commit("setGuide", data);
|
|
setCookie("isBeginner", false);
|
|
driverObj__.destroy();//销毁方法
|
|
},
|
|
//销毁前
|
|
onDestroyed:()=>{
|
|
},
|
|
|
|
|
|
|
|
// onNextClick:(element, step, options) =>{
|
|
// // if(options.state.activeIndex == 2){
|
|
// // driverObj__.moveTo(4)
|
|
// // }else{
|
|
// // driverObj__.moveNext()
|
|
// // }
|
|
// }
|
|
});
|
|
function addDiv(element){
|
|
element.style.posiiton = 'relative'
|
|
const mask = document.getElementsByClassName('driver-mask__')?.[0]
|
|
if(mask){
|
|
}else{
|
|
const mask = document.createElement('div');
|
|
mask.style.position = 'absolute';
|
|
mask.style.top = '0';
|
|
mask.style.left = '0';
|
|
mask.style.width = '100%';
|
|
mask.style.height = '100%';
|
|
mask.style.backgroundColor = 'rgba(0, 0, 0, 0)';
|
|
mask.style.zIndex = '9999';
|
|
mask.classList.add('driver-mask__')
|
|
element.appendChild(mask);
|
|
}
|
|
}
|
|
function removeDiv(element){
|
|
const mask = document.getElementsByClassName('driver-mask__')?.[0]
|
|
if(mask){
|
|
// element.removeChild(mask);
|
|
mask.remove()
|
|
}
|
|
}
|
|
|
|
const openGuide = () =>{
|
|
let isBeginner = JSON.parse(getCookie('isBeginner'))
|
|
let data
|
|
// console.log(isBeginner);
|
|
if(isBeginner){
|
|
driverObj__.drive();
|
|
data = {
|
|
index:driverIndex__,
|
|
driver:true,
|
|
}
|
|
}else{
|
|
driverObj__.destroy();
|
|
data = {
|
|
index:driverIndex__,
|
|
driver:false,
|
|
}
|
|
}
|
|
// driverObj__.destroy();
|
|
driverObj__.drive();
|
|
|
|
data = {
|
|
index:driverIndex__,
|
|
driver:true,
|
|
}
|
|
store = useStore()
|
|
// driverObj__.moveTo(18);
|
|
store?.commit("setGuide", data);
|
|
// driverObj__.moveNext();
|
|
// driverObj__.movePrevious();
|
|
}
|
|
|
|
export{
|
|
openGuide,
|
|
driverObj__,
|
|
driverIndex__,
|
|
} |