diff --git a/router-app/.gitignore b/router-app/.gitignore deleted file mode 100644 index 3c3629e..0000000 --- a/router-app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/router-app/pem/https-cert.pem b/router-app/pem/https-cert.pem deleted file mode 100644 index 68f4fce..0000000 --- a/router-app/pem/https-cert.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICXTCCAcagAwIBAgIJHsP036vqWER/MA0GCSqGSIb3DQEBBQUAMF8xCjAIBgNV -BAMTASoxCzAJBgNVBAYTAkNOMREwDwYDVQQIEwhaaGVKaWFuZzERMA8GA1UEBxMI -SGFuZ3pob3UxETAPBgNVBAoTCEVudmlzaW9uMQswCQYDVQQLEwJJVDAeFw0yNTAz -MDcxNDIwMTJaFw0yNjAzMDcxNDIwMTJaMF8xCjAIBgNVBAMTASoxCzAJBgNVBAYT -AkNOMREwDwYDVQQIEwhaaGVKaWFuZzERMA8GA1UEBxMISGFuZ3pob3UxETAPBgNV -BAoTCEVudmlzaW9uMQswCQYDVQQLEwJJVDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw -gYkCgYEAquA2XnwduVSJHvnTW4r5yodz/joTPUi+r8kS/KJyR/NQ5xovtDY2gJoO -nJk8qekcLKuofskIIu4HFsCE7AYBkQGaYmc+0cCQCmEpwivesbeMB0ydz+6NwLQn -32HVjtMtx3gUcywGdMntiQb/P9FIhtE132wOmW9PeSl0dx/nyrUCAwEAAaMhMB8w -HQYDVR0RBBYwFIIBKoIJbG9jYWxob3N0hwR/AAABMA0GCSqGSIb3DQEBBQUAA4GB -AJsjIZgb6iE4OTXoEDiBPmHM+byWs20K2eCvi79V9/vns90IroBQfGirIsovv923 -SqjmdAFsZkRUbZvX99lBX0mmZK9KTE4K9YUm7bv+d8+fBPxAgNFSTRiSNBeNh0Lh -HdJUiI/tzIfI6RRg1pFDC1tOG083Cl/YElN879w3Iipi ------END CERTIFICATE----- diff --git a/router-app/pem/https-key.pem b/router-app/pem/https-key.pem deleted file mode 100644 index 7263037..0000000 --- a/router-app/pem/https-key.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQCq4DZefB25VIke+dNbivnKh3P+OhM9SL6vyRL8onJH81DnGi+0 -NjaAmg6cmTyp6Rwsq6h+yQgi7gcWwITsBgGRAZpiZz7RwJAKYSnCK96xt4wHTJ3P -7o3AtCffYdWO0y3HeBRzLAZ0ye2JBv8/0UiG0TXfbA6Zb095KXR3H+fKtQIDAQAB -AoGADDEbL/qjFEoXzoH8tpdf4zdu60CxhrneASTTmfrtNH0D1LlllfIYSWy0hi/Y -yDa9r+I/j2xAjF13XAQ4d66mBdjCRATLx/aL495o+e6NkIBEAgdP88hHm13F6gg+ -h8iMixs5mkwU41sghnCYeBqlziKPi8fsoTmhK0VETFUtDQECQQDT0kZ7OCEVNcz0 -LAUPO7ukeHAYnGYns+Q3F3kgonzHPGflClH5dsg0NS1HFQj6Ny2oyUupjNePOCJK -88zNehIlAkEAzoO9zrE+AoTPleVpe7TAUlZB1YMa7W1C5owjyEkv4TjIe8mpwWM/ -9vVe+SGUnc6DZy6xkk5zWmA2w18SexXJUQJBAJQbcyy1EmzCMYyJOwBrw8g8biTH -NqaMIgZjY05uTtEAa6S6kpbbdyEKDZ6mFqDd9A8QsNbco9yAY3oE/i6uLAECQHOt -a9aphZiXmEfYl3uJxejZFEtrAtxXxY+qlCiOhllcG0Drt0DyPVQyIZ7fZoX2tbhI -eYMAmrDXEBXj3VBA5eECQCLGpQKqo06QwP2qZ9mEaPB9KvVcABo97b9Lf7VUqcJx -tFWRSlpeICpDQZHqX92nwoD/2fGCH3br3o94k1oyApI= ------END RSA PRIVATE KEY----- diff --git a/router-app/src/app.ts b/router-app/src/app.ts deleted file mode 100644 index ce606b6..0000000 --- a/router-app/src/app.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { App } from '@kevisual/router'; -import { httpsConfig } from './modules/config'; -export const app = new App({ - serverOptions: { - httpType: 'https', - httpsCert: httpsConfig.cert.toString(), - httpsKey: httpsConfig.key.toString(), - }, -}); -app - .route({ - path: 'demo', - }) - .define(async (ctx) => { - ctx.body = 'hello world'; - }) - .addTo(app); -console.log('httpsConfig', `https://localhost:51015/api/router?path=demo`); -app.listen(51015, () => { - console.log('Router App is running on https://localhost:51015'); -}); diff --git a/router-app/src/modules/config.ts b/router-app/src/modules/config.ts deleted file mode 100644 index 2d9d746..0000000 --- a/router-app/src/modules/config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -const pemDir = path.join(process.cwd(), 'router-app', 'pem'); - -export const httpsConfig = { - key: fs.readFileSync(path.join(pemDir, 'https-key.pem')), - cert: fs.readFileSync(path.join(pemDir, 'https-cert.pem')), -}; diff --git a/router-app/src/modules/config/index.ts b/router-app/src/modules/config/index.ts deleted file mode 100644 index 9b1a1ee..0000000 --- a/router-app/src/modules/config/index.ts +++ /dev/null @@ -1,108 +0,0 @@ -import path from 'path'; -import { homedir } from 'os'; -import fs from 'fs'; -import { checkFileExists, createDir } from '../file'; - -export const kevisualUrl = 'https://kevisual.xiongxiao.me'; -const configDir = createDir(path.join(homedir(), '.config/envision')); -export const configPath = path.join(configDir, 'assistant-config.json'); -export const appConfigPath = path.join(configDir, 'assistant-app-config.json'); -export const appDir = createDir(path.join(configDir, 'assistant-app/frontend')); -export const LocalElectronAppUrl = 'https://assistant.app/user/tiptap/'; - -type AssistantConfig = { - pageApi?: string; // https://kevisual.silkyai.cn - loadURL?: string; // https://assistant.app/user/tiptap/ - proxy?: { user: string; key: string; path: string }[]; -}; -let assistantConfig: AssistantConfig; -export const getConfig = () => { - try { - if (!checkFileExists(configPath)) { - fs.writeFileSync(configPath, JSON.stringify({ proxy: [] }, null, 2)); - return { - loadURL: LocalElectronAppUrl, - pageApi: '', - proxy: [], - }; - } - assistantConfig = JSON.parse(fs.readFileSync(configPath, 'utf8')); - return assistantConfig; - } catch (error) { - console.error(error); - return { - loadURL: LocalElectronAppUrl, - pageApi: '', - proxy: [], - }; - } -}; -export const getCacheAssistantConfig = () => { - if (assistantConfig) { - return assistantConfig; - } - return getConfig(); -}; - -export const setConfig = (config?: AssistantConfig) => { - if (!config) { - return assistantConfig; - } - assistantConfig = config; - fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); - return assistantConfig; -}; -type AppConfig = { - list: any[]; -}; -/** - * 应用配置 - * @returns - */ -export const getAppConfig = (): AppConfig => { - if (!checkFileExists(appConfigPath)) { - return { - list: [], - }; - } - return JSON.parse(fs.readFileSync(appConfigPath, 'utf8')); -}; - -export const setAppConfig = (config: AppConfig) => { - fs.writeFileSync(appConfigPath, JSON.stringify(config, null, 2)); - return config; -}; - -export const addAppConfig = (app: any) => { - const config = getAppConfig(); - const assistantConfig = getCacheAssistantConfig(); - const _apps = config.list; - const _proxy = assistantConfig.proxy || []; - const { user, key } = app; - const newProxyInfo = { - user, - key, - path: `/${user}/${key}`, - }; - const _proxyIndex = _proxy.findIndex((_proxy: any) => _proxy.path === newProxyInfo.path); - if (_proxyIndex !== -1) { - _proxy[_proxyIndex] = newProxyInfo; - } else { - _proxy.push(newProxyInfo); - } - - const _app = _apps.findIndex((_app: any) => _app.id === app.id); - if (_app !== -1) { - _apps[_app] = app; - } else { - _apps.push(app); - } - setAppConfig({ ...config, list: _apps }); - setConfig({ ...assistantConfig, proxy: _proxy }); - return config; -}; - -export const getAppList = () => { - const config = getAppConfig(); - return config.list || []; -}; diff --git a/router-app/src/modules/file/index.ts b/router-app/src/modules/file/index.ts deleted file mode 100644 index f1f45bb..0000000 --- a/router-app/src/modules/file/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import fs from 'fs'; - -export const checkFileExists = (filePath: string, checkIsFile = false) => { - try { - fs.accessSync(filePath); - if (checkIsFile) { - return fs.statSync(filePath).isFile(); - } - return true; - } catch (error) { - return false; - } -}; - -export const createDir = (dirPath: string) => { - if (!checkFileExists(dirPath)) { - fs.mkdirSync(dirPath, { recursive: true }); - } - return dirPath; -}; diff --git a/router-app/src/proxy/index.ts b/router-app/src/proxy/index.ts deleted file mode 100644 index 8875722..0000000 --- a/router-app/src/proxy/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import http from 'http'; - -export const handleRequest = async (req: http.IncomingMessage, res: http.ServerResponse) => { - -} \ No newline at end of file diff --git a/router-app/src/scripts/create-sign.ts b/router-app/src/scripts/create-sign.ts deleted file mode 100644 index 9c94a76..0000000 --- a/router-app/src/scripts/create-sign.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { createCert } from '@kevisual/router/sign'; -import { writeFileSync } from 'fs'; -import path from 'path'; -const pemDir = path.join(process.cwd(), 'router-app', 'pem'); - -const { key, cert } = createCert([ - { - name: 'commonName', - value: 'localhost', - }, - { - name: 'organizationName', - value: 'kevisual', - }, -]); - -writeFileSync(path.join(pemDir, 'https-key.pem'), key); -writeFileSync(path.join(pemDir, 'https-cert.pem'), cert); diff --git a/router-app/static/download.ts b/router-app/static/download.ts deleted file mode 100644 index 962021d..0000000 --- a/router-app/static/download.ts +++ /dev/null @@ -1,18 +0,0 @@ -import fs from 'fs'; - -const apps = [ - { user: 'root', key: 'enter', version: '1.0.0' }, // - { user: 'root', key: 'packages', version: '1.0.0' }, -]; - -const baseURL = 'https://kevisual.silkyai.cn'; - -const downloadApps = () => { - // -}; - -export const downloadLink = async (url: string, path: string) => { - const res = await fetch(url); - const blob = await res.blob(); - fs.writeFileSync(path, Buffer.from(await blob.arrayBuffer())); -}; diff --git a/router-app/static/enter/electron.js b/router-app/static/enter/electron.js deleted file mode 100644 index a101fbc..0000000 --- a/router-app/static/enter/electron.js +++ /dev/null @@ -1,23 +0,0 @@ -export const checkIsElectron = () => { - return typeof window !== 'undefined' && typeof window.electron === 'object'; -}; -export const getElectron = () => { - return window.electron; -}; -export const saveAppConfig = async (config) => { - const check = checkIsElectron(); - if (!check) { - console.log('not electron'); - return []; - } - const electron = getElectron(); - const saveResult = await electron.ipcRenderer.invoke('save-app-config', config); - return saveResult; -}; -export const relunch = async () => { - const check = checkIsElectron(); - if (!check) { - console.log('not electron'); - return []; - } -}; \ No newline at end of file diff --git a/router-app/static/enter/index.html b/router-app/static/enter/index.html deleted file mode 100644 index 09ee7a6..0000000 --- a/router-app/static/enter/index.html +++ /dev/null @@ -1,214 +0,0 @@ - - -
- - -new pageApi: ${newPageApi}
- `; - const relunchButton = document.getElementById('relunch'); - relunchButton.addEventListener('click', () => { - window.electron.ipcRenderer.invoke('relunch'); - }); - }); -}; diff --git a/router-app/static/index.html b/router-app/static/index.html deleted file mode 100644 index 5acdf85..0000000 --- a/router-app/static/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -${pkg.description}
-