1.代码优化
parent
675152d6c9
commit
d24693080f
|
|
@ -1,17 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="dialog_visible" class="radius-lg dialog-center oh" width="1168" :close-on-click-modal="false" append-to-body>
|
<el-dialog v-model="dialog_visible" class="radius-lg dialog-center oh" width="1168" :close-on-click-modal="false" destroy-on-close append-to-body>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="title re">
|
<div class="title re">
|
||||||
<div class="middle size-16 fw">预览</div>
|
<div class="middle size-16 fw">预览</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div class="flex-row iframe-content oh">
|
<div class="flex-row iframe-content oh">
|
||||||
<iframe :src="new_link" width="100%" height="100%" frameborder="0"></iframe>
|
<iframe :key="key" :src="new_link + '&key=' + key" width="100%" height="100%" frameborder="0"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { get_cookie, get_math } from '@/utils';
|
import { get_cookie, set_cookie, get_math } from '@/utils';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataId: {
|
dataId: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
@ -25,6 +25,7 @@ const pro_url = window.location.href.substring(0, index);
|
||||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||||
const cookie = get_cookie('admin_info');
|
const cookie = get_cookie('admin_info');
|
||||||
const token = ref('');
|
const token = ref('');
|
||||||
|
const key = ref(0);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../../../temp.d.ts' : '../../../../temp_pro.d');
|
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../../../temp.d.ts' : '../../../../temp_pro.d');
|
||||||
|
|
@ -39,8 +40,17 @@ onMounted(async () => {
|
||||||
watch(
|
watch(
|
||||||
() => dialog_visible.value,
|
() => dialog_visible.value,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
|
key.value = new Date().getTime();
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
new_link.value = (import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API_URL : pro_url) + '?s=diy/preview/id/' + props.dataId + '&system_type=default' + token.value + '&uid=' + get_math();
|
let uid_val = '';
|
||||||
|
if (get_cookie('uid_name')) {
|
||||||
|
uid_val = get_cookie('uid_name');
|
||||||
|
} else {
|
||||||
|
uid_val = get_math();
|
||||||
|
set_cookie('uid_name', uid_val);
|
||||||
|
console.log(get_cookie('uid_name'));
|
||||||
|
}
|
||||||
|
new_link.value = (import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API_URL : pro_url) + '?s=diy/preview/id/' + props.dataId + '&system_type=default' + token.value + '&uid=' + uid_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export function padding_computer(new_style: newPaddingStyle, scale: number = 1)
|
||||||
if (typeof new_style.padding_top_safe_value == 'number') {
|
if (typeof new_style.padding_top_safe_value == 'number') {
|
||||||
top += new_style.padding_top_safe_value;
|
top += new_style.padding_top_safe_value;
|
||||||
}
|
}
|
||||||
return `padding: ${ top * scale || 0}px ${new_style.padding_right * scale || 0}px ${new_style.padding_bottom * scale || 0}px ${new_style.padding_left * scale || 0}px;`;
|
return `padding: ${top * scale || 0}px ${new_style.padding_right * scale || 0}px ${new_style.padding_bottom * scale || 0}px ${new_style.padding_left * scale || 0}px;`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -386,6 +386,9 @@ export const set_cookie = (name: string, value: string, expire_time?: number) =>
|
||||||
cookie_str += ';expires=' + expire_date.toUTCString();
|
cookie_str += ';expires=' + expire_date.toUTCString();
|
||||||
// 将新增的cookie储存到cookie中,可以存储多个而不是替换
|
// 将新增的cookie储存到cookie中,可以存储多个而不是替换
|
||||||
document.cookie = cookie_str;
|
document.cookie = cookie_str;
|
||||||
|
} else {
|
||||||
|
// 将新增的cookie储存到cookie中,可以存储多个而不是替换
|
||||||
|
document.cookie = cookie_str;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue