ant-design / ant-design-pro

👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
https://pro.ant.design
MIT License
36.48k stars 8.14k forks source link

👑 [需求]大神们好!我想问一下nodejs转Denojs,有人转过么 #8078

Closed jicvi closed 3 years ago

jicvi commented 3 years ago

🥰 需求描述

ant-design-pro中nodejs替换成Denojs来实现

例如:home页 import { Vue, VueServerRenderer } from './deps.ts'; import { Router, Request, Response } from 'https://linweiwei123.github.io/aok/mod.ts'; import App from './app.tsx';

export async function init(router: Router) { const browserBundlePath = '/browser.js'; // @ts-ignore const renderer = VueServerRenderer.createRenderer();

const js = `
import "https://cdn.jsdelivr.net/npm/vue/dist/vue.js";
const App = new Vue({
    template: \`<div id="app-4">
    <h1>计数:{{count}}</h1>
    <button v-on:click="inCrease">inCrease</button>
    <ol>
      <li v-for="todo in todos">
        {{ todo.text }}
      </li>
    </ol>
  </div>\`,
    el: '#app',
    data: {
        count: 0,
        todos: [{ text: '学习 JavaScript' }, { text: '学习 Vue' }, { text: '整个牛项目' }],
    },
    methods: {
        inCrease: function () {
            // @ts-ignore
            this.count++;
        },
    },
});`;

const content = await renderer.renderToString(App);
const html = `<html><head><style>* { font-family: Helvetica; }</style><script type="module" src="${browserBundlePath}"></script></head><body>${content}</body></html>`;

router.get(browserBundlePath, async ({ request, response }: { request: Request; response: Response }) => {
    response.body = js;
    response.type = 'application/javascript';
});

router.get('/home', async ({ request, response }: { request: Request; response: Response }) => {
    response.body = html;
});

}

🧐 解决方案

🚑 其他信息

chenshuai2144 commented 3 years ago

尽量不要在生产环境用玩具。现在denojs 还没完成基础建设,自己玩玩就好了

jicvi commented 3 years ago

@chenshuai2144 是的 在安全方面deno比node安全,我在客户端测试是无法查看js/ts代码,deno在安全方面潜力比较大 所以我试着将ant-design-pro的nodejs转换为denojs环境

chenshuai2144 commented 3 years ago

express还没支持 你可以先去先帮他们