fix:app嵌套h5
This commit is contained in:
1
.env
1
.env
@@ -1,5 +1,6 @@
|
|||||||
# .env
|
# .env
|
||||||
VITE_APP_BASE_URL=http://192.168.8.165:15011/
|
VITE_APP_BASE_URL=http://192.168.8.165:15011/
|
||||||
|
VITE_APP_BASE_DEMAIM=http://192.168.8.165:15011/
|
||||||
VITE_APP_ENV=development
|
VITE_APP_ENV=development
|
||||||
VITE_APP_CURRENTMODE=dev
|
VITE_APP_CURRENTMODE=dev
|
||||||
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# .env.development
|
# .env.development
|
||||||
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
|
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
|
||||||
|
VITE_APP_BASEDOMAIM=https://ylst-h5-uat.dctest.digitalyili.com
|
||||||
VITE_APP_ENV=development
|
VITE_APP_ENV=development
|
||||||
VITE_APP_CURRENTMODE=dev
|
VITE_APP_CURRENTMODE=dev
|
||||||
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
||||||
|
|||||||
1
.env.uat
1
.env.uat
@@ -1,5 +1,6 @@
|
|||||||
# .env.development
|
# .env.development
|
||||||
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
|
VITE_APP_BASEURL=https://yls-api-uat.dctest.digitalyili.com
|
||||||
|
VITE_APP_BASEDOMAIM=https://ylst-h5-uat.dctest.digitalyili.com
|
||||||
VITE_APP_ENV=uat
|
VITE_APP_ENV=uat
|
||||||
VITE_APP_CURRENTMODE=uat
|
VITE_APP_CURRENTMODE=uat
|
||||||
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
VITE_APP_BASEOSS=https://diaoyan-files.automark.cc
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// src/config.js
|
// src/config.js
|
||||||
export default {
|
export default {
|
||||||
proxyUrl: import.meta.env.VITE_APP_BASEURL,
|
proxyUrl: import.meta.env.VITE_APP_BASEURL,
|
||||||
|
proxyDomain: import.meta.env.VITE_APP_BASEDOMAIM,
|
||||||
proxyUrlDelivery: import.meta.env.VITE_APP_DELIVERY_BASEURL,
|
proxyUrlDelivery: import.meta.env.VITE_APP_DELIVERY_BASEURL,
|
||||||
proxyUrlMessageCenter: import.meta.env.VITE_APP_MESSAGE_CENTER,
|
proxyUrlMessageCenter: import.meta.env.VITE_APP_MESSAGE_CENTER,
|
||||||
baseOss: import.meta.env.VITE_APP_BASEOSS,
|
baseOss: import.meta.env.VITE_APP_BASEOSS,
|
||||||
@@ -8,7 +9,8 @@ export default {
|
|||||||
socketUrl: import.meta.env.VITE_APP_SOCKETURL,
|
socketUrl: import.meta.env.VITE_APP_SOCKETURL,
|
||||||
jsonpUrl: import.meta.env.VITE_APP_JSONPURL,
|
jsonpUrl: import.meta.env.VITE_APP_JSONPURL,
|
||||||
jqrUrl: import.meta.env.VITE_APP_YQRURL,
|
jqrUrl: import.meta.env.VITE_APP_YQRURL,
|
||||||
currentMode: import.meta.env.VITE_APP_CURRENTMODE
|
currentMode: import.meta.env.VITE_APP_CURRENTMODE,
|
||||||
|
proxyDomain: import.meta.env.VITE_APP_BASEDOMAIM || ''
|
||||||
// appKey: import.meta.env.VITE_APP_APPKEY,
|
// appKey: import.meta.env.VITE_APP_APPKEY,
|
||||||
// appId: import.meta.env.VITE_APP_APPID
|
// appId: import.meta.env.VITE_APP_APPID
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
proxyUrl: process.env.VUE_APP_BASEURL,
|
proxyUrl: process.env.VUE_APP_BASEURL,
|
||||||
|
proxyDomain: process.env.VITE_APP_BASEDOMAIM,
|
||||||
proxyUrlDelivery: process.env.VUE_APP_DELiVERY_BASEURL,
|
proxyUrlDelivery: process.env.VUE_APP_DELiVERY_BASEURL,
|
||||||
proxyUrlMessageCenter: process.env.VUE_APP_MESSAGE_CENTER,
|
proxyUrlMessageCenter: process.env.VUE_APP_MESSAGE_CENTER,
|
||||||
baseOss: process.env.VUE_APP_BASEOSS,
|
baseOss: process.env.VUE_APP_BASEOSS,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="common-layout">
|
<div class="common-layout">
|
||||||
<!-- title 标题和搜索栏 -->
|
<!-- title 标题和搜索栏 -->
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<div class="title">{{ $route.meta.title }}</div>
|
<!-- <div class="title">{{ $route.meta.title }}</div> -->
|
||||||
<van-search placeholder="请输入搜索关键词" background="#A5D380" />
|
<van-search placeholder="请输入搜索关键词" background="#A5D380" />
|
||||||
</header>
|
</header>
|
||||||
<!-- content -->
|
<!-- content -->
|
||||||
|
|||||||
26
src/main.ts
26
src/main.ts
@@ -14,6 +14,14 @@ let vconsole;
|
|||||||
if (import.meta.env.VITE_APP_ENV !== 'production') {
|
if (import.meta.env.VITE_APP_ENV !== 'production') {
|
||||||
vconsole = new VConsole();
|
vconsole = new VConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加 TypeScript 类型声明,在文件顶部添加
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
onAndroidBack: () => void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (to.query.digitalYiliToken) {
|
if (to.query.digitalYiliToken) {
|
||||||
utils.setSessionStorage('xToken', to.query.digitalYiliToken);
|
utils.setSessionStorage('xToken', to.query.digitalYiliToken);
|
||||||
@@ -25,3 +33,21 @@ const app = createApp(App);
|
|||||||
app.use(createPinia());
|
app.use(createPinia());
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
// 定义路由是否可以返回的判断
|
||||||
|
const routerCanGoBack = () => {
|
||||||
|
const position = router.options.history.state?.position;
|
||||||
|
return typeof position === 'number' && position > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 定义调用APP返回的方法
|
||||||
|
const callAppGoBack = () => {
|
||||||
|
appBridge.navigateBack(); // 使用现有的navigateBack方法替代不存在的goBack方法
|
||||||
|
};
|
||||||
|
// 添加 Android 返回按钮监听方法
|
||||||
|
window.onAndroidBack = () => {
|
||||||
|
if (routerCanGoBack()) {
|
||||||
|
router.back(); // 使用 router.back() 而不是 router.goBack(),因为 Vue Router 使用 back() 方法
|
||||||
|
} else {
|
||||||
|
callAppGoBack(); // 调用 APP 的返回方法
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -111,10 +111,9 @@ type OperateItem = (typeof operateList)[0];
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
function getCode() {
|
function getCode() {
|
||||||
console.log(56, configUrl.proxyUrl);
|
|
||||||
publishInfo.value.img_url
|
publishInfo.value.img_url
|
||||||
= 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png';
|
= 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png';
|
||||||
publishInfo.value.url = `${configUrl.proxyUrl}publish?sn=${sn && sn !== undefined ? sn : ''}`;
|
publishInfo.value.url = `${configUrl.proxyDomain}/publish?sn=${sn && sn !== undefined ? sn : ''}`;
|
||||||
publishInfo.value.download_url = {
|
publishInfo.value.download_url = {
|
||||||
title: '问卷下载',
|
title: '问卷下载',
|
||||||
url: 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png'
|
url: 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png'
|
||||||
@@ -123,11 +122,10 @@ function getCode() {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
publishInfo.value = res.data.data || {};
|
publishInfo.value = res.data.data || {};
|
||||||
// console.log(res.data);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
showFailToast(error.data?.message || error.message || '服务器错误');
|
// showFailToast(error.data?.message || error.message || '服务器错误');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// function fetchInfo() {
|
// function fetchInfo() {
|
||||||
@@ -183,18 +181,16 @@ function shareLink() {
|
|||||||
webpageUrl: publishInfo.value.url,
|
webpageUrl: publishInfo.value.url,
|
||||||
scene: 0 // 朋友圈1 微信好友0
|
scene: 0 // 朋友圈1 微信好友0
|
||||||
};
|
};
|
||||||
|
console.log('shareUrl',publishInfo.value.url)
|
||||||
appBridge.shareToWeChat(params, () => {
|
appBridge.shareToWeChat(params, () => {
|
||||||
/**/
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载二维码
|
// 下载二维码
|
||||||
function downLoadImg() {
|
function downLoadImg() {
|
||||||
const { title, url } = publishInfo.value.download_url;
|
const { title, url } = publishInfo.value.download_url;
|
||||||
if (utils.getCookie('xToken')) {
|
if (utils.getSessionStorage('xToken')) {
|
||||||
appBridge.save2Album(url, () => {
|
appBridge.save2Album(url, () => {});
|
||||||
// showSuccessToast('下载成功');
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
|
|||||||
67
vite.config.ts.timestamp-1741938406006-a35225218530b.mjs
Normal file
67
vite.config.ts.timestamp-1741938406006-a35225218530b.mjs
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user