Commit b63a4299 by lirandong

改 less 为 sass

parent 31d03871
module.exports = { module.exports = {
extends: 'stylelint-config-standard', extends: 'stylelint-config-standard',
// 使用的插件 // 使用的插件
// plugins: ['stylelint-less'], plugins: ['stylelint-scss'],
// 需要忽略的文件类型 // 需要忽略的文件类型
ignoreFiles: ['node_modules/**/*', '**/*.md', '**/*.ts', '**/*.tsx', '**/*.js'], ignoreFiles: ['node_modules/**/*.scss', '**/*.md', '**/*.ts', '**/*.tsx', '**/*.js'],
rules: { rules: {
indentation: 2, indentation: 2,
'no-empty-source': null,
'at-rule-no-unknown': null, 'at-rule-no-unknown': null,
'scss/at-rule-no-unknown': true,
'no-descending-specificity': null, 'no-descending-specificity': null,
'selector-type-no-unknown': null 'selector-type-no-unknown': null
} }
......
const path = require('path') const path = require('path')
// NOTE 在 sass 中通过别名(@ 或 ~)引用需要指定路径 // NOTE 在 sass 中通过别名(@ 或 ~)引用需要指定路径
const lessImporter = function (url) { const sassImporter = function (url) {
if (url[0] === '~' && url[1] !== '/') { if (url[0] === '~' && url[1] !== '/') {
return { return {
file: path.resolve(__dirname, '..', 'node_modules', url.substr(1)) file: path.resolve(__dirname, '..', 'node_modules', url.substr(1))
...@@ -10,7 +10,7 @@ const lessImporter = function (url) { ...@@ -10,7 +10,7 @@ const lessImporter = function (url) {
const reg = /^@styles\/(.*)/ const reg = /^@styles\/(.*)/
return { return {
file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url file: reg.test(url) ? path.resolve(__dirname, '..', 'src/constants/styles', url.match(reg)[1]) : url
} }
} }
...@@ -32,6 +32,7 @@ const config = { ...@@ -32,6 +32,7 @@ const config = {
'@/actions': path.resolve(__dirname, '..', 'src/actions'), '@/actions': path.resolve(__dirname, '..', 'src/actions'),
'@/constants': path.resolve(__dirname, '..', 'src/constants'), '@/constants': path.resolve(__dirname, '..', 'src/constants'),
'@/conpoments': path.resolve(__dirname, '..', 'src/conpoments'), '@/conpoments': path.resolve(__dirname, '..', 'src/conpoments'),
'@styles': path.resolve(__dirname, '..', 'src/constants/styles'),
}, },
plugins: { plugins: {
babel: { babel: {
...@@ -47,8 +48,8 @@ const config = { ...@@ -47,8 +48,8 @@ const config = {
'transform-object-rest-spread' 'transform-object-rest-spread'
] ]
}, },
less: { sass: {
importer: lessImporter importer: sassImporter
} }
}, },
defineConstants: { defineConstants: {
...@@ -117,8 +118,8 @@ const config = { ...@@ -117,8 +118,8 @@ const config = {
} }
} }
}, },
lessLoaderOption: { sassLoaderOption: {
importer: lessImporter importer: sassImporter
} }
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"templateInfo": { "templateInfo": {
"name": "redux", "name": "redux",
"typescript": true, "typescript": true,
"css": "less" "css": "sass"
}, },
"scripts": { "scripts": {
"build:weapp": "taro build --type weapp", "build:weapp": "taro build --type weapp",
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"dev:tt": "npm run build:tt -- --watch", "dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch", "dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch", "dev:rn": "npm run build:rn -- --watch",
"lint": "tslint --project ./tsconfig.json && stylelint \"./src/**/*.less\"", "lint": "tslint --project ./tsconfig.json && stylelint \"./src/**/*.scss\"",
"precommit": "npm run lint", "precommit": "npm run lint",
"run:shell": "cd ../taro-native-shell/ && yarn android" "run:shell": "cd ../taro-native-shell/ && yarn android"
}, },
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"devDependencies": { "devDependencies": {
"@tarojs/plugin-babel": "1.3.12", "@tarojs/plugin-babel": "1.3.12",
"@tarojs/plugin-csso": "1.3.12", "@tarojs/plugin-csso": "1.3.12",
"@tarojs/plugin-less": "1.3.12", "@tarojs/plugin-sass": "1.3.12",
"@tarojs/plugin-uglifyjs": "1.3.12", "@tarojs/plugin-uglifyjs": "1.3.12",
"@tarojs/webpack-runner": "1.3.12", "@tarojs/webpack-runner": "1.3.12",
"@types/react": "^16.4.8", "@types/react": "^16.4.8",
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
"stylelint": "^10.1.0", "stylelint": "^10.1.0",
"stylelint-config-standard": "^18.3.0", "stylelint-config-standard": "^18.3.0",
"stylelint-config-taro-rn": "1.3.12", "stylelint-config-taro-rn": "1.3.12",
"stylelint-scss": "^3.9.3",
"stylelint-taro-rn": "1.3.12", "stylelint-taro-rn": "1.3.12",
"tslint": "^5.17.0", "tslint": "^5.17.0",
"tslint-react": "^4.0.0", "tslint-react": "^4.0.0",
......
...@@ -6,9 +6,15 @@ class UsersApi extends ApiClient { ...@@ -6,9 +6,15 @@ class UsersApi extends ApiClient {
return this.request({ method: 'POST', url: `/template/get/list`, data: { p: page, c: 10 } }) return this.request({ method: 'POST', url: `/template/get/list`, data: { p: page, c: 10 } })
} }
getTempDetail(id: string, page: number) { /** 获取 模板详情 我的视频列表 */
getTempDetailFilmList(id: string, page: number) {
return this.request({ method: 'GET', url: `/template/get/film/list/${id}?p=${page}&c=10` }) return this.request({ method: 'GET', url: `/template/get/film/list/${id}?p=${page}&c=10` })
} }
/** 获取模板详情信息 */
getTempDetailData(id: string) {
return this.request({ method: 'GET', url: `/template/get/info/${id}` })
}
} }
export default new UsersApi() export default new UsersApi()
...@@ -7,7 +7,7 @@ import Index from './pages/index' ...@@ -7,7 +7,7 @@ import Index from './pages/index'
import configStore from './store' import configStore from './store'
import token from './constants/token' import token from './constants/token'
import './app.less' import './app.scss'
// 如果需要在 h5 环境中开启 React Devtools // 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释: // 取消以下注释:
......
.modal {
color: white;
}
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './modal.less'
type PageStateProps = {}
type PageDispatchProps = {}
type PageOwnProps = {}
type PageState = {}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
interface Modal {
props: IProps
state: PageState
}
class Modal extends Component {
render() {
return (
<View className="modal">
<Text>hello world</Text>
</View>
)
}
}
export default Modal as ComponentClass<PageOwnProps, PageState>
...@@ -3,7 +3,7 @@ import { View } from '@tarojs/components' ...@@ -3,7 +3,7 @@ import { View } from '@tarojs/components'
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { getStatusBarHeight } from '../utils' import { getStatusBarHeight } from '../utils'
import './less/pageView.less' import './scss/pageView.scss'
type PageStateProps = {} type PageStateProps = {}
......
@bdColor: #d9d9d9; $bdColor: #f7f7f7;
@input-color: #323233; $text-color: #323233;
$input-color: #323233;
$primary-color: #1989fa;
.border-bottom { @mixin border-bottom {
border-style: solid; border-style: solid;
border-bottom-width: 1px; border-bottom-width: 1px;
border-bottom-color: #ccc; border-bottom-color: #ccc;
......
...@@ -4,7 +4,7 @@ import Taro, { Component, Config } from '@tarojs/taro' ...@@ -4,7 +4,7 @@ import Taro, { Component, Config } from '@tarojs/taro'
// import pagesTempaltes from './tempaltes' // import pagesTempaltes from './tempaltes'
// import pagesDevice from './device' // import pagesDevice from './device'
// import pagesUser from './user' // import pagesUser from './user'
import './index.less' import './index.scss'
import { View, Text } from '@tarojs/components' import { View, Text } from '@tarojs/components'
/** RN 的 tabar */ /** RN 的 tabar */
......
import api from '@/api/index'
import { ITempItem } from '.'
import { ComponentClass } from 'react' import { ComponentClass } from 'react'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text, Swiper, Image, ScrollView, Button } from '@tarojs/components'
import './less/detail.less'
import api from '../../../api' import './scss/detail.scss'
import { ITempItem } from '.'
type PageOwnProps = {} type PageOwnProps = {}
export interface IDetailData {
frameId: string
frameUrl: string
resourceId: string
resourceUrl: string
templateDescribe: string
templateId: string
templateName: string
templateUrl: string
}
type PageState = { type PageState = {
page: 1 page: number
count: number
detailData: any
templateId: string
filmDataList: any[]
} }
interface TempDetail { interface TempDetail {
...@@ -22,21 +38,63 @@ class TempDetail extends Component { ...@@ -22,21 +38,63 @@ class TempDetail extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
page: 1 page: 1,
count: 0,
detailData: {},
filmDataList: [],
templateId: this.$router.params.templateId
} }
} }
async componentWillMount() { async componentWillMount() {
const { templateId } = this.props const { templateId } = this.state
const res = await api.common.getTempDetail(templateId, 1) try {
console.log({ res }) const [detailData, filmData] = await Promise.all([
api.common.getTempDetailData(templateId),
api.common.getTempDetailFilmList(templateId, 1)
])
const { list, count } = filmData
this.setState({
count,
filmDataList: list,
detailData: detailData
})
} catch (error) {
console.error(error)
}
}
createFilm = () => {
}
shouldComponentUpdate(_nextProps: ITempItem, _nextState: PageState) {
const { detailData, filmDataList } = this.state
const { detailData: _detailData, filmDataList: _filmDataList } = _nextState
return _filmDataList !== filmDataList || _detailData !== detailData
} }
render() { render() {
// console.log(window) const { detailData, filmDataList } = this.state
const { templateUrl, templateName, templateDescribe } = detailData
return ( return (
<View className="TempDetail"> <View className="temp-detail">
<Text>hello world</Text> <ScrollView scrollY className="scroll-view">
<View className="temp-top-info">
<Image className="temp-top-img" src={templateUrl} />
<View className="temp-top-text-wrapper">
<Text className="temp-top-title">{templateName}</Text>
<View>
<Text className="temp-top-describe">{templateDescribe}</Text>
</View>
</View>
</View>
<View className="temp-top-info-bar" />
<View className="film-list-warpper">
<Text>我的视片({filmDataList.length})</Text>
</View>
</ScrollView>
<Button type="primary" className="bottom-btn" onClick={this.createFilm} >创建视片</Button>
</View> </View>
) )
} }
......
...@@ -3,7 +3,7 @@ import TempItem from './temp_item' ...@@ -3,7 +3,7 @@ import TempItem from './temp_item'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import PageView from '@/constants/components/pageView' import PageView from '@/constants/components/pageView'
import { View, Text, Input, ScrollView, Image } from '@tarojs/components' import { View, Text, Input, ScrollView, Image } from '@tarojs/components'
import './less/index.less' import './scss/index.scss'
import api from '@/api/index' import api from '@/api/index'
import token from '@/constants/token' import token from '@/constants/token'
......
@import '@styles/var.scss';
.temp-detail {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
background-color: white;
}
.scroll-view {
flex: 1;
}
.temp-top-img {
width: 100%;
// height: auto;
}
.temp-top-info-bar {
height: 20px;
background-color: $bdColor;
}
.temp-top-text-wrapper {
padding-left: 20px;
padding-bottom: 20px;
}
.temp-top-title {
font-size: 28px;
color: $text-color;
}
.temp-top-describe {
color: #ccc;
font-size: 26px;
}
.film-list-warpper {
padding-top: 20px;
padding-left: 20px;
padding-right: 20px;
}
.bottom-btn {
width: 100%;
font-size: 28px;
border-radius: 0;
background-color: $primary-color;
}
import { ComponentClass } from 'react' import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import './less/temp_item.less' import './scss/temp_item.scss'
import { ITempItem } from '.' import { ITempItem } from '.'
type IProps = ITempItem type IProps = ITempItem
...@@ -17,7 +17,7 @@ interface TempItem { ...@@ -17,7 +17,7 @@ interface TempItem {
class TempItem extends Component { class TempItem extends Component {
goDetail = () => { goDetail = () => {
const templateId = this.props const { templateId } = this.props
Taro.navigateTo({ url: `/pages/home/tempaltes/detail?templateId=${templateId}` }) Taro.navigateTo({ url: `/pages/home/tempaltes/detail?templateId=${templateId}` })
} }
......
...@@ -8,7 +8,7 @@ import { checkPhone, showErrorToast } from '../../constants/utils' ...@@ -8,7 +8,7 @@ import { checkPhone, showErrorToast } from '../../constants/utils'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, Input, Button, Checkbox, Label } from '@tarojs/components' import { View, Text, Input, Button, Checkbox, Label } from '@tarojs/components'
import './login.less' import './login.scss'
type PageStateProps = { type PageStateProps = {
counter: { counter: {
......
@import '../../constants/less/var.less'; @import '@styles/var.scss';
.login { .login {
width: 100%; width: 100%;
...@@ -22,16 +22,16 @@ ...@@ -22,16 +22,16 @@
} }
.user-phone { .user-phone {
.border-bottom; @include border-bottom;
} }
.user-phone-input { .user-phone-input {
flex: 1; flex: 1;
color: @input-color; color: $input-color;
} }
.check-code { .check-code {
.border-bottom; @include border-bottom;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
......
declare module "*.png"; declare module '*.png'
declare module "*.gif"; declare module '*.gif'
declare module "*.jpg"; declare module '*.jpg'
declare module "*.jpeg"; declare module '*.jpeg'
declare module "*.svg"; declare module '*.svg'
declare module "*.css"; declare module '*.css'
declare module "*.less"; declare module '*.less'
declare module "*.scss"; declare module '*.scss'
declare module "*.sass"; declare module '*.sass'
declare module "*.styl"; declare module '*.styl'
// @ts-ignore // @ts-ignore
declare const process: { declare const process: {
env: { env: {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt'; TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt'
[key: string]: any; [key: string]: any
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment