Commit 52027cf3 authored by 罗超's avatar 罗超

完成文件缓存

parent b836ecad
VUE_APP_API_URL = 'http://reborn.oytour.com/api/common/post'
VUE_APP_UPLOADURLAPI_URL = 'http://upload.oytour.com'
VUE_APP_API_URL = 'https://reborn.oytour.com/api/common/post'
VUE_APP_UPLOADURLAPI_URL = 'https://upload.oytour.com'
VUE_APP_SHARE_URL = 'http://vitto.com'
\ No newline at end of file
......@@ -20,12 +20,9 @@ const LoadMoreDirective: Directive = {
mounted(el: CustomHTMLElement, binding) {
let obj = el.querySelector('.el-scrollbar__wrap')
if(obj){
console.log('找到元素')
el[CTX_SCROLL_LOADMORE_HANDLER] = (event: Event) => callbackEvent(event, binding)
obj.addEventListener('scroll', el[CTX_SCROLL_LOADMORE_HANDLER])
}else{
console.log('没有找到元素')
}
}else{ }
},
unmounted(el: CustomHTMLElement) {
......
......@@ -2,20 +2,20 @@ import { ApiResult } from './../configs/axios';
import { defineStore } from 'pinia'
import FontService from '@/services/FontService'
import { ElLoading } from 'element-plus'
import type { StorageLike } from 'pinia-plugin-persistedstate';
import SecureLS from 'secure-ls';
const ls = new SecureLS({
isCompression: false,
encryptionSecret: '38c31684-d00d-30dc-82e0-fad9eec46d1d',
});
const st: StorageLike = {
setItem(key: string, value: string) {
ls.set(key, value);
},
getItem(key: string): string | null {
return ls.get(key);
},
};
// import type { StorageLike } from 'pinia-plugin-persistedstate';
// import SecureLS from 'secure-ls';
// const ls = new SecureLS({
// isCompression: false,
// encryptionSecret: '38c31684-d00d-30dc-82e0-fad9eec46d1d',
// });
// const st: StorageLike = {
// setItem(key: string, value: string) {
// ls.set(key, value);
// },
// getItem(key: string): string | null {
// return ls.get(key);
// },
// };
export interface CustomerFonts {
fontUrl: string
fontFamily: string
......@@ -104,17 +104,16 @@ export const useFontStore = defineStore('fonts',{
for (let i = 0; i < loadFonts.length; i++) {
const item = loadFonts[i];
const url = item.fontUrl.indexOf('local')==-1?`url('${item.fontUrl}')`:item.fontUrl
if(this.restoreLoaded.indexOf(item.fontFamily)==-1) {
const fontFace = new FontFace(item.fontFamily,url);
try {
fontFace.display = "swap"
await fontFace.load();
} catch (error) {
console.log('加载字体报错',error)
}
document.fonts.add(fontFace)
const fontFace = new FontFace(item.fontFamily,url);
try {
fontFace.display = "swap"
await fontFace.load();
} catch (error) {
console.log('加载字体报错',error)
}
document.fonts.add(fontFace)
this.loaded.push(item.fontFamily)
let newStyle = document.createElement('style');
const fontFormat = item.fontUrl.toLowerCase().indexOf('.ttf')!=-1?'truetype':(item.fontUrl.toLowerCase().indexOf('.otf')!=-1?'opentype':`'${item.fontUrl.split('.').reverse()[0]}'`)
......@@ -151,14 +150,14 @@ export const useFontStore = defineStore('fonts',{
return false
}
},
persist: {
storage: st,
paths:['loaded'],
afterRestore(context) {
console.log('还原了....',context.store.loaded)
context.store.restoreLoaded = JSON.parse(JSON.stringify(context.store.loaded))
context.store.loaded = []
console.log('修改了....',context.store.loaded)
},
}
// persist: {
// storage: st,
// paths:['loaded'],
// afterRestore(context) {
// console.log('还原了....',context.store.loaded)
// context.store.restoreLoaded = JSON.parse(JSON.stringify(context.store.loaded))
// context.store.loaded = []
// console.log('修改了....',context.store.loaded)
// },
// }
})
\ No newline at end of file
......@@ -439,7 +439,6 @@ const GetTripTemplate = async () =>{
let id = generateUniqueId()
x.id = `${ids[0]}-${ids[1]}${id}`
}
console.log(existId,'-----',x.id,'----newSlides ID')
x.elements.forEach(y=>{
if(x.pageType!=1&&y.TemplateDataSource&&y.TemplateDataSource.index==null){
Reflect.set(y.TemplateDataSource, 'index', null)
......@@ -539,7 +538,6 @@ const sellGetTripTemplate = async () =>{
}
if(SalesBack.value==0) slidesStore.setTitle(dataRes.data.data.Title)
if(SalesBack.value==0&&searchData.value.sellId){
console.log(JSON.parse(dataObj.TempData))
let SlidesData = JSON.parse(dataObj.TempData)
let newSlides = []
await SlidesData.forEach((x,i)=>{
......
......@@ -46,7 +46,6 @@ const props = withDefaults(defineProps<{
visible: true,
})
console.log(props.size)
const { viewportRatio } = storeToRefs(useSlidesStore())
const background = computed(() => props.slide.background)
......
......@@ -31,9 +31,12 @@ module.exports = {
}),
Components({
resolvers: [ElementPlusResolver()],
}),
})
],
},
devServer:{
https:true
},
pwa: {
name: 'PPTist',
themeColor: '#d14424',
......@@ -74,21 +77,39 @@ module.exports = {
},
workboxOptions: {
runtimeCaching: [{
urlPattern: /.*/,
handler: 'NetworkFirst',
urlPattern: /\.(woff|ttf|otf)$/,
handler: 'CacheFirst',
options: {
cacheName: 'fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 30, // 30 days
},
},
},{
urlPattern: /^https:\/\/im\.oytour\.com\/tripfont\/.*$/,
handler: 'CacheFirst',
options: {
cacheName: 'fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 30 days
},
},
},{
urlPattern: /^https:\/\/im\.oytour\.com\/pptist\/desgin\/.*$/,
handler: 'CacheFirst',
options: {
cacheName: 'PPTist',
cacheName: 'images-cache',
expiration: {
maxAgeSeconds: 60 * 60 * 10,
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 30 days
},
cacheableResponse: {
statuses: [0, 200]
}
}
}],
include: [
/\.ttf$/,
],
// include: [
// /\.ttf$/,
// ],
skipWaiting: true,
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment