Skip to content

Commit

Permalink
升级
Browse files Browse the repository at this point in the history
  • Loading branch information
aiplat committed Jul 17, 2020
1 parent 33bd676 commit 76cdf1f
Show file tree
Hide file tree
Showing 23 changed files with 5,788 additions and 3,454 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ test/
.vs/
.vscode/
nbproject/
unpackage/dist
/src/envType.ts
/src/builds
/src/manifest.json
/src/mpConf.ts
/src/pages.json
.DS_Store
unpackage/

# local env files
.env.local
Expand Down
29 changes: 19 additions & 10 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
const plugins = [];
const plugins = []

if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
}

if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) {
const path = require('path');
if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
) {
const path = require('path')

const isWin = /^win/.test(process.platform);
const isWin = /^win/.test(process.platform)

const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path);
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)

const input = normalizePath(process.env.UNI_INPUT_DIR);
const input = normalizePath(process.env.UNI_INPUT_DIR)
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file);
file = normalizePath(file)
if (file.indexOf(input) === 0) {
return path.relative(input, file)
}
Expand All @@ -28,7 +37,7 @@ if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) {
} catch (e) {}
}

process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'];
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
Expand All @@ -39,7 +48,7 @@ process.UNI_LIBRARIES.forEach(libraryName => {
}
}
])
});
})
module.exports = {
presets: [
[
Expand All @@ -51,4 +60,4 @@ module.exports = {
]
],
plugins
};
}
15 changes: 6 additions & 9 deletions build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const shell = require('shelljs');
function addEnvType(envType) {
let txt = `const a:string = '${envType}';`;
txt += `export default a;`;
const b = 'src/envType.ts';
const b = 'src/builds/envType.ts';
fs.writeFile(b, txt.toString(), (err) => {
if (err) {
console.error(err);
Expand All @@ -18,11 +18,7 @@ function addEnvType(envType) {
}

function isIn(v, k, v2) {
if (v.indexOf(k) > -1) {
v = `${v.split(k)[1]}`;
} else {
v = v2;
}
v = v.includes(k) ? `${v.split(k)[1]}` : v2;
return v;
}

Expand All @@ -37,6 +33,7 @@ async function configArgv() {
'app-plus': 'APP',
'h5': 'H5',
'custom': 'custom',
'mp-360': '360小程序',
'mp-alipay': '支付宝小程序',
'mp-baidu': '百度小程序',
'mp-qq': 'QQ小程序',
Expand All @@ -56,8 +53,8 @@ async function configArgv() {
ver: 'VER',
pro: '生产',
};
const buildDir = buildType.indexOf('build') > -1 ? 'build' : 'dev';
const isDevTxt = buildType.indexOf('build') > -1 ? '构建' : '开发';
const buildDir = buildType.includes('build') ? 'build' : 'dev';
const isDevTxt = buildType.includes('build') ? '构建' : '开发';
console.log('');
let platName = buildType.split(':');
if (platName && platName.length > 1) {
Expand All @@ -73,7 +70,7 @@ async function configArgv() {
const a = `./src/projects/${project}/mpConf.ts`;
const b = `./src/projects/${project}/pages.json`;
const c = `./src/projects/${project}/${envType}/manifest.json`;
shell.cp('-R', a, './src/mpConf.ts');
shell.cp('-R', a, './src/builds/mpConf.ts');
shell.cp('-R', b, './src/pages.json');
shell.cp('-R', c, './src/manifest.json');
console.log('');
Expand Down
72 changes: 43 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "aiplat.com-miniprogram",
"version": "1.1.1",
"version": "2.0.0",
"private": true,
"scripts": {
"build": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
"build:app-plus": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:custom": "node build.config.js && cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:mp-360": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
"build:mp-alipay": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
"build:mp-baidu": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
"build:mp-qq": "node build.config.js && cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
Expand All @@ -16,6 +17,7 @@
"dev:app-plus": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "node build.config.js && cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
"dev:mp-360": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
"dev:mp-alipay": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
"dev:mp-baidu": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
"dev:mp-qq": "node build.config.js && cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
Expand All @@ -24,44 +26,56 @@
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js"
},
"dependencies": {
"@dcloudio/uni-app-plus": "^2.0.0-24220191115006",
"@dcloudio/uni-h5": "^2.0.0-24220191115006",
"@dcloudio/uni-app-plus": "^2.0.0-27920200618002",
"@dcloudio/uni-h5": "^2.0.0-27920200618002",
"@dcloudio/uni-helper-json": "*",
"@dcloudio/uni-mp-alipay": "^2.0.0-24220191115006",
"@dcloudio/uni-mp-baidu": "^2.0.0-24220191115006",
"@dcloudio/uni-mp-qq": "^2.0.0-24220191115006",
"@dcloudio/uni-mp-toutiao": "^2.0.0-24220191115006",
"@dcloudio/uni-mp-weixin": "^2.0.0-24220191115006",
"@dcloudio/uni-stat": "^2.0.0-24220191115006",
"flyio": "^0.6.2",
"@dcloudio/uni-mp-360": "^2.0.0-27920200618002",
"@dcloudio/uni-mp-alipay": "^2.0.0-27920200618002",
"@dcloudio/uni-mp-baidu": "^2.0.0-27920200618002",
"@dcloudio/uni-mp-qq": "^2.0.0-27920200618002",
"@dcloudio/uni-mp-toutiao": "^2.0.0-27920200618002",
"@dcloudio/uni-mp-weixin": "^2.0.0-27920200618002",
"@dcloudio/uni-quickapp-native": "^2.0.0-27920200618002",
"@dcloudio/uni-quickapp-webview": "^2.0.0-27920200618002",
"@dcloudio/uni-stat": "^2.0.0-27920200618002",
"core-js": "^3.6.5",
"html2canvas": "^1.0.0-rc.5",
"regenerator-runtime": "^0.12.1",
"vue": "^2.6.10",
"vue": "^2.6.11",
"vue-class-component": "^6.3.2",
"vue-property-decorator": "^8.0.0",
"vuex": "^3.1.2"
"vuex": "^3.2.0",
"weixin-js-sdk": "^1.6.0"
},
"devDependencies": {
"@babel/plugin-syntax-typescript": "^7.7.4",
"@babel/plugin-syntax-typescript": "^7.2.0",
"@dcloudio/types": "*",
"@dcloudio/uni-cli-shared": "^2.0.0-24220191115006",
"@dcloudio/uni-migration": "^2.0.0-25120200103006",
"@dcloudio/uni-template-compiler": "^2.0.0-24220191115006",
"@dcloudio/vue-cli-plugin-hbuilderx": "latest",
"@dcloudio/vue-cli-plugin-uni": "latest",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-24220191115006",
"@dcloudio/webpack-uni-mp-loader": "^2.0.0-24220191115006",
"@dcloudio/webpack-uni-pages-loader": "^2.0.0-24220191115006",
"@vue/cli-plugin-babel": "3.5.1",
"@vue/cli-plugin-typescript": "^3.5.1",
"@vue/cli-service": "^4.1.1",
"babel-plugin-import": "^1.13.0",
"@dcloudio/uni-automator": "^2.0.0-27920200618002",
"@dcloudio/uni-cli-shared": "^2.0.0-27920200618002",
"@dcloudio/uni-migration": "^2.0.0-27920200618002",
"@dcloudio/uni-template-compiler": "^2.0.0-27920200618002",
"@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.0-27920200618002",
"@dcloudio/vue-cli-plugin-uni": "^2.0.0-27920200618002",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.0-27920200618002",
"@dcloudio/webpack-uni-mp-loader": "^2.0.0-27920200618002",
"@dcloudio/webpack-uni-pages-loader": "^2.0.0-27920200618002",
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-typescript": "*",
"@vue/cli-service": "~4.4.0",
"babel-plugin-import": "^1.11.0",
"compression-webpack-plugin": "^3.1.0",
"cross-env": "^7.0.2",
"crypto-js": "^3.1.9-1",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"jest": "^25.4.0",
"less": "^3.12.2",
"less-loader": "^6.2.0",
"mini-types": "*",
"miniprogram-api-typings": "*",
"postcss-comment": "^2.0.0",
"qrcode": "^1.4.4",
"shelljs": "^0.8.3",
"typescript": "^3.7.3",
"vue-template-compiler": "^2.6.10"
"typescript": "^3.0.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"Android >= 4",
Expand Down
16 changes: 14 additions & 2 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
const path = require('path')
module.exports = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import'),
require('postcss-import')({
resolve (id) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
} else if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
} else if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
}
return id
}
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
};
}
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
mpType: 'app',
async onLaunch() {
console.log('App Launch');
const t = this;
const $vue:any = this;
// #ifdef MP-WEIXIN
await t.$cmapp.update();
await t.$cmapp.notFound(t);
await $vue.$cmapp.update();
await $vue.$cmapp.notFound($vue);
// #endif
},
async onShow() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/crypto.d.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/lib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare module 'crypto-js/hmac-sha256';
// #ifdef H5
declare module 'weixin-js-sdk';
declare var window: Window & typeof globalThis;
declare module 'qrcode';
// #endif
declare var plus; // h5+
declare var uni; // uni
declare var getCurrentPages; // uni
declare var require; // nodejs
17 changes: 7 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import Vue from 'vue';
import App from './App.vue';
import App from '@/App.vue';
import store from '@/vuex/store';

import store from './vuex/store';
import api from './service/api';
import conf from './service/conf';
import Cmapp from './plugins/cmapp.class';
import uniAjax from './plugins/uniAjax';
import api from '@/service/api';
import conf from '@/service/conf';
import cmappClass from '@/plugins/cmapp.class';
import uniAjax from '@/plugins/uniAjax';

Vue.config.productionTip = false;

// @ts-ignore
const cmapp = new Cmapp();

Vue.prototype.$store = store;
Vue.prototype.$api = api;
Vue.prototype.$conf = conf;
Vue.prototype.$cmapp = cmapp;
Vue.prototype.$cmapp = new cmappClass();
Vue.prototype.$uniAjax = uniAjax;

new App().$mount();
3 changes: 1 addition & 2 deletions src/pages/aiplat/apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@
},
methods: {
toWin(item:any, type = '') {
const t:any = this;
t.$cmapp.toWin(item.url, type);
this.$cmapp.toWin(item.url, type);
},
},
onShareAppMessage() {
Expand Down
17 changes: 5 additions & 12 deletions src/plugins.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import Vue from 'vue';
import api from './service/api';
import conf from './service/conf';
import Cmapp from './plugins/cmapp.class';
import uniAjax from './plugins/uniAjax';

// @ts-ignore
const cmapp = new Cmapp();
import api from '@/service/api';
import conf from '@/service/conf';
import cmappClass from '@/plugins/cmapp.class';
import uniAjax from '@/plugins/uniAjax';

declare module 'vue/types/vue' {
interface Vue {
// @ts-ignore
$api: api,
// @ts-ignore
$conf: conf,
// @ts-ignore
$cmapp: cmapp,
// @ts-ignore
$cmapp: new cmappClass(),
$uniAjax: uniAjax,
}
}
Loading

0 comments on commit 76cdf1f

Please sign in to comment.