diff --git a/build/miniprogram.config.js b/build/miniprogram.config.js index 9eff0d5..02e8e5c 100644 --- a/build/miniprogram.config.js +++ b/build/miniprogram.config.js @@ -3,7 +3,7 @@ */ module.exports = { - origin: 'https://mina.baobeihuijia.com', + origin: 'https://studygolang.com', entry: '/', router: { home: [ @@ -19,6 +19,15 @@ module.exports = { '/list/:id', '/detail/:id', ], + doc: [ + '/doc/index', + ], + docDetail: [ + '/doc/detail/:id', + ], + article: [ + '/article/:id', + ], }, redirect: { notFound: 'home', @@ -27,14 +36,19 @@ module.exports = { generate: { autoBuildNpm: 'npm', tabBar: { - color: '#333', - selectedColor: '#EF4431', + color: '#7F8389', + selectedColor: '#59BF74', backgroundColor: '#ffffff', list: [{ pageName: 'home', text: '主页', iconPath: './imgs/tabs/home.png', selectedIconPath: './imgs/tabs/home_selected.png' + }, { + pageName: 'doc', + text: '文档', + iconPath: './imgs/tabs/doc.png', + selectedIconPath: './imgs/tabs/doc_selected.png' }, { pageName: 'me', text: '我的', @@ -49,9 +63,9 @@ module.exports = { navigationBarTitleText: 'Go 中文网', navigationBarTextStyle: 'black' }, - appExtraConfig: { + appExtraConfig: { sitemapLocation: 'sitemap.json', - }, + }, global: { share: true, windowScroll: false, @@ -76,6 +90,6 @@ module.exports = { }, projectConfig: { projectname: 'mina', - appid: 'wxf7b5556f34553852', + appid: 'wxba351784462a23bd', }, } diff --git a/build/webpack.mp.config.js b/build/webpack.mp.config.js index c846ff4..5f100c4 100644 --- a/build/webpack.mp.config.js +++ b/build/webpack.mp.config.js @@ -20,6 +20,9 @@ module.exports = { home: path.resolve(__dirname, '../src/mp/home/main.mp.js'), other: path.resolve(__dirname, '../src/mp/other/main.mp.js'), me: path.resolve(__dirname, '../src/mp/me/main.mp.js'), + doc: path.resolve(__dirname, '../src/mp/doc/main.mp.js'), + docDetail: path.resolve(__dirname, '../src/mp/docDetail/main.mp.js'), + article: path.resolve(__dirname, '../src/mp/article/main.mp.js'), }, output: { path: path.resolve(__dirname, '../dist/mp/common'), // 放到小程序代码目录中的 common 目录下 diff --git a/imgs/tabs/doc.png b/imgs/tabs/doc.png new file mode 100644 index 0000000..bfb7968 Binary files /dev/null and b/imgs/tabs/doc.png differ diff --git a/imgs/tabs/doc_selected.png b/imgs/tabs/doc_selected.png new file mode 100644 index 0000000..70c2249 Binary files /dev/null and b/imgs/tabs/doc_selected.png differ diff --git a/imgs/tabs/home.png b/imgs/tabs/home.png index 28c7b12..7370908 100644 Binary files a/imgs/tabs/home.png and b/imgs/tabs/home.png differ diff --git a/imgs/tabs/home_1.png b/imgs/tabs/home_1.png new file mode 100644 index 0000000..28c7b12 Binary files /dev/null and b/imgs/tabs/home_1.png differ diff --git a/imgs/tabs/home_selected.png b/imgs/tabs/home_selected.png index 50c6bb1..55db152 100644 Binary files a/imgs/tabs/home_selected.png and b/imgs/tabs/home_selected.png differ diff --git a/imgs/tabs/home_selected_1.png b/imgs/tabs/home_selected_1.png new file mode 100644 index 0000000..50c6bb1 Binary files /dev/null and b/imgs/tabs/home_selected_1.png differ diff --git a/imgs/tabs/me.png b/imgs/tabs/me.png index bb8fc77..3250f93 100644 Binary files a/imgs/tabs/me.png and b/imgs/tabs/me.png differ diff --git a/imgs/tabs/me_1.png b/imgs/tabs/me_1.png new file mode 100644 index 0000000..bb8fc77 Binary files /dev/null and b/imgs/tabs/me_1.png differ diff --git a/imgs/tabs/me_selected.png b/imgs/tabs/me_selected.png index 7bcd80d..25574f0 100644 Binary files a/imgs/tabs/me_selected.png and b/imgs/tabs/me_selected.png differ diff --git a/imgs/tabs/me_selected_1.png b/imgs/tabs/me_selected_1.png new file mode 100644 index 0000000..7bcd80d Binary files /dev/null and b/imgs/tabs/me_selected_1.png differ diff --git a/src/api/commont.js b/src/api/commont.js new file mode 100644 index 0000000..56278a0 --- /dev/null +++ b/src/api/commont.js @@ -0,0 +1,107 @@ +import { get, post } from '../utils/request' + +export function getTotic(params) { + /** + * @description 获取主题 + * @param {string} tab 顶部tab,如果全部,可不传或all,其他使用 node name + * @param {number} p 第几页,不传代表第1页 + */ + return get('/topics', params) +} +export function getToticDetail(tid) { + /** + * @description 获取主题详情 + * @param {number} tid 主题id + */ + return get('/topic/detail', { tid }) +} + +export function checkSession(code) { + /** + * @description 检查登录 + * @param {string} code 小程序登录code + */ + return get('/wechat/check_session', { code }) +} + +export function register(params) { + /** + * @description 注册系统账号并绑定 + * @param {string} params.unbind_token + * @param {string} params.username 用户名 + * @param {string} params.email 邮箱 + * @param {string} params.passwd 密码 + * @param {string} params.pass2 确认密码 + * @param {string} params.userInfo 小程序 wx.getUserInfo 返回的 userInfo,json 格式原样传过来 + */ + return post('/wechat/register', params) +} + +export function login(params) { + /** + * @description 登录 + * @param {string} params.token token + * @param {number} params.uid 中文网用户uid + * @param {string} params.nickname 微信昵称 + * @param {string} params.avatar 微信头像 + */ + return get('/wechat/login', params) +} + +export function getArticles(p) { + /** + * @description 文章列表 + * @param {number} p token + */ + return get('/articles', { p }) +} + +export function articleDetail(id) { + /** + * @description 文章详情 + * @param {number} id + */ + return get('/article/detail', { id }) +} + +export function getSources(p) { + /** + * @description 资源列表 + * @param {number} p + */ + return get('/resources', { p }) +} + +export function getSourceDetail(id) { + /** + * @description 资源详情 + * @param {number} id + */ + return get('/resource/detail', { id }) +} + +export function getProjects(p) { + /** + * @description 项目列表 + * @param {number} p + */ + return get('/projects', { p }) +} + +export function getProjectDetail(id) { + /** + * @description 项目详情 + * @param {number} id + */ + return get('/project/detail', { id }) +} + +export function comment(objid, data) { + /** + * @description 提交评论 + * @param {number} objid + * @param {number} data.objtype 0-主题;1-文章;2-资源;3-wiki;4-开源项目;5-图书; + * @param {string} data.content + */ + return post(`comment/${objid}`, data) +} diff --git a/src/article/Index.vue b/src/article/Index.vue new file mode 100644 index 0000000..92f0e5b --- /dev/null +++ b/src/article/Index.vue @@ -0,0 +1,75 @@ + + + + diff --git a/src/common/utils.js b/src/common/utils.js new file mode 100644 index 0000000..0c25ca7 --- /dev/null +++ b/src/common/utils.js @@ -0,0 +1,66 @@ +// eslint-disable-next-line import/prefer-default-export +export function mpAutoUpdate() { + /** + * @description 执行小程序自动更新 + */ + console.log('runing mp auto update') + if (wx.canIUse('getUpdateManager')) { // 获取小程序更新机制兼容 + const updateManager = wx.getUpdateManager() + updateManager.onCheckForUpdate((res) => { // 1. 检查小程序是否有新版本发布 + if (res.hasUpdate) { // 请求完新版本信息的回调 + // 检测到新版本,需要更新,给出提示 + wx.showModal({ + title: '更新提示', + content: '检测到新版本,是否下载新版本并重启小程序?', + success(res2) { + if (res2.confirm) { // 2. 用户确定下载更新小程序,小程序下载及更新静默进行 + // eslint-disable-next-line no-use-before-define + downLoadAndUpdate(updateManager) + } else if (res2.cancel) { // 用户点击取消按钮的处理,如果需要强制更新,则给出二次弹窗,如果不需要,则这里的代码都可以删掉了 + // wx.showModal({ + // title: '温馨提示~', + // content: '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~', + // showCancel: false, // 隐藏取消按钮 + // confirmText: '确定更新', // 只保留确定更新按钮 + // success(res3) { + // if (res3.confirm) { + // // 下载新版本,并重新应用 + // // eslint-disable-next-line no-use-before-define + // downLoadAndUpdate(updateManager) + // } + // } + // }) + } + } + }) + } + }) + } else { + // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 + wx.showModal({ + title: '提示', + content: '当前微信版本过低,无法使用此小程序功能,请升级到最新微信版本后重试。' + }) + } +} + +export function downLoadAndUpdate(updateManager) { + /** + * @description 下载小程序新版本并重启应用 + * @param {Object} updateManager + */ + wx.showLoading() + updateManager.onUpdateReady(() => { // 静默下载更新小程序新版本 + wx.hideLoading() + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate() + }) + updateManager.onUpdateFailed(() => { + wx.hideLoading() + // 新的版本下载失败 + wx.showModal({ + title: '已经有新版本了哟~', + content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~', + }) + }) +} diff --git a/src/component/ListContent.vue b/src/component/ListContent.vue new file mode 100644 index 0000000..3fbc0dc --- /dev/null +++ b/src/component/ListContent.vue @@ -0,0 +1,168 @@ + + + + diff --git a/src/doc/Index.vue b/src/doc/Index.vue new file mode 100644 index 0000000..2986901 --- /dev/null +++ b/src/doc/Index.vue @@ -0,0 +1,87 @@ + + + + diff --git a/src/docDetail/Index.vue b/src/docDetail/Index.vue new file mode 100644 index 0000000..96c1e7b --- /dev/null +++ b/src/docDetail/Index.vue @@ -0,0 +1,56 @@ + + + + diff --git a/src/home/Index.vue b/src/home/Index.vue index c3ccbfa..9e9e9d4 100644 --- a/src/home/Index.vue +++ b/src/home/Index.vue @@ -1,60 +1,65 @@ diff --git a/src/home/Tabs/Index.vue b/src/home/Tabs/Index.vue new file mode 100644 index 0000000..e97f1cb --- /dev/null +++ b/src/home/Tabs/Index.vue @@ -0,0 +1,98 @@ + + + + diff --git a/src/main.js b/src/main.js index 4952af7..2f24cee 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,9 @@ import { sync } from 'vuex-router-sync' Vue.config.productionTip = false +// 引用kbone-api +Vue.use(kboneAPI) + sync(store, router) new Vue({ diff --git a/src/me/Index.vue b/src/me/Index.vue index 3da1f9f..418a944 100644 --- a/src/me/Index.vue +++ b/src/me/Index.vue @@ -1,6 +1,6 @@ /* eslint-disable vue/no-shared-component-data */