feat:use local data

This commit is contained in:
pengfei.zhou 2020-03-03 18:58:53 +08:00 committed by osborn
parent ef77d5ec95
commit 15ce9cb6ba
4 changed files with 1826 additions and 2 deletions

View File

@ -10,6 +10,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@rollup/plugin-json": "^4.0.2",
"doric": "file:../doric-js", "doric": "file:../doric-js",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rollup": "^1.29.0", "rollup": "^1.29.0",

View File

@ -4,6 +4,7 @@ import bundles from './build/index'
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import buble from '@rollup/plugin-buble'; import buble from '@rollup/plugin-buble';
import json from "@rollup/plugin-json"
function readDirs(dirPath, files) { function readDirs(dirPath, files) {
if (fs.statSync(dirPath).isDirectory()) { if (fs.statSync(dirPath).isDirectory()) {
@ -49,6 +50,7 @@ export default
plugins: [ plugins: [
resolve({ mainFields: ["jsnext"] }), resolve({ mainFields: ["jsnext"] }),
commonjs(), commonjs(),
json(),
], ],
external: ['reflect-metadata', 'doric'], external: ['reflect-metadata', 'doric'],
onwarn: function (warning) { onwarn: function (warning) {
@ -70,6 +72,7 @@ export default
plugins: [ plugins: [
resolve({ mainFields: ["jsnext"] }), resolve({ mainFields: ["jsnext"] }),
commonjs(), commonjs(),
json(),
buble({ buble({
transforms: { dangerousForOf: true } transforms: { dangerousForOf: true }
}), }),

View File

@ -1,5 +1,6 @@
import { Group, text, gravity, Color, LayoutSpec, vlayout, hlayout, layoutConfig, scroller, Text, ViewHolder, VMPanel, ViewModel, network, loge, HLayout, stack, image, Gravity, takeNonNull, Scroller, Image } from "doric"; import { Group, text, gravity, Color, LayoutSpec, vlayout, hlayout, layoutConfig, scroller, Text, ViewHolder, VMPanel, ViewModel, network, loge, HLayout, stack, image, Gravity, takeNonNull, Scroller, Image } from "doric";
import { colors } from "./utils"; import { colors } from "./utils";
import MovieData from './movie.json'
interface DoubanModel { interface DoubanModel {
count: number count: number
@ -16,7 +17,7 @@ interface DoubanModel {
"4": number, "4": number,
"5": number, "5": number,
}, },
stars: number stars: string
min: number, min: number,
} }
genres: string[], genres: string[],
@ -204,7 +205,7 @@ class SliderPanel extends VMPanel<MovieModel, MovieVH>{
} }
getState() { getState() {
return { selectedIdx: 0 } return { selectedIdx: 0, doubanModel: MovieData }
} }
} }

1819
doric-demo/src/movie.json Normal file

File diff suppressed because it is too large Load Diff