If you like this project please show your support with a GitHub star. Much appreciated!
Repository with Angular CLI and Angular Universal
Translations:
Resources:
document is not defined
and window is not defined
- hereMockServerBrowserModule
)TransferHttp
UniversalStorage
ng add @angular/pwa --project universal-demo
)yarn
or npm install
yarn start
or npm run start
- for client renderingyarn ssr
or npm run ssr
- for server-side renderingyarn build:universal
or npm run build:universal
- for assembly in releaseyarn server
or npm run server
- to start the serveryarn build:prerender
or npm run build:prerender
- to generate static by static.paths.ts
npm run ssr:watch
To transfer ssr to your repository, you need the following files:
Official example in English: https://github.com/angular/universal-starterModules used for universal:
import {TransferState} from '@angular/platform-browser';
and it is necessary to implement the request rest api on the server and the absence of the second request a second time. See home.component.ts
(delay 3c)this.http.get('https://reqres.in/api/users?delay=3').subscribe(result => {
this.result = result;
});
export const AppRoutes = RouterModule.forRoot(routes, { initialNavigation: 'enabled' });
- so that there is no flashing of the page!
to work with cookies, it is written AppStorage
, which with DI allows you to give different implementations for the server and the browser. See server.storage.ts
and browser.storage.ts
for implementations. In server.ts
there is
providers: [
{
provide: REQUEST, useValue: (req)
},
{
provide: RESPONSE, useValue: (res)
}
]
to work with REQUEST and RESPONSE via DI - this is necessary for implementing UniversalStorage when working with cookies.
webpack.config.js
is written exclusively for building server.ts file in server.js, since angular-cli has [bug](https: //github.com / angular/angular-cli/issues/7200) to work with 3d dependencies. - To solve some problems, use the following code in server.ts
Solving the problems of global variables, including document is not defined
and window is not defined
const domino = require('domino');
const fs = require('fs');
const path = require('path');
const template = fs.readFileSync(path.join(__dirname, '.', 'dist', 'index.html')).toString();
const win = domino.createWindow(template);
const files = fs.readdirSync(`${process.cwd()}/dist-server`);
// const styleFiles = files.filter(file => file.startsWith('styles'));
// const hashStyle = styleFiles[0].split('.')[1];
// const style = fs.readFileSync(path.join(__dirname, '.', 'dist-server', `styles.${hashStyle}.bundle.css`)).toString();
global['window'] = win;
Object.defineProperty(win.document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true
};
},
});
global['document'] = win.document;
global['CSS'] = null;
// global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
global['Prism'] = null;
global['navigator'] = req['headers']['user-agent'];
this allows you to remove some of the problems when working with undefined
.
ng update @angular/cli
preboot
is not working now描述 (Description) 通用选择器选择文档中可用的所有元素。 语法 (Syntax) 以下是使用此选择器的简单语法 - $('*') 参数 (Parameters) 以下是此选择器使用的所有参数的说明 - * - 一个象征性的明星。 返回值 (Returns) 与任何其他jQuery选择器一样,此选择器也返回一个填充了found元素的数组。 例子 (Example) $('*')选择文
universal Please support this project by simply putting a GitHub star. Share this library with friends on twitter and everywhere else you can. universal is a seed project for Angular Universal apps fo
�� Universal React Simple universal React application with server side rendering. Built using latest version of React (v16), React Router (v5+), Redux (v7+), Express (v5+), Webpack (v4+), Babel Preset
A progressive Node.js framework for building efficient and scalable server-side applications. Description Angular Universal module for Nest. Installation Using the Angular CLI: $ ng add @nestjs/ng-uni
Universal ImageLoader是最早开源的 Android 图片缓存库, 强大的缓存机制。 功能特点: 支持多线程加载图片(同步或者异步加载) 具有很高的定制性 每一张图片都有很多备用资源(原始图片、内存缓存、Bitmap等 ) 图片能缓存在外设的SD卡内 可以监听到图片加载状态相关信息 图片加载流程图: 使用示例: ImageLoader imageLoader = ImageLoa
最近台湾也有一个Android开发者研发了一款类似的一键root程序Universal Androot,同样操作和Easy Root一样简单,而且用户也可以再取得root权限后使用UnRoot功能来还原之前的系统状态,这意味着如果你哪天玩腻了rooted的手机想回到过 去,或者官方Android系统升级推出时也想凑凑热闹可以使用UnRoot功能。 目前这款Universal Androot软件支持