feat: 项目结构优化
This commit is contained in:
@@ -57,26 +57,26 @@ const refreshActiveAddress = () => {
|
||||
}
|
||||
|
||||
const syncList = async () => {
|
||||
const list: TabInfo[] = await (window as any).ipcAPI.tabs.list()
|
||||
const list: TabInfo[] = await (window as any).api.tabs.list()
|
||||
tabs.splice(0, tabs.length, ...list)
|
||||
if (!activeId.value && list.length > 0) activeId.value = list[0].id
|
||||
refreshActiveAddress()
|
||||
}
|
||||
|
||||
const onNewTab = async () => {
|
||||
const info: TabInfo = await (window as any).ipcAPI.tabs.create('about:blank')
|
||||
const info: TabInfo = await (window as any).api.tabs.create('about:blank')
|
||||
activeId.value = info.id
|
||||
}
|
||||
|
||||
const onSwitch = async (id: string) => {
|
||||
await (window as any).ipcAPI.tabs.switch(id)
|
||||
await (window as any).api.tabs.switch(id)
|
||||
activeId.value = id
|
||||
refreshActiveAddress()
|
||||
}
|
||||
|
||||
const onCloseTab = async () => {
|
||||
if (!activeId.value) return
|
||||
await (window as any).ipcAPI.tabs.close(activeId.value)
|
||||
await (window as any).api.tabs.close(activeId.value)
|
||||
}
|
||||
|
||||
const normalizeUrl = (u: string) => {
|
||||
@@ -90,46 +90,46 @@ const onNavigate = async () => {
|
||||
if (!activeId.value || !address.value) return
|
||||
const url = normalizeUrl(address.value)
|
||||
if (!url) return
|
||||
await (window as any).ipcAPI.tabs.navigate(activeId.value, url)
|
||||
await (window as any).api.tabs.navigate(activeId.value, url)
|
||||
}
|
||||
|
||||
const onReload = async () => {
|
||||
if (!activeId.value) return
|
||||
await (window as any).ipcAPI.tabs.reload(activeId.value)
|
||||
await (window as any).api.tabs.reload(activeId.value)
|
||||
}
|
||||
|
||||
const onBack = async () => {
|
||||
if (!activeId.value) return
|
||||
await (window as any).ipcAPI.tabs.back(activeId.value)
|
||||
await (window as any).api.tabs.back(activeId.value)
|
||||
}
|
||||
|
||||
const onForward = async () => {
|
||||
if (!activeId.value) return
|
||||
await (window as any).ipcAPI.tabs.forward(activeId.value)
|
||||
await (window as any).api.tabs.forward(activeId.value)
|
||||
}
|
||||
|
||||
const onCloseTabId = async (id: string) => {
|
||||
await (window as any).ipcAPI.tabs.close(id)
|
||||
await (window as any).api.tabs.close(id)
|
||||
}
|
||||
|
||||
const onCloseWindow = () => (window as any).ipcAPI.window.close()
|
||||
const onMinimizeWindow = () => (window as any).ipcAPI.window.minimize()
|
||||
const onMaximizeWindow = () => (window as any).ipcAPI.window.maximize()
|
||||
const onCloseWindow = () => (window as any).api.window.close()
|
||||
const onMinimizeWindow = () => (window as any).api.window.minimize()
|
||||
const onMaximizeWindow = () => (window as any).api.window.maximize()
|
||||
|
||||
onMounted(async () => {
|
||||
await syncList()
|
||||
; (window as any).ipcAPI.tabs.on('tab-created', (info: TabInfo) => {
|
||||
; (window as any).api.tabs.on('tab-created', (info: TabInfo) => {
|
||||
const i = tabs.findIndex(t => t.id === info.id)
|
||||
if (i === -1) tabs.push(info)
|
||||
activeId.value = info.id
|
||||
refreshActiveAddress()
|
||||
})
|
||||
; (window as any).ipcAPI.tabs.on('tab-updated', (info: TabInfo) => {
|
||||
; (window as any).api.tabs.on('tab-updated', (info: TabInfo) => {
|
||||
const i = tabs.findIndex(t => t.id === info.id)
|
||||
if (i >= 0) tabs[i] = info
|
||||
if (activeId.value === info.id) refreshActiveAddress()
|
||||
})
|
||||
; (window as any).ipcAPI.tabs.on('tab-closed', ({ tabId }: { tabId: string }) => {
|
||||
; (window as any).api.tabs.on('tab-closed', ({ tabId }: { tabId: string }) => {
|
||||
const i = tabs.findIndex(t => t.id === tabId)
|
||||
if (i >= 0) tabs.splice(i, 1)
|
||||
if (activeId.value === tabId) {
|
||||
@@ -138,7 +138,7 @@ onMounted(async () => {
|
||||
refreshActiveAddress()
|
||||
}
|
||||
})
|
||||
; (window as any).ipcAPI.tabs.on('tab-switched', ({ tabId }: { tabId: string }) => {
|
||||
; (window as any).api.tabs.on('tab-switched', ({ tabId }: { tabId: string }) => {
|
||||
activeId.value = tabId
|
||||
refreshActiveAddress()
|
||||
})
|
||||
|
||||
@@ -103,7 +103,7 @@ tab-switched: { tabId: TabId }
|
||||
1. 核心能力(主进程 + IPC + 预加载)
|
||||
- 实现 `TabManager` 与全部导航方法
|
||||
- 注册 IPC(tabs/bookmarks/plugins)与广播
|
||||
- 预加载扩展 `window.ipcAPI.tabs/*`、事件订阅封装
|
||||
- 预加载扩展 `window.api.tabs/*`、事件订阅封装
|
||||
2. 渲染层界面
|
||||
- 新建 `BrowserLayout` 与基础组件(TabBar、AddressBar、Controls)
|
||||
- 打通地址栏与导航;同步标题与加载状态
|
||||
|
||||
7
src/renderer/env.d.ts
vendored
7
src/renderer/env.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
declare module "@store/counter";
|
||||
declare module "@utils/request";
|
||||
declare module "@assets/images/*";
|
||||
declare module "@constant/rate";
|
||||
declare module "@constant/menus";
|
||||
declare module "@remixicon/vue";
|
||||
declare module "vue-router";
|
||||
@@ -105,7 +105,7 @@ const onSubmit = async () => {
|
||||
// const token = res && (res.token || res.data?.token || res.access_token);
|
||||
// if (!token) throw new Error("登录失败");
|
||||
// localStorage.setItem("token", token);
|
||||
// await (window as any).ipcAPI.app.setFrameless('/home')
|
||||
// await (window as any).api.app.setFrameless('/home')
|
||||
router.push('/home');
|
||||
} finally {
|
||||
// loading.value = false;
|
||||
|
||||
Reference in New Issue
Block a user