Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuzhusany committed Jun 3, 2019
2 parents 3c1a5d5 + 31dc09c commit 030b368
Show file tree
Hide file tree
Showing 47 changed files with 494 additions and 192 deletions.
9 changes: 8 additions & 1 deletion blueapps/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.utils.translation import ugettext_lazy as _

from blueapps.account.forms import UserCreationForm
from blueapps.account.models import User
from blueapps.account.models import User, UserProperty


class UserAdmin(admin.ModelAdmin):
Expand All @@ -39,4 +39,11 @@ class UserAdmin(admin.ModelAdmin):
'is_superuser', 'last_login']


class UserPropertyAdmin(admin.ModelAdmin):
list_display = ['user', 'key', 'value']
list_filter = ['user__username']
search_fields = ['user__username', 'key']


admin.site.register(User, UserAdmin)
admin.site.register(UserProperty, UserPropertyAdmin)
1 change: 1 addition & 0 deletions blueapps/conf/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# 蓝鲸静态资源服务
'whitenoise.middleware.WhiteNoiseMiddleware',
# Auth middleware
'blueapps.core.sites.middleware.UserAgentMiddleware',
'blueapps.account.middlewares.RioLoginRequiredMiddleware',
'blueapps.account.middlewares.WeixinLoginRequiredMiddleware',
'blueapps.account.middlewares.LoginRequiredMiddleware',
Expand Down
10 changes: 5 additions & 5 deletions blueapps/core/sites/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
specific language governing permissions and limitations under the License.
"""

from django.conf import settings
from django.http.request import split_domain_port, validate_host
from django.utils.module_loading import import_module
from django.utils.deprecation import MiddlewareMixin

from blueapps.conf import settings


class UserAgentMiddleware(object):
class UserAgentMiddleware(MiddlewareMixin):

def process_request(self, request):
request.is_mobile = lambda: bool(settings.RE_MOBILE.search(
Expand All @@ -32,7 +32,7 @@ def process_request(self, request):
request.META.get('HTTP_USER_AGENT', '')) and not request.is_rio())


class SiteUrlconfMiddleware(object):
class SiteUrlconfMiddleware(MiddlewareMixin):
top_module = 'conf.sites'

def process_request(self, request):
Expand All @@ -55,7 +55,7 @@ def process_request(self, request):
request.urlconf = urlconf


class SiteSettingsMiddleware(object):
class SiteSettingsMiddleware(MiddlewareMixin):
top_module = 'conf.sites'

def _enter(self, module):
Expand Down
2 changes: 2 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
'weixin.core.middlewares.WeixinLoginMiddleware',
)

MIDDLEWARE = ('weixin.core.middlewares.WeixinProxyPatchMiddleware',) + MIDDLEWARE

# 所有环境的日志级别可以在这里配置
LOG_LEVEL = 'INFO'

Expand Down
32 changes: 29 additions & 3 deletions frontend/mobile/build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,38 @@ import path from 'path'
import prodEnv from './prod.env'
import devEnv from './dev.env'

/**
* 生产环境分版本打包命令
* npm run build -- --SITE_URL="/o/bk_sops" --STATIC_ENV="open/prod"
*/
let SITE_URL = ''
let STATIC_ENV = ''

process.argv.forEach(val => {
if (/--SITE_URL=/.test(val)) {
SITE_URL = val.replace(/--SITE_URL=/, '')
}
if (/--STATIC_ENV=/.test(val)) {
STATIC_ENV = val.replace(/--STATIC_ENV=/, '')
}
})

process.env.STATIC_ENV = STATIC_ENV

// const publicPath = path.posix.join(SITE_URL, '/static/')

console.log('build mode:', process.env.NODE_ENV)
console.log('SITE_URL:', SITE_URL)
console.log('publicPath:', STATIC_ENV)

const prodPubPath = SITE_URL + '/static/weixin/' + (STATIC_ENV ? STATIC_ENV + '/' : '')

export default {
build: {
env: prodEnv,
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
assetsRoot: path.resolve(__dirname, '../dist', STATIC_ENV),
assetsSubDirectory: 'dist',
assetsPublicPath: prodPubPath,
productionSourceMap: true,
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
Expand Down
6 changes: 5 additions & 1 deletion frontend/mobile/build/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import os from 'os'
import path from 'path'

import config from './config'

const isProd = process.env.NODE_ENV === 'production'

export function resolve (dir) {
return path.join(__dirname, '..', dir)
}

export function assetsPath (_path) {
const assetsSubDirectory = 'static'
const assetsSubDirectory = isProd ? config.build.assetsSubDirectory : config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}

Expand Down
14 changes: 3 additions & 11 deletions frontend/mobile/build/webpack.base.conf.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
import webpack from 'webpack'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import {VueLoaderPlugin} from 'vue-loader'
import friendlyFormatter from 'eslint-friendly-formatter'

Expand Down Expand Up @@ -103,7 +102,7 @@ export default {
loader: 'url-loader',
options: {
limit: 10000,
name: assetsPath('images/[name].[hash:7].[ext]')
name: assetsPath('images/[name].[ext]')
}
},
{
Expand All @@ -112,7 +111,7 @@ export default {
loader: 'url-loader',
options: {
limit: 10000,
name: assetsPath('media/[name].[hash:7].[ext]')
name: assetsPath('media/[name].[ext]')
}
}
},
Expand All @@ -122,7 +121,7 @@ export default {
loader: 'url-loader',
options: {
limit: 10000,
name: assetsPath('fonts/[name].[hash:7].[ext]')
name: assetsPath('fonts/[name].[ext]')
}
}
}
Expand All @@ -132,13 +131,6 @@ export default {
new VueLoaderPlugin(),
// moment 优化,只提取本地包
new webpack.ContextReplacementPlugin(/moment\/locale$/, /zh-cn/),
new CopyWebpackPlugin([
{
from: resolve('static/images'),
to: resolve('dist/static/images'),
toType: 'dir'
}
]),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
Expand Down
13 changes: 12 additions & 1 deletion frontend/mobile/build/webpack.dev.conf.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import path from 'path'

import webpack from 'webpack'
import merge from 'webpack-merge'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin'

import config from './config'
import baseConf from './webpack.base.conf.babel'
import manifest from '../static/lib-manifest.json'

import { resolve } from './util'


// const HOST = 'localhost'
// const PORT = 8080

Expand Down Expand Up @@ -69,7 +73,14 @@ const webpackConfig = merge(baseConf, {
staticUrl: config.dev.env.staticUrl
}),

new FriendlyErrorsPlugin()
new FriendlyErrorsPlugin(),
new CopyWebpackPlugin([
{
from: resolve('static/images'),
to: resolve('dist/static/images'),
toType: 'dir'
}
]),
]
})

Expand Down
25 changes: 16 additions & 9 deletions frontend/mobile/build/webpack.prod.conf.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import OptimizeCSSPlugin from 'optimize-css-assets-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import CopyWebpackPlugin from 'copy-webpack-plugin'
import bundleAnalyzer from 'webpack-bundle-analyzer'
import { CleanWebpackPlugin } from 'clean-webpack-plugin'

import config from './config'
import {assetsPath} from './util'
Expand All @@ -26,8 +27,8 @@ const prodConf = merge(baseConf, {
main: './src/main.js'
},
output: {
filename: assetsPath('js/[name].[chunkhash].js'),
chunkFilename: assetsPath('js/[name].[chunkhash].js')
filename: assetsPath('js/[name].js'),
chunkFilename: assetsPath('js/[name].js')
},
optimization: {
minimizer: [
Expand Down Expand Up @@ -115,30 +116,37 @@ const prodConf = merge(baseConf, {
module: {
rules: [
{
test: /\.css?$/,
test: /\.s?[ac]ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1
exportOnlyLocals: false
}
},
},
{
loader: 'postcss-loader',
options: {
config: {
path: resolve(__dirname, '..', 'postcss.config.js')
}
}
}
},
'sass-loader'
]
}
},
]
},
plugins: [
new webpack.DefinePlugin(config.build.env),

new CleanWebpackPlugin({
root: process.cwd(),
verbose: true,
dry: false
}),

new webpack.DllReferencePlugin({
context: __dirname,
manifest: manifest
Expand All @@ -162,9 +170,8 @@ const prodConf = merge(baseConf, {
}),

new MiniCssExtractPlugin({
filename: assetsPath('css/[name].[contenthash].css')
filename: assetsPath('css/[name].css')
}),

new CopyWebpackPlugin([
{
from: resolve(__dirname, '../static'),
Expand Down
3 changes: 2 additions & 1 deletion frontend/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}
},
"build": {
"command": "npm run clean && npm run clean-dll && npm run dll && babel-node build/build.js",
"command": "npm run clean-dll && npm run dll && babel-node build/build.js",
"env": {
"NODE_ENV": "production"
}
Expand Down Expand Up @@ -82,6 +82,7 @@
"better-npm-run": "^0.1.1",
"body-parser": "^1.18.3",
"chalk": "^2.4.2",
"clean-webpack-plugin": "^3.0.0",
"connect-history-api-fallback": "^1.6.0",
"copy-webpack-plugin": "^4.6.0",
"cross-env": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
plugins: {
// 把 import 的内容转换为 inline
// @see https://github.com/postcss/postcss-import#postcss-import
'postcss-import': {},
// 'postcss-import': {},

// mixins,本插件需要放在 postcss-simple-vars 和 postcss-nested 插件前面
// @see https://github.com/postcss/postcss-mixins#postcss-mixins-
Expand Down
3 changes: 2 additions & 1 deletion frontend/mobile/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
}
</script>

<style>
<style lang="scss">
@import '../static/style/app.scss';
.app-container {
font-family: 'PingFang SC', Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}
</script>
<style lang="scss" scoped>
@import '../../../static/style/app.scss';
@import '../../../static/style/var.scss';
.bk-flow-location {
width: 152px;
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/src/components/MobileStatusIcon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</script>

<style lang="scss">
@import '../../../static/style/app.scss';
@import '../../../static/style/var.scss';
.bk-block .status{
.task-icon{
Expand Down
4 changes: 0 additions & 4 deletions frontend/mobile/src/components/NoData/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@
}
}
</script>

<style lang="scss">
@import '../../../static/style/app.scss';
</style>
4 changes: 0 additions & 4 deletions frontend/mobile/src/components/VantForm/VantTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@
}
}
</script>

<style lang="scss">
@import '../../../static/style/app.scss';
</style>
2 changes: 1 addition & 1 deletion frontend/mobile/src/components/navbar/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</script>

<style lang="scss">
@import '../../../static/style/app.scss';
@import '../../../static/style/var.scss';
/*navbar*/
.navbar{
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ global.$ = $
global.$.atoms = {}
global.bus = bus
global.getMobileUrlPrefix = (bizId) => {
const ajaxUrlPrefix = `${AJAX_URL_PREFIX}${global.SITE_URL || ''}`
const ajaxUrlPrefix = `${global.SITE_URL || '/'}`
return getMobileUrlSetting(ajaxUrlPrefix, bizId)
}

Expand Down
Loading

0 comments on commit 030b368

Please sign in to comment.