From 8f6e5c84238cb8ac84d0982a8faf2336b76fe0ab Mon Sep 17 00:00:00 2001 From: dmy Date: Sun, 18 Jan 2026 18:53:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8A=95=E6=A0=87?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=9F=A5=E7=9C=8B=E5=99=A8=E7=9A=84Ionic?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增基于Ionic + Vue 3 + TypeScript + Tailwind CSS的移动端应用,适配Android平台。主要功能包括AI推荐项目展示、爬虫信息统计、置顶项目管理和下拉刷新功能。同时更新前后端API端口配置为3300。 --- frontend/.env.development | 2 +- frontend/.env.production | 2 +- ionic-app/.env.development | 1 + ionic-app/.env.production | 1 + ionic-app/README.md | 129 ++++++++ ionic-app/android/.gitignore | 101 ++++++ ionic-app/android/app/.gitignore | 2 + ionic-app/android/app/build.gradle | 54 ++++ ionic-app/android/app/capacitor.build.gradle | 19 ++ ionic-app/android/build.gradle | 29 ++ ionic-app/android/capacitor.settings.gradle | 6 + ionic-app/android/gradle.properties | 22 ++ ionic-app/android/gradlew | 248 +++++++++++++++ ionic-app/android/gradlew.bat | 92 ++++++ ionic-app/android/settings.gradle | 5 + ionic-app/android/variables.gradle | 16 + ionic-app/capacitor.config.json | 25 ++ ionic-app/index.html | 28 ++ ionic-app/ionic.config.json | 7 + ionic-app/package.json | 36 +++ ionic-app/postcss.config.js | 6 + ionic-app/src/App.vue | 21 ++ .../src/components/AiRecommendations.vue | 219 +++++++++++++ ionic-app/src/components/CrawlInfo.vue | 299 ++++++++++++++++++ ionic-app/src/components/PinnedBids.vue | 199 ++++++++++++ ionic-app/src/main.ts | 28 ++ ionic-app/src/pages/HomePage.vue | 81 +++++ ionic-app/src/pages/LoginPage.vue | 121 +++++++ ionic-app/src/router/index.ts | 42 +++ ionic-app/src/stores/auth.ts | 79 +++++ ionic-app/src/theme/variables.css | 229 ++++++++++++++ ionic-app/src/types/index.ts | 40 +++ ionic-app/src/utils/api.ts | 90 ++++++ ionic-app/src/vite-env.d.ts | 9 + ionic-app/tailwind.config.js | 11 + ionic-app/tsconfig.json | 25 ++ ionic-app/tsconfig.node.json | 11 + ionic-app/vite.config.ts | 19 ++ src/main.ts | 4 +- src/scripts/update-source.ts | 4 +- 40 files changed, 2357 insertions(+), 5 deletions(-) create mode 100644 ionic-app/.env.development create mode 100644 ionic-app/.env.production create mode 100644 ionic-app/README.md create mode 100644 ionic-app/android/.gitignore create mode 100644 ionic-app/android/app/.gitignore create mode 100644 ionic-app/android/app/build.gradle create mode 100644 ionic-app/android/app/capacitor.build.gradle create mode 100644 ionic-app/android/build.gradle create mode 100644 ionic-app/android/capacitor.settings.gradle create mode 100644 ionic-app/android/gradle.properties create mode 100644 ionic-app/android/gradlew create mode 100644 ionic-app/android/gradlew.bat create mode 100644 ionic-app/android/settings.gradle create mode 100644 ionic-app/android/variables.gradle create mode 100644 ionic-app/capacitor.config.json create mode 100644 ionic-app/index.html create mode 100644 ionic-app/ionic.config.json create mode 100644 ionic-app/package.json create mode 100644 ionic-app/postcss.config.js create mode 100644 ionic-app/src/App.vue create mode 100644 ionic-app/src/components/AiRecommendations.vue create mode 100644 ionic-app/src/components/CrawlInfo.vue create mode 100644 ionic-app/src/components/PinnedBids.vue create mode 100644 ionic-app/src/main.ts create mode 100644 ionic-app/src/pages/HomePage.vue create mode 100644 ionic-app/src/pages/LoginPage.vue create mode 100644 ionic-app/src/router/index.ts create mode 100644 ionic-app/src/stores/auth.ts create mode 100644 ionic-app/src/theme/variables.css create mode 100644 ionic-app/src/types/index.ts create mode 100644 ionic-app/src/utils/api.ts create mode 100644 ionic-app/src/vite-env.d.ts create mode 100644 ionic-app/tailwind.config.js create mode 100644 ionic-app/tsconfig.json create mode 100644 ionic-app/tsconfig.node.json create mode 100644 ionic-app/vite.config.ts diff --git a/frontend/.env.development b/frontend/.env.development index f77d71b..e5bbc01 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -2,4 +2,4 @@ VITE_ARK_API_KEY=a63d58b6-cf56-434b-8a42-5c781ba0822a # 后端 API 地址 -VITE_API_BASE_URL=http://localhost:3000/ +VITE_API_BASE_URL=http://localhost:3300/ diff --git a/frontend/.env.production b/frontend/.env.production index 0d810f3..b84169b 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -2,4 +2,4 @@ VITE_ARK_API_KEY=a63d58b6-cf56-434b-8a42-5c781ba0822a # 后端 API 地址 -VITE_API_BASE_URL=http://139.180.190.142:3000/ +VITE_API_BASE_URL=http://139.180.190.142:3300/ diff --git a/ionic-app/.env.development b/ionic-app/.env.development new file mode 100644 index 0000000..93024c8 --- /dev/null +++ b/ionic-app/.env.development @@ -0,0 +1 @@ +VITE_API_BASE_URL=http://localhost:3300 diff --git a/ionic-app/.env.production b/ionic-app/.env.production new file mode 100644 index 0000000..fe45c8a --- /dev/null +++ b/ionic-app/.env.production @@ -0,0 +1 @@ +VITE_API_BASE_URL=http://139.180.190.142:3300/ diff --git a/ionic-app/README.md b/ionic-app/README.md new file mode 100644 index 0000000..356d439 --- /dev/null +++ b/ionic-app/README.md @@ -0,0 +1,129 @@ +# 投标项目查看器 - Ionic 版本 + +基于 Ionic + Vue 3 + TypeScript + Tailwind CSS 的移动端应用,适配 Android 平台。 + +## 功能特性 + +- **AI 推荐** - 显示 AI 推荐的投标项目,带推荐度标签 +- **爬虫信息** - 显示各爬虫来源的统计信息和状态 +- **置顶项目** - 显示用户置顶的投标项目 +- **下拉刷新** - 支持下拉刷新数据 + +## 技术栈 + +- **Ionic 8** - 移动端 UI 框架 +- **Vue 3** - 前端框架 +- **TypeScript** - 类型安全 +- **Tailwind CSS** - 样式框架 +- **Capacitor** - 原生功能集成 +- **Axios** - HTTP 客户端 + +## 安装依赖 + +```bash +npm install +``` + +## 开发 + +启动开发服务器: + +```bash +npm run dev +``` + +应用将在 http://localhost:8100 运行。 + +## 构建 + +构建生产版本: + +```bash +npm run build +``` + +## Android 构建 + +### 添加 Android 平台 + +```bash +npm install -g @capacitor/cli +npx cap init +npx cap add android +``` + +### 同步资源 + +```bash +npm run build +npx cap sync +``` + +### 在 Android Studio 中打开 + +```bash +npx cap open android +``` + +## 环境变量 + +创建 `.env.development` 文件: + +```env +VITE_API_BASE_URL=http://localhost:3001 +``` + +创建 `.env.production` 文件: + +```env +VITE_API_BASE_URL=https://your-production-api.com +``` + +## 项目结构 + +``` +ionic-app/ +├── src/ +│ ├── components/ # 组件 +│ │ ├── AiRecommendations.vue +│ │ ├── CrawlInfo.vue +│ │ └── PinnedBids.vue +│ ├── pages/ # 页面 +│ │ └── HomePage.vue +│ ├── router/ # 路由 +│ │ └── index.ts +│ ├── theme/ # 主题 +│ │ └── variables.css +│ ├── types/ # 类型定义 +│ │ └── index.ts +│ ├── utils/ # 工具函数 +│ │ └── api.ts +│ ├── App.vue # 根组件 +│ ├── main.ts # 入口文件 +│ └── vite-env.d.ts # Vite 类型声明 +├── public/ # 静态资源 +├── .env.development # 开发环境变量 +├── .env.production # 生产环境变量 +├── capacitor.config.ts # Capacitor 配置 +├── ionic.config.json # Ionic 配置 +├── package.json +├── tailwind.config.js # Tailwind 配置 +├── tsconfig.json # TypeScript 配置 +└── vite.config.ts # Vite 配置 +``` + +## API 接口 + +| 接口 | 方法 | 说明 | +|------|------|------| +| `/api/ai/latest-recommendations` | GET | 获取最新 AI 推荐 | +| `/api/bids/crawl-info-stats` | GET | 获取爬虫统计信息 | +| `/api/bids/pinned` | GET | 获取置顶项目 | +| `/api/bids/{title}/pin` | PATCH | 切换置顶状态 | + +## 注意事项 + +1. 确保后端 API 服务正在运行 +2. 开发环境默认 API 地址为 `http://localhost:3001` +3. 首次运行需要安装所有依赖 +4. Android 构建需要安装 Android Studio 和 Android SDK diff --git a/ionic-app/android/.gitignore b/ionic-app/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/ionic-app/android/.gitignore @@ -0,0 +1,101 @@ +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/ionic-app/android/app/.gitignore b/ionic-app/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/ionic-app/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/ionic-app/android/app/build.gradle b/ionic-app/android/app/build.gradle new file mode 100644 index 0000000..bab55e9 --- /dev/null +++ b/ionic-app/android/app/build.gradle @@ -0,0 +1,54 @@ +apply plugin: 'com.android.application' + +android { + namespace "com.bidding.app" + compileSdk rootProject.ext.compileSdkVersion + defaultConfig { + applicationId "com.bidding.app" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + aaptOptions { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation project(':capacitor-android') + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/ionic-app/android/app/capacitor.build.gradle b/ionic-app/android/app/capacitor.build.gradle new file mode 100644 index 0000000..151fee4 --- /dev/null +++ b/ionic-app/android/app/capacitor.build.gradle @@ -0,0 +1,19 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN + +android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } +} + +apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" +dependencies { + implementation project(':capacitor-app') + +} + + +if (hasProperty('postBuildExtras')) { + postBuildExtras() +} diff --git a/ionic-app/android/build.gradle b/ionic-app/android/build.gradle new file mode 100644 index 0000000..85a5dda --- /dev/null +++ b/ionic-app/android/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.2.1' + classpath 'com.google.gms:google-services:4.4.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/ionic-app/android/capacitor.settings.gradle b/ionic-app/android/capacitor.settings.gradle new file mode 100644 index 0000000..2085c86 --- /dev/null +++ b/ionic-app/android/capacitor.settings.gradle @@ -0,0 +1,6 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN +include ':capacitor-android' +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') + +include ':capacitor-app' +project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') diff --git a/ionic-app/android/gradle.properties b/ionic-app/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/ionic-app/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/ionic-app/android/gradlew b/ionic-app/android/gradlew new file mode 100644 index 0000000..fcb6fca --- /dev/null +++ b/ionic-app/android/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/ionic-app/android/gradlew.bat b/ionic-app/android/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/ionic-app/android/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/ionic-app/android/settings.gradle b/ionic-app/android/settings.gradle new file mode 100644 index 0000000..3b4431d --- /dev/null +++ b/ionic-app/android/settings.gradle @@ -0,0 +1,5 @@ +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + +apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/ionic-app/android/variables.gradle b/ionic-app/android/variables.gradle new file mode 100644 index 0000000..8ef305d --- /dev/null +++ b/ionic-app/android/variables.gradle @@ -0,0 +1,16 @@ +ext { + minSdkVersion = 22 + compileSdkVersion = 34 + targetSdkVersion = 34 + androidxActivityVersion = '1.8.0' + androidxAppCompatVersion = '1.6.1' + androidxCoordinatorLayoutVersion = '1.2.0' + androidxCoreVersion = '1.12.0' + androidxFragmentVersion = '1.6.2' + coreSplashScreenVersion = '1.0.1' + androidxWebkitVersion = '1.9.0' + junitVersion = '4.13.2' + androidxJunitVersion = '1.1.5' + androidxEspressoCoreVersion = '3.5.1' + cordovaAndroidVersion = '10.1.1' +} \ No newline at end of file diff --git a/ionic-app/capacitor.config.json b/ionic-app/capacitor.config.json new file mode 100644 index 0000000..e189e46 --- /dev/null +++ b/ionic-app/capacitor.config.json @@ -0,0 +1,25 @@ +{ + "appId": "com.bidding.app", + "appName": "BiddingApp", + "webDir": "dist", + "server": { + "androidScheme": "https" + }, + "plugins": { + "SplashScreen": { + "launchShowDuration": 0, + "launchAutoHide": true, + "backgroundColor": "#3880ff", + "androidSplashResourceName": "splash", + "androidScaleType": "CENTER_CROP", + "showSpinner": true, + "androidSpinnerStyle": "large", + "iosSpinnerStyle": "small", + "spinnerColor": "#3880ff", + "splashFullScreen": true, + "splashImmersive": true, + "layoutName": "launch_screen", + "useDialog": true + } + } +} diff --git a/ionic-app/index.html b/ionic-app/index.html new file mode 100644 index 0000000..f522617 --- /dev/null +++ b/ionic-app/index.html @@ -0,0 +1,28 @@ + + + + + 投标项目查看器 + + + + + + + + + + + + + + + + +
+ + + diff --git a/ionic-app/ionic.config.json b/ionic-app/ionic.config.json new file mode 100644 index 0000000..ceaa876 --- /dev/null +++ b/ionic-app/ionic.config.json @@ -0,0 +1,7 @@ +{ + "name": "bidding-looker-ionic", + "integrations": { + "capacitor": {} + }, + "type": "vue" +} diff --git a/ionic-app/package.json b/ionic-app/package.json new file mode 100644 index 0000000..0712c65 --- /dev/null +++ b/ionic-app/package.json @@ -0,0 +1,36 @@ +{ + "name": "bidding-looker-ionic", + "version": "1.0.0", + "description": "投标项目查看器 - Ionic 版本", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "ionic:build": "npm run build", + "ionic:serve": "vite --port 8100 --host", + "cap:sync": "capacitor sync", + "cap:open:android": "capacitor open android" + }, + "dependencies": { + "@capacitor/android": "^6.1.2", + "@capacitor/app": "^6.0.1", + "@capacitor/core": "^6.0.0", + "@ionic/vue": "^8.3.2", + "@ionic/vue-router": "^8.3.2", + "axios": "^1.7.9", + "ionicons": "^7.4.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@capacitor/cli": "^6.0.0", + "@vitejs/plugin-vue": "^5.2.1", + "autoprefixer": "^10.4.20", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "typescript": "^5.7.2", + "vite": "^6.0.3", + "vue-tsc": "^2.1.10" + } +} diff --git a/ionic-app/postcss.config.js b/ionic-app/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/ionic-app/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/ionic-app/src/App.vue b/ionic-app/src/App.vue new file mode 100644 index 0000000..22b3032 --- /dev/null +++ b/ionic-app/src/App.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/ionic-app/src/components/AiRecommendations.vue b/ionic-app/src/components/AiRecommendations.vue new file mode 100644 index 0000000..fd67185 --- /dev/null +++ b/ionic-app/src/components/AiRecommendations.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/ionic-app/src/components/CrawlInfo.vue b/ionic-app/src/components/CrawlInfo.vue new file mode 100644 index 0000000..9aa70a1 --- /dev/null +++ b/ionic-app/src/components/CrawlInfo.vue @@ -0,0 +1,299 @@ + + + + + diff --git a/ionic-app/src/components/PinnedBids.vue b/ionic-app/src/components/PinnedBids.vue new file mode 100644 index 0000000..c884a28 --- /dev/null +++ b/ionic-app/src/components/PinnedBids.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/ionic-app/src/main.ts b/ionic-app/src/main.ts new file mode 100644 index 0000000..32f92e5 --- /dev/null +++ b/ionic-app/src/main.ts @@ -0,0 +1,28 @@ +import { createApp } from 'vue' +import { IonicVue } from '@ionic/vue' + +/* Core CSS required for Ionic components to work properly */ +import '@ionic/vue/css/core.css' + +/* Basic CSS for apps built with Ionic */ +import '@ionic/vue/css/normalize.css' +import '@ionic/vue/css/structure.css' +import '@ionic/vue/css/typography.css' +import '@ionic/vue/css/padding.css' +import '@ionic/vue/css/float-elements.css' +import '@ionic/vue/css/text-alignment.css' +import '@ionic/vue/css/text-transformation.css' +import '@ionic/vue/css/flex-utils.css' +import '@ionic/vue/css/display.css' + +/* Theme variables */ +import './theme/variables.css' + +import App from './App.vue' +import router from './router' + +const app = createApp(App) +app.use(IonicVue) +app.use(router) + +app.mount('#app') diff --git a/ionic-app/src/pages/HomePage.vue b/ionic-app/src/pages/HomePage.vue new file mode 100644 index 0000000..b664e88 --- /dev/null +++ b/ionic-app/src/pages/HomePage.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/ionic-app/src/pages/LoginPage.vue b/ionic-app/src/pages/LoginPage.vue new file mode 100644 index 0000000..cdc269d --- /dev/null +++ b/ionic-app/src/pages/LoginPage.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/ionic-app/src/router/index.ts b/ionic-app/src/router/index.ts new file mode 100644 index 0000000..b104151 --- /dev/null +++ b/ionic-app/src/router/index.ts @@ -0,0 +1,42 @@ +import { createRouter, createWebHistory } from '@ionic/vue-router' +import HomePage from '@/pages/HomePage.vue' +import LoginPage from '@/pages/LoginPage.vue' +import { useAuthStore } from '@/stores/auth' + +const routes = [ + { + path: '/', + redirect: '/login' + }, + { + path: '/login', + component: LoginPage + }, + { + path: '/home', + component: HomePage, + meta: { requiresAuth: true } + } +] + +const router = createRouter({ + history: createWebHistory(), + routes +}) + +// 路由守卫 +router.beforeEach((to, from, next) => { + const authStore = useAuthStore() + + if (to.meta.requiresAuth && !authStore.state.value.isAuthenticated) { + // 需要认证但未登录,跳转到登录页 + next('/login') + } else if (to.path === '/login' && authStore.state.value.isAuthenticated) { + // 已登录用户访问登录页,跳转到首页 + next('/home') + } else { + next() + } +}) + +export default router diff --git a/ionic-app/src/stores/auth.ts b/ionic-app/src/stores/auth.ts new file mode 100644 index 0000000..9296a70 --- /dev/null +++ b/ionic-app/src/stores/auth.ts @@ -0,0 +1,79 @@ +import { ref } from 'vue' +import api from '@/utils/api' + +interface AuthState { + isAuthenticated: boolean + username: string | null + token: string | null +} + +const state = ref({ + isAuthenticated: false, + username: null, + token: null +}) + +export const useAuthStore = () => { + const login = async (username: string, password: string) => { + // 创建 Basic Auth token + const credentials = btoa(`${username}:${password}`) + const token = `Basic ${credentials}` + + // 保存 token 到 localStorage + localStorage.setItem('auth_token', token) + localStorage.setItem('auth_username', username) + + // 更新 API 实例的默认 headers + api.defaults.headers.common['Authorization'] = token + + // 更新状态 + state.value = { + isAuthenticated: true, + username, + token + } + } + + const logout = () => { + // 清除 localStorage + localStorage.removeItem('auth_token') + localStorage.removeItem('auth_username') + + // 清除 API headers + delete api.defaults.headers.common['Authorization'] + + // 更新状态 + state.value = { + isAuthenticated: false, + username: null, + token: null + } + } + + const checkAuth = () => { + const token = localStorage.getItem('auth_token') + const username = localStorage.getItem('auth_username') + + if (token && username) { + api.defaults.headers.common['Authorization'] = token + state.value = { + isAuthenticated: true, + username, + token + } + return true + } + + return false + } + + // 初始化时检查认证状态 + checkAuth() + + return { + state, + login, + logout, + checkAuth + } +} diff --git a/ionic-app/src/theme/variables.css b/ionic-app/src/theme/variables.css new file mode 100644 index 0000000..7142f42 --- /dev/null +++ b/ionic-app/src/theme/variables.css @@ -0,0 +1,229 @@ +/* Ionic Variables and Theming. For more info, please see: +http://ionicframework.com/docs/theming/theming-base-variables */ + +/** Ionic CSS Variables **/ +:root { + /** primary **/ + --ion-color-primary: #3880ff; + --ion-color-primary-rgb: 56, 128, 255; + --ion-color-primary-contrast: #ffffff; + --ion-color-primary-contrast-rgb: 255, 255, 255; + --ion-color-primary-shade: #3171e0; + --ion-color-primary-tint: #4c8dff; + + /** secondary **/ + --ion-color-secondary: #3dc2ff; + --ion-color-secondary-rgb: 61, 194, 255; + --ion-color-secondary-contrast: #ffffff; + --ion-color-secondary-contrast-rgb: 255, 255, 255; + --ion-color-secondary-shade: #36abe0; + --ion-color-secondary-tint: #50c8ff; + + /** tertiary **/ + --ion-color-tertiary: #5260ff; + --ion-color-tertiary-rgb: 82, 96, 255; + --ion-color-tertiary-contrast: #ffffff; + --ion-color-tertiary-contrast-rgb: 255, 255, 255; + --ion-color-tertiary-shade: #4854e0; + --ion-color-tertiary-tint: #6370ff; + + /** success **/ + --ion-color-success: #2dd36f; + --ion-color-success-rgb: 45, 211, 111; + --ion-color-success-contrast: #ffffff; + --ion-color-success-contrast-rgb: 255, 255, 255; + --ion-color-success-shade: #28ba62; + --ion-color-success-tint: #42d77d; + + /** warning **/ + --ion-color-warning: #ffc409; + --ion-color-warning-rgb: 255, 196, 9; + --ion-color-warning-contrast: #000000; + --ion-color-warning-contrast-rgb: 0, 0, 0; + --ion-color-warning-shade: #e0ac08; + --ion-color-warning-tint: #ffca22; + + /** danger **/ + --ion-color-danger: #eb445a; + --ion-color-danger-rgb: 235, 68, 90; + --ion-color-danger-contrast: #ffffff; + --ion-color-danger-contrast-rgb: 255, 255, 255; + --ion-color-danger-shade: #cf3c4f; + --ion-color-danger-tint: #ed576b; + + /** dark **/ + --ion-color-dark: #222428; + --ion-color-dark-rgb: 34, 36, 40; + --ion-color-dark-contrast: #ffffff; + --ion-color-dark-contrast-rgb: 255, 255, 255; + --ion-color-dark-shade: #1e2023; + --ion-color-dark-tint: #383a3e; + + /** medium **/ + --ion-color-medium: #92949c; + --ion-color-medium-rgb: 146, 148, 156; + --ion-color-medium-contrast: #ffffff; + --ion-color-medium-contrast-rgb: 255, 255, 255; + --ion-color-medium-shade: #808289; + --ion-color-medium-tint: #9d9fa6; + + /** light **/ + --ion-color-light: #f4f5f8; + --ion-color-light-rgb: 244, 245, 248; + --ion-color-light-contrast: #000000; + --ion-color-light-contrast-rgb: 0, 0, 0; + --ion-color-light-shade: #d7d8da; + --ion-color-light-tint: #f5f6f9; +} + +@media (prefers-color-scheme: dark) { + /* + * Dark Colors + * ------------------------------------------- + */ + + body.dark { + --ion-color-primary: #428cff; + --ion-color-primary-rgb: 66, 140, 255; + --ion-color-primary-contrast: #ffffff; + --ion-color-primary-contrast-rgb: 255, 255, 255; + --ion-color-primary-shade: #3a7be0; + --ion-color-primary-tint: #5598ff; + + --ion-color-secondary: #50c8ff; + --ion-color-secondary-rgb: 80, 200, 255; + --ion-color-secondary-contrast: #ffffff; + --ion-color-secondary-contrast-rgb: 255, 255, 255; + --ion-color-secondary-shade: #46b0e0; + --ion-color-secondary-tint: #62ceff; + + --ion-color-tertiary: #6a64ff; + --ion-color-tertiary-rgb: 106, 100, 255; + --ion-color-tertiary-contrast: #ffffff; + --ion-color-tertiary-contrast-rgb: 255, 255, 255; + --ion-color-tertiary-shade: #5d58e0; + --ion-color-tertiary-tint: #7974ff; + + --ion-color-success: #2fdf75; + --ion-color-success-rgb: 47, 223, 117; + --ion-color-success-contrast: #000000; + --ion-color-success-contrast-rgb: 0, 0, 0; + --ion-color-success-shade: #29c467; + --ion-color-success-tint: #44e283; + + --ion-color-warning: #ffd534; + --ion-color-warning-rgb: 255, 213, 52; + --ion-color-warning-contrast: #000000; + --ion-color-warning-contrast-rgb: 0, 0, 0; + --ion-color-warning-shade: #e0bb2e; + --ion-color-warning-tint: #ffd948; + + --ion-color-danger: #ff4961; + --ion-color-danger-rgb: 255, 73, 97; + --ion-color-danger-contrast: #ffffff; + --ion-color-danger-contrast-rgb: 255, 255, 255; + --ion-color-danger-shade: #e04055; + --ion-color-danger-tint: #ff5b71; + + --ion-color-dark: #f4f5f8; + --ion-color-dark-rgb: 244, 245, 248; + --ion-color-dark-contrast: #000000; + --ion-color-dark-contrast-rgb: 0, 0, 0; + --ion-color-dark-shade: #d7d8da; + --ion-color-dark-tint: #f5f6f9; + + --ion-color-medium: #989aa2; + --ion-color-medium-rgb: 152, 154, 162; + --ion-color-medium-contrast: #000000; + --ion-color-medium-contrast-rgb: 0, 0, 0; + --ion-color-medium-shade: #86888f; + --ion-color-medium-tint: #a2a4ab; + + --ion-color-light: #222428; + --ion-color-light-rgb: 34, 36, 40; + --ion-color-light-contrast: #ffffff; + --ion-color-light-contrast-rgb: 255, 255, 255; + --ion-color-light-shade: #1e2023; + --ion-color-light-tint: #383a3e; + } + + /* + * iOS Dark Theme + * ------------------------------------------- + */ + + .ios body.dark { + --ion-background-color: #03060b; + --ion-background-color-rgb: 3, 6, 11; + + --ion-text-color: #ffffff; + --ion-text-color-rgb: 255, 255, 255; + + --ion-color-step-50: #0d0d0d; + --ion-color-step-100: #1a1a1a; + --ion-color-step-150: #262626; + --ion-color-step-200: #333333; + --ion-color-step-250: #404040; + --ion-color-step-300: #4d4d4d; + --ion-color-step-350: #595959; + --ion-color-step-400: #666666; + --ion-color-step-450: #737373; + --ion-color-step-500: #808080; + --ion-color-step-550: #8c8c8c; + --ion-color-step-600: #999999; + --ion-color-step-650: #a6a6a6; + --ion-color-step-700: #b3b3b3; + --ion-color-step-750: #bfbfbf; + --ion-color-step-800: #cccccc; + --ion-color-step-850: #d9d9d9; + --ion-color-step-900: #e6e6e6; + --ion-color-step-950: #f2f2f2; + + --ion-item-background: #000000; + + --ion-card-background: #1c1c1d; + } + + /* + * Material Design Dark Theme + * ------------------------------------------- + */ + + .md body.dark { + --ion-background-color: #121212; + --ion-background-color-rgb: 18, 18, 18; + + --ion-text-color: #ffffff; + --ion-text-color-rgb: 255, 255, 255; + + --ion-border-color: #222222; + + --ion-color-step-50: #1e1e1e; + --ion-color-step-100: #2a2a2a; + --ion-color-step-150: #363636; + --ion-color-step-200: #414141; + --ion-color-step-250: #4d4d4d; + --ion-color-step-300: #595959; + --ion-color-step-350: #656565; + --ion-color-step-400: #717171; + --ion-color-step-450: #7d7d7d; + --ion-color-step-500: #898989; + --ion-color-step-550: #949494; + --ion-color-step-600: #a0a0a0; + --ion-color-step-650: #acacac; + --ion-color-step-700: #b8b8b8; + --ion-color-step-750: #c4c4c4; + --ion-color-step-800: #d0d0d0; + --ion-color-step-850: #dbdbdb; + --ion-color-step-900: #e7e7e7; + --ion-color-step-950: #f3f3f3; + + --ion-item-background: #1e1e1e; + + --ion-toolbar-background: #1f1f1f; + + --ion-tab-bar-background: #1f1f1f; + + --ion-card-background: #1e1e1e; + } +} diff --git a/ionic-app/src/types/index.ts b/ionic-app/src/types/index.ts new file mode 100644 index 0000000..b17fe6e --- /dev/null +++ b/ionic-app/src/types/index.ts @@ -0,0 +1,40 @@ +// 投标项目类型 +export interface BidItem { + id: string + title: string + url: string + publishDate: string + source: string + pin: boolean + createdAt?: string + updatedAt?: string +} + +// AI 推荐类型 +export interface AiRecommendation { + id: string + title: string + url: string + source: string + confidence: number + publishDate?: string + pin?: boolean +} + +// 爬虫统计信息类型 +export interface CrawlInfoStat { + source: string + count: number + latestUpdate: string | null + latestPublishDate: string | null + error: string | null +} + +// API 响应类型 +export interface ApiResponse { + data: T + message?: string +} + +// 日期范围类型 +export type DateRange = [string, string] | null diff --git a/ionic-app/src/utils/api.ts b/ionic-app/src/utils/api.ts new file mode 100644 index 0000000..e1e2d2d --- /dev/null +++ b/ionic-app/src/utils/api.ts @@ -0,0 +1,90 @@ +import axios from 'axios' +import type { BidItem, AiRecommendation, CrawlInfoStat, DateRange } from '@/types' + +// 从环境变量读取 API 基础地址 +const BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:3001' + +// 创建 axios 实例 +const api = axios.create({ + baseURL: BASE_URL, + timeout: 30000, + headers: { + 'Content-Type': 'application/json' + } +}) + +// 请求拦截器 +api.interceptors.request.use( + (config) => { + return config + }, + (error) => { + return Promise.reject(error) + } +) + +// 响应拦截器 +api.interceptors.response.use( + (response) => { + return response + }, + (error) => { + console.error('API 请求错误:', error) + return Promise.reject(error) + } +) + +/** + * 获取置顶投标项目 + */ +export function getPinnedBids(): Promise { + return api.get('/api/bids/pinned').then(res => res.data) +} + +/** + * 获取最新 AI 推荐 + */ +export function getAiRecommendations(): Promise { + return api.get('/api/ai/latest-recommendations').then(res => res.data) +} + +/** + * 获取爬虫统计信息 + */ +export function getCrawlInfoStats(): Promise { + return api.get('/api/bids/crawl-info-stats').then(res => res.data) +} + +/** + * 切换置顶状态 + */ +export function togglePin(title: string, pin: boolean): Promise { + return api.patch(`/api/bids/${encodeURIComponent(title)}/pin`, { pin }).then(res => res.data) +} + +/** + * 按日期范围获取工程 + */ +export function getBidsByDateRange(startDate: string, endDate?: string): Promise { + const params: any = { startDate } + if (endDate) { + params.endDate = endDate + } + return api.get('/api/bids/by-date-range', { params }).then(res => res.data) +} + +/** + * 获取 AI 推荐(发送 bids 数据) + */ +export function fetchAiRecommendations(bids: { title: string }[]): Promise { + return api.post('/api/ai/recommendations', { bids }).then(res => res.data) +} + +/** + * 保存 AI 推荐结果 + */ +export function saveAiRecommendations(recommendations: AiRecommendation[]): Promise { + return api.post('/api/ai/save-recommendations', { recommendations }).then(res => res.data) +} + +export default api diff --git a/ionic-app/src/vite-env.d.ts b/ionic-app/src/vite-env.d.ts new file mode 100644 index 0000000..8ab4f00 --- /dev/null +++ b/ionic-app/src/vite-env.d.ts @@ -0,0 +1,9 @@ +/// + +interface ImportMetaEnv { + readonly VITE_API_BASE_URL: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/ionic-app/tailwind.config.js b/ionic-app/tailwind.config.js new file mode 100644 index 0000000..bd3eb14 --- /dev/null +++ b/ionic-app/tailwind.config.js @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./index.html", + "./src/**/*.{vue,js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], +} diff --git a/ionic-app/tsconfig.json b/ionic-app/tsconfig.json new file mode 100644 index 0000000..4e5ea1b --- /dev/null +++ b/ionic-app/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/ionic-app/tsconfig.node.json b/ionic-app/tsconfig.node.json new file mode 100644 index 0000000..97ede7e --- /dev/null +++ b/ionic-app/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": ["vite.config.ts"] +} diff --git a/ionic-app/vite.config.ts b/ionic-app/vite.config.ts new file mode 100644 index 0000000..9244698 --- /dev/null +++ b/ionic-app/vite.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import { resolve } from 'path' +import { fileURLToPath } from 'url' + +const __dirname = fileURLToPath(new URL('.', import.meta.url)) + +export default defineConfig({ + plugins: [vue()], + resolve: { + alias: { + '@': resolve(__dirname, 'src') + } + }, + server: { + port: 8100, + host: true + } +}) diff --git a/src/main.ts b/src/main.ts index 0ecbab2..c852d03 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,6 +25,8 @@ async function bootstrap() { const httpAdapter = app.getHttpAdapter(); httpAdapter.getInstance().set('trust proxy', true); - await app.listen(process.env.PORT ?? 3000); + const host = process.env.HOST ?? '0.0.0.0'; + const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000; + await app.listen(port, host); } void bootstrap(); diff --git a/src/scripts/update-source.ts b/src/scripts/update-source.ts index 94f4caa..e67ca20 100644 --- a/src/scripts/update-source.ts +++ b/src/scripts/update-source.ts @@ -19,8 +19,8 @@ async function updateSource() { getRepositoryToken(BidItem), ); - const oldSource = '北京电力交易平台'; - const newSource = '北京京能电子商务平台'; + const oldSource = '电能e招采平台'; + const newSource = '电能e招采平台(国电投)'; logger.log(`开始更新 source 字段: "${oldSource}" -> "${newSource}"`);