From 7d27d891f1fd85892f6dd6890a8da04c690d4092 Mon Sep 17 00:00:00 2001 From: barney <15270405776@163.com> Date: Thu, 6 Oct 2022 00:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E5=92=8C=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 185 +++++++++++++++++++++++++++ README.md | 6 + db.sqlite3 | Bin 0 -> 131072 bytes django_weixinapp/__init__.py | 0 django_weixinapp/asgi.py | 16 +++ django_weixinapp/settings.py | 126 ++++++++++++++++++ django_weixinapp/urls.py | 23 ++++ django_weixinapp/wsgi.py | 16 +++ frontend/.eslintrc.js | 31 +++++ frontend/app.js | 19 +++ frontend/app.json | 17 +++ frontend/app.wxss | 0 frontend/pages/index/index.js | 124 ++++++++++++++++++ frontend/pages/index/index.json | 3 + frontend/pages/index/index.wxml | 25 ++++ frontend/pages/index/index.wxss | 6 + frontend/pages/logs/logs.js | 18 +++ frontend/pages/logs/logs.json | 4 + frontend/pages/logs/logs.wxml | 6 + frontend/pages/logs/logs.wxss | 8 ++ frontend/project.config.json | 51 ++++++++ frontend/project.private.config.json | 8 ++ frontend/sitemap.json | 7 + frontend/utils/util.js | 19 +++ manage.py | 22 ++++ weixin/__init__.py | 0 weixin/admin.py | 3 + weixin/apps.py | 6 + weixin/migrations/__init__.py | 0 weixin/models.py | 3 + weixin/tests.py | 3 + weixin/urls.py | 7 + weixin/views.py | 10 ++ 33 files changed, 772 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 db.sqlite3 create mode 100644 django_weixinapp/__init__.py create mode 100644 django_weixinapp/asgi.py create mode 100644 django_weixinapp/settings.py create mode 100644 django_weixinapp/urls.py create mode 100644 django_weixinapp/wsgi.py create mode 100644 frontend/.eslintrc.js create mode 100644 frontend/app.js create mode 100644 frontend/app.json create mode 100644 frontend/app.wxss create mode 100644 frontend/pages/index/index.js create mode 100644 frontend/pages/index/index.json create mode 100644 frontend/pages/index/index.wxml create mode 100644 frontend/pages/index/index.wxss create mode 100644 frontend/pages/logs/logs.js create mode 100644 frontend/pages/logs/logs.json create mode 100644 frontend/pages/logs/logs.wxml create mode 100644 frontend/pages/logs/logs.wxss create mode 100644 frontend/project.config.json create mode 100644 frontend/project.private.config.json create mode 100644 frontend/sitemap.json create mode 100644 frontend/utils/util.js create mode 100644 manage.py create mode 100644 weixin/__init__.py create mode 100644 weixin/admin.py create mode 100644 weixin/apps.py create mode 100644 weixin/migrations/__init__.py create mode 100644 weixin/models.py create mode 100644 weixin/tests.py create mode 100644 weixin/urls.py create mode 100644 weixin/views.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..783d77f --- /dev/null +++ b/.gitignore @@ -0,0 +1,185 @@ +### Python template + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject +### VirtualEnv template +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +.venv +pip-selfcheck.json + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# idea folder, uncomment if you don't need it +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..1021e51 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +### 基于Django4.0+微信小程序开发的待办清单 + +##### 参考链接:[Django+微信小程序开发待办清单](https://www.dusaiphoto.com/article/167/) + + + diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..c68be680a7f2e61266d256e61b30c802a2a4ed00 GIT binary patch literal 131072 zcmeI5eQXB~ugv)w(k2S^;clR$z+NJt>~gIAr<-AU*WLV(~7bc+Ochk$<;PP#h;x;vrc zB%bH-*z;mL$wn>eman%vnVIMJ{O0?7o@bt!`906rYuA^G4K1))t(DbAKz58eIL`5M zAmDH~g5-btxBZzTE3Wni`OBHs`>h5YGs?4r)R_MPwGsFq_)ZOfZ}|D)KlZ-o`L6fZ z-Cr6kxPHO;&4C{dtZ<)pe5IeG!|rc>e9R-P6|$0y$WbvT=9HaE@s8bme10{ZT2BXVWEQXANCy@(m(n)_LA%ufPJ@A!On0VW z;Czq?E9Qe20zoE^=n00JbH_bGA;~pWqXezgZLL-=*6YP;rLGw3v=E6%E}Bb*HKwe~ zcuX&aS$>yMACD&SU0G-mEINqzsZo#c1`)r!pZJz1qB|>v#awnX*<1JVL+S2vc97(D z2BLP09}=3*B)50wP;xDWRm5Cg4o9=1(Q>*7jrMOpUA9J(+~+WdE*oi57B{4@XZ@sV zrYu!sGRajd4Xx5p8uzy~+N8ppk$6mtWLec1c6^UIF;bO&UQD_TYubKn8Hmg^pGUYq z#qIG%l^9vN4v?$nwTfES6j4&May+UUwPED)_pb)S=#Z`tT@q3QZE?ZS-pvt@kV
w^QtLcrXFppQBI-upVo&kug;-BrTuPh!6T2bBN;;B2kyL0ws|7ME>w(OTrKP~N z)y3u1>PFyddLxj!vA(jHAugBGnROzSIq8{eHT_C@HJzDHubB?2A0rgFL{nFpq{YnQ z`eJHnX+z(czSPwSyES!rH&`6*7@<9J*dt6&a}URDXxSNN0@~Uh>4&kE{6xWP^$~}w z6=r)#WN&`V>k&?$=H5PIMb>G2$NE4z5}j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o(7Mj~u!fcAtkSfS!j)zdJ#u+L z$zkIrgZZ`>=cHbo9`_qP?K}PFK1cf?1tsU3#ShP~jQ>ADAq_|Y0T2KI5C8!X009sH0T2KI5CDP4 zL;%nKj|nW?f&d7B00@8p2!H?xfB*=900@A<6GQ;d|4&e5Kne(e00@8p2!H?xfB*=9 z00@8p2s|bNc>aG(VBr=7KmY_l00ck)1V8`;KmY_l00f>O0(ky^f+_=2KmY_l00ck) z1V8`;KmY_l00cnbF%j?)zi$2=2mdYpANarIzrepsHt+!f5C8!X009sH0T2KI5C8!X z009tqOa#W=F2|{7^wljebUDtQ(SMnvaerH@o7P8MF2}?K{h0vzlLkH~*%Ig$ z`*#1a0kSzsH;vyRIL^5o!YTGMCgdk$v`V9PpFaOPMjum=;1&cx00ck)1V8`;KmY_l z00ck)1VG@4AYhvR&p#1@AOZwH00ck)1V8`;KmY_l00ck)1VG@C6QIxk9RIHl@(&*n z009sH0T2KI5C8!X009sH0T2Lz4=sUH&XhMShQrg6I4vauQfy92%!%{}&nV BMa=*J literal 0 HcmV?d00001 diff --git a/django_weixinapp/__init__.py b/django_weixinapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_weixinapp/asgi.py b/django_weixinapp/asgi.py new file mode 100644 index 0000000..db9c3b3 --- /dev/null +++ b/django_weixinapp/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for django_weixinapp project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_weixinapp.settings') + +application = get_asgi_application() diff --git a/django_weixinapp/settings.py b/django_weixinapp/settings.py new file mode 100644 index 0000000..4d886b0 --- /dev/null +++ b/django_weixinapp/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for django_weixinapp project. + +Generated by 'django-admin startproject' using Django 4.1.1. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-gpkscwp1ofoqtk$m34few$y+yvukj61l42*_av@4+rkhd9eeg6' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'rest_framework', + 'weixin', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'django_weixinapp.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [BASE_DIR / 'templates'] + , + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'django_weixinapp.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/django_weixinapp/urls.py b/django_weixinapp/urls.py new file mode 100644 index 0000000..d9681aa --- /dev/null +++ b/django_weixinapp/urls.py @@ -0,0 +1,23 @@ +"""django_weixinapp URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api-auth/', include('rest_framework.urls')), + path('api/weixin/', include('weixin.urls', namespace='weixin')), +] diff --git a/django_weixinapp/wsgi.py b/django_weixinapp/wsgi.py new file mode 100644 index 0000000..6ba430c --- /dev/null +++ b/django_weixinapp/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for django_weixinapp project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_weixinapp.settings') + +application = get_wsgi_application() diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/frontend/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/frontend/app.js b/frontend/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/frontend/app.js @@ -0,0 +1,19 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + userInfo: null + } +}) diff --git a/frontend/app.json b/frontend/app.json new file mode 100644 index 0000000..e4c3fcb --- /dev/null +++ b/frontend/app.json @@ -0,0 +1,17 @@ +{ + "pages":[ + "pages/index/index", + "pages/logs/logs" + ], + "window":{ + "backgroundTextStyle":"light", + "navigationBarBackgroundColor": "#6495ED", + "navigationBarTitleText": "Todo-List", + "navigationBarTextStyle":"black" + }, + "style": "v2", + "sitemapLocation": "sitemap.json", + "useExtendedLib": { + "weui": true + } +} diff --git a/frontend/app.wxss b/frontend/app.wxss new file mode 100644 index 0000000..e69de29 diff --git a/frontend/pages/index/index.js b/frontend/pages/index/index.js new file mode 100644 index 0000000..8f78228 --- /dev/null +++ b/frontend/pages/index/index.js @@ -0,0 +1,124 @@ +Component({ + data: { + // 数据 + items: [{ + id: 3, + content: '打游戏', + checked: false + }, { + id: 2, + content: '吃饭', + checked: false, + }, { + id: 1, + content: '睡觉', + checked: false, + }], + // 输入框当前内容 + inputedValue: "", + }, + methods: { + // 监听多选框的状态改变事件 + checkboxChange(e) { + // 页面特有的数据 + // 获取本地数据的写法为this.data.xxx + const items = JSON.parse(JSON.stringify(this.data.items)); + // checkbox的value + const values = e.detail.value; + // 将items和values进行对比 + // 根据values的值更新页面数据(即data.items) + for (let i = 0, lenI = items.length; i < lenI; i++) { + items[i].checked = false; + for (let j = 0, lenJ = values.length; j < lenJ; j++) { + if (items[i].id === parseInt(values[j])) { + // 如果当前条目被选中则将items中对应的条目设置为已选中 + items[i].checked = true; + break; + } + } + } + // 更新页面数据 + this.setData({ + items: items, + }); + + // 将items存储到缓存 + wx.setStorage({ + key: "items", + data: items, + }) + + // 打印的内容会展现在调试器中 + // console.log(this.data.items) + + }, + // 监听键盘输入事件 + keyInput(e) { + this.setData({ + inputedValue: e.detail.value + }) + }, + // 监听提交按钮 + inputSubmit() { + // 读取数据 + let items = JSON.parse(JSON.stringify(this.data.items)); + // 设置新条目的id + let newId = 1; + if (this.data.inputedValue === "") { + console.log("待办事项不能为空!"); + return; + } + for (let value of items) { + if (value.content === this.data.inputedValue) { + console.log("该待办事件已存在!"); + return; + } + } + if (items[0] !== undefined) { + newId = items[0].id + 1; // 注意第一个item的id最大 + } + // 将新条目更新到items中 + items.unshift({ // unshift表示将数据插到第一个位置 + id: newId, + content: this.data.inputedValue, + checked: false + }); + console.log(items[0]); + // 更新data + this.setData({ + items: items, + inputedValue: "", //将输入框中的值清空 + }); + // 将items本地存储 + wx.setStorage({ + key: "items", + data: items + }); + } + }, + //生命周期函数 + lifetimes: { + // 在组件实例进入页面节点树时执行 + attached() { + // const that = this; + // 从缓存中读取items + wx.getStorage({ + key: 'items', + success: res => { + this.setData({ + items: res.data.filter(v=>v.checked===false) + }) + } + }); + + // 请求后端数据 + wx.request({ + url: 'http://127.0.0.1:8000/api/weixin/login/', + success: res => { + console.log(res.data); + } + }) + } + } + +}) \ No newline at end of file diff --git a/frontend/pages/index/index.json b/frontend/pages/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/frontend/pages/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/frontend/pages/index/index.wxml b/frontend/pages/index/index.wxml new file mode 100644 index 0000000..98aba8e --- /dev/null +++ b/frontend/pages/index/index.wxml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/pages/index/index.wxss b/frontend/pages/index/index.wxss new file mode 100644 index 0000000..f60ca13 --- /dev/null +++ b/frontend/pages/index/index.wxss @@ -0,0 +1,6 @@ +.line { + width: 100%; + height: 3rpx; + background: #ddd; + margin-bottom: 20rpx; +} \ No newline at end of file diff --git a/frontend/pages/logs/logs.js b/frontend/pages/logs/logs.js new file mode 100644 index 0000000..85f6aac --- /dev/null +++ b/frontend/pages/logs/logs.js @@ -0,0 +1,18 @@ +// logs.js +const util = require('../../utils/util.js') + +Page({ + data: { + logs: [] + }, + onLoad() { + this.setData({ + logs: (wx.getStorageSync('logs') || []).map(log => { + return { + date: util.formatTime(new Date(log)), + timeStamp: log + } + }) + }) + } +}) diff --git a/frontend/pages/logs/logs.json b/frontend/pages/logs/logs.json new file mode 100644 index 0000000..3ee76c1 --- /dev/null +++ b/frontend/pages/logs/logs.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "查看启动日志", + "usingComponents": {} +} \ No newline at end of file diff --git a/frontend/pages/logs/logs.wxml b/frontend/pages/logs/logs.wxml new file mode 100644 index 0000000..0b6b645 --- /dev/null +++ b/frontend/pages/logs/logs.wxml @@ -0,0 +1,6 @@ + + + + {{index + 1}}. {{log.date}} + + diff --git a/frontend/pages/logs/logs.wxss b/frontend/pages/logs/logs.wxss new file mode 100644 index 0000000..94d4b88 --- /dev/null +++ b/frontend/pages/logs/logs.wxss @@ -0,0 +1,8 @@ +.log-list { + display: flex; + flex-direction: column; + padding: 40rpx; +} +.log-item { + margin: 10rpx; +} diff --git a/frontend/project.config.json b/frontend/project.config.json new file mode 100644 index 0000000..045a154 --- /dev/null +++ b/frontend/project.config.json @@ -0,0 +1,51 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "bundle": false, + "userConfirmedBundleSwitch": false, + "urlCheck": true, + "scopeDataCheck": false, + "coverView": true, + "es6": true, + "postcss": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "newFeature": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "useIsolateContext": true, + "nodeModules": false, + "enhance": true, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "enableEngineNative": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false, + "minifyWXML": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "compileType": "miniprogram", + "libVersion": "2.19.4", + "appid": "wxe35222de7aa53383", + "projectname": "miniprogram-92", + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/frontend/project.private.config.json b/frontend/project.private.config.json new file mode 100644 index 0000000..2a76516 --- /dev/null +++ b/frontend/project.private.config.json @@ -0,0 +1,8 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "frontend", + "setting": { + "compileHotReLoad": true, + "urlCheck": false + } +} \ No newline at end of file diff --git a/frontend/sitemap.json b/frontend/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/frontend/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/frontend/utils/util.js b/frontend/utils/util.js new file mode 100644 index 0000000..764bc2c --- /dev/null +++ b/frontend/utils/util.js @@ -0,0 +1,19 @@ +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : `0${n}` +} + +module.exports = { + formatTime +} diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..d65dfae --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_weixinapp.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/weixin/__init__.py b/weixin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weixin/admin.py b/weixin/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/weixin/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/weixin/apps.py b/weixin/apps.py new file mode 100644 index 0000000..a001189 --- /dev/null +++ b/weixin/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WeixinConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'weixin' diff --git a/weixin/migrations/__init__.py b/weixin/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/weixin/models.py b/weixin/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/weixin/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/weixin/tests.py b/weixin/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/weixin/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/weixin/urls.py b/weixin/urls.py new file mode 100644 index 0000000..b086e02 --- /dev/null +++ b/weixin/urls.py @@ -0,0 +1,7 @@ +from django.urls import path +from weixin.views import WeixinLogin + +app_name = 'weixin' +urlpatterns = [ + path('login/', WeixinLogin.as_view(), name='login') +] \ No newline at end of file diff --git a/weixin/views.py b/weixin/views.py new file mode 100644 index 0000000..92296e7 --- /dev/null +++ b/weixin/views.py @@ -0,0 +1,10 @@ +from rest_framework.views import APIView +from rest_framework.response import Response + + +class WeixinLogin(APIView): + def get(self, request, format=None): + """ + 提供get请求 + """ + return Response({"data": "Hello World!"})