docs: init omiu docs
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"parser": "babel-eslint",
|
||||
"extends": ["prettier"],
|
||||
"plugins": ["prettier"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"mocha": true,
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"modules": true,
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"sinon": true,
|
||||
"expect": true
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"no-cond-assign": 1,
|
||||
"no-empty": 0,
|
||||
"no-console": 1,
|
||||
"semi": [1, "never"],
|
||||
"camelcase": 0,
|
||||
"comma-style": 2,
|
||||
"comma-dangle": [2, "never"],
|
||||
"indent": ["error", 2],
|
||||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
||||
"no-trailing-spaces": [2, { "skipBlankLines": true }],
|
||||
"max-nested-callbacks": [2, 3],
|
||||
"no-eval": 2,
|
||||
"no-implied-eval": 2,
|
||||
"no-new-func": 2,
|
||||
"guard-for-in": 0,
|
||||
"eqeqeq": 0,
|
||||
"no-else-return": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-dupe-keys": 2,
|
||||
"radix": 2,
|
||||
"strict": [2, "never"],
|
||||
"no-shadow": 0,
|
||||
"callback-return": [1, ["callback", "cb", "next", "done"]],
|
||||
"no-delete-var": 2,
|
||||
"no-undef-init": 2,
|
||||
"no-shadow-restricted-names": 2,
|
||||
"handle-callback-err": 0,
|
||||
"no-lonely-if": 2,
|
||||
"keyword-spacing": 2,
|
||||
"constructor-super": 2,
|
||||
"no-this-before-super": 2,
|
||||
"no-dupe-class-members": 2,
|
||||
"no-const-assign": 2,
|
||||
"prefer-spread": 2,
|
||||
"no-useless-concat": 2,
|
||||
"no-var": 2,
|
||||
"object-shorthand": 2,
|
||||
"prefer-arrow-callback": 2,
|
||||
"quotes": [1, "single"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
|
@ -0,0 +1,68 @@
|
|||
## Develop
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Release
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
## Eslint + Prettier
|
||||
|
||||
``` bash
|
||||
npm run fix
|
||||
```
|
||||
|
||||
## Directory description
|
||||
|
||||
```
|
||||
├─ config
|
||||
├─ public
|
||||
├─ scripts
|
||||
├─ src
|
||||
│ ├─ assets
|
||||
│ ├─ elements //Store all custom elements
|
||||
│ ├─ store //Store all this store of pages
|
||||
│ ├─ admin.js //Entry js of compiler,will build to admin.html
|
||||
│ └─ index.js //Entry js of compiler,will build to index.html
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
About compiled website URL:
|
||||
|
||||
Such as in windows:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"_build": "node scripts/build.js",
|
||||
"build":"set PUBLIC_URL=https://fe.wxpay.oa.com/dv&& npm run _build"
|
||||
}
|
||||
```
|
||||
|
||||
In mac os:
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"_build": "node scripts/build.js",
|
||||
"build":"PUBLIC_URL=https://fe.wxpay.oa.com/dv npm run _build",
|
||||
"fix": "eslint src --fix"
|
||||
},
|
||||
```
|
||||
|
||||
If you only want to use relative addresses:
|
||||
|
||||
```
|
||||
"build":"set PUBLIC_URL=.&& npm run _build" //windows
|
||||
"build":"PUBLIC_URL=. npm run _build", //mac os
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
Cli's auto-created project scaffolding is based on a single-page create-react-app to be converted into a multi-page one, with configuration issues to see [create-react-app user guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md)
|
|
@ -0,0 +1,28 @@
|
|||
let fs = require('fs'),
|
||||
fileList = [];
|
||||
|
||||
|
||||
if (typeof String.prototype.endsWith != 'function') {
|
||||
String.prototype.endsWith = function (suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
};
|
||||
}
|
||||
|
||||
function walk(path) {
|
||||
let dirList = fs.readdirSync(path);
|
||||
dirList.forEach(function (item) {
|
||||
if (!fs.statSync(path + '/' + item).isDirectory()) {
|
||||
if (item.endsWith('\.js')) {
|
||||
fileList.push(item.substr(0, item.length - 3));
|
||||
}
|
||||
} else {
|
||||
//walk(path + '/' + item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walk('./src');
|
||||
|
||||
|
||||
|
||||
module.exports = fileList;
|
|
@ -0,0 +1,93 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const paths = require('./paths');
|
||||
|
||||
// Make sure that including paths.js after env.js will read .env variables.
|
||||
delete require.cache[require.resolve('./paths')];
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV;
|
||||
if (!NODE_ENV) {
|
||||
throw new Error(
|
||||
'The NODE_ENV environment variable is required but was not specified.'
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
||||
var dotenvFiles = [
|
||||
`${paths.dotenv}.${NODE_ENV}.local`,
|
||||
`${paths.dotenv}.${NODE_ENV}`,
|
||||
// Don't include `.env.local` for `test` environment
|
||||
// since normally you expect tests to produce the same
|
||||
// results for everyone
|
||||
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
|
||||
paths.dotenv,
|
||||
].filter(Boolean);
|
||||
|
||||
// Load environment variables from .env* files. Suppress warnings using silent
|
||||
// if this file is missing. dotenv will never modify any environment variables
|
||||
// that have already been set. Variable expansion is supported in .env files.
|
||||
// https://github.com/motdotla/dotenv
|
||||
// https://github.com/motdotla/dotenv-expand
|
||||
dotenvFiles.forEach(dotenvFile => {
|
||||
if (fs.existsSync(dotenvFile)) {
|
||||
require('dotenv-expand')(
|
||||
require('dotenv').config({
|
||||
path: dotenvFile,
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// We support resolving modules according to `NODE_PATH`.
|
||||
// This lets you use absolute paths in imports inside large monorepos:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/253.
|
||||
// It works similar to `NODE_PATH` in Node itself:
|
||||
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
|
||||
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
|
||||
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
|
||||
// We also resolve them to make sure all tools using them work consistently.
|
||||
const appDirectory = fs.realpathSync(process.cwd());
|
||||
process.env.NODE_PATH = (process.env.NODE_PATH || '')
|
||||
.split(path.delimiter)
|
||||
.filter(folder => folder && !path.isAbsolute(folder))
|
||||
.map(folder => path.resolve(appDirectory, folder))
|
||||
.join(path.delimiter);
|
||||
|
||||
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
|
||||
// injected into the application via DefinePlugin in Webpack configuration.
|
||||
const REACT_APP = /^REACT_APP_/i;
|
||||
|
||||
function getClientEnvironment(publicUrl) {
|
||||
const raw = Object.keys(process.env)
|
||||
.filter(key => REACT_APP.test(key))
|
||||
.reduce(
|
||||
(env, key) => {
|
||||
env[key] = process.env[key];
|
||||
return env;
|
||||
},
|
||||
{
|
||||
// Useful for determining whether we’re running in production mode.
|
||||
// Most importantly, it switches React into the correct mode.
|
||||
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||
// Useful for resolving the correct path to static assets in `public`.
|
||||
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
||||
// This should only be used as an escape hatch. Normally you would put
|
||||
// images into the `src` and `import` them in code to get their paths.
|
||||
PUBLIC_URL: publicUrl,
|
||||
}
|
||||
);
|
||||
// Stringify all values so we can feed into Webpack DefinePlugin
|
||||
const stringified = {
|
||||
'process.env': Object.keys(raw).reduce((env, key) => {
|
||||
env[key] = JSON.stringify(raw[key]);
|
||||
return env;
|
||||
}, {}),
|
||||
};
|
||||
|
||||
return { raw, stringified };
|
||||
}
|
||||
|
||||
module.exports = getClientEnvironment;
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
// This is a custom Jest transformer turning style imports into empty objects.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process() {
|
||||
return 'module.exports = {};';
|
||||
},
|
||||
getCacheKey() {
|
||||
// The output is always the same.
|
||||
return 'cssTransform';
|
||||
},
|
||||
};
|
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
// This is a custom Jest transformer turning file imports into filenames.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process(src, filename) {
|
||||
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const url = require('url');
|
||||
|
||||
// Make sure any symlinks in the project folder are resolved:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/637
|
||||
const appDirectory = fs.realpathSync(process.cwd());
|
||||
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
||||
|
||||
const envPublicUrl = process.env.PUBLIC_URL;
|
||||
|
||||
function ensureSlash(path, needsSlash) {
|
||||
const hasSlash = path.endsWith('/');
|
||||
if (hasSlash && !needsSlash) {
|
||||
return path.substr(path, path.length - 1);
|
||||
} else if (!hasSlash && needsSlash) {
|
||||
return `${path}/`;
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
const getPublicUrl = appPackageJson =>
|
||||
envPublicUrl || require(appPackageJson).homepage;
|
||||
|
||||
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
||||
// "public path" at which the app is served.
|
||||
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
||||
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
||||
// We can't use a relative path in HTML because we don't want to load something
|
||||
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
||||
function getServedPath(appPackageJson) {
|
||||
const publicUrl = getPublicUrl(appPackageJson);
|
||||
const servedUrl =
|
||||
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
|
||||
return ensureSlash(servedUrl, true);
|
||||
}
|
||||
|
||||
// config after eject: we're in ./config/
|
||||
module.exports = {
|
||||
dotenv: resolveApp('.env'),
|
||||
appBuild: resolveApp('../docs'),
|
||||
appPublic: resolveApp('public'),
|
||||
appHtml: resolveApp('public/index.html'),
|
||||
appIndexJs: resolveApp('src/index.js'),
|
||||
appPackageJson: resolveApp('package.json'),
|
||||
appSrc: resolveApp('src'),
|
||||
yarnLockFile: resolveApp('yarn.lock'),
|
||||
testsSetup: resolveApp('src/setupTests.js'),
|
||||
appNodeModules: resolveApp('node_modules'),
|
||||
publicUrl: getPublicUrl(resolveApp('package.json')),
|
||||
servedPath: getServedPath(resolveApp('package.json')),
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
if (typeof Promise === 'undefined') {
|
||||
// Rejection tracking prevents a common issue where React gets into an
|
||||
// inconsistent state due to an error, but it gets swallowed by a Promise,
|
||||
// and the user has no idea what causes React's erratic future behavior.
|
||||
require('promise/lib/rejection-tracking').enable();
|
||||
window.Promise = require('promise/lib/es6-extensions.js');
|
||||
}
|
||||
|
||||
// fetch() polyfill for making API calls.
|
||||
require('whatwg-fetch');
|
||||
|
||||
// Object.assign() is commonly used with React.
|
||||
// It will use the native implementation if it's present and isn't buggy.
|
||||
Object.assign = require('object-assign');
|
||||
|
||||
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
|
||||
// We don't polyfill it in the browser--this is user's responsibility.
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
require('raf').polyfill(global);
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
'use strict';
|
||||
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
||||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
|
||||
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
||||
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||
const getClientEnvironment = require('./env');
|
||||
const paths = require('./paths');
|
||||
const fileList = require('./entry');
|
||||
|
||||
let entry = {};
|
||||
let htmlWebpackPlugins = [];
|
||||
|
||||
fileList.forEach(function (item) {
|
||||
entry[item] = [
|
||||
require.resolve('./polyfills'),
|
||||
require.resolve('react-dev-utils/webpackHotDevClient'),
|
||||
paths.appSrc + '/' + item + '.js',
|
||||
];
|
||||
|
||||
htmlWebpackPlugins.push(
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
chunks: [item],
|
||||
template: paths.appHtml,
|
||||
filename: item + '.html'
|
||||
}));
|
||||
});
|
||||
|
||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||
// In development, we always serve from the root. This makes config easier.
|
||||
const publicPath = '/';
|
||||
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
||||
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
|
||||
const publicUrl = '';
|
||||
// Get environment variables to inject into our app.
|
||||
const env = getClientEnvironment(publicUrl);
|
||||
|
||||
// This is the development configuration.
|
||||
// It is focused on developer experience and fast rebuilds.
|
||||
// The production configuration is different and lives in a separate file.
|
||||
module.exports = {
|
||||
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
|
||||
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
|
||||
devtool: 'cheap-module-source-map',
|
||||
// These are the "entry points" to our application.
|
||||
// This means they will be the "root" imports that are included in JS bundle.
|
||||
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
|
||||
entry: entry,
|
||||
output: {
|
||||
// Add /* filename */ comments to generated require()s in the output.
|
||||
pathinfo: true,
|
||||
path: paths.appBuild,
|
||||
// This does not produce a real file. It's just the virtual path that is
|
||||
// served by WebpackDevServer in development. This is the JS bundle
|
||||
// containing code from all our entry points, and the Webpack runtime.
|
||||
filename: 'static/js/[name].bundle.js',
|
||||
// There are also additional JS chunk files if you use code splitting.
|
||||
chunkFilename: 'static/js/[name].chunk.js',
|
||||
// This is the URL that app is served from. We use "/" in development.
|
||||
publicPath: publicPath,
|
||||
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||
devtoolModuleFilenameTemplate: info =>
|
||||
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
|
||||
},
|
||||
resolve: {
|
||||
// This allows you to set a fallback for where Webpack should look for modules.
|
||||
// We placed these paths second because we want `node_modules` to "win"
|
||||
// if there are any conflicts. This matches Node resolution mechanism.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/253
|
||||
modules: ['node_modules', paths.appNodeModules].concat(
|
||||
// It is guaranteed to exist because we tweak it in `env.js`
|
||||
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
|
||||
),
|
||||
// These are the reasonable defaults supported by the Node ecosystem.
|
||||
// We also include JSX as a common component filename extension to support
|
||||
// some tools, although we do not recommend using it, see:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/290
|
||||
// `web` extension prefixes have been added for better support
|
||||
// for React Native Web.
|
||||
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
|
||||
alias: {
|
||||
'omi': 'omio'
|
||||
// Support React Native Web
|
||||
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||
//'react-native': 'react-native-web',
|
||||
},
|
||||
plugins: [
|
||||
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||
// This often causes confusion because we only process files within src/ with babel.
|
||||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||
//new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
strictExportPresence: true,
|
||||
rules: [
|
||||
// TODO: Disable require.ensure as it's not a standard language feature.
|
||||
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
|
||||
// { parser: { requireEnsure: false } },
|
||||
|
||||
// First, run the linter.
|
||||
// It's important to do this before Babel processes the JS.
|
||||
// {
|
||||
// test: /\.(js|jsx|mjs)$/,
|
||||
// enforce: 'pre',
|
||||
// use: [
|
||||
// {
|
||||
// options: {
|
||||
// formatter: eslintFormatter,
|
||||
// eslintPath: require.resolve('eslint'),
|
||||
|
||||
// },
|
||||
// loader: require.resolve('eslint-loader'),
|
||||
// },
|
||||
// ],
|
||||
// include: paths.appSrc,
|
||||
// },
|
||||
{
|
||||
// "oneOf" will traverse all following loaders until one will
|
||||
// match the requirements. When no loader matches it will fall
|
||||
// back to the "file" loader at the end of the loader list.
|
||||
oneOf: [
|
||||
// "url" loader works like "file" loader except that it embeds assets
|
||||
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||
// A missing `test` is equivalent to a match.
|
||||
{
|
||||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// Process JS with Babel.
|
||||
{
|
||||
test: /\.(js|jsx|mjs)$/,
|
||||
//include: paths.appSrc,
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
|
||||
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
||||
// It enables caching results in ./node_modules/.cache/babel-loader/
|
||||
// directory for faster rebuilds.
|
||||
cacheDirectory: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /[\\|\/]_[\S]*\.css$/,
|
||||
use: [
|
||||
'to-string-loader',
|
||||
'css-loader'
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: [
|
||||
'md-text-loader'
|
||||
]
|
||||
},
|
||||
// "postcss" loader applies autoprefixer to our CSS.
|
||||
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||
// "style" loader turns CSS into JS modules that inject <style> tags.
|
||||
// In production, we use a plugin to extract that CSS to a file, but
|
||||
// in development "style" loader enables hot editing of CSS.
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
require.resolve('style-loader'),
|
||||
{
|
||||
loader: require.resolve('css-loader'),
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: require.resolve('postcss-loader'),
|
||||
options: {
|
||||
// Necessary for external CSS imports to work
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2677
|
||||
ident: 'postcss',
|
||||
plugins: () => [
|
||||
require('postcss-flexbugs-fixes'),
|
||||
autoprefixer({
|
||||
browsers: [
|
||||
'>1%',
|
||||
'last 4 versions',
|
||||
'Firefox ESR',
|
||||
'not ie < 9', // React doesn't support IE8 anyway
|
||||
],
|
||||
flexbox: 'no-2009',
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||
// When you `import` an asset, you get its (virtual) filename.
|
||||
// In production, they would get copied to the `build` folder.
|
||||
// This loader doesn't use a "test" so it will catch all modules
|
||||
// that fall through the other loaders.
|
||||
{
|
||||
// Exclude `js` files to keep "css" loader working as it injects
|
||||
// its runtime that would otherwise processed through "file" loader.
|
||||
// Also exclude `html` and `json` extensions so they get processed
|
||||
// by webpacks internal loaders.
|
||||
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||
loader: require.resolve('file-loader'),
|
||||
options: {
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// ** STOP ** Are you adding a new loader?
|
||||
// Make sure to add the new loader(s) before the "file" loader.
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// Makes some environment variables available in index.html.
|
||||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
// In development, this will be an empty string.
|
||||
new InterpolateHtmlPlugin(env.raw),
|
||||
...htmlWebpackPlugins,
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
// new HtmlWebpackPlugin({
|
||||
// inject: true,
|
||||
// chunks:["index"],
|
||||
// template: paths.appHtml,
|
||||
// }),
|
||||
// new HtmlWebpackPlugin({
|
||||
// inject: true,
|
||||
// chunks:["admin"],
|
||||
// template:paths.appHtml,
|
||||
// filename:'admin.html'
|
||||
// }),
|
||||
// Add module names to factory functions so they appear in browser profiler.
|
||||
new webpack.NamedModulesPlugin(),
|
||||
// Makes some environment variables available to the JS code, for example:
|
||||
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
|
||||
new webpack.DefinePlugin(env.stringified),
|
||||
// This is necessary to emit hot updates (currently CSS only):
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
// Watcher doesn't work well if you mistype casing in a path so we use
|
||||
// a plugin that prints an error when you attempt to do this.
|
||||
// See https://github.com/facebookincubator/create-react-app/issues/240
|
||||
new CaseSensitivePathsPlugin(),
|
||||
// If you require a missing module and then `npm install` it, you still have
|
||||
// to restart the development server for Webpack to discover it. This plugin
|
||||
// makes the discovery automatic so you don't have to restart.
|
||||
// See https://github.com/facebookincubator/create-react-app/issues/186
|
||||
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
|
||||
// Moment.js is an extremely popular library that bundles large locale files
|
||||
// by default due to how Webpack interprets its code. This is a practical
|
||||
// solution that requires the user to opt into importing specific locales.
|
||||
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||
// You can remove this if you don't use Moment.js:
|
||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||
],
|
||||
// Some libraries import Node modules but don't use them in the browser.
|
||||
// Tell Webpack to provide empty mocks for them so importing them works.
|
||||
node: {
|
||||
dgram: 'empty',
|
||||
fs: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
child_process: 'empty',
|
||||
},
|
||||
// Turn off performance hints during development because we don't do any
|
||||
// splitting or minification in interest of speed. These warnings become
|
||||
// cumbersome.
|
||||
performance: {
|
||||
hints: false,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,371 @@
|
|||
'use strict';
|
||||
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
|
||||
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
||||
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||
const paths = require('./paths');
|
||||
const getClientEnvironment = require('./env');
|
||||
const fileList = require('./entry');
|
||||
|
||||
let entry = {};
|
||||
let htmlWebpackPlugins = [];
|
||||
|
||||
fileList.forEach(function (item) {
|
||||
entry[item] = [
|
||||
require.resolve('./polyfills'),
|
||||
paths.appSrc + '/' + item + '.js',
|
||||
];
|
||||
|
||||
htmlWebpackPlugins.push(
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
chunks:[item],
|
||||
template: paths.appHtml,
|
||||
filename: item + '.html',
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
removeRedundantAttributes: true,
|
||||
useShortDoctype: true,
|
||||
removeEmptyAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
keepClosingSlash: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true,
|
||||
minifyURLs: true,
|
||||
},
|
||||
}))
|
||||
});
|
||||
|
||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||
// It requires a trailing slash, or the file assets will get an incorrect path.
|
||||
const publicPath = paths.servedPath;
|
||||
// Some apps do not use client-side routing with pushState.
|
||||
// For these, "homepage" can be set to "." to enable relative asset paths.
|
||||
const shouldUseRelativeAssetPaths = publicPath === './';
|
||||
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
||||
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
|
||||
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
||||
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
||||
const publicUrl = publicPath.slice(0, -1);
|
||||
// Get environment variables to inject into our app.
|
||||
const env = getClientEnvironment(publicUrl);
|
||||
|
||||
// Assert this just to be safe.
|
||||
// Development builds of React are slow and not intended for production.
|
||||
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
|
||||
throw new Error('Production builds must have NODE_ENV=production.');
|
||||
}
|
||||
|
||||
// Note: defined here because it will be used more than once.
|
||||
const cssFilename = 'static/css/[name].[contenthash:8].css';
|
||||
|
||||
// ExtractTextPlugin expects the build output to be flat.
|
||||
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
|
||||
// However, our output is structured with css, js and media folders.
|
||||
// To have this structure working with relative paths, we have to use custom options.
|
||||
const extractTextPluginOptions = shouldUseRelativeAssetPaths
|
||||
? // Making sure that the publicPath goes back to to build folder.
|
||||
{ publicPath: Array(cssFilename.split('/').length).join('../') }
|
||||
: {};
|
||||
|
||||
// This is the production configuration.
|
||||
// It compiles slowly and is focused on producing a fast and minimal bundle.
|
||||
// The development configuration is different and lives in a separate file.
|
||||
module.exports = {
|
||||
// Don't attempt to continue if there are any errors.
|
||||
bail: true,
|
||||
// We generate sourcemaps in production. This is slow but gives good results.
|
||||
// You can exclude the *.map files from the build during deployment.
|
||||
devtool: shouldUseSourceMap ? 'source-map' : false,
|
||||
// In production, we only want to load the polyfills and the app code.
|
||||
entry: entry,
|
||||
output: {
|
||||
// The build folder.
|
||||
path: paths.appBuild,
|
||||
// Generated JS file names (with nested folders).
|
||||
// There will be one main bundle, and one file per asynchronous chunk.
|
||||
// We don't currently advertise code splitting but Webpack supports it.
|
||||
filename: 'static/js/[name].[chunkhash:8].js',
|
||||
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
|
||||
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||
publicPath: publicPath,
|
||||
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||
devtoolModuleFilenameTemplate: info =>
|
||||
path
|
||||
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||
.replace(/\\/g, '/'),
|
||||
},
|
||||
resolve: {
|
||||
// This allows you to set a fallback for where Webpack should look for modules.
|
||||
// We placed these paths second because we want `node_modules` to "win"
|
||||
// if there are any conflicts. This matches Node resolution mechanism.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/253
|
||||
modules: ['node_modules', paths.appNodeModules].concat(
|
||||
// It is guaranteed to exist because we tweak it in `env.js`
|
||||
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
|
||||
),
|
||||
// These are the reasonable defaults supported by the Node ecosystem.
|
||||
// We also include JSX as a common component filename extension to support
|
||||
// some tools, although we do not recommend using it, see:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/290
|
||||
// `web` extension prefixes have been added for better support
|
||||
// for React Native Web.
|
||||
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
|
||||
alias: {
|
||||
'omi': 'omio'
|
||||
// Support React Native Web
|
||||
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||
//'react-native': 'react-native-web',
|
||||
},
|
||||
plugins: [
|
||||
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||
// This often causes confusion because we only process files within src/ with babel.
|
||||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||
//new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
strictExportPresence: true,
|
||||
rules: [
|
||||
// TODO: Disable require.ensure as it's not a standard language feature.
|
||||
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
|
||||
// { parser: { requireEnsure: false } },
|
||||
|
||||
// First, run the linter.
|
||||
// It's important to do this before Babel processes the JS.
|
||||
// {
|
||||
// test: /\.(js|jsx|mjs)$/,
|
||||
// enforce: 'pre',
|
||||
// use: [
|
||||
// {
|
||||
// options: {
|
||||
// formatter: eslintFormatter,
|
||||
// eslintPath: require.resolve('eslint'),
|
||||
|
||||
// },
|
||||
// loader: require.resolve('eslint-loader'),
|
||||
// },
|
||||
// ],
|
||||
// include: paths.appSrc,
|
||||
// },
|
||||
{
|
||||
// "oneOf" will traverse all following loaders until one will
|
||||
// match the requirements. When no loader matches it will fall
|
||||
// back to the "file" loader at the end of the loader list.
|
||||
oneOf: [
|
||||
// "url" loader works just like "file" loader but it also embeds
|
||||
// assets smaller than specified size as data URLs to avoid requests.
|
||||
{
|
||||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// Process JS with Babel.
|
||||
{
|
||||
test: /\.(js|jsx|mjs)$/,
|
||||
//include: paths.appSrc,
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
|
||||
compact: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /[\\|\/]_[\S]*\.css$/,
|
||||
use: [
|
||||
'to-string-loader',
|
||||
'css-loader'
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: [
|
||||
'md-text-loader'
|
||||
]
|
||||
},
|
||||
// The notation here is somewhat confusing.
|
||||
// "postcss" loader applies autoprefixer to our CSS.
|
||||
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||
// "style" loader normally turns CSS into JS modules injecting <style>,
|
||||
// but unlike in development configuration, we do something different.
|
||||
// `ExtractTextPlugin` first applies the "postcss" and "css" loaders
|
||||
// (second argument), then grabs the result CSS and puts it into a
|
||||
// separate file in our build process. This way we actually ship
|
||||
// a single CSS file in production instead of JS code injecting <style>
|
||||
// tags. If you use code splitting, however, any async bundles will still
|
||||
// use the "style" loader inside the async code so CSS from them won't be
|
||||
// in the main CSS file.
|
||||
{
|
||||
test: /\.css$/,
|
||||
loader: ExtractTextPlugin.extract(
|
||||
Object.assign(
|
||||
{
|
||||
fallback: {
|
||||
loader: require.resolve('style-loader'),
|
||||
options: {
|
||||
hmr: false,
|
||||
},
|
||||
},
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve('css-loader'),
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
minimize: true,
|
||||
sourceMap: shouldUseSourceMap,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: require.resolve('postcss-loader'),
|
||||
options: {
|
||||
// Necessary for external CSS imports to work
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2677
|
||||
ident: 'postcss',
|
||||
plugins: () => [
|
||||
require('postcss-flexbugs-fixes'),
|
||||
autoprefixer({
|
||||
browsers: [
|
||||
'>1%',
|
||||
'last 4 versions',
|
||||
'Firefox ESR',
|
||||
'not ie < 9', // React doesn't support IE8 anyway
|
||||
],
|
||||
flexbox: 'no-2009',
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
extractTextPluginOptions
|
||||
)
|
||||
),
|
||||
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
|
||||
},
|
||||
// "file" loader makes sure assets end up in the `build` folder.
|
||||
// When you `import` an asset, you get its filename.
|
||||
// This loader doesn't use a "test" so it will catch all modules
|
||||
// that fall through the other loaders.
|
||||
{
|
||||
loader: require.resolve('file-loader'),
|
||||
// Exclude `js` files to keep "css" loader working as it injects
|
||||
// it's runtime that would otherwise processed through "file" loader.
|
||||
// Also exclude `html` and `json` extensions so they get processed
|
||||
// by webpacks internal loaders.
|
||||
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||
options: {
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// ** STOP ** Are you adding a new loader?
|
||||
// Make sure to add the new loader(s) before the "file" loader.
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// Makes some environment variables available in index.html.
|
||||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
// In production, it will be an empty string unless you specify "homepage"
|
||||
// in `package.json`, in which case it will be the pathname of that URL.
|
||||
new InterpolateHtmlPlugin(env.raw),
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
...htmlWebpackPlugins,
|
||||
// Makes some environment variables available to the JS code, for example:
|
||||
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
||||
// It is absolutely essential that NODE_ENV was set to production here.
|
||||
// Otherwise React will be compiled in the very slow development mode.
|
||||
new webpack.DefinePlugin(env.stringified),
|
||||
// Minify the code.
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false,
|
||||
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2376
|
||||
// Pending further investigation:
|
||||
// https://github.com/mishoo/UglifyJS2/issues/2011
|
||||
comparisons: false,
|
||||
},
|
||||
mangle: {
|
||||
safari10: true,
|
||||
},
|
||||
output: {
|
||||
comments: false,
|
||||
// Turned on because emoji and regex is not minified properly using default
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2488
|
||||
ascii_only: true,
|
||||
},
|
||||
sourceMap: shouldUseSourceMap,
|
||||
}),
|
||||
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
|
||||
new ExtractTextPlugin({
|
||||
filename: cssFilename,
|
||||
}),
|
||||
// Generate a manifest file which contains a mapping of all asset filenames
|
||||
// to their corresponding output file so that tools can pick it up without
|
||||
// having to parse `index.html`.
|
||||
new ManifestPlugin({
|
||||
fileName: 'asset-manifest.json',
|
||||
}),
|
||||
// Generate a service worker script that will precache, and keep up to date,
|
||||
// the HTML & assets that are part of the Webpack build.
|
||||
new SWPrecacheWebpackPlugin({
|
||||
// By default, a cache-busting query parameter is appended to requests
|
||||
// used to populate the caches, to ensure the responses are fresh.
|
||||
// If a URL is already hashed by Webpack, then there is no concern
|
||||
// about it being stale, and the cache-busting can be skipped.
|
||||
dontCacheBustUrlsMatching: /\.\w{8}\./,
|
||||
filename: 'service-worker.js',
|
||||
logger(message) {
|
||||
if (message.indexOf('Total precache size is') === 0) {
|
||||
// This message occurs for every build and is a bit too noisy.
|
||||
return;
|
||||
}
|
||||
if (message.indexOf('Skipping static resource') === 0) {
|
||||
// This message obscures real errors so we ignore it.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2612
|
||||
return;
|
||||
}
|
||||
console.log(message);
|
||||
},
|
||||
minify: true,
|
||||
// For unknown URLs, fallback to the index page
|
||||
navigateFallback: publicUrl + '/index.html',
|
||||
// Ignores URLs starting from /__ (useful for Firebase):
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
|
||||
navigateFallbackWhitelist: [/^(?!\/__).*/],
|
||||
// Don't precache sourcemaps (they're large) and build asset manifest:
|
||||
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
|
||||
}),
|
||||
// Moment.js is an extremely popular library that bundles large locale files
|
||||
// by default due to how Webpack interprets its code. This is a practical
|
||||
// solution that requires the user to opt into importing specific locales.
|
||||
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||
// You can remove this if you don't use Moment.js:
|
||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||
],
|
||||
// Some libraries import Node modules but don't use them in the browser.
|
||||
// Tell Webpack to provide empty mocks for them so importing them works.
|
||||
node: {
|
||||
dgram: 'empty',
|
||||
fs: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
child_process: 'empty',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,108 @@
|
|||
'use strict';
|
||||
|
||||
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
|
||||
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
||||
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
||||
const config = require('./webpack.config.dev');
|
||||
const paths = require('./paths');
|
||||
|
||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
const host = process.env.HOST || '0.0.0.0';
|
||||
|
||||
// const fileList = require('./entry');
|
||||
|
||||
// let rewrites = [];
|
||||
|
||||
// fileList.forEach(function (item) {
|
||||
|
||||
// rewrites.push({ from: new RegExp('^\/' + item + '.html', 'g'), to: '/build/' + item + '.html' })
|
||||
|
||||
// });
|
||||
|
||||
|
||||
|
||||
module.exports = function(proxy, allowedHost) {
|
||||
return {
|
||||
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
||||
// websites from potentially accessing local content through DNS rebinding:
|
||||
// https://github.com/webpack/webpack-dev-server/issues/887
|
||||
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
||||
// However, it made several existing use cases such as development in cloud
|
||||
// environment or subdomains in development significantly more complicated:
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2271
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2233
|
||||
// While we're investigating better solutions, for now we will take a
|
||||
// compromise. Since our WDS configuration only serves files in the `public`
|
||||
// folder we won't consider accessing them a vulnerability. However, if you
|
||||
// use the `proxy` feature, it gets more dangerous because it can expose
|
||||
// remote code execution vulnerabilities in backends like Django and Rails.
|
||||
// So we will disable the host check normally, but enable it if you have
|
||||
// specified the `proxy` setting. Finally, we let you override it if you
|
||||
// really know what you're doing with a special environment variable.
|
||||
disableHostCheck:
|
||||
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
|
||||
// Enable gzip compression of generated files.
|
||||
compress: true,
|
||||
// Silence WebpackDevServer's own logs since they're generally not useful.
|
||||
// It will still show compile warnings and errors with this setting.
|
||||
clientLogLevel: 'none',
|
||||
// By default WebpackDevServer serves physical files from current directory
|
||||
// in addition to all the virtual build products that it serves from memory.
|
||||
// This is confusing because those files won’t automatically be available in
|
||||
// production build folder unless we copy them. However, copying the whole
|
||||
// project directory is dangerous because we may expose sensitive files.
|
||||
// Instead, we establish a convention that only files in `public` directory
|
||||
// get served. Our build script will copy `public` into the `build` folder.
|
||||
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
||||
// Note that we only recommend to use `public` folder as an escape hatch
|
||||
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
||||
// for some reason broken when imported through Webpack. If you just want to
|
||||
// use an image, put it in `src` and `import` it from JavaScript instead.
|
||||
contentBase: paths.appPublic,
|
||||
// By default files from `contentBase` will not trigger a page reload.
|
||||
watchContentBase: true,
|
||||
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
|
||||
// for the WebpackDevServer client so it can learn when the files were
|
||||
// updated. The WebpackDevServer client is included as an entry point
|
||||
// in the Webpack development configuration. Note that only changes
|
||||
// to CSS are currently hot reloaded. JS changes will refresh the browser.
|
||||
hot: true,
|
||||
// It is important to tell WebpackDevServer to use the same "root" path
|
||||
// as we specified in the config. In development, we always serve from /.
|
||||
publicPath: config.output.publicPath,
|
||||
// WebpackDevServer is noisy by default so we emit custom message instead
|
||||
// by listening to the compiler events with `compiler.plugin` calls above.
|
||||
quiet: true,
|
||||
// Reportedly, this avoids CPU overload on some systems.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/293
|
||||
// src/node_modules is not ignored to support absolute imports
|
||||
// https://github.com/facebookincubator/create-react-app/issues/1065
|
||||
watchOptions: {
|
||||
ignored: ignoredFiles(paths.appSrc),
|
||||
},
|
||||
// Enable HTTPS if the HTTPS environment variable is set to 'true'
|
||||
https: protocol === 'https',
|
||||
host: host,
|
||||
overlay: false,
|
||||
historyApiFallback: {
|
||||
// Paths with dots should still use the history fallback.
|
||||
// See https://github.com/facebookincubator/create-react-app/issues/387.
|
||||
disableDotRule: true
|
||||
//rewrites: rewrites
|
||||
},
|
||||
public: allowedHost,
|
||||
proxy,
|
||||
before(app) {
|
||||
// This lets us open files from the runtime error overlay.
|
||||
app.use(errorOverlayMiddleware());
|
||||
// This service worker file is effectively a 'no-op' that will reset any
|
||||
// previous service worker registered for the same host:port combination.
|
||||
// We do this in development to avoid hitting the production cache if
|
||||
// it used the same host and port.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
|
||||
app.use(noopServiceWorkerMiddleware());
|
||||
},
|
||||
};
|
||||
};
|
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
"name": "my-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"autoprefixer": "7.1.6",
|
||||
"babel-core": "6.26.0",
|
||||
"babel-eslint": "7.2.3",
|
||||
"babel-jest": "20.0.3",
|
||||
"babel-loader": "7.1.2",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.5",
|
||||
"babel-plugin-transform-function-bind": "^6.22.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-omi": "^0.1.1",
|
||||
"babel-runtime": "6.26.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.1.1",
|
||||
"chalk": "1.1.3",
|
||||
"classnames": "^2.2.6",
|
||||
"css-loader": "0.28.7",
|
||||
"dotenv": "4.0.0",
|
||||
"dotenv-expand": "4.2.0",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-config-prettier": "^3.1.0",
|
||||
"eslint-loader": "1.9.0",
|
||||
"eslint-plugin-flowtype": "2.39.1",
|
||||
"eslint-plugin-import": "2.8.0",
|
||||
"eslint-plugin-jsx-a11y": "5.1.1",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"extract-text-webpack-plugin": "3.0.2",
|
||||
"file-loader": "1.1.5",
|
||||
"fs-extra": "3.0.1",
|
||||
"html-webpack-plugin": "2.29.0",
|
||||
"jest": "20.0.4",
|
||||
"md-text-loader": "^0.1.0",
|
||||
"object-assign": "4.1.1",
|
||||
"omi": "latest",
|
||||
"omi-router": "latest",
|
||||
"omio": "latest",
|
||||
"path-d": "0.0.1",
|
||||
"postcss-flexbugs-fixes": "3.2.0",
|
||||
"postcss-loader": "2.0.8",
|
||||
"prettier": "^1.14.3",
|
||||
"promise": "8.0.1",
|
||||
"prop-types": "^15.5.8",
|
||||
"raf": "3.4.0",
|
||||
"react-dev-utils": "^5.0.1",
|
||||
"resolve": "1.6.0",
|
||||
"style-loader": "0.19.0",
|
||||
"sw-precache-webpack-plugin": "0.11.4",
|
||||
"to-string-loader": "^1.1.5",
|
||||
"url-loader": "0.6.2",
|
||||
"warning": "^3.0.0",
|
||||
"webpack": "3.8.1",
|
||||
"webpack-dev-server": "2.9.4",
|
||||
"webpack-manifest-plugin": "1.3.2",
|
||||
"whatwg-fetch": "2.0.3"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"build": "PUBLIC_URL=. node scripts/build.js",
|
||||
"build-windows": "set PUBLIC_URL=.&& node scripts/build.js",
|
||||
"fix": "eslint src --fix"
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverageFrom": [
|
||||
"src/**/*.{js,jsx,mjs}"
|
||||
],
|
||||
"setupFiles": [
|
||||
"<rootDir>/config/polyfills.js"
|
||||
],
|
||||
"testMatch": [
|
||||
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
|
||||
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
|
||||
],
|
||||
"testEnvironment": "node",
|
||||
"testURL": "http://localhost",
|
||||
"transform": {
|
||||
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
|
||||
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
|
||||
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
|
||||
},
|
||||
"transformIgnorePatterns": [
|
||||
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"^react-native$": "react-native-web"
|
||||
},
|
||||
"moduleFileExtensions": [
|
||||
"web.js",
|
||||
"js",
|
||||
"json",
|
||||
"web.jsx",
|
||||
"jsx",
|
||||
"node",
|
||||
"mjs"
|
||||
]
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
"env",
|
||||
"omi"
|
||||
],
|
||||
"plugins": [
|
||||
"transform-class-properties",
|
||||
"transform-decorators-legacy",
|
||||
"transform-object-rest-spread",
|
||||
"syntax-dynamic-import",
|
||||
"transform-function-bind"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 66 KiB |
|
@ -0,0 +1,218 @@
|
|||
/* PrismJS 1.15.0
|
||||
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+bash+json+typescript+jsx+tsx&plugins=line-highlight+line-numbers */
|
||||
/**
|
||||
* okaidia theme for JavaScript, CSS and HTML
|
||||
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
|
||||
* @author ocodia
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #f8f8f2;
|
||||
background: none;
|
||||
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #272822;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number {
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
.token.keyword {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #fd971f;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 3em;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: inherit 0;
|
||||
margin-top: 1em; /* Same as .prism’s padding-top */
|
||||
|
||||
background: hsla(24, 20%, 50%,.08);
|
||||
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
|
||||
|
||||
pointer-events: none;
|
||||
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-start);
|
||||
position: absolute;
|
||||
top: .4em;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
background-color: hsla(24, 20%, 50%,.4);
|
||||
color: hsl(24, 20%, 95%);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
text-align: center;
|
||||
vertical-align: .3em;
|
||||
border-radius: 999px;
|
||||
text-shadow: none;
|
||||
box-shadow: 0 1px white;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
bottom: .4em;
|
||||
}
|
||||
|
||||
.line-numbers .line-highlight:before,
|
||||
.line-numbers .line-highlight:after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers {
|
||||
position: relative;
|
||||
padding-left: 3.8em;
|
||||
counter-reset: linenumber;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers > code {
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.line-numbers .line-numbers-rows {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
font-size: 100%;
|
||||
left: -3.8em;
|
||||
width: 3em; /* works for line-numbers below 1000 lines */
|
||||
letter-spacing: -1px;
|
||||
border-right: 1px solid #999;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.line-numbers-rows > span {
|
||||
pointer-events: none;
|
||||
display: block;
|
||||
counter-increment: linenumber;
|
||||
}
|
||||
|
||||
.line-numbers-rows > span:before {
|
||||
content: counter(linenumber);
|
||||
color: #999;
|
||||
display: block;
|
||||
padding-right: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is added to the
|
||||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||
-->
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<link rel="stylesheet" href="%PUBLIC_URL%/highlight/prism.css">
|
||||
<style>
|
||||
*{
|
||||
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
|
||||
-moz-user-focus: none;
|
||||
}
|
||||
</style>
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Omi - Front End Cross-Frameworks Framework</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
|
||||
<script src="%PUBLIC_URL%/highlight/prism.js"></script>
|
||||
<script src="%PUBLIC_URL%/js/remarkable.min.js"></script>
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,150 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'production';
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs-extra');
|
||||
const webpack = require('webpack');
|
||||
const config = require('../config/webpack.config.prod');
|
||||
const paths = require('../config/paths');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
||||
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
||||
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
||||
const printBuildError = require('react-dev-utils/printBuildError');
|
||||
|
||||
const measureFileSizesBeforeBuild =
|
||||
FileSizeReporter.measureFileSizesBeforeBuild;
|
||||
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
|
||||
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
||||
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
||||
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// First, read the current file sizes in build directory.
|
||||
// This lets us display how much they changed later.
|
||||
measureFileSizesBeforeBuild(paths.appBuild)
|
||||
.then(previousFileSizes => {
|
||||
// Remove all content but keep the directory so that
|
||||
// if you're in it, you don't end up in Trash
|
||||
fs.emptyDirSync(paths.appBuild);
|
||||
// Merge with the public folder
|
||||
copyPublicFolder();
|
||||
// Start the webpack build
|
||||
return build(previousFileSizes);
|
||||
})
|
||||
.then(
|
||||
({ stats, previousFileSizes, warnings }) => {
|
||||
if (warnings.length) {
|
||||
console.log(chalk.yellow('Compiled with warnings.\n'));
|
||||
console.log(warnings.join('\n\n'));
|
||||
console.log(
|
||||
'\nSearch for the ' +
|
||||
chalk.underline(chalk.yellow('keywords')) +
|
||||
' to learn more about each warning.'
|
||||
);
|
||||
console.log(
|
||||
'To ignore, add ' +
|
||||
chalk.cyan('// eslint-disable-next-line') +
|
||||
' to the line before.\n'
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.green('Compiled successfully.\n'));
|
||||
}
|
||||
|
||||
console.log('File sizes after gzip:\n');
|
||||
printFileSizesAfterBuild(
|
||||
stats,
|
||||
previousFileSizes,
|
||||
paths.appBuild,
|
||||
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||
);
|
||||
console.log();
|
||||
|
||||
const appPackage = require(paths.appPackageJson);
|
||||
const publicUrl = paths.publicUrl;
|
||||
const publicPath = config.output.publicPath;
|
||||
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
||||
printHostingInstructions(
|
||||
appPackage,
|
||||
publicUrl,
|
||||
publicPath,
|
||||
buildFolder,
|
||||
useYarn
|
||||
);
|
||||
},
|
||||
err => {
|
||||
console.log(chalk.red('Failed to compile.\n'));
|
||||
printBuildError(err);
|
||||
process.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// Create the production build and print the deployment instructions.
|
||||
function build(previousFileSizes) {
|
||||
console.log('Creating an optimized production build...');
|
||||
|
||||
let compiler = webpack(config);
|
||||
return new Promise((resolve, reject) => {
|
||||
compiler.run((err, stats) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
const messages = formatWebpackMessages(stats.toJson({}, true));
|
||||
if (messages.errors.length) {
|
||||
// Only keep the first error. Others are often indicative
|
||||
// of the same problem, but confuse the reader with noise.
|
||||
if (messages.errors.length > 1) {
|
||||
messages.errors.length = 1;
|
||||
}
|
||||
return reject(new Error(messages.errors.join('\n\n')));
|
||||
}
|
||||
if (
|
||||
process.env.CI &&
|
||||
(typeof process.env.CI !== 'string' ||
|
||||
process.env.CI.toLowerCase() !== 'false') &&
|
||||
messages.warnings.length
|
||||
) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||
'Most CI servers set it automatically.\n'
|
||||
)
|
||||
);
|
||||
return reject(new Error(messages.warnings.join('\n\n')));
|
||||
}
|
||||
return resolve({
|
||||
stats,
|
||||
previousFileSizes,
|
||||
warnings: messages.warnings,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function copyPublicFolder() {
|
||||
fs.copySync(paths.appPublic, paths.appBuild, {
|
||||
dereference: true,
|
||||
filter: file => file !== paths.appHtml,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'development';
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const fs = require('fs');
|
||||
const chalk = require('chalk');
|
||||
const webpack = require('webpack');
|
||||
const WebpackDevServer = require('webpack-dev-server');
|
||||
const clearConsole = require('react-dev-utils/clearConsole');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const {
|
||||
choosePort,
|
||||
createCompiler,
|
||||
prepareProxy,
|
||||
prepareUrls,
|
||||
} = require('react-dev-utils/WebpackDevServerUtils');
|
||||
const openBrowser = require('react-dev-utils/openBrowser');
|
||||
const paths = require('../config/paths');
|
||||
const config = require('../config/webpack.config.dev');
|
||||
const createDevServerConfig = require('../config/webpackDevServer.config');
|
||||
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
const isInteractive = process.stdout.isTTY;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Tools like Cloud9 rely on this.
|
||||
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
|
||||
if (process.env.HOST) {
|
||||
console.log(
|
||||
chalk.cyan(
|
||||
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
||||
chalk.bold(process.env.HOST)
|
||||
)}`
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
||||
);
|
||||
console.log(`Learn more here: ${chalk.yellow('http://bit.ly/2mwWSwH')}`);
|
||||
console.log();
|
||||
}
|
||||
|
||||
// We attempt to use the default port but if it is busy, we offer the user to
|
||||
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
||||
choosePort(HOST, DEFAULT_PORT)
|
||||
.then(port => {
|
||||
if (port == null) {
|
||||
// We have not found a port.
|
||||
return;
|
||||
}
|
||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
const appName = require(paths.appPackageJson).name;
|
||||
const urls = prepareUrls(protocol, HOST, port);
|
||||
// Create a webpack compiler that is configured with custom messages.
|
||||
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
|
||||
// Load proxy config
|
||||
const proxySetting = require(paths.appPackageJson).proxy;
|
||||
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
|
||||
// Serve webpack assets generated by the compiler over a web sever.
|
||||
const serverConfig = createDevServerConfig(
|
||||
proxyConfig,
|
||||
urls.lanUrlForConfig
|
||||
);
|
||||
const devServer = new WebpackDevServer(compiler, serverConfig);
|
||||
// Launch WebpackDevServer.
|
||||
devServer.listen(port, HOST, err => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
if (isInteractive) {
|
||||
clearConsole();
|
||||
}
|
||||
console.log(chalk.cyan('Starting the development server...\n'));
|
||||
openBrowser(urls.localUrlForBrowser);
|
||||
});
|
||||
|
||||
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
||||
process.on(sig, function() {
|
||||
devServer.close();
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
if (err && err.message) {
|
||||
console.log(err.message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'test';
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.PUBLIC_URL = '';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
const jest = require('jest');
|
||||
let argv = process.argv.slice(2);
|
||||
|
||||
// Watch unless on CI or in coverage mode
|
||||
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
|
||||
argv.push('--watch');
|
||||
}
|
||||
|
||||
|
||||
jest.run(argv);
|
|
@ -0,0 +1,133 @@
|
|||
|
||||
html,body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background-color: #eee;
|
||||
font-family:proxima-nova,"Helvetica Neue",Helvetica,Roboto, PT Sans, DejaVu Sans, Arial,Segoe UI Light,Segoe UI,Microsoft Jhenghei,Mirco Yahei,'sans-serif';
|
||||
}
|
||||
|
||||
img,ul,li{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
a{
|
||||
text-decoration: none;
|
||||
color: #0366d6;
|
||||
}
|
||||
|
||||
table{
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table,td,th{
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
td,th{
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track
|
||||
{
|
||||
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar
|
||||
{
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-color: #F5F5F5;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb
|
||||
{
|
||||
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1000px) {
|
||||
html,body{
|
||||
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.content img{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.content code[class*="language-"],
|
||||
.content pre[class*="language-"] {
|
||||
font-family: Consolas, "Liberation Mono", Courier, monospace;
|
||||
line-height: 18px;
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.content pre[class*="language-"] {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.content p{
|
||||
font-size: 14px;
|
||||
}
|
||||
.content p,.content h1,.content h2,.content h3,.content h4,.content h5{
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
}
|
||||
|
||||
.line-highlight:before, .line-highlight[data-end]:after{
|
||||
top: 0em;
|
||||
}
|
||||
}
|
||||
|
||||
*{
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
blockquote::before{
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0px;
|
||||
background-color: #dfe2e5;
|
||||
height: 24px;
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 1em !important;
|
||||
}
|
||||
|
||||
.line-highlight:before, .line-highlight[data-end]:after{
|
||||
display: none;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"], pre[class*="language-"] {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
|
||||
img{
|
||||
max-width: 900px;
|
||||
}
|
||||
|
||||
.content ul{
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
.content table tr:nth-child(2n) {
|
||||
background-color: #f6f8fa;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { render } from 'omi'
|
||||
import './assets/index.css'
|
||||
import './elements/my-frame.js'
|
||||
import Store from './store'
|
||||
|
||||
render(<my-frame />, '#root', new Store({ lan: 'zh-cn' }))
|
|
@ -0,0 +1,37 @@
|
|||
const config = {
|
||||
menus: {
|
||||
'zh-cn': [
|
||||
{
|
||||
title: 'OMIU',
|
||||
list: [
|
||||
{ name: '简介', md: 'introduction' },
|
||||
{ name: '安装', md: 'installation' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '基础概念',
|
||||
list: [
|
||||
{ name: 'Button 按钮', md: 'button' }
|
||||
]
|
||||
}
|
||||
|
||||
],
|
||||
en: [
|
||||
{
|
||||
title: 'OMIU',
|
||||
list: [
|
||||
{ name: 'Introduction', md: 'introduction' },
|
||||
{ name: 'Installation', md: 'installation' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Base',
|
||||
list: [
|
||||
{ name: 'Button', md: 'button' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export default config
|
|
@ -0,0 +1,61 @@
|
|||
## Button
|
||||
|
||||
Click or touch it to trigger an operation. The encapsulated logic is triggered in response to user clicks.
|
||||
|
||||
<iframe height="350" style="width: 100%;" scrolling="no" title="OMIU Button" src="https://codepen.io/omijs/embed/LYppwYG?height=350&theme-id=dark&default-tab=html,result" frameborder="no" allowtransparency="true" allowfullscreen="true" loading="lazy">
|
||||
See the Pen <a href='https://codepen.io/omijs/pen/LYppwYG'>OMIU Button</a> by OMI
|
||||
(<a href='https://codepen.io/omijs'>@omijs</a>) on <a href='https://codepen.io'>CodePen</a>.
|
||||
</iframe>
|
||||
|
||||
## Import
|
||||
|
||||
```js
|
||||
import 'omim/button'
|
||||
```
|
||||
|
||||
Or use script tag to ref it.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```html
|
||||
<m-button ripple icon="favorite">Default</m-button>
|
||||
|
||||
<m-button ripple dense>Dense</m-button>
|
||||
|
||||
<m-button ripple svg-icon="{
|
||||
path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',
|
||||
color: '#0072d9',
|
||||
scale: 1.3
|
||||
}">ICON</m-button>
|
||||
```
|
||||
|
||||
## Usage in Omi
|
||||
|
||||
JSX:
|
||||
|
||||
```jsx
|
||||
<m-button ripple raised icon="favorite">Default</m-button>
|
||||
|
||||
<m-button ripple dense raised>Dense</m-button>
|
||||
|
||||
<m-button ripple raised svgIcon={{
|
||||
path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',
|
||||
color: 'white',
|
||||
scale: 1.3
|
||||
}}>ICON</m-button>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Props
|
||||
|
||||
| **Name** | **Type** | **Defaults** | **Details** |
|
||||
| ------------- |:-------------:|:-----:|:-------------:|
|
||||
| ripple | boolean | -- | Click the button to create a ripple |
|
||||
| raised | boolean | -- | There's padding, there's shading |
|
||||
| dense | boolean | -- | Smaller buttons |
|
||||
| unelevated | boolean | -- | It has padding, no shadows |
|
||||
| outlined | boolean | -- | No padding, have border |
|
||||
| svg-icon | object | -- | svg icon |
|
||||
| icon | string | -- | icon |
|
|
@ -0,0 +1,96 @@
|
|||
## Installation
|
||||
|
||||
Simply download and include with `<script>`. Omi will be registered as a global variable.
|
||||
|
||||
* [Omi Development Version](https://unpkg.com/omi@latest/dist/omi.js)
|
||||
* [Omi Production Version](https://unpkg.com/omi@latest/dist/omi.min.js)
|
||||
|
||||
Install via npm:
|
||||
|
||||
```
|
||||
npm i omi
|
||||
```
|
||||
|
||||
If you need to be compatible with IE8+, you can choose omio, which has almost the same API as omi, and Omi will be registered as a global variable.
|
||||
|
||||
* [Omio Development Version](https://unpkg.com/omio@latest/dist/omi.js)
|
||||
* [Omio Production Version](https://unpkg.com/omi@latest/dist/omi.min.js)
|
||||
|
||||
Install via npm:
|
||||
|
||||
```
|
||||
npm i omio
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
Omi provides the official CLI. You don't need to learn how to configure webpack, Babel or TypeScript. CLI helps you configure everything and provides various templates for different project types.
|
||||
|
||||
```bash
|
||||
$ npm i omi-cli -g # install cli
|
||||
$ omi init my-app # init project
|
||||
$ cd my-app
|
||||
$ npm start # develop
|
||||
$ npm run build # release
|
||||
```
|
||||
|
||||
> `npx omi-cli init my-app` is also supported(npm v5.2.0+).
|
||||
|
||||
Directory description:
|
||||
|
||||
```
|
||||
├─ config
|
||||
├─ public
|
||||
├─ scripts
|
||||
├─ src
|
||||
│ ├─ assets
|
||||
│ ├─ elements //Store all custom elements
|
||||
│ ├─ store //Store all this store of pages
|
||||
│ ├─ admin.js //Entry js of compiler,will build to admin.html
|
||||
│ └─ index.js //Entry js of compiler,will build to index.html
|
||||
```
|
||||
|
||||
|
||||
### Scripts
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"build": "PUBLIC_URL=. node scripts/build.js",
|
||||
"build-windows": "set PUBLIC_URL=.&& node scripts/build.js",
|
||||
"fix": "eslint src --fix"
|
||||
}
|
||||
```
|
||||
|
||||
You can set up the PUBLIC_URL, such as:
|
||||
|
||||
```json
|
||||
...
|
||||
"build": "PUBLIC_URL=https://your.url.com/sub node scripts/build.js",
|
||||
"build-windows": "set PUBLIC_URL=https://your.url.com/sub&& node scripts/build.js",
|
||||
...
|
||||
```
|
||||
|
||||
### Switch omi and omio
|
||||
|
||||
Add or remove the alias config in package.json to switch omi and omio:
|
||||
|
||||
```js
|
||||
...
|
||||
"alias": {
|
||||
"omi": "omio"
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
## Project Template
|
||||
|
||||
| **Template Type**| **Command**| **Describe**|
|
||||
| ------------ | -----------| ----------------- |
|
||||
|Base Template(v3.3.0+)|`omi init my-app`| Basic omi or omio(IE8+) project template.|
|
||||
|Kbone Template|`omi init-kbone my-app` |Developing mini program or web using omi.|
|
||||
|小程序模板(v3.3.5+)|`omi init-p my-app`| Omi 开发小程序 |
|
||||
|Base Template with snapshoot|`omi init-snap my-app`| Basic omi or omio(IE8+) project template with snapshoot prerendering.|
|
||||
|TypeScript Template(omi-cli v3.3.0+)|`omi init-ts my-app`|Basic template with typescript.|
|
||||
|Mobile Template|`omi init-weui my-app`| Mobile web app template with weui and omi-router.|
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
## What's Omi ?
|
||||
|
||||
Omi (pronounced /ˈomɪ/) is cross-frameworks framework base on Web Component, you can also use omio compatible IE8+ with the same grammar. One framework, Mobile & desktop & mini program.
|
||||
|
||||
<em> Omi looks really neat!<br> </em>
|
||||
— [Jason Miller (Creator of Preact)](https://twitter.com/_developit/)
|
||||
|
||||
<em> I really like the trend towards "frameworks" that:<br><br>"export default class WeElement extends HTMLElement {..}"<br> <br>This one, Omi, is from Tencent.</em>
|
||||
— [Dion Almaer](https://twitter.com/dalmaer/)
|
||||
|
||||
## Add Omi in One Minute
|
||||
|
||||
```jsx {8-11}
|
||||
import { render, WeElement, define } from 'omi'
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
static css = `
|
||||
span{
|
||||
color: red;
|
||||
}`
|
||||
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
this.update()
|
||||
}
|
||||
|
||||
add = () => {
|
||||
this.data.count++
|
||||
this.update()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<button onClick={this.sub}>-</button>
|
||||
<span>{this.data.count}</span>
|
||||
<button onClick={this.add}>+</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
render(<my-counter />, 'body')
|
||||
```
|
||||
|
||||
You can also use `my-counter` tag directly in HTML:
|
||||
|
||||
```jsx
|
||||
<body>
|
||||
<my-counter></my-counter>
|
||||
</body>
|
||||
```
|
||||
|
||||
Looking at the highlighted part above, you can style the components. For example, the scope of the span above is only within the components, and it does not pollute other components. So far you have successfully started Omi! You learned:
|
||||
|
||||
* Add **structure** for components, such as JSX writing structure above
|
||||
* Add **behavior** to the component, such as the `onClick` binding event above
|
||||
* Add **style** to the component, such as `static css` above
|
||||
* Rendering components to body, of course, can also render components to any other component
|
||||
|
||||
## Stateless View & Store System
|
||||
|
||||
```jsx
|
||||
import { define, render } from 'omi'
|
||||
|
||||
class Store {
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
}
|
||||
add = () => {
|
||||
this.data.count++
|
||||
}
|
||||
}
|
||||
|
||||
define('my-counter', _ => (
|
||||
<div>
|
||||
<button onClick={_.store.sub}>-</button>
|
||||
<span>{_.store.data.count}</span>
|
||||
<button onClick={_.store.add}>+</button>
|
||||
</div>
|
||||
), {
|
||||
use: ['count'],
|
||||
//or using useSelf, useSelf will update self only, exclude children components
|
||||
//useSelf: ['count'],
|
||||
css: `span { color: red; }`,
|
||||
installed() {
|
||||
console.log('installed')
|
||||
}
|
||||
})
|
||||
|
||||
render(<my-counter />, 'body', new Store)
|
||||
```
|
||||
|
||||
Getting started, Congratulations!
|
|
@ -0,0 +1,60 @@
|
|||
## Button 按钮
|
||||
|
||||
点击或触摸触发一个操作的元素。响应用户点击操作,触发封装的逻辑。
|
||||
|
||||
<iframe height="350" style="width: 100%;" scrolling="no" title="OMIU Button" src="https://codepen.io/omijs/embed/LYppwYG?height=350&theme-id=dark&default-tab=html,result" frameborder="no" allowtransparency="true" allowfullscreen="true" loading="lazy">
|
||||
See the Pen <a href='https://codepen.io/omijs/pen/LYppwYG'>OMIU Button</a> by OMI
|
||||
(<a href='https://codepen.io/omijs'>@omijs</a>) on <a href='https://codepen.io'>CodePen</a>.
|
||||
</iframe>
|
||||
|
||||
## 导入
|
||||
|
||||
```js
|
||||
import 'omim/button'
|
||||
```
|
||||
|
||||
或者直接 script 标签引入。
|
||||
|
||||
## 使用
|
||||
|
||||
```html
|
||||
<m-button ripple icon="favorite">Default</m-button>
|
||||
|
||||
<m-button ripple dense>Dense</m-button>
|
||||
|
||||
<m-button ripple svg-icon="{
|
||||
path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',
|
||||
color: '#0072d9',
|
||||
scale: 1.3
|
||||
}">ICON</m-button>
|
||||
```
|
||||
|
||||
## Omi 中使用
|
||||
|
||||
JSX:
|
||||
|
||||
```jsx
|
||||
<m-button ripple raised icon="favorite">Default</m-button>
|
||||
|
||||
<m-button ripple dense raised>Dense</m-button>
|
||||
|
||||
<m-button ripple raised svgIcon={{
|
||||
path: 'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z',
|
||||
color: 'white',
|
||||
scale: 1.3
|
||||
}}>ICON</m-button>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Props
|
||||
|
||||
| **Name** | **Type** | **Defaults** | **Details** |
|
||||
| ------------- |:-------------:|:-----:|:-------------:|
|
||||
| ripple | boolean | -- | 单击按钮形成波纹 |
|
||||
| raised | boolean | -- | 有填充,有阴影 |
|
||||
| dense | boolean | -- | 更小更精致的按钮 |
|
||||
| unelevated | boolean | -- | 有填充,无阴影 |
|
||||
| outlined | boolean | -- | 无填充,有边框 |
|
||||
| svg-icon | object | -- | svg图标 |
|
||||
| icon | string | -- | 图标 |
|
|
@ -0,0 +1,101 @@
|
|||
## 安装
|
||||
|
||||
直接下载并用 `<script>` 标签引入,Omi 会被注册为一个全局变量。
|
||||
|
||||
* [Omi 开发版本](https://unpkg.com/omi@latest/dist/omi.js)
|
||||
* [Omi 压缩版本](https://unpkg.com/omi@latest/dist/omi.min.js)
|
||||
|
||||
也可以通过 npm 安装
|
||||
|
||||
```bash
|
||||
npm i omi
|
||||
```
|
||||
|
||||
如果需要兼容 IE8+,可以选择 omio,它拥有和 omi 几乎一样的 API,且 Omi 也会被注册为一个全局变量。
|
||||
|
||||
* [Omio 开发版本](https://unpkg.com/omio@latest/dist/omi.js)
|
||||
* [Omio 压缩版本](https://unpkg.com/omi@latest/dist/omi.min.js)
|
||||
|
||||
或者
|
||||
|
||||
```bash
|
||||
npm i omio
|
||||
```
|
||||
|
||||
## 命令行工具
|
||||
|
||||
Omi 提供了官方的 CLI,你不需要去学习怎么配置 webpack、babel或者 TypeScript,CLI 帮你配置好了一切,且提供了各种模板满足不同的项目类型。
|
||||
|
||||
```bash
|
||||
$ npm i omi-cli -g # install cli
|
||||
$ omi init my-app # init project
|
||||
$ cd my-app
|
||||
$ npm start # develop
|
||||
$ npm run build # release
|
||||
```
|
||||
|
||||
> `npx omi-cli init my-app` 也是支持的(npm v5.2.0+).
|
||||
|
||||
目录描述:
|
||||
|
||||
```
|
||||
├─ config
|
||||
├─ public
|
||||
├─ scripts
|
||||
├─ src
|
||||
│ ├─ assets
|
||||
│ ├─ elements //Store all custom elements
|
||||
│ ├─ store //Store all this store of pages
|
||||
│ ├─ admin.js //Entry js of compiler,will build to admin.html
|
||||
│ └─ index.js //Entry js of compiler,will build to index.html
|
||||
```
|
||||
|
||||
|
||||
### npm 脚本
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"start": "node scripts/start.js",
|
||||
"build": "PUBLIC_URL=. node scripts/build.js",
|
||||
"build-windows": "set PUBLIC_URL=.&& node scripts/build.js",
|
||||
"fix": "eslint src --fix"
|
||||
}
|
||||
```
|
||||
|
||||
你也可以设置 PUBLIC_URL, 比如:
|
||||
|
||||
```json
|
||||
...
|
||||
"build": "PUBLIC_URL=https://your.url.com/sub node scripts/build.js",
|
||||
"build-windows": "set PUBLIC_URL=https://your.url.com/sub&& node scripts/build.js",
|
||||
...
|
||||
```
|
||||
|
||||
### 切换 omi 和 omio
|
||||
|
||||
增加或删除 package.json 里的 alias config 可以切换 omi 和 omio 渲染:
|
||||
|
||||
```js
|
||||
...
|
||||
"alias": {
|
||||
"omi": "omio"
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
## 项目模板
|
||||
|
||||
| **Template Type**| **Command**| **Describe**|
|
||||
| ------------ | -----------| ----------------- |
|
||||
|基础模板(v3.3.0+)|`omi init my-app`| 基础模板,支持 omi 和 omio(IE8+)|
|
||||
|Kbone Template|`omi init-kbone my-app` | 使用 omi 开发小程序或者 Web|
|
||||
|小程序模板(v3.3.5+)|`omi init-p my-app`| Omi 开发小程序 |
|
||||
|mps|`omi init-mps my-app`| 原生小程序增强框架(JSX + Less 输出 WXML + WXSS) |
|
||||
|mps ts 版本|`omi init-mps-ts my-app`| 原生小程序增强框架(JSX + Less 输出 WXML + WXSS) |
|
||||
|omi-cloud|`omi init-cloud my-app`| 小程序•云开发|
|
||||
|基础模板(v3.3.9+)|`omi init-o my-app`| 支持 IE8 的基础模板,只是 build 的时候支持 IE8,开发调试请用 IE9|
|
||||
|支持预渲染快照骨架的模板|`omi init-snap my-app`| 基础模板,支持 omi 和 omio(IE8+),内置预渲染|
|
||||
|TypeScript 模板(omi-cli v3.3.0+)|`omi init-ts my-app`|使用 TypeScript 的模板|
|
||||
|Mobile 模板|`omi init-weui my-app`| 使用 weui 和 omi-router 的模板|
|
||||
|omi-mp 模板(omi-cli v3.0.13+)|`omi init-mp my-app` |使用微信小程序开发 H5|
|
|
@ -0,0 +1,108 @@
|
|||
<!-- <p align="center"><img src="https://github.com/Tencent/omi/raw/master/assets/omi-logo2019.svg?sanitize=true" alt="omi" width="300"/></p>
|
||||
<h2 align="center">Omi - 下一代前端框架,去万物糟粕,合精华为一点点 JS</h2>
|
||||
<p align="center"><b>基于 Web Components 并支持 IE8+(omio) 和 小程序(omip)</b></p>
|
||||
-->
|
||||
|
||||
## Omi 是什么?
|
||||
|
||||
Omi (读音 /ˈomɪ/,类似于 欧米) 是跨框架框架,基于 Web Components 设计,也可以使用相同语法的 omio 兼容 IE8+。支持 PC Web、移动 H5 和小程序开发(One framework, Mobile & desktop & mini program)。
|
||||
|
||||
|
||||
<em> Omi looks really neat!<br> </em>
|
||||
— [Jason Miller (Creator of Preact)](https://twitter.com/_developit/)
|
||||
|
||||
<em> I really like the trend towards "frameworks" that:<br><br>"export default class WeElement extends HTMLElement {..}"<br> <br>This one, Omi, is from Tencent.</em>
|
||||
— [Dion Almaer](https://twitter.com/dalmaer/)
|
||||
|
||||
## 快速上手
|
||||
|
||||
```jsx {8-11}
|
||||
import { render, WeElement, define } from 'omi'
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
static css = `
|
||||
span{
|
||||
color: red;
|
||||
}`
|
||||
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
this.update()
|
||||
}
|
||||
|
||||
add = () => {
|
||||
this.data.count++
|
||||
this.update()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<button onClick={this.sub}>-</button>
|
||||
<span>{this.data.count}</span>
|
||||
<button onClick={this.add}>+</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
render(<my-counter />, 'body')
|
||||
```
|
||||
|
||||
通过上面脚本的执行,你已经定义好了一个自定义标签,可以不使用 render 方法,直接使用 `my-counter` 标签:
|
||||
|
||||
```jsx
|
||||
<body>
|
||||
<my-counter></my-counter>
|
||||
</body>
|
||||
```
|
||||
|
||||
看上面高亮的部分,可以给组件加样式,比如上面的 span 的作用域仅仅在组件内部,不会污染别的组件。到现在你已经成功入门 Omi 了!你学会了:
|
||||
|
||||
* 为组件添加**结构**,如上面使用 JSX 书写结构
|
||||
* 为组件添加**行为**,如上面的 `onClick` 绑定事件
|
||||
* 为组件添加**样式**,如上面的 `static css`
|
||||
* 渲染组件到 body,当然也可以把组件渲染到任意其他组件
|
||||
|
||||
|
||||
## 无状态视图和 Store 系统
|
||||
|
||||
```jsx
|
||||
import { define, render } from 'omi'
|
||||
|
||||
class Store {
|
||||
data = {
|
||||
count: 1
|
||||
}
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
}
|
||||
add = () => {
|
||||
this.data.count++
|
||||
}
|
||||
}
|
||||
|
||||
define('my-counter', _ => (
|
||||
<div>
|
||||
<button onClick={_.store.sub}>-</button>
|
||||
<span>{_.store.data.count}</span>
|
||||
<button onClick={_.store.add}>+</button>
|
||||
</div>
|
||||
), {
|
||||
use: ['count'],
|
||||
//or using useSelf, useSelf will update self only, exclude children components
|
||||
//useSelf: ['count'],
|
||||
css: `span { color: red; }`,
|
||||
installed() {
|
||||
console.log('installed')
|
||||
}
|
||||
})
|
||||
|
||||
render(<my-counter />, 'body', new Store)
|
||||
```
|
||||
|
||||
入门了,恭喜你!
|
|
@ -0,0 +1,28 @@
|
|||
.content{
|
||||
position: relative;
|
||||
padding: 70px 0;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
h3{
|
||||
color:#444444;
|
||||
}
|
||||
|
||||
pre{
|
||||
border: 1px solid #eee;
|
||||
width: 100%;
|
||||
}
|
||||
li{
|
||||
text-indent: 20px;
|
||||
list-style:disc inside ;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1000px) {
|
||||
.content{
|
||||
margin-left: 0;
|
||||
border-left: none;
|
||||
padding: 70px 10px 70px 10px;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
import '../my-footer'
|
||||
|
||||
define('my-content', class extends WeElement {
|
||||
static css = require('./_index.css')
|
||||
|
||||
use = [
|
||||
'html'
|
||||
]
|
||||
|
||||
install() {
|
||||
this.store.myContent = this
|
||||
}
|
||||
|
||||
installed() {
|
||||
this.initCodeStyle()
|
||||
}
|
||||
|
||||
afterUpdate() {
|
||||
this.initCodeStyle()
|
||||
}
|
||||
|
||||
touchEnd = () => {
|
||||
this.store.hideSidebar()
|
||||
}
|
||||
|
||||
initCodeStyle() {
|
||||
let codes = document.querySelectorAll('code')
|
||||
|
||||
let codesArr = Array.prototype.slice.call(codes);
|
||||
let codeHlNumArr = []
|
||||
codesArr.forEach(code => {
|
||||
let arr = code.className.match(/{([\S\s]*)}/)
|
||||
let pre = code.parentNode
|
||||
//bug!
|
||||
arr && pre.setAttribute('data-line', arr[1])
|
||||
if (code.className) {
|
||||
pre.className = code.className
|
||||
|
||||
const temp = code.className.match(/language-\w*/g)[0]
|
||||
if (temp) {
|
||||
code.innerHTML = Prism.highlight(code.innerText, Prism.languages[temp.split('-')[1]], temp.split('-')[1])
|
||||
}
|
||||
} else {
|
||||
let pre = code.parentNode
|
||||
code.className = 'language-markup'
|
||||
pre.className = 'language-markup'
|
||||
code.innerHTML = Prism.highlight(code.innerText, Prism.languages.markup, 'markup')
|
||||
}
|
||||
// let hllNums = null
|
||||
// if (arr) {
|
||||
// let numArr = arr[0].replace(/[{|}]/g, '').split(',')
|
||||
// hllNums = this._arrToNumber(numArr)
|
||||
// }
|
||||
//codeHlNumArr.push(hllNums)
|
||||
})
|
||||
|
||||
// codesArr.forEach((code, index) => {
|
||||
// let newP = document.createElement('div')
|
||||
// newP.className = '_code-ctn'
|
||||
// let pre = code.parentNode
|
||||
// let ctn = pre.parentNode
|
||||
// if (pre.nodeName === 'PRE') {
|
||||
// ctn.insertBefore(newP, pre)
|
||||
|
||||
// let hl = document.createElement('div')
|
||||
// hl.className = '_hl'
|
||||
// newP.appendChild(hl)
|
||||
// newP.appendChild(pre)
|
||||
// let nums = codeHlNumArr[index]
|
||||
|
||||
// let max = Math.max.apply(null, nums)
|
||||
|
||||
// let inner = ''
|
||||
// for (let i = 0; i <= max; i++) {
|
||||
// if (nums.indexOf(i) == -1) {
|
||||
// inner += '<br />'
|
||||
// } else {
|
||||
// inner += '<div class="_hll"></div>'
|
||||
// }
|
||||
// }
|
||||
// hl.innerHTML = inner
|
||||
// }
|
||||
// })
|
||||
//fix line-highlight
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
}
|
||||
|
||||
_arrToNumber(numArr) {
|
||||
let arr = []
|
||||
numArr.forEach(item => {
|
||||
if (item.indexOf('-') !== -1) {
|
||||
const tempArr = item.split('-')
|
||||
const begin = Number(tempArr[0])
|
||||
const end = Number(tempArr[1])
|
||||
for (let i = begin; i < end + 1; i++) {
|
||||
arr.push(i)
|
||||
}
|
||||
} else {
|
||||
arr.push(Number(item))
|
||||
}
|
||||
})
|
||||
return arr
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class="content">
|
||||
<div
|
||||
ontouchend={this.touchEnd}
|
||||
dangerouslySetInnerHTML={{ __html: this.store.data.html }}
|
||||
/>
|
||||
<my-footer />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,42 @@
|
|||
iframe{
|
||||
width: 750px;
|
||||
height: 100%;
|
||||
top: 60px;
|
||||
right: 0;
|
||||
position: fixed;
|
||||
border: none;
|
||||
z-index: 9999;
|
||||
border-left: 2px solid #24292E;
|
||||
}
|
||||
|
||||
.switch{
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background-color: #AA0000;
|
||||
border-radius: 50%;
|
||||
position: fixed;
|
||||
right: 50px;
|
||||
bottom: 50px;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.switch img{
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-top:5px;
|
||||
}
|
||||
|
||||
.switch.close img{
|
||||
margin-top:10px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 1000px) {
|
||||
iframe{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 648 B |
|
@ -0,0 +1,53 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
import css from './_index.css'
|
||||
|
||||
define('my-demo', class extends WeElement {
|
||||
install() {
|
||||
this.store.myDemo = this
|
||||
if(this.checkPc())
|
||||
this.show = true
|
||||
else
|
||||
this.show = false
|
||||
this.demo = this.store.demo
|
||||
}
|
||||
|
||||
css() {
|
||||
return css
|
||||
}
|
||||
|
||||
checkPc() {
|
||||
let userAgentInfo = navigator.userAgent
|
||||
let mp = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]
|
||||
for (let i = 0; i < mp.length; i++)
|
||||
if (userAgentInfo.indexOf(mp[i]) > 0)
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
onShow = () => {
|
||||
this.show = true
|
||||
this.update()
|
||||
}
|
||||
|
||||
onClose = () => {
|
||||
this.show = false
|
||||
this.update()
|
||||
}
|
||||
|
||||
render() {
|
||||
if(!this.demo) return
|
||||
return (
|
||||
<div>
|
||||
{ this.show && <iframe style={`height:${window.innerHeight-59}px`} src={this.demo} ></iframe>}
|
||||
|
||||
{!this.show && <div class="switch code" onClick={this.onShow}>
|
||||
<img src={require('./code.png')}></img>
|
||||
</div>}
|
||||
|
||||
{this.show && <div class="switch close" onClick={this.onClose}>
|
||||
<img src={require('./close.png')}></img>
|
||||
</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,14 @@
|
|||
.ft{
|
||||
position: relative;
|
||||
margin-top: 20px
|
||||
}
|
||||
|
||||
.pre{
|
||||
position: absolute;
|
||||
left:15px;
|
||||
}
|
||||
|
||||
.next{
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
|
||||
define('my-footer', class extends WeElement {
|
||||
static css = require('./_index.css')
|
||||
|
||||
use = [
|
||||
'position',
|
||||
'menu'
|
||||
]
|
||||
|
||||
render() {
|
||||
const [
|
||||
position,
|
||||
menus
|
||||
] = this.using
|
||||
const pre = this.store.getPre()
|
||||
const next = this.store.getNext()
|
||||
|
||||
return (
|
||||
<div class='ft'>
|
||||
{pre &&<a href={'#/' + pre.md + `?index=${pre.index}&subIndex=${pre.subIndex}`} class='pre'>← {pre.name}</a>}
|
||||
{next &&<a href={'#/' + next.md + `?index=${next.index}&subIndex=${next.subIndex}`} class='next'>{next.name} →</a>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
})
|
|
@ -0,0 +1,26 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
|
||||
import './my-head'
|
||||
import './my-content'
|
||||
import './my-sidebar'
|
||||
import './my-demo'
|
||||
|
||||
define('my-frame', class extends WeElement {
|
||||
|
||||
installed(){
|
||||
this.store.init()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<my-head />
|
||||
<div class="main">
|
||||
<my-content />
|
||||
</div>
|
||||
<my-sidebar />
|
||||
<my-demo />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,96 @@
|
|||
.head{
|
||||
position:fixed;
|
||||
height:60px;
|
||||
line-height: 60px;
|
||||
border-bottom: 1px solid #eee;
|
||||
width:100%;
|
||||
background-color:#24292e;
|
||||
z-index:100;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
ul,li{
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.logo_box{
|
||||
width:100px;
|
||||
display: inline-block;
|
||||
text-align:center;
|
||||
line-height: 60px;
|
||||
}
|
||||
|
||||
.menu a,.logo_box a{
|
||||
display: inline-block;
|
||||
height:60px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.menu{
|
||||
position: absolute;
|
||||
right:20px;
|
||||
}
|
||||
|
||||
.menu li{
|
||||
margin-left:15px;
|
||||
}
|
||||
|
||||
.logo_box a{
|
||||
font-size: 34px;
|
||||
font-weight: bold;
|
||||
color: #00bff3;
|
||||
padding: 0px 15px;
|
||||
line-height: 60px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.menu a:hover{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.m_menu{
|
||||
position:fixed;
|
||||
display:none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.menu li{
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
.logo{
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-left: 10px;
|
||||
margin-top: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1000px) {
|
||||
|
||||
.logo_box{
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
.logo{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.head{
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.m_menu{
|
||||
top:0;
|
||||
left:0;
|
||||
display:block;
|
||||
width:50px;
|
||||
height:50px;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.m_menu img{
|
||||
width:30px;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
import logo from './omi-logo2019.svg'
|
||||
|
||||
define('my-head', class extends WeElement {
|
||||
static css = require('./_index.css')
|
||||
|
||||
use = [
|
||||
'position'
|
||||
]
|
||||
|
||||
toggleMenus = evt => {
|
||||
this.store.toogleSidebar()
|
||||
evt.stopPropagation()
|
||||
}
|
||||
|
||||
hideSidebar = evt => {
|
||||
this.store.hideSidebar()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class="head bord-btm" onClick={this.hideSidebar}>
|
||||
<div class="m_menu" onClick={this.toggleMenus}>
|
||||
<img src={require('./menu.png')} alt="" />
|
||||
</div>
|
||||
|
||||
<a href="https://tencent.github.io/omi/">
|
||||
<img class="logo" src={logo} />
|
||||
</a>
|
||||
<ul class="menu">
|
||||
<li class="github_li">
|
||||
<a href={this.store.data.lan === 'en'?'https://tencent.github.io/omi/packages/omim/docs/build/index.html':'https://tencent.github.io/omi/packages/omim/docs/build/cn.html'}>{this.store.data.lan === 'en'?'Omim Docs':'Omim文档'}</a>
|
||||
</li>
|
||||
<li style='color:#aaa;'>|</li>
|
||||
<li class="github_li">
|
||||
<a href="https://github.com/Tencent/omi/" target="_blank">Github</a>
|
||||
</li>
|
||||
<li style='color:#aaa;'>|</li>
|
||||
<li class="github_li m_show">
|
||||
{this.store.data.lan === 'en' ? (
|
||||
<a href={`cn.html${location.hash}`}>中文</a>
|
||||
) : (
|
||||
<a href={`index.html${location.hash}`}>English</a>
|
||||
)}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
After Width: | Height: | Size: 227 B |
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="544px" height="544px" viewBox="0 0 544 544" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.3 (57544) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>OMI</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1">
|
||||
<stop stop-color="white" offset="0%"></stop>
|
||||
<stop stop-color="white" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-2">
|
||||
<stop stop-color="white" offset="0%"></stop>
|
||||
<stop stop-color="white" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-3">
|
||||
<stop stop-color="white" offset="0%"></stop>
|
||||
<stop stop-color="white" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="OMI" transform="translate(-72 -72) scale(1.3, 1.3)" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path transform="translate(28 30) scale(0.9, 0.9)" d="M360.461194,392.400665 L331.766299,363.852923 C362.137315,342.610697 382,307.374938 382,267.5 C382,242.280821 374.054892,218.917322 360.531177,199.776002 L264.653589,295.653589 L249.205844,280.205844 L249.063708,280.34798 L168.478308,199.762579 C154.948823,218.906399 147,242.274926 147,267.5 C147,307.374938 166.862685,342.610697 197.233701,363.852923 L168.538806,392.400665 C131.116001,363.605836 107,318.369215 107,267.5 C107,216.869975 130.889745,171.819699 168.011797,143.006609 L222.432893,197.148622 L264.511454,239.227182 L311.034034,192.704602 L360.988203,143.006609 C398.110255,171.819699 422,216.869975 422,267.5 C422,318.369215 397.883999,363.605836 360.461194,392.400665 Z" id="M" fill="url(#linearGradient-1)" fill-rule="nonzero"></path>
|
||||
<path d="M264.5,472 C149.900914,472 57,379.099086 57,264.5 C57,149.900914 149.900914,57 264.5,57 C379.099086,57 472,149.900914 472,264.5 C472,379.099086 379.099086,472 264.5,472 Z M263.5,436 C357.112265,436 433,360.112265 433,266.5 C433,172.887735 357.112265,97 263.5,97 C169.887735,97 94,172.887735 94,266.5 C94,360.112265 169.887735,436 263.5,436 Z" id="O" fill="url(#linearGradient-2)" fill-rule="nonzero"></path>
|
||||
<circle id="I-Dot" fill="url(#linearGradient-3)" fill-rule="nonzero" cx="319" cy="142" r="20"></circle>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW 2017 -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1024px" height="1024px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||
viewBox="0 0 1024 1024"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
<![CDATA[
|
||||
.fil0 {fill:none}
|
||||
.fil2 {fill:#171717}
|
||||
.fil1 {fill:#FEFEFE}
|
||||
]]>
|
||||
</style>
|
||||
</defs>
|
||||
<g id="图层_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<rect class="fil0" width="1024" height="1024"/>
|
||||
<rect class="fil0" width="1024" height="1024"/>
|
||||
<g id="_2225049615792">
|
||||
<circle class="fil1" cx="512" cy="512" r="512"/>
|
||||
<polygon class="fil2" points="159.97,807.8 338.71,532.42 509.9,829.62 519.41,829.62 678.85,536.47 864.03,807.8 739.83,194.38 729.2,194.38 517.73,581.23 293.54,194.38 283.33,194.38 "/>
|
||||
<circle class="fil2" cx="839.36" cy="242.47" r="50"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,32 @@
|
|||
li.title{
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin-bottom:10px;
|
||||
margin-top:10px;
|
||||
text-indent: 23px;
|
||||
}
|
||||
li{
|
||||
margin-bottom:1px;
|
||||
text-indent: 33px;
|
||||
}
|
||||
li a{
|
||||
display:block;
|
||||
font-size:14px;
|
||||
height:30px;
|
||||
line-height:30px;
|
||||
color: black;
|
||||
background-color:#eee;
|
||||
}
|
||||
li a.current,li a.current:hover{
|
||||
background-color:#24292e;
|
||||
color: white;
|
||||
cursor: default;
|
||||
}
|
||||
li a:hover{
|
||||
background-color:#f0f8ff;
|
||||
}
|
||||
|
||||
|
||||
ul,li{
|
||||
list-style:none;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
|
||||
define('my-list', class extends WeElement {
|
||||
static css = require('./_index.css')
|
||||
|
||||
use = [
|
||||
'position'
|
||||
]
|
||||
|
||||
render(props) {
|
||||
const [position] = this.using
|
||||
|
||||
return (
|
||||
<ul>
|
||||
<li class="title">{props.menu.title}</li>
|
||||
{props.menu.list &&
|
||||
props.menu.list.map((item, subIndex) => {
|
||||
const cls = position[0] === props.index && position[1] === subIndex ? { class: 'current' } : null
|
||||
return <li>
|
||||
<a
|
||||
href={
|
||||
'#/' + item.md + `?index=${props.index}&subIndex=${subIndex}`
|
||||
}
|
||||
{...cls}
|
||||
>
|
||||
{item.name}
|
||||
</a>
|
||||
</li>
|
||||
})}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,39 @@
|
|||
@media only screen and (max-width: 1000px) {
|
||||
.list{
|
||||
transform: translateX(-100%);
|
||||
background-color:white;
|
||||
left:0 !important;
|
||||
-moz-transition: all .6s ease;
|
||||
-o-transition: all .6s ease;
|
||||
-webkit-transition: all .6s ease;
|
||||
transition: all .6s ease;
|
||||
width: 70% !important;
|
||||
z-index: 100000;
|
||||
border-right: none !important;
|
||||
}
|
||||
|
||||
.list.show {
|
||||
-moz-transform: translateX(0%) translateZ(0);
|
||||
-ms-transform: translateX(0%) translateZ(0);
|
||||
-o-transform: translateX(0%) translateZ(0);
|
||||
-webkit-transform: translateX(0%) translateZ(0);
|
||||
transform: translateX(0%) translateZ(0);
|
||||
}
|
||||
}
|
||||
|
||||
.list{
|
||||
width: 261px;
|
||||
text-indent: 20px;
|
||||
border-right: 1px solid #eee;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
position:fixed;
|
||||
top:60px;
|
||||
background-color: white;
|
||||
height: 100%;
|
||||
border-right: 1px solid #ccc;
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
.version{
|
||||
height:20px;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import { define, WeElement } from 'omi'
|
||||
import '../my-list'
|
||||
|
||||
define('my-sidebar', class extends WeElement {
|
||||
static css = require('./_index.css')
|
||||
|
||||
use = [
|
||||
'menus',
|
||||
'sideBarShow',
|
||||
'lan'
|
||||
]
|
||||
|
||||
render() {
|
||||
const [menus, sideBarShow, lan] = this.using
|
||||
|
||||
return (
|
||||
<div class={`list${sideBarShow ? ' show' : ''}`}>
|
||||
{menus[lan].map((menu, index) => (
|
||||
<my-list menu={menu} index={index} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
import { render } from 'omi'
|
||||
import './assets/index.css'
|
||||
import './elements/my-frame.js'
|
||||
import Store from './store'
|
||||
|
||||
render(<my-frame />, '#root', new Store({ lan: 'en' }))
|
|
@ -0,0 +1,91 @@
|
|||
import config from '../docs/config.js'
|
||||
import 'omi-router'
|
||||
|
||||
class Store {
|
||||
constructor(data) {
|
||||
this.data = {
|
||||
position: [-1, -1],
|
||||
menus: config.menus,
|
||||
lan: data.lan,
|
||||
html: '',
|
||||
sideBarShow: window.innerWidth > 768
|
||||
}
|
||||
let id = 0
|
||||
this.map = {}
|
||||
this.positionMap = {}
|
||||
config.menus[this.data.lan].forEach((menu, index) => {
|
||||
menu.list.forEach((item, subIndex) => {
|
||||
item.id = id++
|
||||
item.position = [index, subIndex]
|
||||
this.map[item.id] = item
|
||||
item.index = index
|
||||
item.subIndex = subIndex
|
||||
this.positionMap[index+'-'+subIndex] = item
|
||||
})
|
||||
})
|
||||
this.preIndex = 0
|
||||
this.preSubIndex = 0
|
||||
}
|
||||
|
||||
getNext(){
|
||||
const item = this.positionMap[this.data.position.join('-')]
|
||||
if(item){
|
||||
return this.map[item.id+1]
|
||||
}
|
||||
}
|
||||
|
||||
getPre(){
|
||||
const item = this.positionMap[this.data.position.join('-')]
|
||||
if(item){
|
||||
return this.map[item.id-1]
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
this.remarkable = new Remarkable({ html: true })
|
||||
if (location.hash === "") {
|
||||
this.data.position = [0, 0]
|
||||
this.getMarkDown(this.data.menus[this.data.lan][0].list[0].md, this.data.lan, m => {
|
||||
this.data.html = this.remarkable.render(m)
|
||||
})
|
||||
}
|
||||
this.initRouter()
|
||||
}
|
||||
|
||||
toogleSidebar() {
|
||||
this.data.sideBarShow = !this.data.sideBarShow
|
||||
}
|
||||
|
||||
hideSidebar() {
|
||||
this.data.sideBarShow = false
|
||||
}
|
||||
|
||||
initRouter() {
|
||||
const menus = this.data.menus[this.data.lan]
|
||||
menus.forEach(item => {
|
||||
item.list.forEach(subItem => {
|
||||
route('/' + subItem.md, evt => {
|
||||
menus[this.preIndex].list[this.preSubIndex].selected = false
|
||||
this.preIndex = evt.query.index
|
||||
this.preSubIndex = evt.query.subIndex
|
||||
this.data.position = [Number(evt.query.index), Number(evt.query.subIndex)]
|
||||
this.data.sideBarShow = false
|
||||
|
||||
this.getMarkDown(subItem.md, this.data.lan, m => {
|
||||
this.data.html = this.remarkable.render(m)
|
||||
document.body.scrollTop = 0
|
||||
document.documentElement.scrollTop = 0
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
getMarkDown(name, lan, callback) {
|
||||
import('../docs/' + lan + '/' + name + '.md').then(m => {
|
||||
callback(m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default Store
|
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
* mappingjs v2.0.0 by dntzhang
|
||||
* Objects mapping for javascript. Omi MVVM's best partner.
|
||||
* @method mapping
|
||||
* @param {from} options
|
||||
* @param {to} options
|
||||
* @param {rule} options
|
||||
* @return {Object} To Object
|
||||
*/
|
||||
|
||||
let ARRAYTYPE = '[object Array]'
|
||||
let OBJECTTYPE = '[object Object]'
|
||||
|
||||
function mapping(from, to, rule) {
|
||||
let tempRule = Object.assign({}, rule)
|
||||
let res = to || {}
|
||||
Object.keys(from).forEach(key => {
|
||||
let obj = from[key]
|
||||
if (isArray(obj)) {
|
||||
res[key] = res[key] || []
|
||||
arrayMapping(obj, res[key], tempRule, key)
|
||||
} else if (isObject(obj)) {
|
||||
res[key] = res[key] || {}
|
||||
objMapping(obj, res[key], tempRule, key)
|
||||
} else {
|
||||
res[key] = obj
|
||||
}
|
||||
})
|
||||
|
||||
rule &&
|
||||
Object.keys(tempRule).forEach(key => {
|
||||
let arr = key
|
||||
.replace(/]/g, '')
|
||||
.replace(/\[/g, '.')
|
||||
.split('.')
|
||||
|
||||
if (arr.length === 1) {
|
||||
res[key] = tempRule[key].call ? tempRule[key].call(from) : tempRule[key]
|
||||
delete tempRule[key]
|
||||
}
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function arrayMapping(from, to, rule, path) {
|
||||
if (from.length < to.length) {
|
||||
if (to.size) {
|
||||
//obaa extend method
|
||||
to.size(from.length)
|
||||
} else {
|
||||
to.length = from.length
|
||||
}
|
||||
}
|
||||
|
||||
from.forEach((item, index) => {
|
||||
//push method can trigger obaa callback
|
||||
if (index > to.length - 1) {
|
||||
if (isArray(item)) {
|
||||
to.push(arrayMapping(item, to[index], rule, path + '[' + index + ']'))
|
||||
} else if (isObject(item)) {
|
||||
to.push(objMapping(item, to[index], rule, path + '[' + index + ']'))
|
||||
} else {
|
||||
to.push(item)
|
||||
}
|
||||
} else if (isArray(item)) {
|
||||
to[index] = to[index] || []
|
||||
arrayMapping(item, to[index], rule, path + '[' + index + ']')
|
||||
} else if (isObject(item)) {
|
||||
to[index] = objMapping(item, to[index], rule, path + '[' + index + ']')
|
||||
} else {
|
||||
to[index] = item
|
||||
}
|
||||
})
|
||||
|
||||
rule &&
|
||||
Object.keys(rule).forEach(key => {
|
||||
let arr = key
|
||||
.replace(/]/g, '')
|
||||
.replace(/\[/g, '.')
|
||||
.split('.')
|
||||
let pathArr = path
|
||||
.replace(/]/g, '')
|
||||
.replace(/\[/g, '.')
|
||||
.split('.')
|
||||
|
||||
let dl = arr.length - pathArr.length
|
||||
if (dl === 1 && equalArr(arr, pathArr)) {
|
||||
to[arr[arr.length - 1]] = rule[key].call
|
||||
? rule[key].call(from)
|
||||
: rule[key]
|
||||
delete rule[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function objMapping(from, to, rule, path) {
|
||||
let res = to || {}
|
||||
Object.keys(from).forEach(key => {
|
||||
let obj = from[key]
|
||||
if (isArray(obj)) {
|
||||
res[key] = res[key] || []
|
||||
arrayMapping(obj, res[key], rule, path + '.' + key)
|
||||
} else if (isObject(obj)) {
|
||||
res[key] = res[key] || {}
|
||||
objMapping(obj, res[key], rule, path + '.' + key)
|
||||
} else {
|
||||
res[key] = obj
|
||||
}
|
||||
})
|
||||
|
||||
rule &&
|
||||
Object.keys(rule).forEach(key => {
|
||||
let arr = key
|
||||
.replace(/]/g, '')
|
||||
.replace(/\[/g, '.')
|
||||
.split('.')
|
||||
let pathArr = path
|
||||
.replace(/]/g, '')
|
||||
.replace(/\[/g, '.')
|
||||
.split('.')
|
||||
|
||||
if (arr.length - pathArr.length === 1 && equalArr(arr, pathArr)) {
|
||||
res[arr[arr.length - 1]] = rule[key].call
|
||||
? rule[key].call(from)
|
||||
: rule[key]
|
||||
if (arr.indexOf('*') === -1) {
|
||||
delete rule[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function equalArr(arrA, arrB) {
|
||||
let i = 0,
|
||||
len = arrB.length
|
||||
for (; i < len; i++) {
|
||||
if (arrA[i] !== arrB[i] && !(arrA[i] === '*' && !isNaN(Number(arrB[i])))) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function isArray(obj) {
|
||||
return Object.prototype.toString.call(obj) === ARRAYTYPE
|
||||
}
|
||||
|
||||
function isObject(obj) {
|
||||
return Object.prototype.toString.call(obj) === OBJECTTYPE
|
||||
}
|
||||
|
||||
//Compatible with older versions
|
||||
mapping.auto = mapping
|
||||
|
||||
export default mapping
|
|
@ -0,0 +1,6 @@
|
|||
export default {
|
||||
pathA: 'M464 512a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm200 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm-400 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm661.2-173.6c-22.6-53.7-55-101.9-96.3-143.3a444.35 444.35 0 0 0-143.3-96.3C630.6 75.7 572.2 64 512 64h-2c-60.6.3-119.3 12.3-174.5 35.9a445.35 445.35 0 0 0-142 96.5c-40.9 41.3-73 89.3-95.2 142.8-23 55.4-34.6 114.3-34.3 174.9A449.4 449.4 0 0 0 112 714v152a46 46 0 0 0 46 46h152.1A449.4 449.4 0 0 0 510 960h2.1c59.9 0 118-11.6 172.7-34.3a444.48 444.48 0 0 0 142.8-95.2c41.3-40.9 73.8-88.7 96.5-142 23.6-55.2 35.6-113.9 35.9-174.5.3-60.9-11.5-120-34.8-175.6zm-151.1 438C704 845.8 611 884 512 884h-1.7c-60.3-.3-120.2-15.3-173.1-43.5l-8.4-4.5H188V695.2l-4.5-8.4C155.3 633.9 140.3 574 140 513.7c-.4-99.7 37.7-193.3 107.6-263.8 69.8-70.5 163.1-109.5 262.8-109.9h1.7c50 0 98.5 9.7 144.2 28.9 44.6 18.7 84.6 45.6 119 80 34.3 34.3 61.3 74.4 80 119 19.4 46.2 29.1 95.2 28.9 145.8-.6 99.6-39.7 192.9-110.1 262.7z',
|
||||
pathB: 'M678.3 642.4c24.2-13 51.9-20.4 81.4-20.4h.1c3 0 4.4-3.6 2.2-5.6a371.67 371.67 0 0 0-103.7-65.8c-.4-.2-.8-.3-1.2-.5C719.2 505 759.6 431.7 759.6 349c0-137-110.8-248-247.5-248S264.7 212 264.7 349c0 82.7 40.4 156 102.6 201.1-.4.2-.8.3-1.2.5-44.7 18.9-84.8 46-119.3 80.6a373.42 373.42 0 0 0-80.4 119.5A373.6 373.6 0 0 0 137 888.8a8 8 0 0 0 8 8.2h59.9c4.3 0 7.9-3.5 8-7.8 2-77.2 32.9-149.5 87.6-204.3C357 628.2 432.2 597 512.2 597c56.7 0 111.1 15.7 158 45.1a8.1 8.1 0 0 0 8.1.3zM512.2 521c-45.8 0-88.9-17.9-121.4-50.4A171.2 171.2 0 0 1 340.5 349c0-45.9 17.9-89.1 50.3-121.6S466.3 177 512.2 177s88.9 17.9 121.4 50.4A171.2 171.2 0 0 1 683.9 349c0 45.9-17.9 89.1-50.3 121.6C601.1 503.1 558 521 512.2 521zM880 759h-84v-84c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v84h-84c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h84v84c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-84h84c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z',
|
||||
pathC: 'M136 384h56c4.4 0 8-3.6 8-8V200h176c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H196c-37.6 0-68 30.4-68 68v180c0 4.4 3.6 8 8 8zm512-184h176v176c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V196c0-37.6-30.4-68-68-68H648c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zM376 824H200V648c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v180c0 37.6 30.4 68 68 68h180c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm512-184h-56c-4.4 0-8 3.6-8 8v176H648c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h180c37.6 0 68-30.4 68-68V648c0-4.4-3.6-8-8-8zm16-164H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8z',
|
||||
pathD: 'M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm159.6-585h-59.5c-3 0-5.8 1.7-7.1 4.4l-90.6 180H511l-90.6-180a8 8 0 0 0-7.1-4.4h-60.7c-1.3 0-2.6.3-3.8 1-3.9 2.1-5.3 7-3.2 10.9L457 515.7h-61.4c-4.4 0-8 3.6-8 8v29.9c0 4.4 3.6 8 8 8h81.7V603h-81.7c-4.4 0-8 3.6-8 8v29.9c0 4.4 3.6 8 8 8h81.7V717c0 4.4 3.6 8 8 8h54.3c4.4 0 8-3.6 8-8v-68.1h82c4.4 0 8-3.6 8-8V611c0-4.4-3.6-8-8-8h-82v-41.5h82c4.4 0 8-3.6 8-8v-29.9c0-4.4-3.6-8-8-8h-62l111.1-204.8c.6-1.2 1-2.5 1-3.8-.1-4.4-3.7-8-8.1-8z'
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"cn.css": "static/css/cn.4dd07f49.css",
|
||||
"cn.css.map": "static/css/cn.4dd07f49.css.map",
|
||||
"cn.js": "static/js/cn.2311fa0d.js",
|
||||
"cn.js.map": "static/js/cn.2311fa0d.js.map",
|
||||
"index.css": "static/css/index.4dd07f49.css",
|
||||
"index.css.map": "static/css/index.4dd07f49.css.map",
|
||||
"index.js": "static/js/index.f3ba6b3b.js",
|
||||
"index.js.map": "static/js/index.f3ba6b3b.js.map",
|
||||
"static/js/0.3f7d43a8.chunk.js": "static/js/0.3f7d43a8.chunk.js",
|
||||
"static/js/0.3f7d43a8.chunk.js.map": "static/js/0.3f7d43a8.chunk.js.map",
|
||||
"static/js/1.005b6af9.chunk.js": "static/js/1.005b6af9.chunk.js",
|
||||
"static/js/1.005b6af9.chunk.js.map": "static/js/1.005b6af9.chunk.js.map",
|
||||
"static/js/2.8c7af82d.chunk.js": "static/js/2.8c7af82d.chunk.js",
|
||||
"static/js/2.8c7af82d.chunk.js.map": "static/js/2.8c7af82d.chunk.js.map",
|
||||
"static/js/3.652b6d47.chunk.js": "static/js/3.652b6d47.chunk.js",
|
||||
"static/js/3.652b6d47.chunk.js.map": "static/js/3.652b6d47.chunk.js.map",
|
||||
"static/js/4.9553b96d.chunk.js": "static/js/4.9553b96d.chunk.js",
|
||||
"static/js/4.9553b96d.chunk.js.map": "static/js/4.9553b96d.chunk.js.map",
|
||||
"static/js/5.022786ec.chunk.js": "static/js/5.022786ec.chunk.js",
|
||||
"static/js/5.022786ec.chunk.js.map": "static/js/5.022786ec.chunk.js.map",
|
||||
"static/media/omi-logo2019.svg": "static/media/omi-logo2019.923166c3.svg"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>Omi - Front End Cross-Frameworks Framework</title><link href="./static/css/cn.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/cn.2311fa0d.js"></script></body></html>
|
After Width: | Height: | Size: 66 KiB |
|
@ -0,0 +1,218 @@
|
|||
/* PrismJS 1.15.0
|
||||
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+bash+json+typescript+jsx+tsx&plugins=line-highlight+line-numbers */
|
||||
/**
|
||||
* okaidia theme for JavaScript, CSS and HTML
|
||||
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
|
||||
* @author ocodia
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #f8f8f2;
|
||||
background: none;
|
||||
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #272822;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number {
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
.token.keyword {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #fd971f;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 3em;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: inherit 0;
|
||||
margin-top: 1em; /* Same as .prism’s padding-top */
|
||||
|
||||
background: hsla(24, 20%, 50%,.08);
|
||||
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
|
||||
|
||||
pointer-events: none;
|
||||
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-start);
|
||||
position: absolute;
|
||||
top: .4em;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
background-color: hsla(24, 20%, 50%,.4);
|
||||
color: hsl(24, 20%, 95%);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
text-align: center;
|
||||
vertical-align: .3em;
|
||||
border-radius: 999px;
|
||||
text-shadow: none;
|
||||
box-shadow: 0 1px white;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
bottom: .4em;
|
||||
}
|
||||
|
||||
.line-numbers .line-highlight:before,
|
||||
.line-numbers .line-highlight:after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers {
|
||||
position: relative;
|
||||
padding-left: 3.8em;
|
||||
counter-reset: linenumber;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers > code {
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.line-numbers .line-numbers-rows {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
font-size: 100%;
|
||||
left: -3.8em;
|
||||
width: 3em; /* works for line-numbers below 1000 lines */
|
||||
letter-spacing: -1px;
|
||||
border-right: 1px solid #999;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.line-numbers-rows > span {
|
||||
pointer-events: none;
|
||||
display: block;
|
||||
counter-increment: linenumber;
|
||||
}
|
||||
|
||||
.line-numbers-rows > span:before {
|
||||
content: counter(linenumber);
|
||||
color: #999;
|
||||
display: block;
|
||||
padding-right: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="shortcut icon" href="./favicon.ico"><link rel="stylesheet" href="./highlight/prism.css"><style>*{-webkit-tap-highlight-color:rgba(255,255,255,0);-moz-user-focus:none}</style><title>Omi - Front End Cross-Frameworks Framework</title><link href="./static/css/index.4dd07f49.css" rel="stylesheet"></head><body><script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script><script src="./highlight/prism.js"></script><script src="./js/remarkable.min.js"></script><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/index.f3ba6b3b.js"></script></body></html>
|
|
@ -0,0 +1 @@
|
|||
"use strict";var precacheConfig=[["./cn.html","2c19d434b84dc7ad02020a158ad8e307"],["./index.html","56e998f7793371205f93739f050426ae"],["./static/css/cn.4dd07f49.css","476d16186dc05ff3faa0a5d4dc9ac72c"],["./static/css/index.4dd07f49.css","9ad340cc60e8fed0f9856b562708144e"],["./static/js/0.3f7d43a8.chunk.js","9737381cd2902322654bacf0ea2bd3ca"],["./static/js/1.005b6af9.chunk.js","9be28c7acc0282b04fbc3249862aa934"],["./static/js/2.8c7af82d.chunk.js","69b61560dfb86aee241a16b6d7b52c5e"],["./static/js/3.652b6d47.chunk.js","d2a28b98c67331cb6cae4d988f66d96c"],["./static/js/4.9553b96d.chunk.js","9ce3ee9ce173eb6b11bbdc96ae0bbb99"],["./static/js/5.022786ec.chunk.js","d97599ca3b3eb85245c45b3851c2415f"],["./static/js/cn.2311fa0d.js","2c7e4f96da42fde55a2ec60216fdc59e"],["./static/js/index.f3ba6b3b.js","03a8ffaf53a5f85fa33c7292817c17a0"],["./static/media/omi-logo2019.923166c3.svg","923166c362dce831a15c447b19a622f9"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-"+(self.registration?self.registration.scope:""),ignoreUrlParametersMatching=[/^utm_/],addDirectoryIndex=function(e,t){var n=new URL(e);return"/"===n.pathname.slice(-1)&&(n.pathname+=t),n.toString()},cleanResponse=function(t){return t.redirected?("body"in t?Promise.resolve(t.body):t.blob()).then(function(e){return new Response(e,{headers:t.headers,status:t.status,statusText:t.statusText})}):Promise.resolve(t)},createCacheKey=function(e,t,n,a){var r=new URL(e);return a&&r.pathname.match(a)||(r.search+=(r.search?"&":"")+encodeURIComponent(t)+"="+encodeURIComponent(n)),r.toString()},isPathWhitelisted=function(e,t){if(0===e.length)return!0;var n=new URL(t).pathname;return e.some(function(e){return n.match(e)})},stripIgnoredUrlParameters=function(e,n){var t=new URL(e);return t.hash="",t.search=t.search.slice(1).split("&").map(function(e){return e.split("=")}).filter(function(t){return n.every(function(e){return!e.test(t[0])})}).map(function(e){return e.join("=")}).join("&"),t.toString()},hashParamName="_sw-precache",urlsToCacheKeys=new Map(precacheConfig.map(function(e){var t=e[0],n=e[1],a=new URL(t,self.location),r=createCacheKey(a,hashParamName,n,/\.\w{8}\./);return[a.toString(),r]}));function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}self.addEventListener("install",function(e){e.waitUntil(caches.open(cacheName).then(function(a){return setOfCachedUrls(a).then(function(n){return Promise.all(Array.from(urlsToCacheKeys.values()).map(function(t){if(!n.has(t)){var e=new Request(t,{credentials:"same-origin"});return fetch(e).then(function(e){if(!e.ok)throw new Error("Request for "+t+" returned a response with status "+e.status);return cleanResponse(e).then(function(e){return a.put(t,e)})})}}))})}).then(function(){return self.skipWaiting()}))}),self.addEventListener("activate",function(e){var n=new Set(urlsToCacheKeys.values());e.waitUntil(caches.open(cacheName).then(function(t){return t.keys().then(function(e){return Promise.all(e.map(function(e){if(!n.has(e.url))return t.delete(e)}))})}).then(function(){return self.clients.claim()}))}),self.addEventListener("fetch",function(t){if("GET"===t.request.method){var e,n=stripIgnoredUrlParameters(t.request.url,ignoreUrlParametersMatching),a="index.html";(e=urlsToCacheKeys.has(n))||(n=addDirectoryIndex(n,a),e=urlsToCacheKeys.has(n));var r="./index.html";!e&&"navigate"===t.request.mode&&isPathWhitelisted(["^(?!\\/__).*"],t.request.url)&&(n=new URL(r,self.location).toString(),e=urlsToCacheKeys.has(n)),e&&t.respondWith(caches.open(cacheName).then(function(e){return e.match(urlsToCacheKeys.get(n)).then(function(e){if(e)return e;throw Error("The cached response that was expected is missing.")})}).catch(function(e){return console.warn('Couldn\'t serve response for "%s" from cache: %O',t.request.url,e),fetch(t.request)}))}});
|
|
@ -0,0 +1,2 @@
|
|||
body,html{background-color:#eee;font-family:proxima-nova,Helvetica Neue,Helvetica,Roboto,PT Sans,DejaVu Sans,Arial,Segoe UI Light,Segoe UI,Microsoft Jhenghei,Mirco Yahei,"sans-serif"}body,html,img,li,ul{margin:0;padding:0;border:0}a{text-decoration:none;color:#0366d6}table{border-collapse:collapse}table,td,th{border:1px solid #ccc}td,th{padding:4px 8px}::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:#f5f5f5}::-webkit-scrollbar{width:12px;height:12px;background-color:#f5f5f5}::-webkit-scrollbar-thumb{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:#555}@media only screen and (max-width:768px){body,html{overflow-x:hidden}.content img{width:100%}.content code[class*=language-],.content pre[class*=language-]{font-family:Consolas,Liberation Mono,Courier,monospace;line-height:18px;font-size:13px;margin:0;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.content pre[class*=language-]{padding-left:10px}.content p{font-size:14px}.content h1,.content h2,.content h3,.content h4,.content h5,.content p{padding-left:10px;padding-right:10px}.line-highlight:before,.line-highlight[data-end]:after{top:0}}*{-webkit-box-sizing:border-box;box-sizing:border-box}blockquote:before{content:"";position:absolute;left:0;top:0;background-color:#dfe2e5;height:24px;width:4px}blockquote{position:relative;margin:0;padding-left:20px}pre[data-line]{position:relative;padding:1em 0 1em 1em!important}.line-highlight:before,.line-highlight[data-end]:after{display:none}:not(pre)>code[class*=language-],pre[class*=language-]{font-size:.8em}img{max-width:900px}.content ul{padding-left:2em}.content table tr:nth-child(2n){background-color:#f6f8fa}
|
||||
/*# sourceMappingURL=cn.4dd07f49.css.map*/
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["assets/index.css"],"names":[],"mappings":"AACA,UAIE,sBACA,sJAA4J,CAG9J,oBAPE,SACA,UACA,QAAU,CAWZ,EACE,qBACA,aAAe,CAGjB,MACE,wBAA0B,CAE5B,YACE,qBAAuB,CAGzB,MACE,eAAiB,CAGnB,0BAEC,gDACA,wBAA0B,CAG3B,oBAEE,WACA,YACD,wBAA0B,CAG3B,0BAEC,gDACA,qBAAuB,CAGxB,yCACE,UAEE,iBAAmB,CAGrB,aACI,UAAY,CAIhB,+DAEI,uDACA,iBACA,eACA,SACA,WACA,8BACQ,qBAAuB,CAGnC,+BACI,iBAAmB,CAEvB,WACI,cAAgB,CAEpB,uEACI,kBACA,kBAAmB,CAGvB,uDACI,KAAS,CACZ,CAGH,EACE,8BACQ,qBAAuB,CAIjC,kBACE,WACA,kBACA,OACA,MACA,yBACA,YACA,SAAW,CAGb,WACE,kBACA,SACA,iBAAmB,CAGrB,eACE,kBACA,+BAAkC,CAGpC,uDACE,YAAc,CAGhB,uDACE,cAAiB,CAInB,IACE,eAAiB,CAGnB,YACE,gBAAkB,CAGpB,gCACE,wBAA0B","file":"static/css/cn.4dd07f49.css","sourcesContent":["\nhtml,body{\n margin: 0;\n padding: 0;\n border: 0;\n background-color: #eee;\n font-family:proxima-nova,\"Helvetica Neue\",Helvetica,Roboto, PT Sans, DejaVu Sans, Arial,Segoe UI Light,Segoe UI,Microsoft Jhenghei,Mirco Yahei,'sans-serif';\n}\n\nimg,ul,li{\n margin: 0;\n padding: 0;\n border: 0;\n}\n\na{\n text-decoration: none;\n color: #0366d6;\n}\n\ntable{\n border-collapse: collapse;\n}\ntable,td,th{\n border: 1px solid #ccc;\n}\n\ntd,th{\n padding: 4px 8px;\n}\n\n::-webkit-scrollbar-track\n{\n\t-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);\n\tbackground-color: #F5F5F5;\n}\n\n::-webkit-scrollbar\n{\n width: 12px;\n height: 12px;\n\tbackground-color: #F5F5F5;\n}\n\n::-webkit-scrollbar-thumb\n{\n\t-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n\tbackground-color: #555;\n}\n\n@media only screen and (max-width: 768px) {\n html,body{\n\n overflow-x: hidden;\n }\n\n .content img{\n width: 100%;\n }\n\n\n .content code[class*=\"language-\"],\n .content pre[class*=\"language-\"] {\n font-family: Consolas, \"Liberation Mono\", Courier, monospace;\n line-height: 18px;\n font-size: 13px;\n margin: 0;\n width: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n\n .content pre[class*=\"language-\"] {\n padding-left: 10px;\n }\n .content p{\n font-size: 14px;\n }\n .content p,.content h1,.content h2,.content h3,.content h4,.content h5{\n padding-left:10px;\n padding-right:10px;\n }\n\n .line-highlight:before, .line-highlight[data-end]:after{\n top: 0em;\n }\n}\n\n*{\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n\nblockquote::before{\n content: '';\n position: absolute;\n left: 0;\n top: 0px;\n background-color: #dfe2e5;\n height: 24px;\n width: 4px;\n}\n\nblockquote {\n position: relative;\n margin: 0;\n padding-left: 20px;\n}\n\npre[data-line] {\n position: relative;\n padding: 1em 0 1em 1em !important;\n}\n\n.line-highlight:before, .line-highlight[data-end]:after{\n display: none;\n}\n\n:not(pre) > code[class*=\"language-\"], pre[class*=\"language-\"] {\n font-size: 0.8em;\n}\n\n\nimg{\n max-width: 900px;\n}\n\n.content ul{\n padding-left: 2em;\n}\n\n.content table tr:nth-child(2n) {\n background-color: #f6f8fa;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/assets/index.css"],"sourceRoot":""}
|
|
@ -0,0 +1,2 @@
|
|||
body,html{background-color:#eee;font-family:proxima-nova,Helvetica Neue,Helvetica,Roboto,PT Sans,DejaVu Sans,Arial,Segoe UI Light,Segoe UI,Microsoft Jhenghei,Mirco Yahei,"sans-serif"}body,html,img,li,ul{margin:0;padding:0;border:0}a{text-decoration:none;color:#0366d6}table{border-collapse:collapse}table,td,th{border:1px solid #ccc}td,th{padding:4px 8px}::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:#f5f5f5}::-webkit-scrollbar{width:12px;height:12px;background-color:#f5f5f5}::-webkit-scrollbar-thumb{-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,.3);background-color:#555}@media only screen and (max-width:768px){body,html{overflow-x:hidden}.content img{width:100%}.content code[class*=language-],.content pre[class*=language-]{font-family:Consolas,Liberation Mono,Courier,monospace;line-height:18px;font-size:13px;margin:0;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}.content pre[class*=language-]{padding-left:10px}.content p{font-size:14px}.content h1,.content h2,.content h3,.content h4,.content h5,.content p{padding-left:10px;padding-right:10px}.line-highlight:before,.line-highlight[data-end]:after{top:0}}*{-webkit-box-sizing:border-box;box-sizing:border-box}blockquote:before{content:"";position:absolute;left:0;top:0;background-color:#dfe2e5;height:24px;width:4px}blockquote{position:relative;margin:0;padding-left:20px}pre[data-line]{position:relative;padding:1em 0 1em 1em!important}.line-highlight:before,.line-highlight[data-end]:after{display:none}:not(pre)>code[class*=language-],pre[class*=language-]{font-size:.8em}img{max-width:900px}.content ul{padding-left:2em}.content table tr:nth-child(2n){background-color:#f6f8fa}
|
||||
/*# sourceMappingURL=index.4dd07f49.css.map*/
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["assets/index.css"],"names":[],"mappings":"AACA,UAIE,sBACA,sJAA4J,CAG9J,oBAPE,SACA,UACA,QAAU,CAWZ,EACE,qBACA,aAAe,CAGjB,MACE,wBAA0B,CAE5B,YACE,qBAAuB,CAGzB,MACE,eAAiB,CAGnB,0BAEC,gDACA,wBAA0B,CAG3B,oBAEE,WACA,YACD,wBAA0B,CAG3B,0BAEC,gDACA,qBAAuB,CAGxB,yCACE,UAEE,iBAAmB,CAGrB,aACI,UAAY,CAIhB,+DAEI,uDACA,iBACA,eACA,SACA,WACA,8BACQ,qBAAuB,CAGnC,+BACI,iBAAmB,CAEvB,WACI,cAAgB,CAEpB,uEACI,kBACA,kBAAmB,CAGvB,uDACI,KAAS,CACZ,CAGH,EACE,8BACQ,qBAAuB,CAIjC,kBACE,WACA,kBACA,OACA,MACA,yBACA,YACA,SAAW,CAGb,WACE,kBACA,SACA,iBAAmB,CAGrB,eACE,kBACA,+BAAkC,CAGpC,uDACE,YAAc,CAGhB,uDACE,cAAiB,CAInB,IACE,eAAiB,CAGnB,YACE,gBAAkB,CAGpB,gCACE,wBAA0B","file":"static/css/index.4dd07f49.css","sourcesContent":["\nhtml,body{\n margin: 0;\n padding: 0;\n border: 0;\n background-color: #eee;\n font-family:proxima-nova,\"Helvetica Neue\",Helvetica,Roboto, PT Sans, DejaVu Sans, Arial,Segoe UI Light,Segoe UI,Microsoft Jhenghei,Mirco Yahei,'sans-serif';\n}\n\nimg,ul,li{\n margin: 0;\n padding: 0;\n border: 0;\n}\n\na{\n text-decoration: none;\n color: #0366d6;\n}\n\ntable{\n border-collapse: collapse;\n}\ntable,td,th{\n border: 1px solid #ccc;\n}\n\ntd,th{\n padding: 4px 8px;\n}\n\n::-webkit-scrollbar-track\n{\n\t-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);\n\tbackground-color: #F5F5F5;\n}\n\n::-webkit-scrollbar\n{\n width: 12px;\n height: 12px;\n\tbackground-color: #F5F5F5;\n}\n\n::-webkit-scrollbar-thumb\n{\n\t-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n\tbackground-color: #555;\n}\n\n@media only screen and (max-width: 768px) {\n html,body{\n\n overflow-x: hidden;\n }\n\n .content img{\n width: 100%;\n }\n\n\n .content code[class*=\"language-\"],\n .content pre[class*=\"language-\"] {\n font-family: Consolas, \"Liberation Mono\", Courier, monospace;\n line-height: 18px;\n font-size: 13px;\n margin: 0;\n width: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n\n .content pre[class*=\"language-\"] {\n padding-left: 10px;\n }\n .content p{\n font-size: 14px;\n }\n .content p,.content h1,.content h2,.content h3,.content h4,.content h5{\n padding-left:10px;\n padding-right:10px;\n }\n\n .line-highlight:before, .line-highlight[data-end]:after{\n top: 0em;\n }\n}\n\n*{\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n\nblockquote::before{\n content: '';\n position: absolute;\n left: 0;\n top: 0px;\n background-color: #dfe2e5;\n height: 24px;\n width: 4px;\n}\n\nblockquote {\n position: relative;\n margin: 0;\n padding-left: 20px;\n}\n\npre[data-line] {\n position: relative;\n padding: 1em 0 1em 1em !important;\n}\n\n.line-highlight:before, .line-highlight[data-end]:after{\n display: none;\n}\n\n:not(pre) > code[class*=\"language-\"], pre[class*=\"language-\"] {\n font-size: 0.8em;\n}\n\n\nimg{\n max-width: 900px;\n}\n\n.content ul{\n padding-left: 2em;\n}\n\n.content table tr:nth-child(2n) {\n background-color: #f6f8fa;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/assets/index.css"],"sourceRoot":""}
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([0],{45:function(n,e){n.exports="\x3c!-- <p align=\"center\"><img src=\"https://github.com/Tencent/omi/raw/master/assets/omi-logo2019.svg?sanitize=true\" alt=\"omi\" width=\"300\"/></p>\n<h2 align=\"center\">Omi - \u4e0b\u4e00\u4ee3\u524d\u7aef\u6846\u67b6\uff0c\u53bb\u4e07\u7269\u7cdf\u7c95\uff0c\u5408\u7cbe\u534e\u4e3a\u4e00\u70b9\u70b9 JS</h2>\n<p align=\"center\"><b>\u57fa\u4e8e Web Components \u5e76\u652f\u6301 IE8+(omio) \u548c \u5c0f\u7a0b\u5e8f(omip)</b></p>\n --\x3e\n\n## Omi \u662f\u4ec0\u4e48\uff1f\n\nOmi (\u8bfb\u97f3 /\u02c8om\u026a/\uff0c\u7c7b\u4f3c\u4e8e \u6b27\u7c73) \u662f\u8de8\u6846\u67b6\u6846\u67b6\uff0c\u57fa\u4e8e Web Components \u8bbe\u8ba1\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u8bed\u6cd5\u7684 omio \u517c\u5bb9 IE8+\u3002\u652f\u6301 PC Web\u3001\u79fb\u52a8 H5 \u548c\u5c0f\u7a0b\u5e8f\u5f00\u53d1(One framework, Mobile & desktop & mini program)\u3002\n\n\n<em> Omi looks really neat!<br> </em>\n\u3000\u3000\u3000\u3000\u2014 [Jason Miller (Creator of Preact)](https://twitter.com/_developit/)\n\n<em> I really like the trend towards \"frameworks\" that:<br><br>\"export default class WeElement extends HTMLElement {..}\"<br> <br>This one, Omi, is from Tencent.</em> \n\u3000\u3000\u3000\u3000\u2014 [Dion Almaer](https://twitter.com/dalmaer/)\n\n## \u5feb\u901f\u4e0a\u624b\n\n```jsx {8-11}\nimport { render, WeElement, define } from 'omi'\n\ndefine('my-counter', class extends WeElement {\n data = {\n count: 1\n }\n\n static css = `\n span{\n color: red;\n }`\n\n sub = () => {\n this.data.count--\n this.update()\n }\n\n add = () => {\n this.data.count++\n this.update()\n }\n\n render() {\n return (\n <div>\n <button onClick={this.sub}>-</button>\n <span>{this.data.count}</span>\n <button onClick={this.add}>+</button>\n </div>\n )\n }\n})\n\nrender(<my-counter />, 'body')\n```\n\n\u901a\u8fc7\u4e0a\u9762\u811a\u672c\u7684\u6267\u884c\uff0c\u4f60\u5df2\u7ecf\u5b9a\u4e49\u597d\u4e86\u4e00\u4e2a\u81ea\u5b9a\u4e49\u6807\u7b7e\uff0c\u53ef\u4ee5\u4e0d\u4f7f\u7528 render \u65b9\u6cd5\uff0c\u76f4\u63a5\u4f7f\u7528 `my-counter` \u6807\u7b7e\uff1a\n\n```jsx\n<body>\n <my-counter></my-counter>\n</body>\n```\n\n\u770b\u4e0a\u9762\u9ad8\u4eae\u7684\u90e8\u5206\uff0c\u53ef\u4ee5\u7ed9\u7ec4\u4ef6\u52a0\u6837\u5f0f\uff0c\u6bd4\u5982\u4e0a\u9762\u7684 span \u7684\u4f5c\u7528\u57df\u4ec5\u4ec5\u5728\u7ec4\u4ef6\u5185\u90e8\uff0c\u4e0d\u4f1a\u6c61\u67d3\u522b\u7684\u7ec4\u4ef6\u3002\u5230\u73b0\u5728\u4f60\u5df2\u7ecf\u6210\u529f\u5165\u95e8 Omi \u4e86\uff01\u4f60\u5b66\u4f1a\u4e86:\n\n* \u4e3a\u7ec4\u4ef6\u6dfb\u52a0**\u7ed3\u6784**\uff0c\u5982\u4e0a\u9762\u4f7f\u7528 JSX \u4e66\u5199\u7ed3\u6784\n* \u4e3a\u7ec4\u4ef6\u6dfb\u52a0**\u884c\u4e3a**\uff0c\u5982\u4e0a\u9762\u7684 `onClick` \u7ed1\u5b9a\u4e8b\u4ef6\n* \u4e3a\u7ec4\u4ef6\u6dfb\u52a0**\u6837\u5f0f**\uff0c\u5982\u4e0a\u9762\u7684 `static css`\n* \u6e32\u67d3\u7ec4\u4ef6\u5230 body\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u628a\u7ec4\u4ef6\u6e32\u67d3\u5230\u4efb\u610f\u5176\u4ed6\u7ec4\u4ef6\n\n\n## \u65e0\u72b6\u6001\u89c6\u56fe\u548c Store \u7cfb\u7edf\n\n```jsx\nimport { define, render } from 'omi'\n\nclass Store {\n data = {\n count: 1\n }\n sub = () => {\n this.data.count--\n }\n add = () => {\n this.data.count++\n }\n}\n\ndefine('my-counter', _ => (\n <div>\n <button onClick={_.store.sub}>-</button>\n <span>{_.store.data.count}</span>\n <button onClick={_.store.add}>+</button>\n </div>\n), {\n use: ['count'], \n //or using useSelf, useSelf will update self only, exclude children components\n //useSelf: ['count'], \n css: `span { color: red; }`,\n installed() {\n console.log('installed')\n }\n })\n\nrender(<my-counter />, 'body', new Store)\n```\n\n\u5165\u95e8\u4e86\uff0c\u606d\u559c\u4f60\uff01"}});
|
||||
//# sourceMappingURL=0.3f7d43a8.chunk.js.map
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([1],{44:function(n,i){n.exports='## \u5b89\u88c5 \n\n\u76f4\u63a5\u4e0b\u8f7d\u5e76\u7528 `<script>` \u6807\u7b7e\u5f15\u5165\uff0cOmi \u4f1a\u88ab\u6ce8\u518c\u4e3a\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u3002\n\n* [Omi \u5f00\u53d1\u7248\u672c](https://unpkg.com/omi@latest/dist/omi.js)\n* [Omi \u538b\u7f29\u7248\u672c](https://unpkg.com/omi@latest/dist/omi.min.js)\n\n\u4e5f\u53ef\u4ee5\u901a\u8fc7 npm \u5b89\u88c5\n\n```bash\nnpm i omi\n```\n\n\u5982\u679c\u9700\u8981\u517c\u5bb9 IE8+\uff0c\u53ef\u4ee5\u9009\u62e9 omio\uff0c\u5b83\u62e5\u6709\u548c omi \u51e0\u4e4e\u4e00\u6837\u7684 API\uff0c\u4e14 Omi \u4e5f\u4f1a\u88ab\u6ce8\u518c\u4e3a\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u3002\n\n* [Omio \u5f00\u53d1\u7248\u672c](https://unpkg.com/omio@latest/dist/omi.js)\n* [Omio \u538b\u7f29\u7248\u672c](https://unpkg.com/omi@latest/dist/omi.min.js)\n\n\u6216\u8005\n\n```bash\nnpm i omio\n```\n\n## \u547d\u4ee4\u884c\u5de5\u5177\n\nOmi \u63d0\u4f9b\u4e86\u5b98\u65b9\u7684 CLI\uff0c\u4f60\u4e0d\u9700\u8981\u53bb\u5b66\u4e60\u600e\u4e48\u914d\u7f6e webpack\u3001babel\u6216\u8005 TypeScript\uff0cCLI \u5e2e\u4f60\u914d\u7f6e\u597d\u4e86\u4e00\u5207\uff0c\u4e14\u63d0\u4f9b\u4e86\u5404\u79cd\u6a21\u677f\u6ee1\u8db3\u4e0d\u540c\u7684\u9879\u76ee\u7c7b\u578b\u3002\n\n```bash\n$ npm i omi-cli -g # install cli\n$ omi init my-app # init project\n$ cd my-app \n$ npm start # develop\n$ npm run build # release\n```\n\n> `npx omi-cli init my-app` \u4e5f\u662f\u652f\u6301\u7684(npm v5.2.0+).\n\n\u76ee\u5f55\u63cf\u8ff0:\n\n```\n\u251c\u2500 config\n\u251c\u2500 public\n\u251c\u2500 scripts\n\u251c\u2500 src\n\u2502 \u251c\u2500 assets\n\u2502 \u251c\u2500 elements //Store all custom elements\n\u2502 \u251c\u2500 store //Store all this store of pages\n\u2502 \u251c\u2500 admin.js //Entry js of compiler\uff0cwill build to admin.html\n\u2502 \u2514\u2500 index.js //Entry js of compiler\uff0cwill build to index.html\n```\n\n\n### npm \u811a\u672c\n\n```json\n"scripts": {\n "start": "node scripts/start.js",\n "build": "PUBLIC_URL=. node scripts/build.js",\n "build-windows": "set PUBLIC_URL=.&& node scripts/build.js",\n "fix": "eslint src --fix"\n}\n```\n\n\u4f60\u4e5f\u53ef\u4ee5\u8bbe\u7f6e PUBLIC_URL, \u6bd4\u5982\uff1a\n\n```json\n...\n"build": "PUBLIC_URL=https://your.url.com/sub node scripts/build.js",\n"build-windows": "set PUBLIC_URL=https://your.url.com/sub&& node scripts/build.js",\n...\n```\n\n### \u5207\u6362 omi \u548c omio\n\n\u589e\u52a0\u6216\u5220\u9664 package.json \u91cc\u7684 alias config \u53ef\u4ee5\u5207\u6362 omi \u548c omio \u6e32\u67d3:\n\n```js\n ...\n "alias": {\n "omi": "omio"\n }\n ...\n```\n \n\n## \u9879\u76ee\u6a21\u677f\n\n| **Template Type**| **Command**| **Describe**|\n| ------------ | -----------| ----------------- |\n|\u57fa\u7840\u6a21\u677f(v3.3.0+)|`omi init my-app`| \u57fa\u7840\u6a21\u677f\uff0c\u652f\u6301 omi \u548c omio(IE8+)|\n|Kbone Template|`omi init-kbone my-app` | \u4f7f\u7528 omi \u5f00\u53d1\u5c0f\u7a0b\u5e8f\u6216\u8005 Web|\n|\u5c0f\u7a0b\u5e8f\u6a21\u677f(v3.3.5+)|`omi init-p my-app`| Omi \u5f00\u53d1\u5c0f\u7a0b\u5e8f |\n|mps|`omi init-mps my-app`| \u539f\u751f\u5c0f\u7a0b\u5e8f\u589e\u5f3a\u6846\u67b6(JSX + Less \u8f93\u51fa WXML + WXSS) |\n|mps ts \u7248\u672c|`omi init-mps-ts my-app`| \u539f\u751f\u5c0f\u7a0b\u5e8f\u589e\u5f3a\u6846\u67b6(JSX + Less \u8f93\u51fa WXML + WXSS) |\n|omi-cloud|`omi init-cloud my-app`| \u5c0f\u7a0b\u5e8f\u2022\u4e91\u5f00\u53d1|\n|\u57fa\u7840\u6a21\u677f(v3.3.9+)|`omi init-o my-app`| \u652f\u6301 IE8 \u7684\u57fa\u7840\u6a21\u677f\uff0c\u53ea\u662f build \u7684\u65f6\u5019\u652f\u6301 IE8\uff0c\u5f00\u53d1\u8c03\u8bd5\u8bf7\u7528 IE9|\n|\u652f\u6301\u9884\u6e32\u67d3\u5feb\u7167\u9aa8\u67b6\u7684\u6a21\u677f|`omi init-snap my-app`| \u57fa\u7840\u6a21\u677f\uff0c\u652f\u6301 omi \u548c omio(IE8+)\uff0c\u5185\u7f6e\u9884\u6e32\u67d3|\n|TypeScript \u6a21\u677f(omi-cli v3.3.0+)|`omi init-ts my-app`|\u4f7f\u7528 TypeScript \u7684\u6a21\u677f|\n|Mobile \u6a21\u677f|`omi init-weui my-app`| \u4f7f\u7528 weui \u548c omi-router \u7684\u6a21\u677f|\n|omi-mp \u6a21\u677f(omi-cli v3.0.13+)|`omi init-mp my-app` |\u4f7f\u7528\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5f00\u53d1 H5|\n'}});
|
||||
//# sourceMappingURL=1.005b6af9.chunk.js.map
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([2],{43:function(n,e){n.exports='## Button \u6309\u94ae \n\n\u70b9\u51fb\u6216\u89e6\u6478\u89e6\u53d1\u4e00\u4e2a\u64cd\u4f5c\u7684\u5143\u7d20\u3002\u54cd\u5e94\u7528\u6237\u70b9\u51fb\u64cd\u4f5c\uff0c\u89e6\u53d1\u5c01\u88c5\u7684\u903b\u8f91\u3002\n\n<iframe height="350" style="width: 100%;" scrolling="no" title="OMIU Button" src="https://codepen.io/omijs/embed/LYppwYG?height=350&theme-id=dark&default-tab=html,result" frameborder="no" allowtransparency="true" allowfullscreen="true" loading="lazy">\n See the Pen <a href=\'https://codepen.io/omijs/pen/LYppwYG\'>OMIU Button</a> by OMI\n (<a href=\'https://codepen.io/omijs\'>@omijs</a>) on <a href=\'https://codepen.io\'>CodePen</a>.\n</iframe>\n\n## \u5bfc\u5165\n\n```js\nimport \'omim/button\'\n```\n\n\u6216\u8005\u76f4\u63a5 script \u6807\u7b7e\u5f15\u5165\u3002\n\n## \u4f7f\u7528\n\n```html\n<m-button ripple icon="favorite">Default</m-button>\n\n<m-button ripple dense>Dense</m-button>\n\n<m-button ripple svg-icon="{\n path: \'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z\',\n color: \'#0072d9\',\n scale: 1.3\n}">ICON</m-button>\n```\n\n## Omi \u4e2d\u4f7f\u7528\n\nJSX:\n\n```jsx\n<m-button ripple raised icon="favorite">Default</m-button>\n\n<m-button ripple dense raised>Dense</m-button>\n\n<m-button ripple raised svgIcon={{\n path: \'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z\',\n color: \'white\',\n scale: 1.3\n}}>ICON</m-button>\n```\n\n## API\n\n### Props\n\n| **Name** | **Type** | **Defaults** | **Details** |\n| ------------- |:-------------:|:-----:|:-------------:|\n| ripple | boolean | -- | \u5355\u51fb\u6309\u94ae\u5f62\u6210\u6ce2\u7eb9 |\n| raised | boolean | -- | \u6709\u586b\u5145\uff0c\u6709\u9634\u5f71 |\n| dense | boolean | -- | \u66f4\u5c0f\u66f4\u7cbe\u81f4\u7684\u6309\u94ae |\n| unelevated | boolean | -- | \u6709\u586b\u5145\uff0c\u65e0\u9634\u5f71 |\n| outlined | boolean | -- | \u65e0\u586b\u5145\uff0c\u6709\u8fb9\u6846 |\n| svg-icon | object | -- | svg\u56fe\u6807 |\n| icon | string | -- | \u56fe\u6807 |\n'}});
|
||||
//# sourceMappingURL=2.8c7af82d.chunk.js.map
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([3],{42:function(n,e){n.exports="## What's Omi \uff1f\n\nOmi (pronounced /\u02c8om\u026a/) is cross-frameworks framework base on Web Component, you can also use omio compatible IE8+ with the same grammar. One framework, Mobile & desktop & mini program.\n\n<em> Omi looks really neat!<br> </em>\n\u3000\u3000\u3000\u3000\u2014 [Jason Miller (Creator of Preact)](https://twitter.com/_developit/)\n\n<em> I really like the trend towards \"frameworks\" that:<br><br>\"export default class WeElement extends HTMLElement {..}\"<br> <br>This one, Omi, is from Tencent.</em> \n\u3000\u3000\u3000\u3000\u2014 [Dion Almaer](https://twitter.com/dalmaer/)\n\n## Add Omi in One Minute\n\n```jsx {8-11}\nimport { render, WeElement, define } from 'omi'\n\ndefine('my-counter', class extends WeElement {\n data = {\n count: 1\n }\n\n static css = `\n span{\n color: red;\n }`\n\n sub = () => {\n this.data.count--\n this.update()\n }\n\n add = () => {\n this.data.count++\n this.update()\n }\n\n render() {\n return (\n <div>\n <button onClick={this.sub}>-</button>\n <span>{this.data.count}</span>\n <button onClick={this.add}>+</button>\n </div>\n )\n }\n})\n\nrender(<my-counter />, 'body')\n```\n\nYou can also use `my-counter` tag directly in HTML\uff1a\n\n```jsx\n<body>\n <my-counter></my-counter>\n</body>\n```\n\nLooking at the highlighted part above, you can style the components. For example, the scope of the span above is only within the components, and it does not pollute other components. So far you have successfully started Omi! You learned:\n\n* Add **structure** for components, such as JSX writing structure above\n* Add **behavior** to the component, such as the `onClick` binding event above\n* Add **style** to the component, such as `static css` above\n* Rendering components to body, of course, can also render components to any other component\n\n## Stateless View & Store System\n\n```jsx\nimport { define, render } from 'omi'\n\nclass Store {\n data = {\n count: 1\n }\n sub = () => {\n this.data.count--\n }\n add = () => {\n this.data.count++\n }\n}\n\ndefine('my-counter', _ => (\n <div>\n <button onClick={_.store.sub}>-</button>\n <span>{_.store.data.count}</span>\n <button onClick={_.store.add}>+</button>\n </div>\n), {\n use: ['count'], \n //or using useSelf, useSelf will update self only, exclude children components\n //useSelf: ['count'], \n css: `span { color: red; }`,\n installed() {\n console.log('installed')\n }\n })\n\nrender(<my-counter />, 'body', new Store)\n```\n\nGetting started, Congratulations!"}});
|
||||
//# sourceMappingURL=3.652b6d47.chunk.js.map
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([4],{41:function(n,i){n.exports='## Installation \n\nSimply download and include with `<script>`. Omi will be registered as a global variable.\n\n* [Omi Development Version](https://unpkg.com/omi@latest/dist/omi.js)\n* [Omi Production Version](https://unpkg.com/omi@latest/dist/omi.min.js)\n\nInstall via npm:\n\n```\nnpm i omi\n```\n\nIf you need to be compatible with IE8+, you can choose omio, which has almost the same API as omi, and Omi will be registered as a global variable.\n\n* [Omio Development Version](https://unpkg.com/omio@latest/dist/omi.js)\n* [Omio Production Version](https://unpkg.com/omi@latest/dist/omi.min.js)\n\nInstall via npm:\n\n```\nnpm i omio\n```\n\n## CLI\n\nOmi provides the official CLI. You don\'t need to learn how to configure webpack, Babel or TypeScript. CLI helps you configure everything and provides various templates for different project types.\n\n```bash\n$ npm i omi-cli -g # install cli\n$ omi init my-app # init project\n$ cd my-app \n$ npm start # develop\n$ npm run build # release\n```\n\n> `npx omi-cli init my-app` is also supported(npm v5.2.0+).\n\nDirectory description:\n\n```\n\u251c\u2500 config\n\u251c\u2500 public\n\u251c\u2500 scripts\n\u251c\u2500 src\n\u2502 \u251c\u2500 assets\n\u2502 \u251c\u2500 elements //Store all custom elements\n\u2502 \u251c\u2500 store //Store all this store of pages\n\u2502 \u251c\u2500 admin.js //Entry js of compiler\uff0cwill build to admin.html\n\u2502 \u2514\u2500 index.js //Entry js of compiler\uff0cwill build to index.html\n```\n\n\n### Scripts\n\n```json\n"scripts": {\n "start": "node scripts/start.js",\n "build": "PUBLIC_URL=. node scripts/build.js",\n "build-windows": "set PUBLIC_URL=.&& node scripts/build.js",\n "fix": "eslint src --fix"\n}\n```\n\nYou can set up the PUBLIC_URL, such as\uff1a\n\n```json\n...\n"build": "PUBLIC_URL=https://your.url.com/sub node scripts/build.js",\n"build-windows": "set PUBLIC_URL=https://your.url.com/sub&& node scripts/build.js",\n...\n```\n\n### Switch omi and omio\n\nAdd or remove the alias config in package.json to switch omi and omio\uff1a\n\n```js\n ...\n "alias": {\n "omi": "omio"\n }\n ...\n```\n\n## Project Template\n\n| **Template Type**| **Command**| **Describe**|\n| ------------ | -----------| ----------------- |\n|Base Template(v3.3.0+)|`omi init my-app`| Basic omi or omio(IE8+) project template.|\n|Kbone Template|`omi init-kbone my-app` |Developing mini program or web using omi.|\n|\u5c0f\u7a0b\u5e8f\u6a21\u677f(v3.3.5+)|`omi init-p my-app`| Omi \u5f00\u53d1\u5c0f\u7a0b\u5e8f |\n|Base Template with snapshoot|`omi init-snap my-app`| Basic omi or omio(IE8+) project template with snapshoot prerendering.|\n|TypeScript Template(omi-cli v3.3.0+)|`omi init-ts my-app`|Basic template with typescript.|\n|Mobile Template|`omi init-weui my-app`| Mobile web app template with weui and omi-router.|\n\n'}});
|
||||
//# sourceMappingURL=4.9553b96d.chunk.js.map
|
|
@ -0,0 +1,2 @@
|
|||
webpackJsonp([5],{40:function(n,e){n.exports='## Button \n\nClick or touch it to trigger an operation. The encapsulated logic is triggered in response to user clicks.\n\n<iframe height="350" style="width: 100%;" scrolling="no" title="OMIU Button" src="https://codepen.io/omijs/embed/LYppwYG?height=350&theme-id=dark&default-tab=html,result" frameborder="no" allowtransparency="true" allowfullscreen="true" loading="lazy">\n See the Pen <a href=\'https://codepen.io/omijs/pen/LYppwYG\'>OMIU Button</a> by OMI\n (<a href=\'https://codepen.io/omijs\'>@omijs</a>) on <a href=\'https://codepen.io\'>CodePen</a>.\n</iframe>\n\n## Import\n\n```js\nimport \'omim/button\'\n```\n\nOr use script tag to ref it.\n\n\n## Usage\n\n```html\n<m-button ripple icon="favorite">Default</m-button>\n\n<m-button ripple dense>Dense</m-button>\n\n<m-button ripple svg-icon="{\n path: \'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z\',\n color: \'#0072d9\',\n scale: 1.3\n}">ICON</m-button>\n```\n\n## Usage in Omi\n\nJSX:\n\n```jsx\n<m-button ripple raised icon="favorite">Default</m-button>\n\n<m-button ripple dense raised>Dense</m-button>\n\n<m-button ripple raised svgIcon={{\n path: \'M923 283.6a260.04 260.04 0 0 0-56.9-82.8 264.4 264.4 0 0 0-84-55.5A265.34 265.34 0 0 0 679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 0 0-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z\',\n color: \'white\',\n scale: 1.3\n}}>ICON</m-button>\n```\n\n## API\n\n### Props\n\n| **Name** | **Type** | **Defaults** | **Details** |\n| ------------- |:-------------:|:-----:|:-------------:|\n| ripple | boolean | -- | Click the button to create a ripple |\n| raised | boolean | -- | There\'s padding, there\'s shading |\n| dense | boolean | -- | Smaller buttons |\n| unelevated | boolean | -- | It has padding, no shadows |\n| outlined | boolean | -- | No padding, have border |\n| svg-icon | object | -- | svg icon |\n| icon | string | -- | icon |\n'}});
|
||||
//# sourceMappingURL=5.022786ec.chunk.js.map
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW 2017 -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1024px" height="1024px" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||
viewBox="0 0 1024 1024"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
<![CDATA[
|
||||
.fil0 {fill:none}
|
||||
.fil2 {fill:#171717}
|
||||
.fil1 {fill:#FEFEFE}
|
||||
]]>
|
||||
</style>
|
||||
</defs>
|
||||
<g id="图层_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<rect class="fil0" width="1024" height="1024"/>
|
||||
<rect class="fil0" width="1024" height="1024"/>
|
||||
<g id="_2225049615792">
|
||||
<circle class="fil1" cx="512" cy="512" r="512"/>
|
||||
<polygon class="fil2" points="159.97,807.8 338.71,532.42 509.9,829.62 519.41,829.62 678.85,536.47 864.03,807.8 739.83,194.38 729.2,194.38 517.73,581.23 293.54,194.38 283.33,194.38 "/>
|
||||
<circle class="fil2" cx="839.36" cy="242.47" r="50"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |