新增商店外链
This commit is contained in:
@@ -5,4 +5,4 @@ VITE_REGISTER_API_URL=http://192.168.2.22:48080
|
|||||||
# pk api地址
|
# pk api地址
|
||||||
VITE_PK_MINI_API_URL=http://192.168.2.22:8086
|
VITE_PK_MINI_API_URL=http://192.168.2.22:8086
|
||||||
# 商店地址
|
# 商店地址
|
||||||
VITE_SHOP_URL=http://192.168.2.128:8085
|
VITE_SHOP_URL=https://ck.ninisc.cn/
|
||||||
|
|||||||
@@ -138,13 +138,17 @@
|
|||||||
<PkMiniWorkbench />
|
<PkMiniWorkbench />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab 6: yolo商店 - iframe 嵌入 -->
|
<!-- Tab 6: yolo商店 - Electron 用 BrowserView,Web 用 iframe 兜底 -->
|
||||||
<div v-show="currentView === 'shop'" class="absolute inset-0 z-20 h-full overflow-hidden">
|
<div v-show="currentView === 'shop'" class="absolute inset-0 z-20 h-full overflow-hidden">
|
||||||
|
<div v-if="isElectron()" class="w-full h-full flex items-center justify-center text-sm text-slate-500 bg-white">
|
||||||
|
正在进入商店...
|
||||||
|
</div>
|
||||||
<iframe
|
<iframe
|
||||||
v-if="adminLoaded"
|
v-else-if="adminLoaded"
|
||||||
:src="shopUrl"
|
:src="shopUrl"
|
||||||
class="w-full h-full border-0"
|
class="w-full h-full border-0"
|
||||||
allow="clipboard-read; clipboard-write"
|
allow="clipboard-read; clipboard-write"
|
||||||
|
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"
|
||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -173,7 +177,8 @@ const emit = defineEmits(['logout', 'go-back', 'stop-all'])
|
|||||||
|
|
||||||
const currentView = ref('tk') // Default Tab
|
const currentView = ref('tk') // Default Tab
|
||||||
const autoDmMode = ref('config') // Default Sub-state: 'config' or 'browser'
|
const autoDmMode = ref('config') // Default Sub-state: 'config' or 'browser'
|
||||||
const adminLoaded = ref(false) // 懒加载:首次切换到管理后台时才加载 iframe
|
const adminLoaded = ref(false) // Web iframe 懒加载(仅非 Electron)
|
||||||
|
const shopOpened = ref(false) // Electron 只首开加载一次
|
||||||
const shopUrl = ENV.SHOP_URL
|
const shopUrl = ENV.SHOP_URL
|
||||||
|
|
||||||
const handleGoToBrowser = async () => {
|
const handleGoToBrowser = async () => {
|
||||||
@@ -196,13 +201,36 @@ const handleStopAll = () => {
|
|||||||
|
|
||||||
// Watch for view changes to manage native Electron BrowserViews
|
// Watch for view changes to manage native Electron BrowserViews
|
||||||
watch(currentView, async (newVal, oldVal) => {
|
watch(currentView, async (newVal, oldVal) => {
|
||||||
// 懒加载管理后台 iframe
|
// 懒加载 Web 端 iframe(仅非 Electron)
|
||||||
if (newVal === 'shop' && !adminLoaded.value) {
|
if (newVal === 'shop' && !adminLoaded.value && !isElectron()) {
|
||||||
adminLoaded.value = true
|
adminLoaded.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isElectron()) return
|
if (!isElectron()) return
|
||||||
|
|
||||||
|
if (newVal === 'shop') {
|
||||||
|
if (!shopOpened.value) {
|
||||||
|
shopOpened.value = true
|
||||||
|
try {
|
||||||
|
await window.electronAPI.openShop(shopUrl)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('打开商店失败:', e)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await window.electronAPI.openShop(shopUrl)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('打开商店失败:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (oldVal === 'shop') {
|
||||||
|
try {
|
||||||
|
await window.electronAPI.hideShop()
|
||||||
|
} catch (e) {
|
||||||
|
console.error('隐藏商店失败:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (newVal === 'auto_dm' && autoDmMode.value === 'browser') {
|
if (newVal === 'auto_dm' && autoDmMode.value === 'browser') {
|
||||||
// Switching TO Auto DM tab AND we are in browser mode: Show views
|
// Switching TO Auto DM tab AND we are in browser mode: Show views
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user