1 Star 0 Fork 50

ffcoder/一个uniapp的小说阅读app

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.js 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
哈哈哈 提交于 2022-03-01 21:50 . add backed
import Vue from 'vue';
import App from './App';
Vue.config.productionTip = false;
Vue.prototype.apidomain = 'http://bappdemo.wonyes.org';
// #ifndef APP-PLUS
var plus = {
storage: {
setItem: uni.setStorageSync,
removeItem: uni.removeStorageSync,
getItem: uni.getStorageSync
},
navigator: {
setFullscreen: function() {}
}
};
// #endif
// 引入全局uView
import uView from 'uview-ui';
Vue.use(uView);
// 此处为演示vuex使用,非uView的功能部分
import store from '@/store';
// 引入uView提供的对vuex的简写法文件
let vuexStore = require('@/store/$u.mixin.js');
Vue.mixin(vuexStore);
Vue.mixin({
methods: {
setData: function(obj, callback) {
let that = this;
const handleData = (tepData, tepKey, afterKey) => {
tepKey = tepKey.split('.');
tepKey.forEach(item => {
if (tepData[item] === null || tepData[item] === undefined) {
let reg = /^[0-9]+$/;
tepData[item] = reg.test(afterKey) ? [] : {};
tepData = tepData[item];
} else {
tepData = tepData[item];
}
});
return tepData;
};
const isFn = function(value) {
return typeof value == 'function' || false;
};
Object.keys(obj).forEach(function(key) {
let val = obj[key];
key = key.replace(/\]/g, '').replace(/\[/g, '.');
let front, after;
let index_after = key.lastIndexOf('.');
if (index_after != -1) {
after = key.slice(index_after + 1);
front = handleData(that, key.slice(0, index_after), after);
} else {
after = key;
front = that;
}
if (front.$data && front.$data[after] === undefined) {
Object.defineProperty(front, after, {
get() {
return front.$data[after];
},
set(newValue) {
front.$data[after] = newValue;
that.$forceUpdate();
},
enumerable: true,
configurable: true
});
front[after] = val;
} else {
that.$set(front, after, val);
}
});
isFn(callback) && this.$nextTick(callback);
}
}
});
App.mpType = 'app';
const app = new Vue({
store,
...App
});
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js';
Vue.use(httpInterceptor, app);
// http接口API抽离,免于写url或者一些固定的参数
import httpApi from '@/common/http.api.js';
Vue.use(httpApi, app);
app.$mount();
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ffcoder/novelappofuniapp.git
[email protected]:ffcoder/novelappofuniapp.git
ffcoder
novelappofuniapp
一个uniapp的小说阅读app
master

搜索帮助