-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b671be1
commit 493fc58
Showing
16 changed files
with
235 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { onMounted, version } from 'vue' | ||
import { trpc } from './trpc' | ||
|
||
export function initMPClient() { | ||
sendVersion() | ||
getCurrentPage() | ||
} | ||
|
||
function sendVersion() { | ||
const { uniRuntimeVersion } = uni.getSystemInfoSync() | ||
|
||
const vueVersion = version | ||
const uniVersion = uniRuntimeVersion | ||
|
||
trpc.sendVersion.subscribe({ | ||
vueVersion, | ||
uniVersion, | ||
}, { | ||
onComplete: () => {}, | ||
}) | ||
} | ||
|
||
export function getCurrentPage() { | ||
onMounted(() => { | ||
// const i = getCurrentInstance() | ||
|
||
// const pages = getCurrentPages() | ||
// const i = pages[pages.length - 1] | ||
|
||
// console.log('instance', i) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { EventEmitter } from 'node:stream' | ||
import { z } from 'zod' | ||
import { observable } from '@trpc/server/observable' | ||
import { publicProcedure, router } from './../trpc' | ||
|
||
interface Version { | ||
vueVersion: string | ||
uniVersion: string | ||
} | ||
|
||
export function versionRouter(eventEmitter: EventEmitter) { | ||
const { input, subscription } = publicProcedure | ||
|
||
return router({ | ||
sendVersion: input( | ||
z.object({ | ||
vueVersion: z.string(), | ||
uniVersion: z.string(), | ||
}), | ||
).subscription(({ input }) => { | ||
eventEmitter.emit('version', input) | ||
}), | ||
onVersion: subscription(() => { | ||
return observable<Version>((emit) => { | ||
const versionHandler = (data: Version) => { | ||
emit.next(data) | ||
} | ||
|
||
eventEmitter.on('version', versionHandler) | ||
|
||
return () => { | ||
eventEmitter.off('version', versionHandler) | ||
} | ||
}) | ||
}), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Application } from '@webviewjs/webview' | ||
|
||
export function open(port: number) { | ||
const app = new Application() | ||
const window = app.createBrowserWindow() | ||
console.log(`http://localhost:${port}`) | ||
window.createWebview({ | ||
url: `http://localhost:${port}`, | ||
}) | ||
app.run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.