Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@srejs/vue-next #8

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@
{
"type": "node",
"request": "launch",
"name": "vue dev",
"name": "vue3 start",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"dev"
"start"
],
"port": 9229,
"skipFiles": [
"<node_internals>/**"
],
"cwd": "${workspaceRoot}/packages/app-vue",
"cwd": "${workspaceRoot}/packages/app-vue-next",
},
]
}
11 changes: 11 additions & 0 deletions example/uma-css-module/web/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ declare global {
}
}

declare module '*.module.less' {
const classes: { [key: string]: string };
export default classes;
}

declare module '*.module.scss' {
const classes: { [key: string]: string };
export default classes;
}

declare module 'react-dom'
export {};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
"prepublish": "npm run test && lerna run lint && lerna run build",
"publish": "lerna publish",
"watch":"lerna run watch",
"postinstall": "npm run lint && npx checker-init && npm run init && npm run linkReact && npm run linkReactDom && npm run linkReactRouter && cd packages/app && npm run link",
"postinstall": "npm run lint && npx checker-init && npm run init && npm run linkReact && npm run linkReactDom && npm run linkReactRouter && npm run linkVue && npm run linkApp && npm run linkVueNext",
"linkApp": "cd packages/app && npm run link ",
"linkVueNext": "cd packages/vue-next && npm run link ",
"linkReact": "cd packages/react/node_modules/react && yarn link",
"linkReactDom": "cd packages/react/node_modules/react-dom && yarn link",
"linkReactRouter": "cd packages/react/node_modules/react-router-dom && yarn link",
"linkVue": "cd packages/app-vue-next/node_modules/vue && yarn link",
"linkVuex": "cd packages/app-vue-next/node_modules/vuex && yarn link",
"linkVueRouter": "cd packages/app-vue-next/node_modules/vue-router && yarn link",
"lint": "eslint packages/*/src --fix"
},
"devDependencies": {
Expand Down
45 changes: 45 additions & 0 deletions packages/app-vue-next/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"parser": "babel-eslint",
"plugins": [
"prettier"
],
"parserOptions": {
"ecmaVersion":6,
"sourceType":"module",
"ecmaFeatures":
{
"jsx":true,
"experimentalObjectRestSpread":true,
"modules":true
}
},
"env": {
"browser": true,
"amd": true,
"es6": true,
"node": true,
"mocha": true
},
"rules": {
"comma-dangle": 1,
"quotes": [ 0, "single" ],
"no-undef":"error",
"global-strict": 0,
"no-extra-semi": 1,
"no-underscore-dangle": 0,
"no-console": 0,
"no-unused-vars": 1,
"no-trailing-spaces": [1, { "skipBlankLines": true }],
"no-unreachable": 1,
"no-alert": 0,
"prettier/prettier":["error",{
"printWidth": 100,
"tabWidth": 4,
"semi": true,
"trailingComma": "none",
"singleQuote": true,
"bracketSpacing": true,
"jsxBracketSameLine": true
}]
}
}
63 changes: 63 additions & 0 deletions packages/app-vue-next/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Koa from 'koa';
import srejs from '@srejs/vue-next';

const app = new Koa();
const Sre = new srejs(app, process.env.NODE_ENV != 'production', false, { version: '3' });
app.use(async (ctx, next) => {
if (ctx.path === '/vue' || ctx.path === '/') {
const html = await Sre.render(
ctx,
'vue',
{
title: 'vue ssr',
keywords: 'srejs vue ssr',
description: '简单好用的服务端渲染引擎工具!',
state: {
msg: 'vuex state',
say: 'vuex 你好 vue ssr!'
}
},
{ ssr: true }
);
ctx.type = 'text/html';
ctx.body = html;
} else if (ctx.path.startsWith('/index')) {
const html = await Sre.render(
ctx,
'index',
{
title: 'Vue-Router',
keywords: 'srejs vue ssr',
description: '简单好用的服务端渲染引擎工具!',
home: '这是home页',
about: '这是about页'
},
{ ssr: true }
);
ctx.type = 'text/html';
ctx.body = html;
} else if (ctx.path.startsWith('/vuex')) {
const html = await Sre.render(
ctx,
'vuex',
{
title: '简单的计数器',
keywords: 'vuessr vuex server',
description: '简单的计数器 server',
message: '这是来自服务端初始化数据',
state: {
count: 200
}
},
{ ssr: true }
);
ctx.type = 'text/html';
ctx.body = html;
} else {
await next();
ctx.type = 'text/html';
ctx.body = '404 not found';
}
});
app.listen(8001);
console.log('8001端口启动成功!');
3 changes: 3 additions & 0 deletions packages/app-vue-next/config/ssr.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
version: '3'
};
Loading