From 883919244f1dd8293166e1f63b003faa53803296 Mon Sep 17 00:00:00 2001 From: hupeng Date: Thu, 18 Jun 2026 16:11:44 +0800 Subject: [PATCH] =?UTF-8?q?config/index.js=20=E5=8C=BA=E5=88=86=20dev=20pr?= =?UTF-8?q?od,fixed=20store.js=20userpage.js=20=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yshop-drink-uniapp-vue3/.gitignore | 3 +++ yshop-drink-uniapp-vue3/api/api.js | 7 ++++--- yshop-drink-uniapp-vue3/config/index.js | 10 ++++++++-- yshop-drink-uniapp-vue3/hooks/usePage.js | 9 +++------ yshop-drink-uniapp-vue3/package.json | 6 +----- yshop-drink-uniapp-vue3/pages/menu/menu.vue | 6 +++--- yshop-drink-uniapp-vue3/store/store.js | 9 +++++---- yshop-drink-uniapp-vue3/utils/logger.js | 17 +++++++++++++++++ 8 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 yshop-drink-uniapp-vue3/utils/logger.js diff --git a/yshop-drink-uniapp-vue3/.gitignore b/yshop-drink-uniapp-vue3/.gitignore index 534ceab..42a816d 100644 --- a/yshop-drink-uniapp-vue3/.gitignore +++ b/yshop-drink-uniapp-vue3/.gitignore @@ -39,3 +39,6 @@ dev-stats.json .vscode .history +.cursor/ +#忽略openspec目录 +openspec/ \ No newline at end of file diff --git a/yshop-drink-uniapp-vue3/api/api.js b/yshop-drink-uniapp-vue3/api/api.js index 3697793..0e98528 100644 --- a/yshop-drink-uniapp-vue3/api/api.js +++ b/yshop-drink-uniapp-vue3/api/api.js @@ -17,6 +17,7 @@ import { isWeixin } from '@/utils/util' import { VUE_APP_API_URL } from '@/config' import cookie from '@/utils/cookie' import { replace } from '@/utils/router' +import { logger } from '@/utils/logger' const fly = new Fly() fly.config.baseURL = VUE_APP_API_URL @@ -51,7 +52,7 @@ const defaultOpt = { login: true } function baseRequest(options) { const token = cookie.get('accessToken') - console.log('--> % token % token:\n', token) + logger.debug('[api] request token present:', !!token) options.headers = { ...options.headers, @@ -81,7 +82,7 @@ function baseRequest(options) { if (res.data.code == 1004004002) { if(isWeixin()){ const url = cookie.get('index_url') - console.log('redirect_uri:',url) + logger.debug('[api] redirect_uri:', url) //const url = `${location.origin}/h5/#/pages/index/index` location.href = url return @@ -144,7 +145,7 @@ const request = ['post', 'put', 'patch'].reduce((request, method) => { * @returns {AxiosPromise} */ request[method] = (url, data = {}, options = {}) => { - console.log(url, data) + logger.debug('[api]', method.toUpperCase(), url, data) return baseRequest(Object.assign({ url, data, method }, defaultOpt, options)) } return request diff --git a/yshop-drink-uniapp-vue3/config/index.js b/yshop-drink-uniapp-vue3/config/index.js index 6de8a6a..8e2a3c3 100644 --- a/yshop-drink-uniapp-vue3/config/index.js +++ b/yshop-drink-uniapp-vue3/config/index.js @@ -1,5 +1,11 @@ -export const VUE_APP_API_URL = 'http://localhost:48081/app-api' -//export const VUE_APP_API_URL = 'https://apidc.yixiang.co/app-api' +const DEV_API_URL = 'http://localhost:48081/app-api' +const PROD_API_URL = 'https://apidc.yixiang.co/app-api' + +// #ifdef APP-PLUS || H5 || MP-WEIXIN +export const VUE_APP_API_URL = + process.env.NODE_ENV === 'development' ? DEV_API_URL : PROD_API_URL +// #endif + export const VUE_APP_RESOURCES_URL = 'https://h5.yixiang.co/static' export const VUE_APP_UPLOAD_URL = VUE_APP_API_URL + '/infra/file/upload' export const APP_ID = 'wxdbdbc123c8c30b45' diff --git a/yshop-drink-uniapp-vue3/hooks/usePage.js b/yshop-drink-uniapp-vue3/hooks/usePage.js index b9075ba..eb1a2ce 100644 --- a/yshop-drink-uniapp-vue3/hooks/usePage.js +++ b/yshop-drink-uniapp-vue3/hooks/usePage.js @@ -1,5 +1,5 @@ // mouse.js -import { ref, onMounted, onUnmounted } from 'vue' +import { ref } from 'vue' import { onReady, onReachBottom } from '@dcloudio/uni-app' export const usePage = getPage => { @@ -33,8 +33,6 @@ export const usePage = getPage => { const dataList = ref([]) const handleGetDataList = async () => { - console.log('--> % handleGetDataList % loading:\n', loading.value) - console.log('--> % handleGetDataList % loadend:\n', loadend.value) if (loading.value || loadend.value) return loading.value = true @@ -47,7 +45,6 @@ export const usePage = getPage => { news: news.value, isIntegral: isIntegral.value, }) - console.log('--> % handleGetDataList % products:\n', products) if (products) { if (products.length <= 0) { loadend.value = true @@ -65,13 +62,13 @@ export const usePage = getPage => { } onReady(() => { - console.log('onReady') // handleGetDataList() }) onReachBottom(() => { - if (loading.value) return + if (loading.value || loadend.value) return page.value += 1 + handleGetDataList() }) // 通过返回值暴露所管理的状态 diff --git a/yshop-drink-uniapp-vue3/package.json b/yshop-drink-uniapp-vue3/package.json index 10fbaae..5ef2690 100644 --- a/yshop-drink-uniapp-vue3/package.json +++ b/yshop-drink-uniapp-vue3/package.json @@ -10,13 +10,9 @@ "license": "ISC", "dependencies": { "@vant/area-data": "^1.5.0", - "add": "^2.0.6", "flyio": "^0.6.14", "jweixin-module": "^1.6.0", - "openai": "^6.38.0", "pinia": "^2.1.6", - "vant": "^4.6.2", - "weixin-js-sdk": "^1.6.3", - "yarn": "^1.22.19" + "weixin-js-sdk": "^1.6.3" } } diff --git a/yshop-drink-uniapp-vue3/pages/menu/menu.vue b/yshop-drink-uniapp-vue3/pages/menu/menu.vue index 4873f2a..aba4dc1 100644 --- a/yshop-drink-uniapp-vue3/pages/menu/menu.vue +++ b/yshop-drink-uniapp-vue3/pages/menu/menu.vue @@ -806,14 +806,14 @@ $menu-divider-height: 2rpx; @mixin quantity-control($size) { .btn, .number { - width: $size; - height: $size; + //width: $size; + //height: $size; line-height: $size; text-align: center; } .btn { - padding: 0; + //padding: 0; border-radius: $border-radius-circle; } } diff --git a/yshop-drink-uniapp-vue3/store/store.js b/yshop-drink-uniapp-vue3/store/store.js index 8eed33a..738dc0b 100644 --- a/yshop-drink-uniapp-vue3/store/store.js +++ b/yshop-drink-uniapp-vue3/store/store.js @@ -92,10 +92,11 @@ export const useMainStore = defineStore('main', { return null }, logout() { - this.user = null - this.address = [] - this.areaList = [] - this.selectAddress = null + this.member = {} + this.cart = [] + this.token = '' + cookie.remove('accessToken') + cookie.remove('userinfo') navigateTo('/pages/login/login') }, }, diff --git a/yshop-drink-uniapp-vue3/utils/logger.js b/yshop-drink-uniapp-vue3/utils/logger.js new file mode 100644 index 0000000..4301926 --- /dev/null +++ b/yshop-drink-uniapp-vue3/utils/logger.js @@ -0,0 +1,17 @@ +export const IS_DEV = process.env.NODE_ENV !== 'production' + +const noop = () => {} + +function createLogMethod(method) { + if (IS_DEV) { + return (...args) => console[method](...args) + } + return noop +} + +export const logger = { + debug: createLogMethod('log'), + info: createLogMethod('info'), + warn: createLogMethod('warn'), + error: createLogMethod('error'), +}