diff --git a/README.md b/README.md
index 304f54657714a34d4bc95a0914370c902020a785..733cb65296588792bd63015aa3083793e326e11c 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,13 @@
-### github项目2023-06-02 执行存档,gitee是最新的
-这个项目地址已经存档,不维护了
-https://github.com/pythonstock/stock
-
-迁移到了gitee地址:
-https://gitee.com/pythonstock/stock
-
-### 项目部署放到docker-compose
-
-单独的项目部署脚本维护:
-https://gitee.com/pythonstock/docker-compose
-
-
-
-### pythonstock V2 项目简介
+### pythonstock V3.0 项目简介,2025.01.09更新
**特别说明:股市有风险投资需谨慎,本项目只能用于Python代码学习,股票分析,投资失败亏钱不负责,不算BUG。**
```
-PythonStock V2 是基于Python的pandas,akshare,bokeh,tornado,stockstats,ta-lib等框架开发的全栈股票系统。
+PythonStock V3.0 是基于Python的pandas,akshare,bokeh,tornado,stockstats,ta-lib等框架开发的全栈股票系统。
项目创建于2017年7月17日,每月不定期更新。
1)可以直接使用docker直接本地部署运行,整个项目在docker hub上压缩后200MB,本地占用500MB磁盘空间。
2)使用Docker解决了Python库安装问题,使用Mariadb(MySQL)存储数据。借助akshare抓取数据。
@@ -30,15 +16,17 @@ PythonStock V2 是基于Python的pandas,akshare,bokeh,tornado,stockstats
5)使用tornado开发web系统,支持每日股票数据-东财,龙虎榜-个股上榜-新浪,数据中心-大宗交易行情等。
6)数据展示系统,是通用数据展示系统,配置字典模板之后,页面自动加载数据,并完成数据展示,后续自己开发的指标数据可以加入进去。
7)增加曲线数据分析,在查看股票中,可以直接跳转到东方财富页面查看相关信息,点击指标之后使用Bokeh将多达 17 个指标的数据绘图,进行图表展示。
-8) 2.0 最大的更新在于替换tushare库(因部分库不能使用),使用akshare进行数据抓取。
+8)2.0 最大的更新在于替换tushare库(因部分库不能使用),使用akshare进行数据抓取。
+9)3.0 主要做的是项目整合,前端使用vue开发了,后端使用API,使用docker-compose开发部署。
基础库版本
-1,pandas使用【 1.3.5 】版本,升级了
-2,numpy使用【 1.21.6 】版本,升级了
-3,akshare使用【 1.10.5 】版本,升级了
-4,bokeh使用【 2.4.2 】版本,升级了
-5,stockstats使用【 0.3.2 】版本
+1,pandas使用【 2.2.3 】版本,
+2,numpy使用【 2.2.1 】版本,
+3,sqlalchemy使用【 2.0.36 】版本,
+4,akshare使用【 1.15.59 】版本,
+5,bokeh使用【 3.6.2 】版本,
+6,stockstats使用【 0.3.2 】版本,
```
@@ -47,10 +35,6 @@ PythonStock V2 是基于Python的pandas,akshare,bokeh,tornado,stockstats


- bokeh 绘图指标数据:
-
- 
-
然后根据3个指标进行股票数据计算:
```
@@ -96,6 +80,31 @@ CCI
| 17, VR,MAVR指标 | http://wiki.mbalib.com/wiki/%E6%88%90%E4%BA%A4%E9%87%8F%E6%AF%94%E7%8E%87 成交量比率(Volumn Ratio,VR)(简称VR),是一项通过分析股价上升日成交额(或成交量,下同)与股价下降日成交额比值, 从而掌握市场买卖气势的中期技术指标。 |
+### github项目2023-06-02 执行存档,gitee是最新的
+
+这个项目地址已经存档,不维护了
+https://github.com/pythonstock/stock
+
+迁移到了gitee地址:
+https://gitee.com/pythonstock/stock
+
+### 项目部署放到docker-compose
+
+
+```bash
+
+# 下载 docker
+curl -fsSL https://get.docker.com -o get-docker.sh
+sh get-docker.sh
+
+#
+curl -L "https://www.ghproxy.cn/https://github.com/docker/compose/releases/download/v2.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+
+```
+
+单独的项目部署脚本维护:
+https://gitee.com/pythonstock/docker-compose
+
### 使用方法(依赖docker,docker-compose)
@@ -125,7 +134,8 @@ sh /data/stock/jobs/cron.daily/run_daily
### 本地访问端口
-> http://localhost:9999 股票系统
+> http://localhost:8080 股票系统前端地址
+> http://localhost:9090 股票系统后端地址
### 股票系统设计
diff --git a/docs/1-todo-2020-12-06.md b/backend/docs/1-todo-2020-12-06.md
similarity index 100%
rename from docs/1-todo-2020-12-06.md
rename to backend/docs/1-todo-2020-12-06.md
diff --git a/docs/git-push-tag.md b/backend/docs/git-push-tag.md
similarity index 100%
rename from docs/git-push-tag.md
rename to backend/docs/git-push-tag.md
diff --git a/jobs/18h_daily_job.py b/backend/jobs/18h_daily_job.py
similarity index 91%
rename from jobs/18h_daily_job.py
rename to backend/jobs/18h_daily_job.py
index 491a765a2aa0b8ac518f8ac1b5462597d1abfa31..c58c8d2c280f35d9a10be488cce2a3c59f045019 100644
--- a/jobs/18h_daily_job.py
+++ b/backend/jobs/18h_daily_job.py
@@ -11,7 +11,7 @@ from sqlalchemy.types import NVARCHAR
from sqlalchemy import inspect
import datetime
import akshare as ak
-
+import traceback
import MySQLdb
# 600开头的股票是上证A股,属于大盘股
@@ -83,6 +83,7 @@ def stat_all(tmp_datetime):
common.insert_db(data, "stock_zh_a_spot_em", True, "`date`,`code`")
except Exception as e:
print("error :", e)
+ traceback.print_exc()
@@ -95,7 +96,7 @@ def stat_all(tmp_datetime):
#
try:
- stock_lhb_ggtj_sina = ak.stock_lhb_ggtj_sina(recent_day="5")
+ stock_lhb_ggtj_sina = ak.stock_lhb_ggtj_sina(symbol="5")
print(stock_lhb_ggtj_sina)
stock_lhb_ggtj_sina.columns = ['code', 'name', 'ranking_times', 'sum_buy', 'sum_sell', 'net_amount', 'buy_seat',
@@ -117,6 +118,8 @@ def stat_all(tmp_datetime):
except Exception as e:
print("error :", e)
+ traceback.print_exc()
+
# 每日统计
@@ -125,12 +128,16 @@ def stat_all(tmp_datetime):
# 目标地址: http://data.eastmoney.com/dzjy/dzjy_mrtj.aspx
#
# 描述: 获取东方财富网-数据中心-大宗交易-每日统计
+ # https://akshare.akfamily.xyz/data/stock/stock.html#id318
+ # import akshare as ak
+ # stock_dzjy_mrtj_df = ak.stock_dzjy_mrtj(start_date='20220105', end_date='20220105')
+ # print(stock_dzjy_mrtj_df)
try:
- print("################ tmp_datetime : " + datetime_str)
-
- stock_dzjy_mrtj = ak.stock_dzjy_mrtj(start_date=datetime_str, end_date=datetime_str)
+ print("################ tmp_datetime : " + datetime_int)
+ # 格式要 int类型日期
+ stock_dzjy_mrtj = ak.stock_dzjy_mrtj(start_date=datetime_int, end_date=datetime_int)
print(stock_dzjy_mrtj)
stock_dzjy_mrtj.columns = ['index', 'trade_date', 'code', 'name', 'quote_change', 'close_price', 'average_price',
@@ -154,6 +161,7 @@ def stat_all(tmp_datetime):
stock_dzjy_mrtj["turnover_market_rate"] = stock_dzjy_mrtj["turnover_market_rate"].round(6)
except Exception as e:
print("round error :", e)
+ traceback.print_exc()
# 删除老数据。
del_sql = " DELETE FROM `stock_dzjy_mrtj` where `date` = '%s' " % datetime_int
@@ -165,6 +173,7 @@ def stat_all(tmp_datetime):
except Exception as e:
print("error :", e)
+ traceback.print_exc()
# main函数入口
if __name__ == '__main__':
diff --git a/jobs/README.txt b/backend/jobs/README.txt
similarity index 100%
rename from jobs/README.txt
rename to backend/jobs/README.txt
diff --git a/jobs/aps_job.py b/backend/jobs/aps_job.py
similarity index 100%
rename from jobs/aps_job.py
rename to backend/jobs/aps_job.py
diff --git a/jobs/basic_job.py b/backend/jobs/basic_job.py
similarity index 100%
rename from jobs/basic_job.py
rename to backend/jobs/basic_job.py
diff --git a/jobs/cron.daily/run_daily b/backend/jobs/cron.daily/run_daily
similarity index 89%
rename from jobs/cron.daily/run_daily
rename to backend/jobs/cron.daily/run_daily
index 429ba15805212c0962c1c81da484187883ac2129..ac06a128fae61ac580e1f79930169ec239cfafcd 100644
--- a/jobs/cron.daily/run_daily
+++ b/backend/jobs/cron.daily/run_daily
@@ -19,6 +19,7 @@ echo "###################"$DATETIME"###################" >> /data/logs/daily.${D
echo "###################"$DATETIME"###################" >> /data/logs/daily.${DATE}.log
#使用股票指标预测。
/usr/local/bin/python3 /data/stock/jobs/guess_indicators_daily_job.py >> /data/logs/daily.${DATE}.log
+/usr/local/bin/python3 /data/stock/jobs/guess_indicators_daily_buy_job.py >> /data/logs/daily.${DATE}.log
#清除前3天数据。
DATE_20=`date -d '-20 days' +%Y-%m-%d`
diff --git a/jobs/cron.hourly/run_hourly b/backend/jobs/cron.hourly/run_hourly
similarity index 100%
rename from jobs/cron.hourly/run_hourly
rename to backend/jobs/cron.hourly/run_hourly
diff --git a/jobs/cron.minutely/run_1minute b/backend/jobs/cron.minutely/run_1minute
similarity index 100%
rename from jobs/cron.minutely/run_1minute
rename to backend/jobs/cron.minutely/run_1minute
diff --git a/jobs/cron.monthly/run_monthly b/backend/jobs/cron.monthly/run_monthly
similarity index 100%
rename from jobs/cron.monthly/run_monthly
rename to backend/jobs/cron.monthly/run_monthly
diff --git a/jobs/daily_job.py b/backend/jobs/daily_job.py
similarity index 100%
rename from jobs/daily_job.py
rename to backend/jobs/daily_job.py
diff --git a/backend/jobs/guess_indicators_daily_buy_job.py b/backend/jobs/guess_indicators_daily_buy_job.py
new file mode 100644
index 0000000000000000000000000000000000000000..b5738a0451709666222b163c03a8e7aa0920f278
--- /dev/null
+++ b/backend/jobs/guess_indicators_daily_buy_job.py
@@ -0,0 +1,77 @@
+#!/usr/local/bin/python3
+# -*- coding: utf-8 -*-
+
+
+import libs.common as common
+import pandas as pd
+import numpy as np
+import math
+import datetime
+import stockstats
+from sqlalchemy import text
+
+
+### 对每日指标数据,进行筛选。将符合条件的。二次筛选出来。
+### 只是做简单筛选
+def stat_all_lite_buy(tmp_datetime):
+ datetime_str = (tmp_datetime).strftime("%Y-%m-%d")
+ datetime_int = (tmp_datetime).strftime("%Y%m%d")
+ print("datetime_str:", datetime_str)
+ print("datetime_int:", datetime_int)
+
+ # 查询参数
+ params = {"datetime": datetime_int}
+
+ sql_kdjk = text(" SELECT avg(`kdjk`) as avg_kdjk FROM guess_indicators_daily ")
+ data_kdjk = pd.read_sql(sql=sql_kdjk, con=common.engine(), params=params)
+ kdjk = data_kdjk["avg_kdjk"][0]
+
+ sql_kdjd = text(" SELECT avg(`kdjd`) as avg_kdjd FROM guess_indicators_daily ")
+ data_kdjd = pd.read_sql(sql=sql_kdjd, con=common.engine(), params=params)
+ kdjd = data_kdjd["avg_kdjd"][0]
+
+ sql_kdjj = text(" SELECT avg(`kdjj`) as avg_kdjj FROM guess_indicators_daily ")
+ data_kdjj = pd.read_sql(sql=sql_kdjj, con=common.engine(), params=params)
+ kdjj = data_kdjj["avg_kdjj"][0]
+
+ # K值在80以上,D值在70以上,J值大于90时为超买。
+ # J大于100时为超买,小于10时为超卖。
+ # 当六日指标上升到达80时,表示股市已有超买现象
+ # 当CCI>﹢100 时,表明股价已经进入非常态区间——超买区间,股价的异动现象应多加关注。
+ params_1 = {"datetime": datetime_int, "kdjk": kdjk, "kdjd": kdjd, "kdjj": kdjj}
+ sql_1 = text("""
+ SELECT `date`,`code`,`name`,`last_price`,`change_percent`,`change_amount`,`volume`,`turnover`,
+ `amplitude`,`high`,`low`,`open`,`closed`,`volume_ratio`,`turnover_rate`,
+ `pe_ratio`,`pb_ratio`,`market_cap`,`circulating_market_cap`,`rise_speed`,
+ `change_5min`,`change_ercent_60day`,`ytd_change_percent`,
+ `boll`, `boll_lb`, `boll_ub`, `kdjd`, `kdjj`, `kdjk`, `macd`, `macdh`,
+ `macds`, `pdi`,`trix`, `trix_9_sma`, `vr`, `vr_6_sma`, `wr_10`, `wr_6`
+ FROM stock_data.guess_indicators_daily WHERE `date` = :datetime
+ and kdjk >= :kdjk and kdjd >= :kdjd and kdjj >= :kdjj
+ """) # and kdjj > 100 and rsi_6 > 80 and cci > 100 # 调整参数,提前获得股票增长。
+
+ try:
+ # 删除老数据。
+ del_sql = " DELETE FROM `stock_data`.`guess_indicators_lite_buy_daily` WHERE `date`= '%s' " % datetime_int
+ common.insert(del_sql)
+ except Exception as e:
+ print("error :", e)
+
+ print(f"sql_1 : {sql_1}")
+ data = pd.read_sql(sql=sql_1, con=common.engine(), params=params_1)
+ data = data.drop_duplicates(subset="code", keep="last")
+ print("######## stat_all_lite_buy len data ########:", len(data))
+
+ try:
+ common.insert_db(data, "guess_indicators_lite_buy_daily", False, "`date`,`code`")
+ except Exception as e:
+ print("error :", e)
+
+
+
+# main函数入口
+if __name__ == '__main__':
+ # 使用方法传递。
+ # 二次筛选数据。直接计算买卖股票数据。
+ tmp_datetime = common.run_with_args(stat_all_lite_buy)
+
diff --git a/jobs/guess_indicators_daily_job.py b/backend/jobs/guess_indicators_daily_job.py
similarity index 71%
rename from jobs/guess_indicators_daily_job.py
rename to backend/jobs/guess_indicators_daily_job.py
index 47a873198f23e483f2d28f0442f5806fbd68db1c..3075741ff8126015373b0541e5bb300b0a6d0888 100644
--- a/jobs/guess_indicators_daily_job.py
+++ b/backend/jobs/guess_indicators_daily_job.py
@@ -9,78 +9,6 @@ import math
import datetime
import stockstats
-
-### 对每日指标数据,进行筛选。将符合条件的。二次筛选出来。
-### 只是做简单筛选
-def stat_all_lite_buy(tmp_datetime):
- datetime_str = (tmp_datetime).strftime("%Y-%m-%d")
- datetime_int = (tmp_datetime).strftime("%Y%m%d")
- print("datetime_str:", datetime_str)
- print("datetime_int:", datetime_int)
-
- # K值在80以上,D值在70以上,J值大于90时为超买。
- # J大于100时为超买,小于10时为超卖。
- # 当六日指标上升到达80时,表示股市已有超买现象
- # 当CCI>﹢100 时,表明股价已经进入非常态区间——超买区间,股价的异动现象应多加关注。
- sql_1 = """
- SELECT `date`,`code`,`name`,`latest_price`,`quote_change`,`ups_downs`,`volume`,`turnover`,
- `amplitude`,`high`,`low`,`open`,`closed`,`quantity_ratio`,`turnover_rate`,`pe_dynamic`,`pb`,
- `kdjj`,`rsi_6`,`cci`
- FROM stock_data.guess_indicators_daily WHERE `date` = %s
- and kdjk >= 80 and kdjd >= 70 and kdjj >= 90
- """ # and kdjj > 100 and rsi_6 > 80 and cci > 100 # 调整参数,提前获得股票增长。
-
- try:
- # 删除老数据。
- del_sql = " DELETE FROM `stock_data`.`guess_indicators_lite_buy_daily` WHERE `date`= '%s' " % datetime_int
- common.insert(del_sql)
- except Exception as e:
- print("error :", e)
-
- data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
- data = data.drop_duplicates(subset="code", keep="last")
- print("######## stat_all_lite_buy len data ########:", len(data))
-
- try:
- common.insert_db(data, "guess_indicators_lite_buy_daily", False, "`date`,`code`")
- except Exception as e:
- print("error :", e)
-
-# 设置卖出数据。
-def stat_all_lite_sell(tmp_datetime):
- datetime_str = (tmp_datetime).strftime("%Y-%m-%d")
- datetime_int = (tmp_datetime).strftime("%Y%m%d")
- print("datetime_str:", datetime_str)
- print("datetime_int:", datetime_int)
-
- # 超卖区:K值在20以下,D值在30以下为超卖区。一般情况下,股价有可能上涨,反弹的可能性增大。局内人不应轻易抛出股票,局外人可寻机入场。
- # J大于100时为超买,小于10时为超卖。
- # 当六日强弱指标下降至20时,表示股市有超卖现象
- # 当CCI<﹣100时,表明股价已经进入另一个非常态区间——超卖区间,投资者可以逢低吸纳股票。
- sql_1 = """
- SELECT `date`,`code`,`name`,`latest_price`,`quote_change`,`ups_downs`,`volume`,`turnover`,
- `amplitude`,`high`,`low`,`open`,`closed`,`quantity_ratio`,`turnover_rate`,`pe_dynamic`,`pb`,
- `kdjj`,`rsi_6`,`cci`
- FROM stock_data.guess_indicators_daily WHERE `date` = %s
- and kdjk <= 20 and kdjd <= 30 and kdjj <= 10
- """
-
- try:
- # 删除老数据。
- del_sql = " DELETE FROM `stock_data`.`guess_indicators_lite_sell_daily` WHERE `date`= '%s' " % datetime_int
- common.insert(del_sql)
- except Exception as e:
- print("error :", e)
-
- data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
- data = data.drop_duplicates(subset="code", keep="last")
- print("######## stat_all_lite_sell len data ########:", len(data))
-
- try:
- common.insert_db(data, "guess_indicators_lite_sell_daily", False, "`date`,`code`")
- except Exception as e:
- print("error :", e)
-
# 批处理数据。
def stat_all_batch(tmp_datetime):
datetime_str = (tmp_datetime).strftime("%Y-%m-%d")
@@ -96,7 +24,7 @@ def stat_all_batch(tmp_datetime):
print("error :", e)
sql_count = """
- SELECT count(1) FROM stock_zh_ah_name WHERE `date` = %s and `open` > 0
+ SELECT count(1) FROM stock_zh_a_spot_em WHERE `date` = %s and `open` > 0
"""
# 修改逻辑,增加中小板块计算。 中小板:002,创业板:300 。已经是经过筛选的数据了。
count = common.select_count(sql_count, params=[datetime_int])
@@ -109,21 +37,24 @@ def stat_all_batch(tmp_datetime):
# 查询今日满足股票数据。剔除数据:创业板股票数据,中小板股票数据,所有st股票
# #`code` not like '002%' and `code` not like '300%' and `name` not like '%st%'
sql_1 = """
- SELECT `date`,`code`,`name`,`latest_price`,`quote_change`,`ups_downs`,`volume`,`turnover`,
- `amplitude`,`high`,`low`,`open`,`closed`,`quantity_ratio`,`turnover_rate`,`pe_dynamic`,`pb`
- FROM stock_zh_ah_name WHERE `date` = %s and `open` > 0 limit %s , %s
+ SELECT `date`,`code`,`name`,`last_price`,`change_percent`,`change_amount`,`volume`,`turnover`,
+ `amplitude`,`high`,`low`,`open`,`closed`,`volume_ratio`,`turnover_rate`,
+ `pe_ratio`,`pb_ratio`,`market_cap`,`circulating_market_cap`,`rise_speed`,
+ `change_5min`,`change_ercent_60day`,`ytd_change_percent`
+ FROM stock_zh_a_spot_em WHERE `date` = %s and `open` > 0 limit %s , %s
"""
- print(sql_1)
+ sql_2 = sql_1 % (datetime_int, i, batch_size)
+ print(sql_2)
# data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int, '002%', '300%', '%st%', i, batch_size])
- data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int, i, batch_size])
+ data = pd.read_sql(sql=sql_2, con=common.engine())
data = data.drop_duplicates(subset="code", keep="last")
- print("########data[latest_price]########:", len(data))
+ print("########data[last_price]########:", len(data))
stat_index_all(data, i)
# 分批执行。
def stat_index_all(data, idx):
- # print(data["latest_price"])
+ # print(data["last_price"])
# 1), n天涨跌百分百计算
# open price change (in percent) between today and the day before yesterday ‘r’ stands for rate.
# stock[‘close_-2_r’]
@@ -205,11 +136,15 @@ def stat_index_all(data, idx):
# http://wiki.mbalib.com/wiki/%E6%88%90%E4%BA%A4%E9%87%8F%E6%AF%94%E7%8E%87
# 成交量比率(Volumn Ratio,VR)(简称VR),是一项通过分析股价上升日成交额(或成交量,下同)与股价下降日成交额比值,
# 从而掌握市场买卖气势的中期技术指标。
-
- stock_column = ['adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
- 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
- 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'mdi', 'pdi',
- 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6']
+
+ #stock_column = ['adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
+ # 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
+ # 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'pdi',
+ # 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6']
+
+ stock_column = ['date','code', 'boll', 'boll_lb', 'boll_ub',
+ 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'pdi',
+ 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6']
# code cr cr-ma1 cr-ma2 cr-ma3 date
data_new = concat_guess_data(stock_column, data)
@@ -236,7 +171,7 @@ def concat_guess_data(stock_column, data):
elif col == 'code':
tmp_dic[col] = data["code"]
else:
- tmp_dic[col] = data["latest_price"]
+ tmp_dic[col] = data["last_price"]
# print("##########tmp_dic: ", tmp_dic)
print("########################## BEGIN ##########################")
stock_guess = pd.DataFrame(tmp_dic, index=data.index.values)
@@ -268,6 +203,7 @@ def apply_guess(tmp, stock_column):
# 设置返回数组。
stock_data_list = []
stock_name_list = []
+ print(f"stock_column : {stock_column}")
# 增加空判断,如果是空返回 0 数据。
if stock is None:
for col in stock_column:
@@ -285,14 +221,16 @@ def apply_guess(tmp, stock_column):
# print(stock.head())
# open high close low volume
# stock = pd.DataFrame({"close": stock["close"]}, index=stock.index.values)
- stock = stock.sort_index(0) # 将数据按照日期排序下。
+ # stock = stock.sort_index(0) # 将数据按照日期排序下。
stock["date"] = stock.index.values # 增加日期列。
- stock = stock.sort_index(0) # 将数据按照日期排序下。
+ print(f"stock: {stock}")
+ # stock = stock.sort_index(0) # 将数据按照日期排序下。
# print(stock) [186 rows x 14 columns]
# 初始化统计类
# stockStat = stockstats.StockDataFrame.retype(pd.read_csv('002032.csv'))
stockStat = stockstats.StockDataFrame.retype(stock)
+ print(f"stockStat : {stockStat}")
print("########################## print result ##########################")
for col in stock_column:
@@ -304,7 +242,12 @@ def apply_guess(tmp, stock_column):
stock_name_list.append('code')
else:
# 将数据的最后一个返回。
- tmp_val = stockStat[col].tail(1).values[0]
+ print(col)
+ print(stockStat[col])
+ print(stockStat[col].values[1])
+ #print(stockStat[col].head(1))
+
+ tmp_val = stockStat[col].values[1]
if np.isinf(tmp_val): # 解决值中存在INF问题。
tmp_val = 0
if np.isnan(tmp_val): # 解决值中存在NaN问题。
@@ -332,6 +275,4 @@ if __name__ == '__main__':
# 使用方法传递。
tmp_datetime = common.run_with_args(stat_all_batch)
# 二次筛选数据。直接计算买卖股票数据。
- tmp_datetime = common.run_with_args(stat_all_lite_buy)
- tmp_datetime = common.run_with_args(stat_all_lite_sell)
diff --git a/backend/jobs/guess_indicators_daily_sell_job.py b/backend/jobs/guess_indicators_daily_sell_job.py
new file mode 100644
index 0000000000000000000000000000000000000000..6b92886136de02e718f9469499d5b17b61bda47f
--- /dev/null
+++ b/backend/jobs/guess_indicators_daily_sell_job.py
@@ -0,0 +1,61 @@
+#!/usr/local/bin/python3
+# -*- coding: utf-8 -*-
+
+
+import libs.common as common
+import pandas as pd
+import numpy as np
+import math
+import datetime
+import stockstats
+from sqlalchemy import text
+
+# 设置卖出数据。
+def stat_all_lite_sell(tmp_datetime):
+ datetime_str = (tmp_datetime).strftime("%Y-%m-%d")
+ datetime_int = (tmp_datetime).strftime("%Y%m%d")
+ print("datetime_str:", datetime_str)
+ print("datetime_int:", datetime_int)
+
+ # 超卖区:K值在20以下,D值在30以下为超卖区。一般情况下,股价有可能上涨,反弹的可能性增大。局内人不应轻易抛出股票,局外人可寻机入场。
+ # J大于100时为超买,小于10时为超卖。
+ # 当六日强弱指标下降至20时,表示股市有超卖现象
+ # 当CCI<﹣100时,表明股价已经进入另一个非常态区间——超卖区间,投资者可以逢低吸纳股票。
+ sql_1 = text("""
+ SELECT `date`,`code`,`name`,`last_price`,`change_percent`,`change_amount`,`volume`,`turnover`,
+ `amplitude`,`high`,`low`,`open`,`closed`,`volume_ratio`,`turnover_rate`,
+ `pe_ratio`,`pb_ratio`,`market_cap`,`circulating_market_cap`,`rise_speed`,
+ `change_5min`,`change_ercent_60day`,`ytd_change_percent`,
+ `boll`, `boll_lb`, `boll_ub`, `kdjd`, `kdjj`, `kdjk`, `macd`, `macdh`,
+ `macds`, `pdi`,`trix`, `trix_9_sma`, `vr`, `vr_6_sma`, `wr_10`, `wr_6`
+ FROM stock_data.guess_indicators_daily WHERE `date` = :datetime
+ and kdjk <= 20 and kdjd <= 30 and kdjj <= 10
+ """)
+
+ try:
+ # 删除老数据。
+ del_sql = " DELETE FROM `stock_data`.`guess_indicators_lite_sell_daily` WHERE `date`= '%s' " % datetime_int
+ common.insert(del_sql)
+ except Exception as e:
+ print("error :", e)
+
+ # 查询参数
+ params = {"datetime": datetime_int}
+ print(sql_1)
+ data = pd.read_sql(sql=sql_1, con=common.engine(), params=params)
+ data = data.drop_duplicates(subset="code", keep="last")
+ print("######## stat_all_lite_sell len data ########:", len(data))
+
+ try:
+ common.insert_db(data, "guess_indicators_lite_sell_daily", False, "`date`,`code`")
+ except Exception as e:
+ print("error :", e)
+
+
+
+# main函数入口
+if __name__ == '__main__':
+ # 使用方法传递。
+ # 二次筛选数据。直接计算买卖股票数据。
+ tmp_datetime = common.run_with_args(stat_all_lite_sell)
+
diff --git a/jobs/guess_rsrs_daily_job.py b/backend/jobs/guess_rsrs_daily_job.py
similarity index 100%
rename from jobs/guess_rsrs_daily_job.py
rename to backend/jobs/guess_rsrs_daily_job.py
diff --git a/jobs/quarter_job.py b/backend/jobs/quarter_job.py
similarity index 100%
rename from jobs/quarter_job.py
rename to backend/jobs/quarter_job.py
diff --git a/jobs/restart_mnist_serving.sh b/backend/jobs/restart_mnist_serving.sh
similarity index 100%
rename from jobs/restart_mnist_serving.sh
rename to backend/jobs/restart_mnist_serving.sh
diff --git a/jobs/restart_web.sh b/backend/jobs/restart_web.sh
similarity index 100%
rename from jobs/restart_web.sh
rename to backend/jobs/restart_web.sh
diff --git a/jobs/run_init.sh b/backend/jobs/run_init.sh
similarity index 100%
rename from jobs/run_init.sh
rename to backend/jobs/run_init.sh
diff --git a/jobs/run_jupyter.sh b/backend/jobs/run_jupyter.sh
similarity index 100%
rename from jobs/run_jupyter.sh
rename to backend/jobs/run_jupyter.sh
diff --git a/jobs/run_web.sh b/backend/jobs/run_web.sh
similarity index 100%
rename from jobs/run_web.sh
rename to backend/jobs/run_web.sh
diff --git a/jobs/start_mariadb.sh b/backend/jobs/start_mariadb.sh
similarity index 100%
rename from jobs/start_mariadb.sh
rename to backend/jobs/start_mariadb.sh
diff --git a/jobs/test_akshare/test_stock_zh_a_daily.py b/backend/jobs/test_akshare/test_stock_zh_a_daily.py
similarity index 100%
rename from jobs/test_akshare/test_stock_zh_a_daily.py
rename to backend/jobs/test_akshare/test_stock_zh_a_daily.py
diff --git a/jobs/test_akshare/test_stock_zh_a_spot.py b/backend/jobs/test_akshare/test_stock_zh_a_spot.py
similarity index 100%
rename from jobs/test_akshare/test_stock_zh_a_spot.py
rename to backend/jobs/test_akshare/test_stock_zh_a_spot.py
diff --git a/jobs/test_akshare/test_stock_zh_index_spot.py b/backend/jobs/test_akshare/test_stock_zh_index_spot.py
similarity index 100%
rename from jobs/test_akshare/test_stock_zh_index_spot.py
rename to backend/jobs/test_akshare/test_stock_zh_index_spot.py
diff --git a/libs/common.py b/backend/libs/common.py
similarity index 81%
rename from libs/common.py
rename to backend/libs/common.py
index 5b03b14143ca6830d2d982532f5ee3ed9e9ff77a..3f2768926fc5feaa20b1cb939007ec5a68c0f0d8 100644
--- a/libs/common.py
+++ b/backend/libs/common.py
@@ -30,14 +30,16 @@ print("MYSQL_CONN_URL :", MYSQL_CONN_URL)
__version__ = "2.0.0"
# 每次发布时候更新。
+# https://docs.sqlalchemy.org/en/20/errors.html#error-e3q8
+#
def engine():
- engine = create_engine(MYSQL_CONN_URL)
+ engine = create_engine(MYSQL_CONN_URL, pool_size=10, max_overflow=20)
#encoding='utf8', convert_unicode=True)
return engine
def engine_to_db(to_db):
MYSQL_CONN_URL_NEW = "mysql+mysqldb://" + MYSQL_USER + ":" + MYSQL_PWD + "@" + MYSQL_HOST + ":" + MYSQL_PORT + "/" + to_db + "?charset=utf8mb4"
- engine = create_engine(MYSQL_CONN_URL_NEW)
+ engine = create_engine(MYSQL_CONN_URL_NEW, pool_size=10, max_overflow=20)
#encoding='utf8', convert_unicode=True)
return engine
@@ -195,13 +197,46 @@ def get_hist_data_cache(code, date_start, date_end):
print("######### read from cache #########", cache_file)
return pd.read_pickle(cache_file, compression="gzip")
else:
+ # https://akshare.akfamily.xyz/data/index/index.html#id4
+ # 获取历史行情,em
+ #stock = ak.stock_zh_a_hist(symbol= code, start_date=date_start,
+ # end_date=date_end, adjust="")
+ code = gp_type_szsh(code)+ code
print("######### get data, write cache #########", code, date_start, date_end)
- stock = ak.stock_zh_a_hist(symbol= code, start_date=date_start, end_date=date_end, adjust="")
- stock.columns = ['date', 'open', 'close', 'high', 'low', 'volume', 'amount', 'amplitude', 'quote_change',
- 'ups_downs', 'turnover']
- if stock is None:
+
+ stock = ak.stock_zh_index_daily_em(symbol= code,
+ start_date=date_start.replace("-", ""), end_date=date_end.replace("-", ""))
+ print(stock)
+ if stock is None or stock.empty:
return None
- stock = stock.sort_index(0) # 将数据按照日期排序下。
+
+ stock.columns = ['date', 'open', 'close', 'high', 'low', 'volume', 'amount']
+ # 数据返回的是带 0 列是索引,第一列是 date 日期
+ # date open close high low volume amount
+ # 0 2024-09-20 9.81 9.90 9.90 9.78 797297 7.851212e+08
+
+ stock.set_index('date', inplace=True)
+ #stock = stock.sort_index(0) # 将数据按照日期排序下。
print(stock)
stock.to_pickle(cache_file, compression="gzip")
return stock
+
+
+# 沪市股票包含上证主板和科创板和B股:沪市主板股票代码是60开头、科创板股票代码是688开头、B股代码900开头。
+# 深市股票包含主板、中小板、创业板和B股:深市主板股票代码是000开头、中小板股票代码002开头、创业板300开头、B股代码200开头
+# print(gp_type_szsh('002340'))
+#
+def gp_type_szsh(gp):
+ if gp.find('60',0,3)==0:
+ gp_type='sh'
+ elif gp.find('688',0,4)==0:
+ gp_type='sh'
+ elif gp.find('900',0,4)==0:
+ gp_type='sh'
+ elif gp.find('00',0,3)==0:
+ gp_type='sz'
+ elif gp.find('300',0,4)==0:
+ gp_type='sz'
+ elif gp.find('200',0,4)==0:
+ gp_type='sz'
+ return gp_type
diff --git a/libs/stock_web_dic.py b/backend/libs/stock_web_dic.py
similarity index 46%
rename from libs/stock_web_dic.py
rename to backend/libs/stock_web_dic.py
index 9609abff0484fe8e124709fcf5aeb3cb5d8f9ecf..3179c623eb40d7d0cb242a44a45603aeb4188903 100644
--- a/libs/stock_web_dic.py
+++ b/backend/libs/stock_web_dic.py
@@ -79,12 +79,26 @@ STOCK_WEB_DATA_LIST.append(
type="2,每日数据猜想",
name="股票指标lite猜想买入",
table_name="guess_indicators_lite_buy_daily",
- columns=['date', 'code', 'name', 'latest_price', 'quote_change', 'ups_downs', 'volume', 'turnover',
- 'amplitude', 'high', 'low', 'open', 'closed', 'quantity_ratio', 'turnover_rate', 'pe_dynamic', 'pb',
- 'kdjj', 'rsi_6', 'cci'],
- column_names=['日期', '代码', '名称', '最新价', '涨跌幅', '涨跌额', '成交量', '成交额',
- '振幅', '最高', '最低', '今开', '昨收', '量比', '换手率', '动态市盈率', '市净率',
- 'kdjj', 'rsi_6', 'cci'],
+ # columns=['date', 'code', 'name', 'latest_price', 'quote_change', 'ups_downs', 'volume', 'turnover',
+ # 'amplitude', 'high', 'low', 'open', 'closed', 'volume_ratio', 'turnover_rate', 'pe_dynamic', 'pb',
+ # 'kdjj', 'rsi_6', 'cci'],
+ # column_names=['日期', '代码', '名称', '最新价', '涨跌幅', '涨跌额', '成交量', '成交额',
+ # '振幅', '最高', '最低', '今开', '昨收', '量比', '换手率', '动态市盈率', '市净率',
+ # 'kdjj', 'rsi_6', 'cci'],
+ columns= ['date', 'code', 'name', 'last_price', 'change_percent', 'change_amount',
+ 'volume', 'turnover', 'amplitude', 'high', 'low', 'open', 'closed', 'volume_ratio',
+ 'turnover_rate', 'pe_ratio','pb_ratio', 'market_cap','circulating_market_cap','rise_speed',
+ 'change_5min', 'change_ercent_60day','ytd_change_percent',
+ 'boll', 'boll_lb', 'boll_ub', 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh',
+ 'macds', 'pdi','trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'] ,
+ # 中文说明前面和 1 数据一致。
+ column_names=['日期','代码','名称','最新价','涨跌幅','涨跌额','成交量','成交额',
+ '振幅','最高','最低','今开','昨收','量比','换手率','动态市盈率',
+ '市净率', '总市值', '流通市值', '涨速', '5分钟涨跌', '60日涨跌幅',
+ '年初至今涨跌幅',
+ 'boll', 'boll_lb', 'boll_ub',
+ 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'pdi',
+ 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
primary_key=[],
order_by=" buy_date desc "
)
@@ -97,12 +111,26 @@ STOCK_WEB_DATA_LIST.append(
type="2,每日数据猜想",
name="股票指标lite猜想卖出",
table_name="guess_indicators_lite_sell_daily",
- columns=['date', 'code', 'name', 'latest_price', 'quote_change', 'ups_downs', 'volume', 'turnover',
- 'amplitude', 'high', 'low', 'open', 'closed', 'quantity_ratio', 'turnover_rate', 'pe_dynamic', 'pb',
- 'kdjj', 'rsi_6', 'cci'],
- column_names=['日期', '代码', '名称', '最新价', '涨跌幅', '涨跌额', '成交量', '成交额',
- '振幅', '最高', '最低', '今开', '昨收', '量比', '换手率', '动态市盈率', '市净率',
- 'kdjj', 'rsi_6', 'cci'],
+ # columns=['date', 'code', 'name', 'latest_price', 'quote_change', 'ups_downs', 'volume', 'turnover',
+ # 'amplitude', 'high', 'low', 'open', 'closed', 'volume_ratio', 'turnover_rate', 'pe_dynamic', 'pb',
+ # 'kdjj', 'rsi_6', 'cci'],
+ # column_names=['日期', '代码', '名称', '最新价', '涨跌幅', '涨跌额', '成交量', '成交额',
+ # '振幅', '最高', '最低', '今开', '昨收', '量比', '换手率', '动态市盈率', '市净率',
+ # 'kdjj', 'rsi_6', 'cci'],
+ columns= ['date', 'code', 'name', 'last_price', 'change_percent', 'change_amount',
+ 'volume', 'turnover', 'amplitude', 'high', 'low', 'open', 'closed', 'volume_ratio',
+ 'turnover_rate', 'pe_ratio','pb_ratio', 'market_cap','circulating_market_cap','rise_speed',
+ 'change_5min', 'change_ercent_60day','ytd_change_percent',
+ 'boll', 'boll_lb', 'boll_ub', 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh',
+ 'macds', 'pdi','trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'] ,
+ # 中文说明前面和 1 数据一致。
+ column_names=['日期','代码','名称','最新价','涨跌幅','涨跌额','成交量','成交额',
+ '振幅','最高','最低','今开','昨收','量比','换手率','动态市盈率',
+ '市净率', '总市值', '流通市值', '涨速', '5分钟涨跌', '60日涨跌幅',
+ '年初至今涨跌幅',
+ 'boll', 'boll_lb', 'boll_ub',
+ 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'pdi',
+ 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
primary_key=[],
order_by=" buy_date desc "
)
@@ -115,16 +143,33 @@ STOCK_WEB_DATA_LIST.append(
type="2,每日数据猜想",
name="股票指标猜想原始数据",
table_name="guess_indicators_daily",
- columns=['date','code','name','latest_price','quote_change','ups_downs',
- 'adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
- 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
- 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'mdi', 'pdi',
- 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
- column_names=['日期','代码','名称','最新价','涨跌幅','涨跌额',
- 'adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
- 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
- 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'mdi', 'pdi',
- 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
+
+ columns= ['date', 'code', 'name', 'last_price', 'change_percent', 'change_amount',
+ 'volume', 'turnover', 'amplitude', 'high', 'low', 'open', 'closed', 'volume_ratio',
+ 'turnover_rate', 'pe_ratio','pb_ratio', 'market_cap','circulating_market_cap','rise_speed',
+ 'change_5min', 'change_ercent_60day','ytd_change_percent',
+ 'boll', 'boll_lb', 'boll_ub', 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh',
+ 'macds', 'pdi','trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'] ,
+ # 中文说明前面和 1 数据一致。
+ column_names=['日期','代码','名称','最新价','涨跌幅','涨跌额','成交量','成交额',
+ '振幅','最高','最低','今开','昨收','量比','换手率','动态市盈率',
+ '市净率', '总市值', '流通市值', '涨速', '5分钟涨跌', '60日涨跌幅',
+ '年初至今涨跌幅',
+ 'boll', 'boll_lb', 'boll_ub',
+ 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'pdi',
+ 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
+
+ # columns=['date','code','name','latest_price','quote_change','ups_downs',
+ # 'adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
+ # 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
+ # 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'mdi', 'pdi',
+ # 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
+ # column_names=['日期','代码','名称','最新价','涨跌幅','涨跌额',
+ # 'adx', 'adxr', 'boll', 'boll_lb', 'boll_ub', 'cci', 'cci_20', 'close_-1_r',
+ # 'close_-2_r', 'code', 'cr', 'cr-ma1', 'cr-ma2', 'cr-ma3', 'date', 'dma', 'dx',
+ # 'kdjd', 'kdjj', 'kdjk', 'macd', 'macdh', 'macds', 'mdi', 'pdi',
+ # 'rsi_12', 'rsi_6', 'trix', 'trix_9_sma', 'vr', 'vr_6_sma', 'wr_10', 'wr_6'],
+
primary_key=[],
order_by=' date desc '
)
@@ -138,12 +183,12 @@ STOCK_WEB_DATA_MAP = {}
WEB_EASTMONEY_URL = "http://quote.eastmoney.com/%s.html"
# 再拼接成Map使用。
for tmp in STOCK_WEB_DATA_LIST:
- try:
- # 增加columns 字段中的【查看股票】
- tmp_idx = tmp.columns.index("code")
- tmp.column_names.insert(tmp_idx + 1, "查看股票")
- except Exception as e:
- print("error :", e)
+ # try:
+ # # 增加columns 字段中的【查看股票】
+ # tmp_idx = tmp.columns.index("code")
+ # tmp.column_names.insert(tmp_idx + 1, "查看股票")
+ # except Exception as e:
+ # print("error :", e)
STOCK_WEB_DATA_MAP[tmp.table_name] = tmp
diff --git a/libs/stock_web_dic.py.bk b/backend/libs/stock_web_dic.py.bk
similarity index 100%
rename from libs/stock_web_dic.py.bk
rename to backend/libs/stock_web_dic.py.bk
diff --git a/old_jobs/README.md b/backend/old_jobs/README.md
similarity index 100%
rename from old_jobs/README.md
rename to backend/old_jobs/README.md
diff --git a/old_jobs/guess_indicators_lite_buy_daily_job.py b/backend/old_jobs/guess_indicators_lite_buy_daily_job.py
similarity index 100%
rename from old_jobs/guess_indicators_lite_buy_daily_job.py
rename to backend/old_jobs/guess_indicators_lite_buy_daily_job.py
diff --git a/old_jobs/guess_indicators_lite_sell_daily_job.py b/backend/old_jobs/guess_indicators_lite_sell_daily_job.py
similarity index 100%
rename from old_jobs/guess_indicators_lite_sell_daily_job.py
rename to backend/old_jobs/guess_indicators_lite_sell_daily_job.py
diff --git a/old_jobs/guess_period_daily_job.py b/backend/old_jobs/guess_period_daily_job.py
similarity index 100%
rename from old_jobs/guess_period_daily_job.py
rename to backend/old_jobs/guess_period_daily_job.py
diff --git a/old_jobs/guess_return_daily_job.py b/backend/old_jobs/guess_return_daily_job.py
similarity index 100%
rename from old_jobs/guess_return_daily_job.py
rename to backend/old_jobs/guess_return_daily_job.py
diff --git a/old_jobs/guess_sklearn_ma_daily_job.py b/backend/old_jobs/guess_sklearn_ma_daily_job.py
similarity index 100%
rename from old_jobs/guess_sklearn_ma_daily_job.py
rename to backend/old_jobs/guess_sklearn_ma_daily_job.py
diff --git a/supervisor/example_supervisord_conf b/backend/supervisor/example_supervisord_conf
similarity index 100%
rename from supervisor/example_supervisord_conf
rename to backend/supervisor/example_supervisord_conf
diff --git a/supervisor/supervisord.conf b/backend/supervisor/supervisord.conf
similarity index 100%
rename from supervisor/supervisord.conf
rename to backend/supervisor/supervisord.conf
diff --git a/web/README.md b/backend/web/README.md
similarity index 100%
rename from web/README.md
rename to backend/web/README.md
diff --git a/web/base.py b/backend/web/base.py
similarity index 39%
rename from web/base.py
rename to backend/web/base.py
index 0c249f4b4aa45f5261ca383034245b5aaf435672..8c8700aecdf91a4552480e67290d125c5ae14604 100755
--- a/web/base.py
+++ b/backend/web/base.py
@@ -4,9 +4,28 @@
import tornado.web
import libs.stock_web_dic as stock_web_dic
import libs.common as common
+import logging
#基础handler,主要负责检查mysql的数据库链接。
class BaseHandler(tornado.web.RequestHandler):
+ def set_default_headers(self):
+ headers = self.request.headers
+ # logging.info('head的类型:',type(headers))
+ origin = headers.get('origin',None)
+ logging.info("######################## BaseHandler ########################")
+ logging.info(origin)
+
+ if origin != None and origin.find("localhost") > 0:
+ self.set_header("Access-Control-Allow-Credentials", "true")
+ self.set_header("Access-Control-Allow-Origin",origin)
+ self.set_header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS")
+ self.set_header("Access-Control-Allow-Headers", "x-token, authorization, Authorization, Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Headers, X-Requested-By, Access-Control-Allow-Methods")
+ self.set_header("Access-Control-Expose-Headers", "Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma")
+ # 同时定义一个option方法
+ def options(self):
+ self.set_status(204)
+ self.finish()
+
@property
def db(self):
try:
diff --git a/web/chartHandler.py b/backend/web/chartHandler.py
similarity index 100%
rename from web/chartHandler.py
rename to backend/web/chartHandler.py
diff --git a/web/dataEditorHandler.py b/backend/web/dataEditorHandler.py
similarity index 100%
rename from web/dataEditorHandler.py
rename to backend/web/dataEditorHandler.py
diff --git a/web/dataIndicatorsHandler.py b/backend/web/dataIndicatorsHandler.py
similarity index 100%
rename from web/dataIndicatorsHandler.py
rename to backend/web/dataIndicatorsHandler.py
diff --git a/web/dataTableHandler.py b/backend/web/dataTableHandler.py
similarity index 61%
rename from web/dataTableHandler.py
rename to backend/web/dataTableHandler.py
index c65e30989ef384c50f7e4336c2abf19dd7c23e3f..2b4d47c719f741f3b72d3e563835d3d1402cb7c2 100755
--- a/web/dataTableHandler.py
+++ b/backend/web/dataTableHandler.py
@@ -29,12 +29,12 @@ WEB_EASTMONEY_URL = u"""
eastmoney_name = "查看股票"
-# 获得页面数据。
+# 获得页面数据,进入页面中。
class GetStockHtmlHandler(webBase.BaseHandler):
@gen.coroutine
def get(self):
name = self.get_argument("table_name", default=None, strip=False)
- stockWeb = stock_web_dic.STOCK_WEB_DATA_MAP[name]
+ tableInfo = stock_web_dic.STOCK_WEB_DATA_MAP[name]
# self.uri_ = ("self.request.url:", self.request.uri)
# print self.uri_
date_now = datetime.datetime.now()
@@ -43,22 +43,22 @@ class GetStockHtmlHandler(webBase.BaseHandler):
if date_now.hour < 16:
date_now_str = (date_now + datetime.timedelta(days=-1)).strftime("%Y%m%d")
- try:
- # 增加columns 字段中的【查看股票 东方财富】
- logging.info(eastmoney_name in stockWeb.column_names)
- if eastmoney_name in stockWeb.column_names:
- tmp_idx = stockWeb.column_names.index(eastmoney_name)
- logging.info(tmp_idx)
- try:
- # 防止重复插入数据。可能会报错。
- stockWeb.columns.remove("eastmoney_url")
- except Exception as e:
- print("error :", e)
- stockWeb.columns.insert(tmp_idx, "eastmoney_url")
- except Exception as e:
- print("error :", e)
+ # try:
+ # # 增加columns 字段中的【查看股票 东方财富】
+ # logging.info(eastmoney_name in tableInfo.column_names)
+ # if eastmoney_name in tableInfo.column_names:
+ # tmp_idx = tableInfo.column_names.index(eastmoney_name)
+ # logging.info(tmp_idx)
+ # try:
+ # # 防止重复插入数据。可能会报错。
+ # tableInfo.columns.remove("eastmoney_url")
+ # except Exception as e:
+ # print("error :", e)
+ # tableInfo.columns.insert(tmp_idx, "eastmoney_url")
+ # except Exception as e:
+ # print("error :", e)
logging.info("####################GetStockHtmlHandlerEnd")
- self.render("stock_web.html", stockWeb=stockWeb, date_now=date_now_str,
+ self.render("tableInfo.html", tableInfo=tableInfo, date_now=date_now_str,
pythonStockVersion=common.__version__,
leftMenu=webBase.GetLeftMenu(self.request.uri))
@@ -67,18 +67,36 @@ class GetStockHtmlHandler(webBase.BaseHandler):
class GetStockDataHandler(webBase.BaseHandler):
def get(self):
+ self.set_header('Content-Type', 'application/json;charset=UTF-8')
+
+ logging.info("######################## GetStockDataHandler ########################")
# 获得分页参数。
- start_param = self.get_argument("start", default=0, strip=False)
- length_param = self.get_argument("length", default=10, strip=False)
- print("page param:", length_param, start_param)
+ page_param = self.get_argument("page", default=0, strip=False)
+ limit_param = self.get_argument("limit", default=10, strip=False)
- name_param = self.get_argument("name", default=None, strip=False)
+ name_param = self.get_argument("name", default="stock_zh_ah_name", strip=False)
type_param = self.get_argument("type", default=None, strip=False)
+ date_param = self.get_argument("date", default=None, strip=False)
- stock_web = stock_web_dic.STOCK_WEB_DATA_MAP[name_param]
+ logging.info(f"page param: {page_param}, {limit_param}, {type_param}, {date_param}")
- # https://datatables.net/manual/server-side
- self.set_header('Content-Type', 'application/json;charset=UTF-8')
+
+ if name_param == ":tableName":
+ obj = {
+ "code": 20000,
+ "message": "success",
+ "draw": 0,
+ "data": []
+ }
+ # logging.info("####################")
+ # logging.info(obj)
+ self.write(json.dumps(obj))
+ return
+
+
+ tableInfo = stock_web_dic.STOCK_WEB_DATA_MAP[name_param]
+
+
order_by_column = []
order_by_dir = []
# 支持多排序。使用shift+鼠标左键。
@@ -104,12 +122,15 @@ class GetStockDataHandler(webBase.BaseHandler):
# 找到字符串
str_val = val[0].decode("utf-8")
if str_val != "": # 字符串。
- search_by_column.append(stock_web.columns[int_idx])
+ search_by_column.append(tableInfo.columns[int_idx])
search_by_data.append(val[0].decode("utf-8")) # bytes转换字符串
# 打印日志。
search_sql = ""
search_idx = 0
+
+ logging.info("################# search_by_column #################")
+
logging.info(search_by_column)
logging.info(search_by_data)
for item in search_by_column:
@@ -122,7 +143,12 @@ class GetStockDataHandler(webBase.BaseHandler):
search_sql = search_sql + " AND `%s` = '%s' " % (item, val)
search_idx = search_idx + 1
- # print("stockWeb :", stock_web)
+ if date_param:
+ if "WHERE" not in search_sql:
+ search_sql += f" WHERE `date` = '{date_param}' "
+ else:
+ search_sql += f" AND `date` = '{date_param}' "
+ # print("tableInfo :", stock_web)
order_by_sql = ""
# 增加排序。
if len(order_by_column) != 0 and len(order_by_dir) != 0:
@@ -130,7 +156,7 @@ class GetStockDataHandler(webBase.BaseHandler):
idx = 0
for key in order_by_column:
# 找到排序字段和dir。
- col_tmp = stock_web.columns[key]
+ col_tmp = tableInfo.columns[key]
dir_tmp = order_by_dir[idx]
if idx != 0:
order_by_sql += " ,cast(`%s` as decimal) %s" % (col_tmp, dir_tmp)
@@ -139,48 +165,48 @@ class GetStockDataHandler(webBase.BaseHandler):
idx += 1
# 查询数据库。
limit_sql = ""
- if int(length_param) > 0:
- limit_sql = " LIMIT %s , %s " % (start_param, length_param)
+ if int(limit_param) > 0:
+ start = ( int(page_param) - 1 ) * int(limit_param)
+ limit_sql = f" LIMIT {start} , {limit_param} "
sql = " SELECT * FROM `%s` %s %s %s " % (
- stock_web.table_name, search_sql, order_by_sql, limit_sql)
- count_sql = " SELECT count(1) as num FROM `%s` %s " % (stock_web.table_name, search_sql)
+ tableInfo.table_name, search_sql, order_by_sql, limit_sql)
+ count_sql = " SELECT count(1) as num FROM `%s` %s " % (tableInfo.table_name, search_sql)
logging.info("select sql : " + sql)
logging.info("count sql : " + count_sql)
stock_web_list = self.db.query(sql)
- for tmp_obj in (stock_web_list):
- logging.info("####################")
- if type_param == "editor":
- tmp_obj["DT_RowId"] = tmp_obj[stock_web.columns[0]]
- # logging.info(tmp_obj)
- try:
- # 增加columns 字段中的【东方财富】
- logging.info("eastmoney_name : %s " % eastmoney_name)
- if eastmoney_name in stock_web.column_names:
- tmp_idx = stock_web.column_names.index(eastmoney_name)
-
- code_tmp = tmp_obj["code"]
- # 判断上海还是 深圳,东方财富 接口要求。
- if code_tmp.startswith("6"):
- code_tmp = "SH" + code_tmp
- else:
- code_tmp = "SZ" + code_tmp
-
- tmp_url = WEB_EASTMONEY_URL % (tmp_obj["code"], tmp_obj["code"], code_tmp)
- tmp_obj["eastmoney_url"] = tmp_url
- logging.info(tmp_idx)
- logging.info(tmp_obj["eastmoney_url"])
- # logging.info(type(tmp_obj))
- # tmp.column_names.insert(tmp_idx, eastmoney_name)
- except Exception as e:
- print("error :", e)
-
stock_web_size = self.db.query(count_sql)
- logging.info("stockWebList size : %s " % stock_web_size)
+ logging.info("tableInfoList size : %s " % stock_web_size)
+
+ # 动态表格展示:
+ table_columns = []
+ try:
+ tmp_len = len(tableInfo.columns)
+ logging.info("ableInfo.columns tmp_len : %s " % tmp_len)
+ # 循环数据,转换成对象,放入到数组中,方便前端 vue table 循环使用。
+ for tmp_idx in range(0, tmp_len):
+ logging.info(tmp_idx)
+
+ column = tableInfo.columns[tmp_idx]
+ column_name = tableInfo.column_names[tmp_idx]
+
+ tpm_column_obj = {
+ "column": column,
+ "columnName" : column_name
+ }
+ table_columns.append(tpm_column_obj)
+
+ except Exception as e:
+ print("error :", e)
obj = {
+ "code": 20000,
+ "message": "success",
"draw": 0,
+ "tableName" : tableInfo.name,
+ "tableColumns": table_columns,
+ "total": stock_web_size[0]["num"],
"recordsTotal": stock_web_size[0]["num"],
"recordsFiltered": stock_web_size[0]["num"],
"data": stock_web_list
diff --git a/web/demo-chart.py b/backend/web/demo-chart.py
similarity index 99%
rename from web/demo-chart.py
rename to backend/web/demo-chart.py
index 165ed6a2b141e8ab30ba39340f36843307f5a532..12bef64c47d24385e62f77055ebdd348e9fc1d13 100644
--- a/web/demo-chart.py
+++ b/backend/web/demo-chart.py
@@ -238,7 +238,7 @@ if __name__ == "__main__":
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(9999)
- print("http://127.0.0.1:9999/")
+ print("http://127.0.0.1:9090/")
print("Press Ctrl+C to quit")
tornado.ioloop.IOLoop.instance().start()
diff --git a/web/main.py b/backend/web/main.py
similarity index 55%
rename from web/main.py
rename to backend/web/main.py
index d32af45fed27b945aedd9d8b0e19416b8d963cbf..bef8cfb0e81643c9ed35bd05871ec9d1f7199bbb 100755
--- a/web/main.py
+++ b/backend/web/main.py
@@ -18,6 +18,8 @@ import pandas as pd
import numpy as np
import akshare as ak
import bokeh as bh
+import sqlalchemy
+import json
class Application(tornado.web.Application):
def __init__(self):
@@ -25,16 +27,18 @@ class Application(tornado.web.Application):
# 设置路由
(r"/", HomeHandler),
(r"/stock/", HomeHandler),
+ (r"/api/v1/package_verison", PackageVersionHandler),# 包版本
+ (r"/api/v1/menu_list", MenuListHandler), # 菜单接口
(r"/test_akshare", TestHandler),# 测试页面,做写js 测试。
(r"/test2", Test2Handler),# 测试页面,做写js 测试。
# 使用datatable 展示报表数据模块。
- (r"/stock/api_data", dataTableHandler.GetStockDataHandler),
+ (r"/api/v1/api_data", dataTableHandler.GetStockDataHandler),
(r"/stock/data", dataTableHandler.GetStockHtmlHandler),
# 数据修改dataEditor。
(r"/data/editor", dataEditorHandler.GetEditorHtmlHandler),
(r"/data/editor/save", dataEditorHandler.SaveEditorHandler),
# 获得股票指标数据。
- (r"/stock/data/indicators", dataIndicatorsHandler.GetDataIndicatorsHandler),
+ (r"/api/v1/data/indicators", dataIndicatorsHandler.GetDataIndicatorsHandler),
]
settings = dict( # 配置
template_path=os.path.join(os.path.dirname(__file__), "templates"),
@@ -43,6 +47,7 @@ class Application(tornado.web.Application):
# cookie加密
cookie_secret="027bb1b670eddf0392cdda8709268a17b58b7",
debug=True,
+ default_encoding="utf-8",
)
super(Application, self).__init__(handlers, **settings)
# Have one global connection to the blog DB across all handlers
@@ -52,6 +57,80 @@ class Application(tornado.web.Application):
user=common.MYSQL_USER, password=common.MYSQL_PWD)
+# 获得包版本 handler。
+class PackageVersionHandler(webBase.BaseHandler):
+ @gen.coroutine
+ def get(self):
+ pandasVersion = pd.__version__
+ numpyVersion = np.__version__
+ sqlalchemyVersion = sqlalchemy.__version__
+ akshareVersion = ak.__version__
+ bokehVersion = bh.__version__
+ # 返回包的版本信息。
+ obj = {
+ "code": 20000,
+ "message": "success",
+ "pandasVersion" : pandasVersion,
+ "numpyVersion" : numpyVersion,
+ "sqlalchemyVersion" : sqlalchemyVersion,
+ "akshareVersion" : akshareVersion,
+ "bokehVersion" : bokehVersion,
+ "stockstatsVersion": "0.3.2"
+ }
+ # logging.info("####################")
+ # logging.info(obj)
+ self.write(json.dumps(obj))
+
+
+# 获得菜单列表数据 handler。
+class MenuListHandler(webBase.BaseHandler):
+ @gen.coroutine
+ def get(self):
+
+ leftMenuList = stock_web_dic.STOCK_WEB_DATA_LIST
+ out_data = []
+ menu_name = ''
+ menu_children = []
+ index = 0
+ for table_info in leftMenuList:
+ print(table_info.name)
+ index = index + 1
+ # 使用 children 作为二级菜单。
+ tmp_menu = {
+ "name": table_info.name,
+ "path": "/stock/table/" + table_info.table_name
+ }
+ menu_children.append(tmp_menu)
+
+ # 使用 type作为 一级目录
+ if menu_name != table_info.type or index == len(leftMenuList):
+ # 进行数据循环
+ if menu_name != '' :
+ if index != len(leftMenuList):
+ menu_children.pop() # 删除当前的节点信息。
+ tmp_children = list(menu_children)
+ tmp_menu2 = {
+ "name": menu_name,
+ "path": "#",
+ "children": tmp_children
+ }
+ # 下一个数据清空和放置。
+ menu_children = []
+ menu_children.append(tmp_menu)
+
+ out_data.append(tmp_menu2)
+ menu_name = table_info.type
+
+ obj = {
+ "code": 20000,
+ "message": "success",
+ "data": out_data
+ }
+ print(out_data)
+ # self.write(json.dumps(o
+ self.write(json.dumps(obj))
+
+
# 首页handler。
class HomeHandler(webBase.BaseHandler):
@gen.coroutine
@@ -84,7 +163,7 @@ class Test2Handler(webBase.BaseHandler):
def main():
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
- port = 9999
+ port = 9090
http_server.listen(port)
# tornado.options.options.logging = "debug"
tornado.options.parse_command_line()
diff --git a/web/minstServingHandler.py b/backend/web/minstServingHandler.py
similarity index 100%
rename from web/minstServingHandler.py
rename to backend/web/minstServingHandler.py
diff --git a/web/static/css/ace.min.css b/backend/web/static/css/ace.min.css
similarity index 100%
rename from web/static/css/ace.min.css
rename to backend/web/static/css/ace.min.css
diff --git a/web/static/css/bokeh-tables.min.css b/backend/web/static/css/bokeh-tables.min.css
similarity index 100%
rename from web/static/css/bokeh-tables.min.css
rename to backend/web/static/css/bokeh-tables.min.css
diff --git a/web/static/css/bokeh-widgets.min.css b/backend/web/static/css/bokeh-widgets.min.css
similarity index 100%
rename from web/static/css/bokeh-widgets.min.css
rename to backend/web/static/css/bokeh-widgets.min.css
diff --git a/web/static/css/bokeh.min.css b/backend/web/static/css/bokeh.min.css
similarity index 100%
rename from web/static/css/bokeh.min.css
rename to backend/web/static/css/bokeh.min.css
diff --git a/web/static/css/bootstrap-colorpicker.min.css b/backend/web/static/css/bootstrap-colorpicker.min.css
similarity index 100%
rename from web/static/css/bootstrap-colorpicker.min.css
rename to backend/web/static/css/bootstrap-colorpicker.min.css
diff --git a/web/static/css/bootstrap-datepicker3.min.css b/backend/web/static/css/bootstrap-datepicker3.min.css
similarity index 100%
rename from web/static/css/bootstrap-datepicker3.min.css
rename to backend/web/static/css/bootstrap-datepicker3.min.css
diff --git a/web/static/css/bootstrap-datetimepicker.min.css b/backend/web/static/css/bootstrap-datetimepicker.min.css
similarity index 100%
rename from web/static/css/bootstrap-datetimepicker.min.css
rename to backend/web/static/css/bootstrap-datetimepicker.min.css
diff --git a/web/static/css/bootstrap-timepicker.min.css b/backend/web/static/css/bootstrap-timepicker.min.css
similarity index 100%
rename from web/static/css/bootstrap-timepicker.min.css
rename to backend/web/static/css/bootstrap-timepicker.min.css
diff --git a/web/static/css/bootstrap.min.css b/backend/web/static/css/bootstrap.min.css
similarity index 100%
rename from web/static/css/bootstrap.min.css
rename to backend/web/static/css/bootstrap.min.css
diff --git a/web/static/css/buttons.dataTables.min.css b/backend/web/static/css/buttons.dataTables.min.css
similarity index 100%
rename from web/static/css/buttons.dataTables.min.css
rename to backend/web/static/css/buttons.dataTables.min.css
diff --git a/web/static/css/chosen.min.css b/backend/web/static/css/chosen.min.css
similarity index 100%
rename from web/static/css/chosen.min.css
rename to backend/web/static/css/chosen.min.css
diff --git a/web/static/css/daterangepicker.min.css b/backend/web/static/css/daterangepicker.min.css
similarity index 100%
rename from web/static/css/daterangepicker.min.css
rename to backend/web/static/css/daterangepicker.min.css
diff --git a/web/static/css/editor.dataTables.min.css b/backend/web/static/css/editor.dataTables.min.css
similarity index 100%
rename from web/static/css/editor.dataTables.min.css
rename to backend/web/static/css/editor.dataTables.min.css
diff --git a/web/static/css/font-awesome.min.css b/backend/web/static/css/font-awesome.min.css
similarity index 100%
rename from web/static/css/font-awesome.min.css
rename to backend/web/static/css/font-awesome.min.css
diff --git a/web/static/css/fonts.googleapis.com.css b/backend/web/static/css/fonts.googleapis.com.css
similarity index 100%
rename from web/static/css/fonts.googleapis.com.css
rename to backend/web/static/css/fonts.googleapis.com.css
diff --git a/web/static/css/jquery-ui.custom.min.css b/backend/web/static/css/jquery-ui.custom.min.css
similarity index 100%
rename from web/static/css/jquery-ui.custom.min.css
rename to backend/web/static/css/jquery-ui.custom.min.css
diff --git a/web/static/css/jquery-ui.min.css b/backend/web/static/css/jquery-ui.min.css
similarity index 100%
rename from web/static/css/jquery-ui.min.css
rename to backend/web/static/css/jquery-ui.min.css
diff --git a/web/static/css/select.dataTables.min.css b/backend/web/static/css/select.dataTables.min.css
similarity index 100%
rename from web/static/css/select.dataTables.min.css
rename to backend/web/static/css/select.dataTables.min.css
diff --git a/web/static/font-awesome/4.5.0/css/font-awesome.min.css b/backend/web/static/font-awesome/4.5.0/css/font-awesome.min.css
similarity index 100%
rename from web/static/font-awesome/4.5.0/css/font-awesome.min.css
rename to backend/web/static/font-awesome/4.5.0/css/font-awesome.min.css
diff --git a/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.ttf b/backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.ttf
similarity index 100%
rename from web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.ttf
rename to backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.ttf
diff --git a/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff b/backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff
similarity index 100%
rename from web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff
rename to backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff
diff --git a/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff2 b/backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff2
similarity index 100%
rename from web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff2
rename to backend/web/static/font-awesome/4.5.0/fonts/fontawesome-webfont.woff2
diff --git a/web/static/font-awesome/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff b/backend/web/static/font-awesome/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff
similarity index 100%
rename from web/static/font-awesome/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff
rename to backend/web/static/font-awesome/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff
diff --git a/web/static/font-awesome/opensans/v13/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff b/backend/web/static/font-awesome/opensans/v13/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff
similarity index 100%
rename from web/static/font-awesome/opensans/v13/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff
rename to backend/web/static/font-awesome/opensans/v13/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff
diff --git a/web/static/img/diff-n-bokeh.png b/backend/web/static/img/diff-n-bokeh.png
similarity index 100%
rename from web/static/img/diff-n-bokeh.png
rename to backend/web/static/img/diff-n-bokeh.png
diff --git a/web/static/img/stock-show-01.jpg b/backend/web/static/img/stock-show-01.jpg
similarity index 100%
rename from web/static/img/stock-show-01.jpg
rename to backend/web/static/img/stock-show-01.jpg
diff --git a/web/static/img/stock2-001.png b/backend/web/static/img/stock2-001.png
similarity index 100%
rename from web/static/img/stock2-001.png
rename to backend/web/static/img/stock2-001.png
diff --git a/web/static/img/stock2-002.png b/backend/web/static/img/stock2-002.png
similarity index 100%
rename from web/static/img/stock2-002.png
rename to backend/web/static/img/stock2-002.png
diff --git a/web/static/img/stock2-003.png b/backend/web/static/img/stock2-003.png
similarity index 100%
rename from web/static/img/stock2-003.png
rename to backend/web/static/img/stock2-003.png
diff --git "a/web/static/img/\346\224\257\344\273\230\345\256\235--\345\276\256\344\277\241\346\224\257\344\273\230.jpg" "b/backend/web/static/img/\346\224\257\344\273\230\345\256\235--\345\276\256\344\277\241\346\224\257\344\273\230.jpg"
similarity index 100%
rename from "web/static/img/\346\224\257\344\273\230\345\256\235--\345\276\256\344\277\241\346\224\257\344\273\230.jpg"
rename to "backend/web/static/img/\346\224\257\344\273\230\345\256\235--\345\276\256\344\277\241\346\224\257\344\273\230.jpg"
diff --git a/web/static/js/ace-elements.min.js b/backend/web/static/js/ace-elements.min.js
similarity index 100%
rename from web/static/js/ace-elements.min.js
rename to backend/web/static/js/ace-elements.min.js
diff --git a/web/static/js/ace-extra.min.js b/backend/web/static/js/ace-extra.min.js
similarity index 100%
rename from web/static/js/ace-extra.min.js
rename to backend/web/static/js/ace-extra.min.js
diff --git a/web/static/js/ace.min.js b/backend/web/static/js/ace.min.js
similarity index 100%
rename from web/static/js/ace.min.js
rename to backend/web/static/js/ace.min.js
diff --git a/web/static/js/autosize.min.js b/backend/web/static/js/autosize.min.js
similarity index 100%
rename from web/static/js/autosize.min.js
rename to backend/web/static/js/autosize.min.js
diff --git a/web/static/js/bokeh-api.min.js b/backend/web/static/js/bokeh-api.min.js
similarity index 100%
rename from web/static/js/bokeh-api.min.js
rename to backend/web/static/js/bokeh-api.min.js
diff --git a/web/static/js/bokeh-gl.min.js b/backend/web/static/js/bokeh-gl.min.js
similarity index 100%
rename from web/static/js/bokeh-gl.min.js
rename to backend/web/static/js/bokeh-gl.min.js
diff --git a/web/static/js/bokeh-tables.min.js b/backend/web/static/js/bokeh-tables.min.js
similarity index 100%
rename from web/static/js/bokeh-tables.min.js
rename to backend/web/static/js/bokeh-tables.min.js
diff --git a/web/static/js/bokeh-widgets.min.js b/backend/web/static/js/bokeh-widgets.min.js
similarity index 100%
rename from web/static/js/bokeh-widgets.min.js
rename to backend/web/static/js/bokeh-widgets.min.js
diff --git a/web/static/js/bokeh.min.js b/backend/web/static/js/bokeh.min.js
similarity index 100%
rename from web/static/js/bokeh.min.js
rename to backend/web/static/js/bokeh.min.js
diff --git a/web/static/js/bootbox.js b/backend/web/static/js/bootbox.js
similarity index 100%
rename from web/static/js/bootbox.js
rename to backend/web/static/js/bootbox.js
diff --git a/web/static/js/bootstrap-datepicker.min.js b/backend/web/static/js/bootstrap-datepicker.min.js
similarity index 100%
rename from web/static/js/bootstrap-datepicker.min.js
rename to backend/web/static/js/bootstrap-datepicker.min.js
diff --git a/web/static/js/bootstrap-datepicker.zh-CN.js b/backend/web/static/js/bootstrap-datepicker.zh-CN.js
similarity index 100%
rename from web/static/js/bootstrap-datepicker.zh-CN.js
rename to backend/web/static/js/bootstrap-datepicker.zh-CN.js
diff --git a/web/static/js/bootstrap-datetimepicker.min.js b/backend/web/static/js/bootstrap-datetimepicker.min.js
similarity index 100%
rename from web/static/js/bootstrap-datetimepicker.min.js
rename to backend/web/static/js/bootstrap-datetimepicker.min.js
diff --git a/web/static/js/bootstrap-timepicker.min.js b/backend/web/static/js/bootstrap-timepicker.min.js
similarity index 100%
rename from web/static/js/bootstrap-timepicker.min.js
rename to backend/web/static/js/bootstrap-timepicker.min.js
diff --git a/web/static/js/bootstrap.min.js b/backend/web/static/js/bootstrap.min.js
similarity index 100%
rename from web/static/js/bootstrap.min.js
rename to backend/web/static/js/bootstrap.min.js
diff --git a/web/static/js/buttons.colVis.min.js b/backend/web/static/js/buttons.colVis.min.js
similarity index 100%
rename from web/static/js/buttons.colVis.min.js
rename to backend/web/static/js/buttons.colVis.min.js
diff --git a/web/static/js/buttons.html5.min.js b/backend/web/static/js/buttons.html5.min.js
similarity index 100%
rename from web/static/js/buttons.html5.min.js
rename to backend/web/static/js/buttons.html5.min.js
diff --git a/web/static/js/buttons.print.min.js b/backend/web/static/js/buttons.print.min.js
similarity index 100%
rename from web/static/js/buttons.print.min.js
rename to backend/web/static/js/buttons.print.min.js
diff --git a/web/static/js/chosen.jquery.min.js b/backend/web/static/js/chosen.jquery.min.js
similarity index 100%
rename from web/static/js/chosen.jquery.min.js
rename to backend/web/static/js/chosen.jquery.min.js
diff --git a/web/static/js/dataTables.buttons.min.js b/backend/web/static/js/dataTables.buttons.min.js
similarity index 100%
rename from web/static/js/dataTables.buttons.min.js
rename to backend/web/static/js/dataTables.buttons.min.js
diff --git a/web/static/js/dataTables.editor.min.js b/backend/web/static/js/dataTables.editor.min.js
similarity index 100%
rename from web/static/js/dataTables.editor.min.js
rename to backend/web/static/js/dataTables.editor.min.js
diff --git a/web/static/js/dataTables.select.min.js b/backend/web/static/js/dataTables.select.min.js
similarity index 100%
rename from web/static/js/dataTables.select.min.js
rename to backend/web/static/js/dataTables.select.min.js
diff --git a/web/static/js/datatables.Chinese.json b/backend/web/static/js/datatables.Chinese.json
similarity index 100%
rename from web/static/js/datatables.Chinese.json
rename to backend/web/static/js/datatables.Chinese.json
diff --git a/web/static/js/daterangepicker.min.js b/backend/web/static/js/daterangepicker.min.js
similarity index 100%
rename from web/static/js/daterangepicker.min.js
rename to backend/web/static/js/daterangepicker.min.js
diff --git a/web/static/js/draw.js b/backend/web/static/js/draw.js
similarity index 100%
rename from web/static/js/draw.js
rename to backend/web/static/js/draw.js
diff --git a/web/static/js/grid.locale-en.js b/backend/web/static/js/grid.locale-en.js
similarity index 100%
rename from web/static/js/grid.locale-en.js
rename to backend/web/static/js/grid.locale-en.js
diff --git a/web/static/js/holder.min.js b/backend/web/static/js/holder.min.js
similarity index 100%
rename from web/static/js/holder.min.js
rename to backend/web/static/js/holder.min.js
diff --git a/web/static/js/jquery-2.1.4.min.js b/backend/web/static/js/jquery-2.1.4.min.js
similarity index 100%
rename from web/static/js/jquery-2.1.4.min.js
rename to backend/web/static/js/jquery-2.1.4.min.js
diff --git a/web/static/js/jquery-ui.custom.min.js b/backend/web/static/js/jquery-ui.custom.min.js
similarity index 100%
rename from web/static/js/jquery-ui.custom.min.js
rename to backend/web/static/js/jquery-ui.custom.min.js
diff --git a/web/static/js/jquery-ui.min.js b/backend/web/static/js/jquery-ui.min.js
similarity index 100%
rename from web/static/js/jquery-ui.min.js
rename to backend/web/static/js/jquery-ui.min.js
diff --git a/web/static/js/jquery.colorbox.min.js b/backend/web/static/js/jquery.colorbox.min.js
similarity index 100%
rename from web/static/js/jquery.colorbox.min.js
rename to backend/web/static/js/jquery.colorbox.min.js
diff --git a/web/static/js/jquery.dataTables.bootstrap.min.js b/backend/web/static/js/jquery.dataTables.bootstrap.min.js
similarity index 100%
rename from web/static/js/jquery.dataTables.bootstrap.min.js
rename to backend/web/static/js/jquery.dataTables.bootstrap.min.js
diff --git a/web/static/js/jquery.dataTables.min.js b/backend/web/static/js/jquery.dataTables.min.js
similarity index 100%
rename from web/static/js/jquery.dataTables.min.js
rename to backend/web/static/js/jquery.dataTables.min.js
diff --git a/web/static/js/jquery.validate.min.js b/backend/web/static/js/jquery.validate.min.js
similarity index 100%
rename from web/static/js/jquery.validate.min.js
rename to backend/web/static/js/jquery.validate.min.js
diff --git a/web/static/js/moment.min.js b/backend/web/static/js/moment.min.js
similarity index 100%
rename from web/static/js/moment.min.js
rename to backend/web/static/js/moment.min.js
diff --git a/web/static/update_bokeh.sh b/backend/web/static/update_bokeh.sh
similarity index 100%
rename from web/static/update_bokeh.sh
rename to backend/web/static/update_bokeh.sh
diff --git a/web/templates/bokeh_embed.html b/backend/web/templates/bokeh_embed.html
similarity index 100%
rename from web/templates/bokeh_embed.html
rename to backend/web/templates/bokeh_embed.html
diff --git a/web/templates/common/footer.html b/backend/web/templates/common/footer.html
similarity index 100%
rename from web/templates/common/footer.html
rename to backend/web/templates/common/footer.html
diff --git a/web/templates/common/header.html b/backend/web/templates/common/header.html
similarity index 100%
rename from web/templates/common/header.html
rename to backend/web/templates/common/header.html
diff --git a/web/templates/common/left_menu.html b/backend/web/templates/common/left_menu.html
similarity index 100%
rename from web/templates/common/left_menu.html
rename to backend/web/templates/common/left_menu.html
diff --git a/web/templates/common/meta.html b/backend/web/templates/common/meta.html
similarity index 100%
rename from web/templates/common/meta.html
rename to backend/web/templates/common/meta.html
diff --git a/web/templates/data_editor.html b/backend/web/templates/data_editor.html
similarity index 98%
rename from web/templates/data_editor.html
rename to backend/web/templates/data_editor.html
index da981a8a77160ba517efc940af07531dca6a3531..555f18901865412ef7efb7e18b67ff0fb2ee8076 100644
--- a/web/templates/data_editor.html
+++ b/backend/web/templates/data_editor.html
@@ -97,7 +97,7 @@
"language": {
"url": "/static/js/datatables.Chinese.json"
},
- "ajax": "/stock/api_data?type=editor&name="+nameParam,
+ "ajax": "/api/v1/api_data?type=editor&name="+nameParam,
"columns": [
{
"data": "",
diff --git a/web/templates/index.html b/backend/web/templates/index.html
similarity index 100%
rename from web/templates/index.html
rename to backend/web/templates/index.html
diff --git a/web/templates/layout/default.html b/backend/web/templates/layout/default.html
similarity index 100%
rename from web/templates/layout/default.html
rename to backend/web/templates/layout/default.html
diff --git a/web/templates/layout/indicators-main.html b/backend/web/templates/layout/indicators-main.html
similarity index 100%
rename from web/templates/layout/indicators-main.html
rename to backend/web/templates/layout/indicators-main.html
diff --git a/web/templates/layout/indicators.html b/backend/web/templates/layout/indicators.html
similarity index 100%
rename from web/templates/layout/indicators.html
rename to backend/web/templates/layout/indicators.html
diff --git a/web/templates/layout/main.html b/backend/web/templates/layout/main.html
similarity index 100%
rename from web/templates/layout/main.html
rename to backend/web/templates/layout/main.html
diff --git a/web/templates/layout/single_default.html b/backend/web/templates/layout/single_default.html
similarity index 100%
rename from web/templates/layout/single_default.html
rename to backend/web/templates/layout/single_default.html
diff --git a/web/templates/layout/single_main.html b/backend/web/templates/layout/single_main.html
similarity index 100%
rename from web/templates/layout/single_main.html
rename to backend/web/templates/layout/single_main.html
diff --git a/web/templates/minst_serving.html b/backend/web/templates/minst_serving.html
similarity index 100%
rename from web/templates/minst_serving.html
rename to backend/web/templates/minst_serving.html
diff --git a/web/templates/stock_chart.html b/backend/web/templates/stock_chart.html
similarity index 100%
rename from web/templates/stock_chart.html
rename to backend/web/templates/stock_chart.html
diff --git a/web/templates/stock_indicators.html b/backend/web/templates/stock_indicators.html
similarity index 100%
rename from web/templates/stock_indicators.html
rename to backend/web/templates/stock_indicators.html
diff --git a/web/templates/stock_web.html b/backend/web/templates/stock_web.html
similarity index 97%
rename from web/templates/stock_web.html
rename to backend/web/templates/stock_web.html
index 01fdcb89d5d4baa587c7fe6404d9539bb36e3b26..0628cb96763b86744b1f6abdac0407dd6846bcb3 100644
--- a/web/templates/stock_web.html
+++ b/backend/web/templates/stock_web.html
@@ -76,7 +76,7 @@
//每次动态加载 指标分析窗口
function showIndicatorsWindow(code) {
- var baseUrl = '/stock/data/indicators?code='+code; // 没有跨域问题,直接加载
+ var baseUrl = '/api/v1/data/indicators?code='+code; // 没有跨域问题,直接加载
$('#indicators-window-body').html( "
数据加载中...请稍候.
" );
$('#indicators-window-body').context = $("#indicators-window-body").load(baseUrl);
$('#indicators-window-modal').modal('show');
@@ -127,7 +127,7 @@
"language": {
"url": "/static/js/datatables.Chinese.json"
},
- "ajax": "/stock/api_data?name="+nameParam,
+ "ajax": "/api/v1/api_data?name="+nameParam,
"columns": [
{% for column in stockWeb.columns %}
{ "data": "{{ column }}" },
diff --git a/web/templates/test.html b/backend/web/templates/test.html
similarity index 100%
rename from web/templates/test.html
rename to backend/web/templates/test.html
diff --git a/web/templates/test2.html b/backend/web/templates/test2.html
similarity index 100%
rename from web/templates/test2.html
rename to backend/web/templates/test2.html
diff --git a/web/test_thread.py b/backend/web/test_thread.py
similarity index 98%
rename from web/test_thread.py
rename to backend/web/test_thread.py
index fd79744dc830aee3408d7712630d608fa9f988cc..e874855d5e60324809582c1a4e886da3c15060ac 100644
--- a/web/test_thread.py
+++ b/backend/web/test_thread.py
@@ -99,6 +99,6 @@ if __name__ == "__main__":
("/", MainPage),
("/add_job", AddJobHandler),
("/job_check", JobCheckHandler)
- ], debug=True)).listen(9999)
+ ], debug=True)).listen(9090)
print("start web .")
IOLoop.instance().start()
diff --git a/web/test_thread_v2.py b/backend/web/test_thread_v2.py
similarity index 100%
rename from web/test_thread_v2.py
rename to backend/web/test_thread_v2.py
diff --git a/web/tornado_bokeh_embed.py b/backend/web/tornado_bokeh_embed.py
similarity index 98%
rename from web/tornado_bokeh_embed.py
rename to backend/web/tornado_bokeh_embed.py
index 916f483b601ba6e7ddb7de8f537f3b9edba2f330..17992c9e75887ea79fc1b7bd561ee47d4cbadeec 100644
--- a/web/tornado_bokeh_embed.py
+++ b/backend/web/tornado_bokeh_embed.py
@@ -14,7 +14,7 @@ from bokeh.themes import Theme
from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature
env = Environment(loader=FileSystemLoader('templates'))
-server_url = "http://localhost:9999/"
+server_url = "http://localhost:9090/"
class IndexHandler(RequestHandler):
diff --git a/docker-compose/.gitignore b/docker-compose/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..41ed8c8fa28b982e87436a60120343ada00024c9
--- /dev/null
+++ b/docker-compose/.gitignore
@@ -0,0 +1,14 @@
+# C extensions
+*.so
+
+data
+.idea
+*.iml
+.DS_Store
+*.zip
+*.log
+*.pyc
+doc
+/bin
+pkg
+*.tmp
\ No newline at end of file
diff --git a/docker-compose/LICENSE b/docker-compose/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..29f81d812f3e768fa89638d1f72920dbfd1413a8
--- /dev/null
+++ b/docker-compose/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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
+
+ http://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.
diff --git a/docker-compose/README.md b/docker-compose/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..be9937438f2bd0b628ddae0fba2e4705f9538470
--- /dev/null
+++ b/docker-compose/README.md
@@ -0,0 +1,60 @@
+## 镜像仓库选择
+
+https://github.com/DaoCloud/public-image-mirror
+
+```bash
+
+# python使用镜像
+docker.m.daocloud.io/library/python:3.11-slim-bullseye
+
+# mysql使用:
+docker.m.daocloud.io/library/mysql:8
+
+```
+
+
+## 本地部署方法
+
+
+```
+git clone git@gitee.com:pythonstock/docker-compose.git
+
+cd docker-compose
+
+docker-compose up -d
+
+```
+
+## 访问地址
+
+http://localhost:9090/
+
+
+
+## 查看日至,进入项目代码
+
+```
+# 查看启动日志:
+docker logs -f stock
+
+# 进入stock容器
+docker exec -it stock bash
+```
+
+## 开发模式,映射stock 代码方法
+
+直接使用 dev yml 即可,会映射stock到/data/stock 然后在外部修改代码容器中运行即可。
+
+```bash
+docker-compose -f dev-docker-compose.yml up -d
+```
+
+```bash
+docker-compose -f docker-compose-v2.0.yml up -d
+```
+
+## 老镜像还保存一个版本
+
+```
+pythonstock/pythonstock:v2021
+```
\ No newline at end of file
diff --git a/docker-compose/build_stock.sh b/docker-compose/build_stock.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ee099b1d35c64562dac9baf6e8537a7febf3b473
--- /dev/null
+++ b/docker-compose/build_stock.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+cd ../stock
+
+NOW_MONTH=$(date "+%Y-%m")
+
+DOCKER_TAG=pythonstock/pythonstock:latest
+DOCKER_TAG_MONTH=pythonstock/pythonstock:stock-${NOW_MONTH}
+
+echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
+docker build -f Dockerfile -t ${DOCKER_TAG} .
+echo " docker build tag xxx ${DOCKER_TAG_MONTH} "
+echo "#################################################################"
+echo " docker push ${DOCKER_TAG} "
+
+
diff --git a/docker-compose/dev-docker-compose-restart.sh b/docker-compose/dev-docker-compose-restart.sh
new file mode 100755
index 0000000000000000000000000000000000000000..5e1f06b77d75605d8df4243b7b73874451a0ab59
--- /dev/null
+++ b/docker-compose/dev-docker-compose-restart.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+
+git pull
+
+sleep 1
+docker-compose -f dev-docker-compose.yml down
+
+sleep 1
+docker-compose -f dev-docker-compose.yml up -d
+
+echo "restart dev-docker-compose"
+
diff --git a/docker-compose/dev-docker-compose.yml b/docker-compose/dev-docker-compose.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7c415e3e72ded83b375004deb9953ac4ef054856
--- /dev/null
+++ b/docker-compose/dev-docker-compose.yml
@@ -0,0 +1,87 @@
+networks:
+ stock-dev-network:
+ driver: bridge
+
+version: "3"
+services:
+ frontend:
+ image: pythonstock/frontend-dev:latest
+ build:
+ context: .
+ dockerfile: docker/DevFrontendDockerfile
+ container_name: frontend
+ ports:
+ - "8080:8080"
+ volumes:
+ # 设置开发目录,方便开发调试
+ - "../frontend:/usr/src/app"
+ environment:
+ LANG: zh_CN.UTF-8
+ LC_CTYPE: zh_CN.UTF-8
+ restart: always
+ networks:
+ stock-dev-network: {}
+ # 入口写死,手动启动应用。
+ entrypoint: /usr/src/app/docker-entrypoint.sh
+ depends_on:
+ - backend
+ backend:
+ image: pythonstock/backend-dev:latest
+ build:
+ context: .
+ dockerfile: docker/DevBackendDockerfile
+ container_name: backend
+ ports:
+ - "8888:8888"
+ - "9090:9090"
+ volumes:
+ # 设置开发目录,方便开发调试
+ - "../backend:/data/stock"
+ - "../backend/supervisor:/data/supervisor"
+ - "./data/notebooks:/data/notebooks"
+ - "./data/logs:/data/logs"
+ environment:
+ MYSQL_HOST: mysql-stock
+ MYSQL_USER: root
+ MYSQL_PWD: mysql-stock
+ MYSQL_DB: stock_data
+ MYSQL_PORT: 3306
+ LANG: zh_CN.UTF-8
+ LC_CTYPE: zh_CN.UTF-8
+ PYTHONIOENCODING: utf-8
+ restart: always
+ networks:
+ stock-dev-network: {}
+ # 入口写死,手动启动应用。
+ #entrypoint: sleep 999999d
+ depends_on:
+ - mysql-stock
+ mysql-stock:
+ # image: hub.atomgit.com/library/mysql:5.7
+ # https://hub.atomgit.com/repos/amd64/mysql
+ image: docker.m.daocloud.io/library/mysql:8
+ container_name: mysql-stock
+ # 执行命令:https://juejin.cn/s/mysql%20healthcheck%20docker-compose
+ healthcheck:
+ test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-pmysql-stock"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+ ports:
+ - "3306:3306"
+ networks:
+ stock-dev-network: {}
+ volumes:
+ - "./mysql/my.cnf:/etc/mysql/my.cnf"
+ - "./data/mysql-stock/data:/var/lib/mysql"
+ - ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
+ environment:
+ MYSQL_ROOT_PASSWORD: mysql-stock
+ MYSQL_DATABASE: stock_data
+ TZ: Asia/Shanghai
+ command: [
+ '--character-set-server=utf8mb4',
+ '--collation-server=utf8mb4_general_ci',
+ '--max_connections=3000'
+ ]
+ restart: always
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
new file mode 100644
index 0000000000000000000000000000000000000000..f2f6b9a2b699a58e66db0a45833fb46ec9f653ce
--- /dev/null
+++ b/docker-compose/docker-compose.yml
@@ -0,0 +1,87 @@
+networks:
+ stock-prod-network:
+ driver: bridge
+
+version: "3"
+services:
+ frontend:
+ image: pythonstock/frontend-prod:latest
+ build:
+ context: .
+ dockerfile: docker/ProdFrontendDockerfile
+ container_name: frontend
+ ports:
+ - "8080:8080"
+ volumes:
+ # 设置开发目录,方便开发调试
+ - "../frontend:/usr/src/app"
+ environment:
+ LANG: zh_CN.UTF-8
+ LC_CTYPE: zh_CN.UTF-8
+ restart: always
+ networks:
+ stock-prod-network: {}
+ # 入口写死,手动启动应用。
+ entrypoint: /usr/src/app/docker-entrypoint.sh
+ depends_on:
+ - backend
+ backend:
+ image: pythonstock/backend-prod:latest
+ build:
+ context: .
+ dockerfile: docker/ProdBackendDockerfile
+ container_name: backend
+ ports:
+ - "8888:8888"
+ - "9090:9090"
+ volumes:
+ # 设置开发目录,方便开发调试
+ - "../backend:/data/stock"
+ - "../backend/supervisor:/data/supervisor"
+ - "./data/notebooks:/data/notebooks"
+ - "./data/logs:/data/logs"
+ environment:
+ MYSQL_HOST: mysql-stock
+ MYSQL_USER: root
+ MYSQL_PWD: mysql-stock
+ MYSQL_DB: stock_data
+ MYSQL_PORT: 3306
+ LANG: zh_CN.UTF-8
+ LC_CTYPE: zh_CN.UTF-8
+ PYTHONIOENCODING: utf-8
+ restart: always
+ networks:
+ stock-prod-network: {}
+ # 入口写死,手动启动应用。
+ #entrypoint: sleep 999999d
+ depends_on:
+ - mysql-stock
+ mysql-stock:
+ # image: hub.atomgit.com/library/mysql:5.7
+ # https://hub.atomgit.com/repos/amd64/mysql
+ image: docker.m.daocloud.io/library/mysql:8
+ container_name: mysql-stock
+ # 执行命令:https://juejin.cn/s/mysql%20healthcheck%20docker-compose
+ healthcheck:
+ test: ["CMD", "mysqladmin" ,"ping", "-uroot", "-pmysql-stock"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+ ports:
+ - "3306:3306"
+ networks:
+ stock-prod-network: {}
+ volumes:
+ - "./mysql/my.cnf:/etc/mysql/my.cnf"
+ - "./data/mysql-stock/data:/var/lib/mysql"
+ - ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
+ environment:
+ MYSQL_ROOT_PASSWORD: mysql-stock
+ MYSQL_DATABASE: stock_data
+ TZ: Asia/Shanghai
+ command: [
+ '--character-set-server=utf8mb4',
+ '--collation-server=utf8mb4_general_ci',
+ '--max_connections=3000'
+ ]
+ restart: always
diff --git a/Dockerfile b/docker-compose/docker/DevBackendDockerfile
similarity index 42%
rename from Dockerfile
rename to docker-compose/docker/DevBackendDockerfile
index a388c5437833aee8c97d8bc36b7cfade5b000288..7cd1960b4dc91d723c3137a883688041a5687679 100644
--- a/Dockerfile
+++ b/docker-compose/docker/DevBackendDockerfile
@@ -1,14 +1,10 @@
-# 拆分基础镜像: docker/dockerfile
-# 基础镜像,按照季度,月度更新。不影响应用镜像的构建。
-FROM pythonstock/pythonstock:base-2023-06 as builder
+# https://hub.docker.com/_/python?tab=tags&page=1&name=3.11-slim-bullseye
+# 用这个做为基础镜像,防止每次都进行构建。
-# 拷贝本地文件到目录
-COPY . /data
-
-# service
-FROM docker.io/python:3.8-slim-bullseye
+#FROM docker.io/python:3.11-slim-bullseye
+FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
# https://opsx.alibaba.com/mirror
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
@@ -33,7 +29,53 @@ ENV LC_CTYPE=zh_CN.UTF-8
ENV LC_ALL=C
ENV PYTHONPATH=/data/stock
-WORKDIR /data
+# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
+# RUN pip3 install tensorflow==2.0.0-rc1 keras
+# RUN pip3 install tensorflow keras sklearn
+
+# 设置 vim 的语言配置
+RUN mkdir -p /etc/vim/ && \
+ echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
+ echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
+ echo "set encoding=utf-8" >> /etc/vim/vimrc
+
+# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
+# 安装 nodejs 库
+# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
+# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
+RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
+ pip3 install mysqlclient sqlalchemy && \
+ pip3 install supervisor && \
+ pip3 install numpy pandas && \
+ pip3 install akshare --upgrade && \
+ apt-get install -y nodejs && \
+ pip3 install tornado torndb && \
+ pip3 install bokeh stockstats scikit-learn && \
+ apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
+ rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
+ cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
+
+# /usr/local/lib/python3.11/site-packages/pandas/
+# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
+# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
+# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
+# 增加了一个 IGNORE 参数。
+# 2.解决torndb在python3下面的问题:
+# http://blog.csdn.net/littlethunder/article/details/8917378
+# 3. 解决 type 问题,使用sed 进行替换。
+# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in
+# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
+# TypeError: can only concatenate list (not "type") to list
+
+RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
+ sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
+ /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
+ rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
+ sed -i -e 's/itertools\.izip/zip/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py && \
+ sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py
+
#add cron sesrvice.
#每分钟,每小时1分钟,每天1点1分,每月1号执行
@@ -48,30 +90,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
chmod 600 /var/spool/cron/crontabs/root
-#增加服务端口就两个 6006 8500 9001
-EXPOSE 8888 9999
-
-
-# 直接使用基础镜像然后拷贝 site-packages 安装包即可。
-COPY --from=builder /data/jobs /data/stock/jobs
-COPY --from=builder /data/libs /data/stock/libs
-COPY --from=builder /data/web /data/stock/web
-COPY --from=builder /data/supervisor /data/supervisor
-# 拷贝二进制文件。
-COPY --from=builder /usr/local/bin/supervisord /usr/local/bin/supervisord
-COPY --from=builder /usr/lib/x86_64-linux-gnu/libmariadb.so.3 /usr/lib/x86_64-linux-gnu/libmariadb.so.3
-
-# 拷贝 cron 定时任务:
-COPY --from=builder /data/jobs/cron.minutely /etc/cron.minutely
-COPY --from=builder /data/jobs/cron.hourly /etc/cron.hourly
-COPY --from=builder /data/jobs/cron.daily /etc/cron.daily
-COPY --from=builder /data/jobs/cron.monthly /etc/cron.monthly
-
-# 拷贝类库
-COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
+#增加服务端口
+EXPOSE 8888 9090
-RUN mkdir -p /data/logs && ls /data/stock/ && chmod 755 /data/stock/jobs/run_* && \
- chmod 755 /etc/cron.minutely/* && chmod 755 /etc/cron.hourly/* && \
- chmod 755 /etc/cron.daily/* && chmod 755 /etc/cron.monthly/*
+ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
-ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
\ No newline at end of file
diff --git a/docker-compose/docker/DevFrontendDockerfile b/docker-compose/docker/DevFrontendDockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..fa1335a0575353cf6e2794948eaa9285f5bd813a
--- /dev/null
+++ b/docker-compose/docker/DevFrontendDockerfile
@@ -0,0 +1,41 @@
+#使用 node:bullseye-slim 做基础镜像减少大小。
+
+FROM docker.m.daocloud.io/library/node:bullseye-slim
+
+# https://opsx.alibaba.com/mirror
+# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
+# 设置debian的镜像源
+RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "[global]\n\
+trusted-host=mirrors.aliyun.com\n\
+index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
+ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
+ echo "Asia/Shanghai" > /etc/timezone
+
+#增加语言utf-8
+ENV LANG=zh_CN.UTF-8
+ENV LC_CTYPE=zh_CN.UTF-8
+ENV LC_ALL=C
+
+# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
+# RUN pip3 install tensorflow==2.0.0-rc1 keras
+# RUN pip3 install tensorflow keras sklearn
+
+# 设置 vim 的语言配置
+RUN mkdir -p /etc/vim/ && \
+ echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
+ echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
+ echo "set encoding=utf-8" >> /etc/vim/vimrc
+
+# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
+# 安装 nodejs 库
+# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
+# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
+RUN apt-get update && apt-get install -y python3 make g++ && apt-get clean
diff --git a/docker-compose/docker/Dockerfile b/docker-compose/docker/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..c8c8a68a3355579828f625433fdbdb1eb5e4e371
--- /dev/null
+++ b/docker-compose/docker/Dockerfile
@@ -0,0 +1,103 @@
+#使用 python:3.8-slim 做基础镜像减少大小。其中tensorflow再用另外的镜像跑数据。
+
+# 之前使用的是python:3.6-slim
+# 可以更新 3.8-slim-bullseye slim-bullseye
+
+# https://hub.docker.com/_/python?tab=tags&page=1&name=3.8-slim-bullseye
+# 用这个做为基础镜像,防止每次都进行构建。
+
+#FROM docker.io/python:3.8-slim-bullseye
+#FROM hub.atomgit.com/amd64/python:3.8-slim-bullseye
+# https://hub.atomgit.com/repos/amd64/python
+#FROM hub.atomgit.com/amd64/python:3.11-slim-bullseye
+FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
+
+# https://opsx.alibaba.com/mirror
+# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
+# 设置debian的镜像源
+RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "[global]\n\
+trusted-host=mirrors.aliyun.com\n\
+index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
+ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
+ echo "Asia/Shanghai" > /etc/timezone
+
+#增加语言utf-8
+ENV LANG=zh_CN.UTF-8
+ENV LC_CTYPE=zh_CN.UTF-8
+ENV LC_ALL=C
+ENV PYTHONPATH=/data/stock
+
+# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
+# RUN pip3 install tensorflow==2.0.0-rc1 keras
+# RUN pip3 install tensorflow keras sklearn
+
+# 设置 vim 的语言配置
+RUN mkdir -p /etc/vim/ && \
+ echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
+ echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
+ echo "set encoding=utf-8" >> /etc/vim/vimrc
+
+# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
+# 安装 nodejs 库
+# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
+# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
+RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
+ pip3 install mysqlclient sqlalchemy && \
+ pip3 install supervisor && \
+ pip3 install numpy pandas && \
+ pip3 install akshare --upgrade && \
+ apt-get install -y nodejs && \
+ pip3 install tornado torndb && \
+ pip3 install bokeh stockstats scikit-learn && \
+ apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
+ rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
+ cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
+
+# /usr/local/lib/python3.11/site-packages/pandas/
+# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
+# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
+# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
+# 增加了一个 IGNORE 参数。
+# 2.解决torndb在python3下面的问题:
+# http://blog.csdn.net/littlethunder/article/details/8917378
+# 3. 解决 type 问题,使用sed 进行替换。
+# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in
+# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
+# TypeError: can only concatenate list (not "type") to list
+
+RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
+ sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
+ /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
+ rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
+ sed -i -e 's/itertools\.izip/zip/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py && \
+ sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py
+
+
+#add cron sesrvice.
+#每分钟,每小时1分钟,每天1点1分,每月1号执行
+RUN mkdir -p /etc/cron.minutely && mkdir -p /etc/cron.hourly && mkdir -p /etc/cron.monthly && mkdir -p /var/spool/cron/crontabs && \
+ echo "SHELL=/bin/sh \n\
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
+# min hour day month weekday command \n\
+*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
+10 * * * * /bin/run-parts /etc/cron.hourly \n\
+30 16 * * * /bin/run-parts /etc/cron.daily \n\
+30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
+ chmod 600 /var/spool/cron/crontabs/root
+
+
+#增加服务端口就两个 6006 8500 9001
+EXPOSE 8888 9999
+
+ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
+
diff --git a/docker-compose/docker/ProdBackendDockerfile b/docker-compose/docker/ProdBackendDockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..c8c8a68a3355579828f625433fdbdb1eb5e4e371
--- /dev/null
+++ b/docker-compose/docker/ProdBackendDockerfile
@@ -0,0 +1,103 @@
+#使用 python:3.8-slim 做基础镜像减少大小。其中tensorflow再用另外的镜像跑数据。
+
+# 之前使用的是python:3.6-slim
+# 可以更新 3.8-slim-bullseye slim-bullseye
+
+# https://hub.docker.com/_/python?tab=tags&page=1&name=3.8-slim-bullseye
+# 用这个做为基础镜像,防止每次都进行构建。
+
+#FROM docker.io/python:3.8-slim-bullseye
+#FROM hub.atomgit.com/amd64/python:3.8-slim-bullseye
+# https://hub.atomgit.com/repos/amd64/python
+#FROM hub.atomgit.com/amd64/python:3.11-slim-bullseye
+FROM docker.m.daocloud.io/library/python:3.11-slim-bullseye
+
+# https://opsx.alibaba.com/mirror
+# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
+# 设置debian的镜像源
+RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "[global]\n\
+trusted-host=mirrors.aliyun.com\n\
+index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
+ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
+ echo "Asia/Shanghai" > /etc/timezone
+
+#增加语言utf-8
+ENV LANG=zh_CN.UTF-8
+ENV LC_CTYPE=zh_CN.UTF-8
+ENV LC_ALL=C
+ENV PYTHONPATH=/data/stock
+
+# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
+# RUN pip3 install tensorflow==2.0.0-rc1 keras
+# RUN pip3 install tensorflow keras sklearn
+
+# 设置 vim 的语言配置
+RUN mkdir -p /etc/vim/ && \
+ echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
+ echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
+ echo "set encoding=utf-8" >> /etc/vim/vimrc
+
+# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
+# 安装 nodejs 库
+# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
+# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
+RUN apt-get update && apt-get install -y git pkg-config net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
+ pip3 install mysqlclient sqlalchemy && \
+ pip3 install supervisor && \
+ pip3 install numpy pandas && \
+ pip3 install akshare --upgrade && \
+ apt-get install -y nodejs && \
+ pip3 install tornado torndb && \
+ pip3 install bokeh stockstats scikit-learn && \
+ apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
+ rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y && \
+ cd /usr/local/lib/python3.11/site-packages && find ./ -name *.pyc | xargs rm -f
+
+# /usr/local/lib/python3.11/site-packages/pandas/
+# 1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy
+# 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
+# /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py
+# 增加了一个 IGNORE 参数。
+# 2.解决torndb在python3下面的问题:
+# http://blog.csdn.net/littlethunder/article/details/8917378
+# 3. 解决 type 问题,使用sed 进行替换。
+# File "/usr/local/lib/python3.11/site-packages/torndb.py", line 260, in
+# CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
+# TypeError: can only concatenate list (not "type") to list
+
+RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
+ sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
+ /usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
+ rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
+ sed -i -e 's/itertools\.izip/zip/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py && \
+ sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
+ /usr/local/lib/python3.11/site-packages/torndb.py
+
+
+#add cron sesrvice.
+#每分钟,每小时1分钟,每天1点1分,每月1号执行
+RUN mkdir -p /etc/cron.minutely && mkdir -p /etc/cron.hourly && mkdir -p /etc/cron.monthly && mkdir -p /var/spool/cron/crontabs && \
+ echo "SHELL=/bin/sh \n\
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
+# min hour day month weekday command \n\
+*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
+10 * * * * /bin/run-parts /etc/cron.hourly \n\
+30 16 * * * /bin/run-parts /etc/cron.daily \n\
+30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
+ chmod 600 /var/spool/cron/crontabs/root
+
+
+#增加服务端口就两个 6006 8500 9001
+EXPOSE 8888 9999
+
+ENTRYPOINT ["supervisord","-n","-c","/data/supervisor/supervisord.conf"]
+
diff --git a/docker-compose/docker/ProdFrontendDockerfile b/docker-compose/docker/ProdFrontendDockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..fa1335a0575353cf6e2794948eaa9285f5bd813a
--- /dev/null
+++ b/docker-compose/docker/ProdFrontendDockerfile
@@ -0,0 +1,41 @@
+#使用 node:bullseye-slim 做基础镜像减少大小。
+
+FROM docker.m.daocloud.io/library/node:bullseye-slim
+
+# https://opsx.alibaba.com/mirror
+# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
+# 设置debian的镜像源
+RUN echo "deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" > /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian-security/ bullseye-security main" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib" >> /etc/apt/sources.list && \
+echo "[global]\n\
+trusted-host=mirrors.aliyun.com\n\
+index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
+ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
+ echo "Asia/Shanghai" > /etc/timezone
+
+#增加语言utf-8
+ENV LANG=zh_CN.UTF-8
+ENV LC_CTYPE=zh_CN.UTF-8
+ENV LC_ALL=C
+
+# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
+# RUN pip3 install tensorflow==2.0.0-rc1 keras
+# RUN pip3 install tensorflow keras sklearn
+
+# 设置 vim 的语言配置
+RUN mkdir -p /etc/vim/ && \
+ echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
+ echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
+ echo "set encoding=utf-8" >> /etc/vim/vimrc
+
+# 安装 mysqlclient akshare (pandas ,numpy) tornado bokeh
+# 安装 nodejs 库
+# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
+# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
+RUN apt-get update && apt-get install -y python3 make g++ && apt-get clean
diff --git a/docker-compose/docker/README.md b/docker-compose/docker/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..c69c9fc403197c41956fa44ebf9700fffad748a7
--- /dev/null
+++ b/docker-compose/docker/README.md
@@ -0,0 +1,35 @@
+
+# python 基础镜像
+
+基础镜像升级到 2020年7月的版本
+
+保证运行的最少基础环境,基础环境使用python3.6的版本。安装了超级多的lib库。非常的好用。
+
+mysqlclient
+sqlalchemy
+requests
+numpy
+tushare
+tornado torndb
+bokeh
+stockstats
+ta-lib
+jupyter
+sklearn
+
+# 2021年6月版本,使用 akshare 替换掉 tushare 库
+
+akshare 地址:
+
+https://www.akshare.xyz/zh_CN/latest/introduction.html
+
+AKShare 是基于 Python 的财经数据接口库, 目的是实现对股票、期货、期权、基金、外汇、债券、指数、
+加密货币等金融产品的基本面数据、实时和历史行情数据、衍生数据从数据采集、数据清洗到数据落地的一套工具,
+主要用于学术研究目的。
+
+
+# 2021年 9 月版本,镜像裁剪,supervisor 使用python3
+
+supervisor 使用 python3 后好像减少了不少大小。
+同时删除掉一直没有用的 ta-lib 和 jupyter 。升级python基础镜像。
+
diff --git a/build.sh b/docker-compose/docker/build.sh
similarity index 69%
rename from build.sh
rename to docker-compose/docker/build.sh
index 5a545bd54d125472fbe003f0ce9b92c7a9c729f2..d0ccd214e4818b6b363b9365dc93cb71b1c47b80 100755
--- a/build.sh
+++ b/docker-compose/docker/build.sh
@@ -1,14 +1,13 @@
#!/bin/sh
-DOCKER_TAG=pythonstock/pythonstock:latest
-sudo rm -rf data
-sudo rm -f jobs/nohup.out
+NOW_MONTH=$(date "+%Y-%m")
+
+DOCKER_TAG=pythonstock/pythonstock:base-${NOW_MONTH}
echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
docker build -f Dockerfile -t ${DOCKER_TAG} .
echo "#################################################################"
echo " docker push ${DOCKER_TAG} "
-mkdir data
diff --git a/docker-compose/mysql/init.sql b/docker-compose/mysql/init.sql
new file mode 100644
index 0000000000000000000000000000000000000000..98c25247fc0fb5859979a11a93a7e644c9e1b421
--- /dev/null
+++ b/docker-compose/mysql/init.sql
@@ -0,0 +1,201 @@
+SET character_set_client = utf8;
+-- 切库:
+use stock_data;
+-- 建表
+-- 表里面都是使用 code 和 date 两个字段做联合主键的。
+
+
+CREATE TABLE IF NOT EXISTS `stock_zh_a_spot_em` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `last_price` varchar(255) DEFAULT NULL,
+ `change_percent` varchar(255) DEFAULT NULL,
+ `change_amount` varchar(255) DEFAULT NULL,
+ `volume` varchar(255) DEFAULT NULL,
+ `turnover` varchar(255) DEFAULT NULL,
+ `amplitude` varchar(255) DEFAULT NULL,
+ `high` varchar(255) DEFAULT NULL,
+ `low` varchar(255) DEFAULT NULL,
+ `open` varchar(255) DEFAULT NULL,
+ `closed` varchar(255) DEFAULT NULL,
+ `volume_ratio` varchar(255) DEFAULT NULL,
+ `turnover_rate` varchar(255) DEFAULT NULL,
+ `pe_ratio` varchar(255) DEFAULT NULL,
+ `pb_ratio` varchar(255) DEFAULT NULL,
+ `market_cap` varchar(255) DEFAULT NULL,
+ `circulating_market_cap` varchar(255) DEFAULT NULL,
+ `rise_speed` varchar(255) DEFAULT NULL,
+ `change_5min` varchar(255) DEFAULT NULL,
+ `change_ercent_60day` varchar(255) DEFAULT NULL,
+ `ytd_change_percent` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+CREATE TABLE IF NOT EXISTS `stock_lhb_ggtj_sina` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `ranking_times` varchar(255) DEFAULT NULL,
+ `sum_buy` varchar(255) DEFAULT NULL,
+ `sum_sell` varchar(255) DEFAULT NULL,
+ `net_amount` varchar(255) DEFAULT NULL,
+ `buy_seat` varchar(255) DEFAULT NULL,
+ `sell_seat` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+
+CREATE TABLE `stock_dzjy_mrtj` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `quote_change` varchar(255) DEFAULT NULL,
+ `close_price` varchar(255) DEFAULT NULL,
+ `average_price` varchar(255) DEFAULT NULL,
+ `overflow_rate` varchar(255) DEFAULT NULL,
+ `trade_number` varchar(255) DEFAULT NULL,
+ `sum_volume` varchar(255) DEFAULT NULL,
+ `sum_turnover` varchar(255) DEFAULT NULL,
+ `turnover_market_rate` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+
+CREATE TABLE `guess_indicators_daily` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `last_price` varchar(255) DEFAULT NULL,
+ `change_percent` varchar(255) DEFAULT NULL,
+ `change_amount` varchar(255) DEFAULT NULL,
+ `volume` varchar(255) DEFAULT NULL,
+ `turnover` varchar(255) DEFAULT NULL,
+ `amplitude` varchar(255) DEFAULT NULL,
+ `high` varchar(255) DEFAULT NULL,
+ `low` varchar(255) DEFAULT NULL,
+ `open` varchar(255) DEFAULT NULL,
+ `closed` varchar(255) DEFAULT NULL,
+ `volume_ratio` varchar(255) DEFAULT NULL,
+ `turnover_rate` varchar(255) DEFAULT NULL,
+ `pe_ratio` varchar(255) DEFAULT NULL,
+ `pb_ratio` varchar(255) DEFAULT NULL,
+ `market_cap` varchar(255) DEFAULT NULL,
+ `circulating_market_cap` varchar(255) DEFAULT NULL,
+ `rise_speed` varchar(255) DEFAULT NULL,
+ `change_5min` varchar(255) DEFAULT NULL,
+ `change_ercent_60day` varchar(255) DEFAULT NULL,
+ `ytd_change_percent` varchar(255) DEFAULT NULL,
+ `boll` varchar(255) DEFAULT NULL,
+ `boll_lb` varchar(255) DEFAULT NULL,
+ `boll_ub` varchar(255) DEFAULT NULL,
+ `kdjd` varchar(255) DEFAULT NULL,
+ `kdjj` varchar(255) DEFAULT NULL,
+ `kdjk` varchar(255) DEFAULT NULL,
+ `macd` varchar(255) DEFAULT NULL,
+ `macdh` varchar(255) DEFAULT NULL,
+ `macds` varchar(255) DEFAULT NULL,
+ `pdi` varchar(255) DEFAULT NULL,
+ `trix` varchar(255) DEFAULT NULL,
+ `trix_9_sma` varchar(255) DEFAULT NULL,
+ `vr` varchar(255) DEFAULT NULL,
+ `vr_6_sma` varchar(255) DEFAULT NULL,
+ `wr_10` varchar(255) DEFAULT NULL,
+ `wr_6` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+
+CREATE TABLE `guess_indicators_lite_buy_daily` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `last_price` varchar(255) DEFAULT NULL,
+ `change_percent` varchar(255) DEFAULT NULL,
+ `change_amount` varchar(255) DEFAULT NULL,
+ `volume` varchar(255) DEFAULT NULL,
+ `turnover` varchar(255) DEFAULT NULL,
+ `amplitude` varchar(255) DEFAULT NULL,
+ `high` varchar(255) DEFAULT NULL,
+ `low` varchar(255) DEFAULT NULL,
+ `open` varchar(255) DEFAULT NULL,
+ `closed` varchar(255) DEFAULT NULL,
+ `volume_ratio` varchar(255) DEFAULT NULL,
+ `turnover_rate` varchar(255) DEFAULT NULL,
+ `pe_ratio` varchar(255) DEFAULT NULL,
+ `pb_ratio` varchar(255) DEFAULT NULL,
+ `market_cap` varchar(255) DEFAULT NULL,
+ `circulating_market_cap` varchar(255) DEFAULT NULL,
+ `rise_speed` varchar(255) DEFAULT NULL,
+ `change_5min` varchar(255) DEFAULT NULL,
+ `change_ercent_60day` varchar(255) DEFAULT NULL,
+ `ytd_change_percent` varchar(255) DEFAULT NULL,
+ `boll` varchar(255) DEFAULT NULL,
+ `boll_lb` varchar(255) DEFAULT NULL,
+ `boll_ub` varchar(255) DEFAULT NULL,
+ `kdjd` varchar(255) DEFAULT NULL,
+ `kdjj` varchar(255) DEFAULT NULL,
+ `kdjk` varchar(255) DEFAULT NULL,
+ `macd` varchar(255) DEFAULT NULL,
+ `macdh` varchar(255) DEFAULT NULL,
+ `macds` varchar(255) DEFAULT NULL,
+ `pdi` varchar(255) DEFAULT NULL,
+ `trix` varchar(255) DEFAULT NULL,
+ `trix_9_sma` varchar(255) DEFAULT NULL,
+ `vr` varchar(255) DEFAULT NULL,
+ `vr_6_sma` varchar(255) DEFAULT NULL,
+ `wr_10` varchar(255) DEFAULT NULL,
+ `wr_6` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+
+CREATE TABLE `guess_indicators_lite_sell_daily` (
+ `date` varchar(255) NOT NULL,
+ `code` varchar(255) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `last_price` varchar(255) DEFAULT NULL,
+ `change_percent` varchar(255) DEFAULT NULL,
+ `change_amount` varchar(255) DEFAULT NULL,
+ `volume` varchar(255) DEFAULT NULL,
+ `turnover` varchar(255) DEFAULT NULL,
+ `amplitude` varchar(255) DEFAULT NULL,
+ `high` varchar(255) DEFAULT NULL,
+ `low` varchar(255) DEFAULT NULL,
+ `open` varchar(255) DEFAULT NULL,
+ `closed` varchar(255) DEFAULT NULL,
+ `volume_ratio` varchar(255) DEFAULT NULL,
+ `turnover_rate` varchar(255) DEFAULT NULL,
+ `pe_ratio` varchar(255) DEFAULT NULL,
+ `pb_ratio` varchar(255) DEFAULT NULL,
+ `market_cap` varchar(255) DEFAULT NULL,
+ `circulating_market_cap` varchar(255) DEFAULT NULL,
+ `rise_speed` varchar(255) DEFAULT NULL,
+ `change_5min` varchar(255) DEFAULT NULL,
+ `change_ercent_60day` varchar(255) DEFAULT NULL,
+ `ytd_change_percent` varchar(255) DEFAULT NULL,
+ `boll` varchar(255) DEFAULT NULL,
+ `boll_lb` varchar(255) DEFAULT NULL,
+ `boll_ub` varchar(255) DEFAULT NULL,
+ `kdjd` varchar(255) DEFAULT NULL,
+ `kdjj` varchar(255) DEFAULT NULL,
+ `kdjk` varchar(255) DEFAULT NULL,
+ `macd` varchar(255) DEFAULT NULL,
+ `macdh` varchar(255) DEFAULT NULL,
+ `macds` varchar(255) DEFAULT NULL,
+ `pdi` varchar(255) DEFAULT NULL,
+ `trix` varchar(255) DEFAULT NULL,
+ `trix_9_sma` varchar(255) DEFAULT NULL,
+ `vr` varchar(255) DEFAULT NULL,
+ `vr_6_sma` varchar(255) DEFAULT NULL,
+ `wr_10` varchar(255) DEFAULT NULL,
+ `wr_6` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`,`date`),
+ KEY `idx_code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
diff --git a/docker-compose/mysql/my.cnf b/docker-compose/mysql/my.cnf
new file mode 100644
index 0000000000000000000000000000000000000000..4392d8c4a3c594b91f54ab822fd9f67d91fc8671
--- /dev/null
+++ b/docker-compose/mysql/my.cnf
@@ -0,0 +1,38 @@
+# https://blog.csdn.net/aichogn/article/details/117788275
+# mysql 推荐配置
+[client]
+socket=/var/lib/mysql/mysql.sock
+port=3306
+[mysqld]
+
+basedir=/var/lib/mysql/
+datadir=/var/lib/mysql/data
+socket=/var/lib/mysql/mysql.sock
+default-storage-engine=INNODB
+character_set_server=utf8mb4
+collation_server=utf8mb4_general_ci
+
+port=3306
+# Disabling symbolic-links is recommended to prevent assorted security risks
+symbolic-links=0
+
+server_id=1
+
+ ## 最大连接数,MySQL服务器允许的最大连接数16384,连接数越多消耗内存越多
+max_connections = 1000
+## 日志过期时间,包括二进制日志(过期自动删除)
+# expire_logs_days = 15
+## Enable Per Table Data for InnoDB to shrink ibdata1(innoDB表优化)
+innodb_file_per_table = 1
+#默认128M,用于存储页面缓存数据外,另外正常情况下还有大约8%的开销,主要用在每个缓存页帧的描述、adaptive hash等数据结构,适当的增加这个参数的大小,可以有效的减少 InnoDB 类型的表的磁盘 I/O
+innodb_buffer_pool_size = 2048M
+innodb_log_file_size = 512M
+#默认是8MB,InnoDB在写事务日志的时候,为了提高性能,也是先将信息写入Innofb Log Buffer中,当满足innodb_flush_log_trx_commit参数所设置的相应条件(或者日志缓冲区写满)之后,才会将日志写到文件 (或者同步到磁盘)中
+innodb_log_buffer_size = 8M
+innodb_flush_log_at_trx_commit = 2
+#表大小写不敏感
+lower_case_table_names=1
+#跳过密码 安装完后屏蔽该选项
+#skip-grant-tables
+#关闭 binlog
+skip-log-bin
\ No newline at end of file
diff --git a/docker-compose/nginx.conf b/docker-compose/nginx.conf
new file mode 100644
index 0000000000000000000000000000000000000000..dddef813322831a1e5e2a3f8621745a287ea309e
--- /dev/null
+++ b/docker-compose/nginx.conf
@@ -0,0 +1,47 @@
+# 设置nginx启动
+# systemctl enable nginx
+server {
+ listen 8080;
+ server_name www.pythonstock.com;
+ root /usr/share/nginx/html;
+
+ error_page 404 /404.html;
+ error_page 500 502 503 504 /50x.html;
+
+ # 开启gzip
+ gzip on;
+ # 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
+ gzip_min_length 1k;
+ # gzip 压缩级别 1-10
+ gzip_comp_level 2;
+ # 进行压缩的文件类型。
+ gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
+ # 是否在http header中添加Vary: Accept-Encoding,建议开启
+ gzip_vary on;
+
+ access_log /var/log/nginx/stock.access.log main;
+ error_log /var/log/nginx/stock.error.log warn;
+
+ # https://medium.com/aviabird/413-414-request-url-entity-too-large-error-nginx-b6dcece6f5dd
+ # 解决GET 参数过长问题。
+ client_max_body_size 10M;
+ large_client_header_buffers 4 20k;
+
+
+ location ^~ /static/ {
+ access_log off;
+ # 需要把源代码,再下载一遍。
+ root /data/pythonstock/stock/web;
+ expires 30d; # 设置30天超时
+ # 参考 https://www.cnblogs.com/kevingrace/p/10459429.html
+ # add_header Cache-Control max-age=360000;
+ }
+
+ location / {
+ proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_pass http://127.0.0.1:9090;
+ expires 0;
+ }
+}
\ No newline at end of file
diff --git a/frontend/.eslintignore b/frontend/.eslintignore
new file mode 100644
index 0000000000000000000000000000000000000000..6b04c852de459325e8c81cea4bc35e8013f58d62
--- /dev/null
+++ b/frontend/.eslintignore
@@ -0,0 +1,5 @@
+build/*.js
+src/assets
+public
+dist
+eslint-disable
\ No newline at end of file
diff --git a/frontend/.gitignore b/frontend/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..b4886309ce831382dff1913d2cd861faea298d1b
--- /dev/null
+++ b/frontend/.gitignore
@@ -0,0 +1,16 @@
+.DS_Store
+node_modules/
+dist/
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+package-lock.json
+tests/**/coverage/
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
\ No newline at end of file
diff --git a/frontend/LICENSE b/frontend/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..61515750df8d215937d8a5c58202d649dcdff957
--- /dev/null
+++ b/frontend/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017-present PanJiaChen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/frontend/README.md b/frontend/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..879bf8b78182d77fb4641ccbac3f8ef234d4b8f5
--- /dev/null
+++ b/frontend/README.md
@@ -0,0 +1,42 @@
+### 说明,项目迁移到了Gitee 啦,最后一次修改,2023-06-02 执行存档
+
+项目迁移到这里了:此项目后续更新访问这里:
+
+https://gitee.com/pythonstock/stock-ui
+
+github项目后续就Archives存档了,不再更新了!
+
+csdn的pythonstock专栏地址,相关资料都在这里有说明:
+
+https://blog.csdn.net/freewebsys/category_9285317.html
+
+
+## 1,股票系统前端项目
+
+elementUI
+
+https://element.eleme.cn/#/zh-CN
+
+使用vue-element-admin的模板进行项目开发:
+
+https://panjiachen.github.io/vue-element-admin-site/zh/guide/
+
+在线预览地址:
+
+https://panjiachen.github.io/vue-element-admin/#/dashboard
+
+模板源自:
+https://gitee.com/panjiachen/vue-admin-template
+
+【相关python stock资料分类】:
+http://blog.csdn.net/freewebsys/article/category/7076584
+
+
+## 2,动态展示表格
+
+http://localhost:9528/#/example/table
+
+
+在.eslintrc.js 文件中配置 eslint-disable 指令来关闭ESlint语法检测。
+
+
diff --git a/frontend/babel.config.js b/frontend/babel.config.js
new file mode 100644
index 0000000000000000000000000000000000000000..fb82b2715f46a87182f3e004dcc731f5a5f49fe8
--- /dev/null
+++ b/frontend/babel.config.js
@@ -0,0 +1,14 @@
+module.exports = {
+ presets: [
+ // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
+ '@vue/cli-plugin-babel/preset'
+ ],
+ 'env': {
+ 'development': {
+ // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
+ // This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
+ // https://panjiachen.github.io/vue-element-admin-site/guide/advanced/lazy-loading.html
+ 'plugins': ['dynamic-import-node']
+ }
+ }
+}
diff --git a/frontend/docker-entrypoint.sh b/frontend/docker-entrypoint.sh
new file mode 100755
index 0000000000000000000000000000000000000000..bdd5f03892de57f08e0010d2aa36ad1f3d7ef8fe
--- /dev/null
+++ b/frontend/docker-entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+sleep 10
+# 只依赖启动。
+cd /usr/src/app
+npm install --registry=https://registry.npmmirror.com
+npm run dev
+sleep 999999d
diff --git a/frontend/jest.config.js b/frontend/jest.config.js
new file mode 100644
index 0000000000000000000000000000000000000000..143cdc868cbc529ca55eff89bbc0dc3f23fba65d
--- /dev/null
+++ b/frontend/jest.config.js
@@ -0,0 +1,24 @@
+module.exports = {
+ moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
+ transform: {
+ '^.+\\.vue$': 'vue-jest',
+ '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
+ 'jest-transform-stub',
+ '^.+\\.jsx?$': 'babel-jest'
+ },
+ moduleNameMapper: {
+ '^@/(.*)$': '/src/$1'
+ },
+ snapshotSerializers: ['jest-serializer-vue'],
+ testMatch: [
+ '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
+ ],
+ collectCoverageFrom: ['src/utils/**/*.{js,vue}', '!src/utils/auth.js', '!src/utils/request.js', 'src/components/**/*.{js,vue}'],
+ coverageDirectory: '/tests/unit/coverage',
+ // 'collectCoverage': true,
+ 'coverageReporters': [
+ 'lcov',
+ 'text-summary'
+ ],
+ testURL: 'http://localhost/'
+}
diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json
new file mode 100644
index 0000000000000000000000000000000000000000..ed079e2b9b8c3deaea3b75d6311c3352c73009f2
--- /dev/null
+++ b/frontend/jsconfig.json
@@ -0,0 +1,9 @@
+{
+ "compilerOptions": {
+ "baseUrl": "./",
+ "paths": {
+ "@/*": ["src/*"]
+ }
+ },
+ "exclude": ["node_modules", "dist"]
+}
diff --git a/frontend/mock/index.js b/frontend/mock/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..c514c1357332895f0c6b1b55379748f5ff59d60d
--- /dev/null
+++ b/frontend/mock/index.js
@@ -0,0 +1,57 @@
+const Mock = require('mockjs')
+const { param2Obj } = require('./utils')
+
+const user = require('./user')
+const table = require('./table')
+
+const mocks = [
+ ...user,
+ ...table
+]
+
+// for front mock
+// please use it cautiously, it will redefine XMLHttpRequest,
+// which will cause many of your third-party libraries to be invalidated(like progress event).
+function mockXHR() {
+ // mock patch
+ // https://github.com/nuysoft/Mock/issues/300
+ Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
+ Mock.XHR.prototype.send = function() {
+ if (this.custom.xhr) {
+ this.custom.xhr.withCredentials = this.withCredentials || false
+
+ if (this.responseType) {
+ this.custom.xhr.responseType = this.responseType
+ }
+ }
+ this.proxy_send(...arguments)
+ }
+
+ function XHR2ExpressReqWrap(respond) {
+ return function(options) {
+ let result = null
+ if (respond instanceof Function) {
+ const { body, type, url } = options
+ // https://expressjs.com/en/4x/api.html#req
+ result = respond({
+ method: type,
+ body: JSON.parse(body),
+ query: param2Obj(url)
+ })
+ } else {
+ result = respond
+ }
+ return Mock.mock(result)
+ }
+ }
+
+ for (const i of mocks) {
+ Mock.mock(new RegExp(i.url), i.type || 'get', XHR2ExpressReqWrap(i.response))
+ }
+}
+
+module.exports = {
+ mocks,
+ mockXHR
+}
+
diff --git a/frontend/mock/mock-server.js b/frontend/mock/mock-server.js
new file mode 100644
index 0000000000000000000000000000000000000000..8941ec0f8035485e9c432ae7789ffd817e96ef42
--- /dev/null
+++ b/frontend/mock/mock-server.js
@@ -0,0 +1,81 @@
+const chokidar = require('chokidar')
+const bodyParser = require('body-parser')
+const chalk = require('chalk')
+const path = require('path')
+const Mock = require('mockjs')
+
+const mockDir = path.join(process.cwd(), 'mock')
+
+function registerRoutes(app) {
+ let mockLastIndex
+ const { mocks } = require('./index.js')
+ const mocksForServer = mocks.map(route => {
+ return responseFake(route.url, route.type, route.response)
+ })
+ for (const mock of mocksForServer) {
+ app[mock.type](mock.url, mock.response)
+ mockLastIndex = app._router.stack.length
+ }
+ const mockRoutesLength = Object.keys(mocksForServer).length
+ return {
+ mockRoutesLength: mockRoutesLength,
+ mockStartIndex: mockLastIndex - mockRoutesLength
+ }
+}
+
+function unregisterRoutes() {
+ Object.keys(require.cache).forEach(i => {
+ if (i.includes(mockDir)) {
+ delete require.cache[require.resolve(i)]
+ }
+ })
+}
+
+// for mock server
+const responseFake = (url, type, respond) => {
+ return {
+ url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`),
+ type: type || 'get',
+ response(req, res) {
+ console.log('request invoke:' + req.path)
+ res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))
+ }
+ }
+}
+
+module.exports = app => {
+ // parse app.body
+ // https://expressjs.com/en/4x/api.html#req.body
+ app.use(bodyParser.json())
+ app.use(bodyParser.urlencoded({
+ extended: true
+ }))
+
+ const mockRoutes = registerRoutes(app)
+ var mockRoutesLength = mockRoutes.mockRoutesLength
+ var mockStartIndex = mockRoutes.mockStartIndex
+
+ // watch files, hot reload mock server
+ chokidar.watch(mockDir, {
+ ignored: /mock-server/,
+ ignoreInitial: true
+ }).on('all', (event, path) => {
+ if (event === 'change' || event === 'add') {
+ try {
+ // remove mock routes stack
+ app._router.stack.splice(mockStartIndex, mockRoutesLength)
+
+ // clear routes cache
+ unregisterRoutes()
+
+ const mockRoutes = registerRoutes(app)
+ mockRoutesLength = mockRoutes.mockRoutesLength
+ mockStartIndex = mockRoutes.mockStartIndex
+
+ console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
+ } catch (error) {
+ console.log(chalk.redBright(error))
+ }
+ }
+ })
+}
diff --git a/frontend/mock/table.js b/frontend/mock/table.js
new file mode 100644
index 0000000000000000000000000000000000000000..bd0e0133e1d8df7ba1411016f4c81fa9f4e69624
--- /dev/null
+++ b/frontend/mock/table.js
@@ -0,0 +1,29 @@
+const Mock = require('mockjs')
+
+const data = Mock.mock({
+ 'items|30': [{
+ id: '@id',
+ title: '@sentence(10, 20)',
+ 'status|1': ['published', 'draft', 'deleted'],
+ author: 'name',
+ display_time: '@datetime',
+ pageviews: '@integer(300, 5000)'
+ }]
+})
+
+module.exports = [
+ {
+ url: '/vue-admin-template/table/list',
+ type: 'get',
+ response: config => {
+ const items = data.items
+ return {
+ code: 20000,
+ data: {
+ total: items.length,
+ items: items
+ }
+ }
+ }
+ }
+]
diff --git a/frontend/mock/user.js b/frontend/mock/user.js
new file mode 100644
index 0000000000000000000000000000000000000000..75553385621b0a659bad234c2a151000793712fe
--- /dev/null
+++ b/frontend/mock/user.js
@@ -0,0 +1,84 @@
+
+const tokens = {
+ admin: {
+ token: 'admin-token'
+ },
+ editor: {
+ token: 'editor-token'
+ }
+}
+
+const users = {
+ 'admin-token': {
+ roles: ['admin'],
+ introduction: 'I am a super administrator',
+ avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
+ name: 'Super Admin'
+ },
+ 'editor-token': {
+ roles: ['editor'],
+ introduction: 'I am an editor',
+ avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
+ name: 'Normal Editor'
+ }
+}
+
+module.exports = [
+ // user login
+ {
+ url: '/vue-admin-template/user/login',
+ type: 'post',
+ response: config => {
+ const { username } = config.body
+ const token = tokens[username]
+
+ // mock error
+ if (!token) {
+ return {
+ code: 60204,
+ message: 'Account and password are incorrect.'
+ }
+ }
+
+ return {
+ code: 20000,
+ data: token
+ }
+ }
+ },
+
+ // get user info
+ {
+ url: '/vue-admin-template/user/info\.*',
+ type: 'get',
+ response: config => {
+ const { token } = config.query
+ const info = users[token]
+
+ // mock error
+ if (!info) {
+ return {
+ code: 50008,
+ message: 'Login failed, unable to get user details.'
+ }
+ }
+
+ return {
+ code: 20000,
+ data: info
+ }
+ }
+ },
+
+ // user logout
+ {
+ url: '/vue-admin-template/user/logout',
+ type: 'post',
+ response: _ => {
+ return {
+ code: 20000,
+ data: 'success'
+ }
+ }
+ }
+]
diff --git a/frontend/mock/utils.js b/frontend/mock/utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..95cc27d5fe6446bc16960a0c2f79975ca6cec411
--- /dev/null
+++ b/frontend/mock/utils.js
@@ -0,0 +1,25 @@
+/**
+ * @param {string} url
+ * @returns {Object}
+ */
+function param2Obj(url) {
+ const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
+ if (!search) {
+ return {}
+ }
+ const obj = {}
+ const searchArr = search.split('&')
+ searchArr.forEach(v => {
+ const index = v.indexOf('=')
+ if (index !== -1) {
+ const name = v.substring(0, index)
+ const val = v.substring(index + 1, v.length)
+ obj[name] = val
+ }
+ })
+ return obj
+}
+
+module.exports = {
+ param2Obj
+}
diff --git a/frontend/package.json b/frontend/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..42990ba8e0c268af134cab60d6fd7c0640580d83
--- /dev/null
+++ b/frontend/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "vue-admin-template",
+ "version": "4.4.0",
+ "description": "A vue admin template with Element UI & axios & iconfont & permission control & lint",
+ "author": "Pan ",
+ "scripts": {
+ "dev": "./node_modules/.bin/vue-cli-service serve ",
+ "build:prod": "./node_modules/.bin/vue-cli-service build",
+ "build:stage": "./node_modules/.bin/vue-cli-service build --mode staging",
+ "preview": "node build/index.js --preview",
+ "svgo": "./node_modules/.bin/svgo -f src/icons/svg --config=src/icons/svgo.yml",
+ "lint": "./node_modules/.bin/eslint --ext .js,.vue src",
+ "test:unit": "./node_modules/.bin/jest --clearCache && vue-cli-service test:unit",
+ "test:ci": "npm run lint && npm run test:unit"
+ },
+ "dependencies": {
+ "axios": "0.18.1",
+ "core-js": "^3.26.1",
+ "element-ui": "2.15.14",
+ "file-saver": "^2.0.5",
+ "js-cookie": "2.2.0",
+ "normalize.css": "7.0.0",
+ "nprogress": "0.2.0",
+ "path-to-regexp": "2.4.0",
+ "vue": "2.6.10",
+ "vue-router": "3.0.6",
+ "vuex": "3.1.0",
+ "xlsx": "^0.18.5"
+ },
+ "devDependencies": {
+ "@vue/cli-plugin-babel": "4.4.4",
+ "@vue/cli-plugin-eslint": "4.4.4",
+ "@vue/cli-plugin-unit-jest": "4.4.4",
+ "@vue/cli-service": "4.4.4",
+ "@vue/test-utils": "1.0.0-beta.29",
+ "autoprefixer": "9.5.1",
+ "babel-eslint": "10.1.0",
+ "babel-jest": "23.6.0",
+ "babel-plugin-dynamic-import-node": "2.3.3",
+ "chalk": "2.4.2",
+ "connect": "3.6.6",
+ "eslint": "6.7.2",
+ "eslint-plugin-vue": "6.2.2",
+ "html-webpack-plugin": "3.2.0",
+ "mockjs": "1.0.1-beta3",
+ "runjs": "4.3.2",
+ "sass": "1.26.8",
+ "sass-loader": "8.0.2",
+ "script-ext-html-webpack-plugin": "2.1.3",
+ "serve-static": "1.13.2",
+ "svg-sprite-loader": "4.1.3",
+ "svgo": "1.2.2",
+ "vue-template-compiler": "2.6.10"
+ },
+ "browserslist": [
+ "> 1%",
+ "last 2 versions"
+ ],
+ "engines": {
+ "node": ">=8.9",
+ "npm": ">= 3.0.0"
+ },
+ "license": "MIT"
+}
diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js
new file mode 100644
index 0000000000000000000000000000000000000000..10473efcf85dc43627ec84b86fe06b5f7fd1296b
--- /dev/null
+++ b/frontend/postcss.config.js
@@ -0,0 +1,8 @@
+// https://github.com/michael-ciniawsky/postcss-load-config
+
+module.exports = {
+ 'plugins': {
+ // to edit target browsers: use "browserslist" field in package.json
+ 'autoprefixer': {}
+ }
+}
diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..34b63ac63a87ee3ea8e7a0f3f5b5406c437e2112
Binary files /dev/null and b/frontend/public/favicon.ico differ
diff --git a/frontend/public/freewebsys-logo.jpg b/frontend/public/freewebsys-logo.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..53440088cd6e343b941ed316ad4856d2aff602eb
Binary files /dev/null and b/frontend/public/freewebsys-logo.jpg differ
diff --git a/frontend/public/index.html b/frontend/public/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..fa2be9164ac798754109790fb853df97fc5e85d4
--- /dev/null
+++ b/frontend/public/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ <%= webpackConfig.name %>
+
+
+
+
+
+
+
diff --git a/frontend/public/stock-001.png b/frontend/public/stock-001.png
new file mode 100644
index 0000000000000000000000000000000000000000..417355a51446f1ed84574b203aa1e6ec7e5deae1
Binary files /dev/null and b/frontend/public/stock-001.png differ
diff --git a/frontend/public/stock-002.png b/frontend/public/stock-002.png
new file mode 100644
index 0000000000000000000000000000000000000000..faf015fc2b77b08d787fa15e92b3dc88f881a042
Binary files /dev/null and b/frontend/public/stock-002.png differ
diff --git a/frontend/public/stock-003.png b/frontend/public/stock-003.png
new file mode 100644
index 0000000000000000000000000000000000000000..5a375168535285ee56659f28b36d2d1025bb82ce
Binary files /dev/null and b/frontend/public/stock-003.png differ
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
new file mode 100644
index 0000000000000000000000000000000000000000..ec9032c1c638e918ec97e413aa081993a95048f4
--- /dev/null
+++ b/frontend/src/App.vue
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/api/article.js b/frontend/src/api/article.js
new file mode 100644
index 0000000000000000000000000000000000000000..c21f6d54101cb86b751005a3a80bd176584579b9
--- /dev/null
+++ b/frontend/src/api/article.js
@@ -0,0 +1,41 @@
+import request from '@/utils/request'
+
+export function fetchList(query) {
+ return request({
+ url: '/api/v1/api_data',
+ method: 'get',
+ params: query
+ })
+}
+
+export function fetchArticle(id) {
+ return request({
+ url: '/vue-element-admin/article/detail',
+ method: 'get',
+ params: { id }
+ })
+}
+
+export function fetchPv(pv) {
+ return request({
+ url: '/vue-element-admin/article/pv',
+ method: 'get',
+ params: { pv }
+ })
+}
+
+export function createArticle(data) {
+ return request({
+ url: '/vue-element-admin/article/create',
+ method: 'post',
+ data
+ })
+}
+
+export function updateArticle(data) {
+ return request({
+ url: '/vue-element-admin/article/update',
+ method: 'post',
+ data
+ })
+}
diff --git a/frontend/src/api/menu.js b/frontend/src/api/menu.js
new file mode 100644
index 0000000000000000000000000000000000000000..54f3fb419688456c06264034996c30d90266071c
--- /dev/null
+++ b/frontend/src/api/menu.js
@@ -0,0 +1,12 @@
+import request from '@/utils/request'
+
+// 同步获得菜单相关数据。
+
+export function fetchMenuList(query) {
+ return request({
+ url: '/api/v1/menu_list',
+ method: 'get',
+ params: query
+ })
+}
+
diff --git a/frontend/src/api/package.js b/frontend/src/api/package.js
new file mode 100644
index 0000000000000000000000000000000000000000..61c97547f39f776fb1942c27b3326f69eb8201d2
--- /dev/null
+++ b/frontend/src/api/package.js
@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+export function fetchPackageVersion(query) {
+ return request({
+ url: '/api/v1/package_verison',
+ method: 'get',
+ params: query
+ })
+}
+
diff --git a/frontend/src/api/table.js b/frontend/src/api/table.js
new file mode 100644
index 0000000000000000000000000000000000000000..2752f52e164096081bd566162e62e4a66fa065d3
--- /dev/null
+++ b/frontend/src/api/table.js
@@ -0,0 +1,9 @@
+import request from '@/utils/request'
+
+export function getList(params) {
+ return request({
+ url: '/vue-admin-template/table/list',
+ method: 'get',
+ params
+ })
+}
diff --git a/frontend/src/api/user.js b/frontend/src/api/user.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ff4389dbae65b9c122be91c4001f0f7ede21cef
--- /dev/null
+++ b/frontend/src/api/user.js
@@ -0,0 +1,24 @@
+import request from '@/utils/request'
+
+export function login(data) {
+ return request({
+ url: '/vue-admin-template/user/login',
+ method: 'post',
+ data
+ })
+}
+
+export function getInfo(token) {
+ return request({
+ url: '/vue-admin-template/user/info',
+ method: 'get',
+ params: { token }
+ })
+}
+
+export function logout() {
+ return request({
+ url: '/vue-admin-template/user/logout',
+ method: 'post'
+ })
+}
diff --git a/frontend/src/assets/404_images/404.png b/frontend/src/assets/404_images/404.png
new file mode 100644
index 0000000000000000000000000000000000000000..3d8e2305cc973ad2121403aee4bf08728f76c461
Binary files /dev/null and b/frontend/src/assets/404_images/404.png differ
diff --git a/frontend/src/assets/404_images/404_cloud.png b/frontend/src/assets/404_images/404_cloud.png
new file mode 100644
index 0000000000000000000000000000000000000000..c6281d09013e0a2c5f8e699a0a6038d9480291e5
Binary files /dev/null and b/frontend/src/assets/404_images/404_cloud.png differ
diff --git a/frontend/src/components/Breadcrumb/index.vue b/frontend/src/components/Breadcrumb/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..29f9a04c9dcf9f8d1b216f5cbdf0046606c4d203
--- /dev/null
+++ b/frontend/src/components/Breadcrumb/index.vue
@@ -0,0 +1,78 @@
+
+
+
+
+ {{ item.meta.title }}
+ {{ item.meta.title }}
+
+
+
+
+
+
+
+
diff --git a/frontend/src/components/Hamburger/index.vue b/frontend/src/components/Hamburger/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..368b002154ef7dfb2625e15a43d2ad264bfa040c
--- /dev/null
+++ b/frontend/src/components/Hamburger/index.vue
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/components/Pagination/index.vue b/frontend/src/components/Pagination/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..c815e132ce2d5ccb63d4a9a9aed80841ec884633
--- /dev/null
+++ b/frontend/src/components/Pagination/index.vue
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/components/SvgIcon/index.vue b/frontend/src/components/SvgIcon/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..b07ded2af39d367113e28f68ca581b74b2625718
--- /dev/null
+++ b/frontend/src/components/SvgIcon/index.vue
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
diff --git a/frontend/src/directive/el-table/adaptive.js b/frontend/src/directive/el-table/adaptive.js
new file mode 100644
index 0000000000000000000000000000000000000000..d229e9fd9b421e333370367502a49d597e601b47
--- /dev/null
+++ b/frontend/src/directive/el-table/adaptive.js
@@ -0,0 +1,41 @@
+import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event'
+
+/**
+ * How to use
+ * ...
+ * el-table height is must be set
+ * bottomOffset: 30(default) // The height of the table from the bottom of the page.
+ */
+
+const doResize = (el, binding, vnode) => {
+ const { componentInstance: $table } = vnode
+
+ const { value } = binding
+
+ if (!$table.height) {
+ throw new Error(`el-$table must set the height. Such as height='100px'`)
+ }
+ const bottomOffset = (value && value.bottomOffset) || 30
+
+ if (!$table) return
+
+ const height = window.innerHeight - el.getBoundingClientRect().top - bottomOffset
+ $table.layout.setHeight(height)
+ $table.doLayout()
+}
+
+export default {
+ bind(el, binding, vnode) {
+ el.resizeListener = () => {
+ doResize(el, binding, vnode)
+ }
+ // parameter 1 is must be "Element" type
+ addResizeListener(window.document.body, el.resizeListener)
+ },
+ inserted(el, binding, vnode) {
+ doResize(el, binding, vnode)
+ },
+ unbind(el) {
+ removeResizeListener(window.document.body, el.resizeListener)
+ }
+}
diff --git a/frontend/src/directive/el-table/index.js b/frontend/src/directive/el-table/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..d3d45150cec3f588d756028057da1213f28eb1d2
--- /dev/null
+++ b/frontend/src/directive/el-table/index.js
@@ -0,0 +1,13 @@
+import adaptive from './adaptive'
+
+const install = function(Vue) {
+ Vue.directive('el-height-adaptive-table', adaptive)
+}
+
+if (window.Vue) {
+ window['el-height-adaptive-table'] = adaptive
+ Vue.use(install); // eslint-disable-line
+}
+
+adaptive.install = install
+export default adaptive
diff --git a/frontend/src/directive/waves/index.js b/frontend/src/directive/waves/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..65f9b3084c2a1f02c1a91f4814fa95b82106ae8d
--- /dev/null
+++ b/frontend/src/directive/waves/index.js
@@ -0,0 +1,13 @@
+import waves from './waves'
+
+const install = function(Vue) {
+ Vue.directive('waves', waves)
+}
+
+if (window.Vue) {
+ window.waves = waves
+ Vue.use(install); // eslint-disable-line
+}
+
+waves.install = install
+export default waves
diff --git a/frontend/src/directive/waves/waves.css b/frontend/src/directive/waves/waves.css
new file mode 100644
index 0000000000000000000000000000000000000000..af7a7efd9f1a0d239a34906c4a49eb2200df55c2
--- /dev/null
+++ b/frontend/src/directive/waves/waves.css
@@ -0,0 +1,26 @@
+.waves-ripple {
+ position: absolute;
+ border-radius: 100%;
+ background-color: rgba(0, 0, 0, 0.15);
+ background-clip: padding-box;
+ pointer-events: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-transform: scale(0);
+ -ms-transform: scale(0);
+ transform: scale(0);
+ opacity: 1;
+}
+
+.waves-ripple.z-active {
+ opacity: 0;
+ -webkit-transform: scale(2);
+ -ms-transform: scale(2);
+ transform: scale(2);
+ -webkit-transition: opacity 1.2s ease-out, -webkit-transform 0.6s ease-out;
+ transition: opacity 1.2s ease-out, -webkit-transform 0.6s ease-out;
+ transition: opacity 1.2s ease-out, transform 0.6s ease-out;
+ transition: opacity 1.2s ease-out, transform 0.6s ease-out, -webkit-transform 0.6s ease-out;
+}
\ No newline at end of file
diff --git a/frontend/src/directive/waves/waves.js b/frontend/src/directive/waves/waves.js
new file mode 100644
index 0000000000000000000000000000000000000000..ec2ff439f77d4815eda95f2259830c7bb057099b
--- /dev/null
+++ b/frontend/src/directive/waves/waves.js
@@ -0,0 +1,72 @@
+import './waves.css'
+
+const context = '@@wavesContext'
+
+function handleClick(el, binding) {
+ function handle(e) {
+ const customOpts = Object.assign({}, binding.value)
+ const opts = Object.assign({
+ ele: el, // 波纹作用元素
+ type: 'hit', // hit 点击位置扩散 center中心点扩展
+ color: 'rgba(0, 0, 0, 0.15)' // 波纹颜色
+ },
+ customOpts
+ )
+ const target = opts.ele
+ if (target) {
+ target.style.position = 'relative'
+ target.style.overflow = 'hidden'
+ const rect = target.getBoundingClientRect()
+ let ripple = target.querySelector('.waves-ripple')
+ if (!ripple) {
+ ripple = document.createElement('span')
+ ripple.className = 'waves-ripple'
+ ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px'
+ target.appendChild(ripple)
+ } else {
+ ripple.className = 'waves-ripple'
+ }
+ switch (opts.type) {
+ case 'center':
+ ripple.style.top = rect.height / 2 - ripple.offsetHeight / 2 + 'px'
+ ripple.style.left = rect.width / 2 - ripple.offsetWidth / 2 + 'px'
+ break
+ default:
+ ripple.style.top =
+ (e.pageY - rect.top - ripple.offsetHeight / 2 - document.documentElement.scrollTop ||
+ document.body.scrollTop) + 'px'
+ ripple.style.left =
+ (e.pageX - rect.left - ripple.offsetWidth / 2 - document.documentElement.scrollLeft ||
+ document.body.scrollLeft) + 'px'
+ }
+ ripple.style.backgroundColor = opts.color
+ ripple.className = 'waves-ripple z-active'
+ return false
+ }
+ }
+
+ if (!el[context]) {
+ el[context] = {
+ removeHandle: handle
+ }
+ } else {
+ el[context].removeHandle = handle
+ }
+
+ return handle
+}
+
+export default {
+ bind(el, binding) {
+ el.addEventListener('click', handleClick(el, binding), false)
+ },
+ update(el, binding) {
+ el.removeEventListener('click', el[context].removeHandle, false)
+ el.addEventListener('click', handleClick(el, binding), false)
+ },
+ unbind(el) {
+ el.removeEventListener('click', el[context].removeHandle, false)
+ el[context] = null
+ delete el[context]
+ }
+}
diff --git a/frontend/src/icons/index.js b/frontend/src/icons/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..2c6b309c96cc2e43761a691860858f232f6d5d1a
--- /dev/null
+++ b/frontend/src/icons/index.js
@@ -0,0 +1,9 @@
+import Vue from 'vue'
+import SvgIcon from '@/components/SvgIcon'// svg component
+
+// register globally
+Vue.component('svg-icon', SvgIcon)
+
+const req = require.context('./svg', false, /\.svg$/)
+const requireAll = requireContext => requireContext.keys().map(requireContext)
+requireAll(req)
diff --git a/frontend/src/icons/svg/dashboard.svg b/frontend/src/icons/svg/dashboard.svg
new file mode 100644
index 0000000000000000000000000000000000000000..5317d37029218281b4da78eccf40ce9e94941301
--- /dev/null
+++ b/frontend/src/icons/svg/dashboard.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/example.svg b/frontend/src/icons/svg/example.svg
new file mode 100644
index 0000000000000000000000000000000000000000..46f42b5323d11686c44b573729db0df115343d5c
--- /dev/null
+++ b/frontend/src/icons/svg/example.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/eye-open.svg b/frontend/src/icons/svg/eye-open.svg
new file mode 100644
index 0000000000000000000000000000000000000000..88dcc98e6c80d145e3807f00a6e5ed91ce5371e4
--- /dev/null
+++ b/frontend/src/icons/svg/eye-open.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/eye.svg b/frontend/src/icons/svg/eye.svg
new file mode 100644
index 0000000000000000000000000000000000000000..16ed2d872d1cadeb36fc9101cbf77397fbf4fd70
--- /dev/null
+++ b/frontend/src/icons/svg/eye.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/form.svg b/frontend/src/icons/svg/form.svg
new file mode 100644
index 0000000000000000000000000000000000000000..dcbaa185a845cdf01a7fdfb849c224ce9c4af011
--- /dev/null
+++ b/frontend/src/icons/svg/form.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/link.svg b/frontend/src/icons/svg/link.svg
new file mode 100644
index 0000000000000000000000000000000000000000..48197ba4da7b4314a16a19a698fe96c1b2a7ad0b
--- /dev/null
+++ b/frontend/src/icons/svg/link.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/nested.svg b/frontend/src/icons/svg/nested.svg
new file mode 100644
index 0000000000000000000000000000000000000000..06713a86c6a3db0cd5eeb26cf81ffb27b538e9a1
--- /dev/null
+++ b/frontend/src/icons/svg/nested.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/password.svg b/frontend/src/icons/svg/password.svg
new file mode 100644
index 0000000000000000000000000000000000000000..e291d85df22083536bb2e40fd18120ef6d6b141d
--- /dev/null
+++ b/frontend/src/icons/svg/password.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/table.svg b/frontend/src/icons/svg/table.svg
new file mode 100644
index 0000000000000000000000000000000000000000..0e3dc9dea5a0ff92d617cdfee4f10ef600a02433
--- /dev/null
+++ b/frontend/src/icons/svg/table.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/tree.svg b/frontend/src/icons/svg/tree.svg
new file mode 100644
index 0000000000000000000000000000000000000000..dd4b7dd22fe06076831935066592caec48e323b0
--- /dev/null
+++ b/frontend/src/icons/svg/tree.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svg/user.svg b/frontend/src/icons/svg/user.svg
new file mode 100644
index 0000000000000000000000000000000000000000..0ba0716a62a92f7cb2f2e6f3c745ace2be6b3b31
--- /dev/null
+++ b/frontend/src/icons/svg/user.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend/src/icons/svgo.yml b/frontend/src/icons/svgo.yml
new file mode 100644
index 0000000000000000000000000000000000000000..d11906aec26dd14372dd1b298f72270c38cce1b7
--- /dev/null
+++ b/frontend/src/icons/svgo.yml
@@ -0,0 +1,22 @@
+# replace default config
+
+# multipass: true
+# full: true
+
+plugins:
+
+ # - name
+ #
+ # or:
+ # - name: false
+ # - name: true
+ #
+ # or:
+ # - name:
+ # param1: 1
+ # param2: 2
+
+- removeAttrs:
+ attrs:
+ - 'fill'
+ - 'fill-rule'
diff --git a/frontend/src/layout/components/AppMain.vue b/frontend/src/layout/components/AppMain.vue
new file mode 100644
index 0000000000000000000000000000000000000000..f6a3286f585e7f86e8c9913c53615d2d74afc497
--- /dev/null
+++ b/frontend/src/layout/components/AppMain.vue
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/Navbar.vue b/frontend/src/layout/components/Navbar.vue
new file mode 100644
index 0000000000000000000000000000000000000000..1f6e40e6fce29c7cb5d5d2bea9473829a8b6001d
--- /dev/null
+++ b/frontend/src/layout/components/Navbar.vue
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/Sidebar/FixiOSBug.js b/frontend/src/layout/components/Sidebar/FixiOSBug.js
new file mode 100644
index 0000000000000000000000000000000000000000..bc14856f0768d6b1aed2f59bbfed3f2775977ac8
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/FixiOSBug.js
@@ -0,0 +1,26 @@
+export default {
+ computed: {
+ device() {
+ return this.$store.state.app.device
+ }
+ },
+ mounted() {
+ // In order to fix the click on menu on the ios device will trigger the mouseleave bug
+ // https://github.com/PanJiaChen/vue-element-admin/issues/1135
+ this.fixBugIniOS()
+ },
+ methods: {
+ fixBugIniOS() {
+ const $subMenu = this.$refs.subMenu
+ if ($subMenu) {
+ const handleMouseleave = $subMenu.handleMouseleave
+ $subMenu.handleMouseleave = (e) => {
+ if (this.device === 'mobile') {
+ return
+ }
+ handleMouseleave(e)
+ }
+ }
+ }
+ }
+}
diff --git a/frontend/src/layout/components/Sidebar/Item.vue b/frontend/src/layout/components/Sidebar/Item.vue
new file mode 100644
index 0000000000000000000000000000000000000000..aa1f5da4de23482ad3fdb4a0d8d07772117ecd36
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/Item.vue
@@ -0,0 +1,41 @@
+
+
+
diff --git a/frontend/src/layout/components/Sidebar/Link.vue b/frontend/src/layout/components/Sidebar/Link.vue
new file mode 100644
index 0000000000000000000000000000000000000000..530b3d5b3749538745ffbf2fcb32547a4de3bfa3
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/Link.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/Sidebar/Logo.vue b/frontend/src/layout/components/Sidebar/Logo.vue
new file mode 100644
index 0000000000000000000000000000000000000000..040fab64696f4a2406edc9a0182a234e2619ed3f
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/Logo.vue
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/Sidebar/SidebarItem.vue b/frontend/src/layout/components/Sidebar/SidebarItem.vue
new file mode 100644
index 0000000000000000000000000000000000000000..a418c3d712a6d23a6aa70f4fa779011cac3b64ef
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/SidebarItem.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/Sidebar/index.vue b/frontend/src/layout/components/Sidebar/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..da39034fd058f2dac91ff5d9cc0157e74189b9b1
--- /dev/null
+++ b/frontend/src/layout/components/Sidebar/index.vue
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/components/index.js b/frontend/src/layout/components/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..97ee3cd12dce9a371b571dfba3c2b9fc16dc988c
--- /dev/null
+++ b/frontend/src/layout/components/index.js
@@ -0,0 +1,3 @@
+export { default as Navbar } from './Navbar'
+export { default as Sidebar } from './Sidebar'
+export { default as AppMain } from './AppMain'
diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..db22a7bc3eb02e559fb32f99667288e6cfe0783a
--- /dev/null
+++ b/frontend/src/layout/index.vue
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/layout/mixin/ResizeHandler.js b/frontend/src/layout/mixin/ResizeHandler.js
new file mode 100644
index 0000000000000000000000000000000000000000..e8d0df8c237c20405aacc19a1e317ce5b09cd5d1
--- /dev/null
+++ b/frontend/src/layout/mixin/ResizeHandler.js
@@ -0,0 +1,45 @@
+import store from '@/store'
+
+const { body } = document
+const WIDTH = 992 // refer to Bootstrap's responsive design
+
+export default {
+ watch: {
+ $route(route) {
+ if (this.device === 'mobile' && this.sidebar.opened) {
+ store.dispatch('app/closeSideBar', { withoutAnimation: false })
+ }
+ }
+ },
+ beforeMount() {
+ window.addEventListener('resize', this.$_resizeHandler)
+ },
+ beforeDestroy() {
+ window.removeEventListener('resize', this.$_resizeHandler)
+ },
+ mounted() {
+ const isMobile = this.$_isMobile()
+ if (isMobile) {
+ store.dispatch('app/toggleDevice', 'mobile')
+ store.dispatch('app/closeSideBar', { withoutAnimation: true })
+ }
+ },
+ methods: {
+ // use $_ for mixins properties
+ // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
+ $_isMobile() {
+ const rect = body.getBoundingClientRect()
+ return rect.width - 1 < WIDTH
+ },
+ $_resizeHandler() {
+ if (!document.hidden) {
+ const isMobile = this.$_isMobile()
+ store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
+
+ if (isMobile) {
+ store.dispatch('app/closeSideBar', { withoutAnimation: true })
+ }
+ }
+ }
+ }
+}
diff --git a/frontend/src/main.js b/frontend/src/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..c57df4f2565f3f10563e69f0de02df3f34ba66f3
--- /dev/null
+++ b/frontend/src/main.js
@@ -0,0 +1,44 @@
+import Vue from 'vue'
+
+import 'normalize.css/normalize.css' // A modern alternative to CSS resets
+
+import ElementUI from 'element-ui'
+import 'element-ui/lib/theme-chalk/index.css'
+import locale from 'element-ui/lib/locale/lang/en' // lang i18n
+
+import '@/styles/index.scss' // global css
+
+import App from './App'
+import store from './store'
+import router from './router'
+
+import '@/icons' // icon
+// import '@/permission' // permission control
+// 不进行登录校验。
+
+/**
+ * If you don't want to use mock-server
+ * you want to use MockJs for mock api
+ * you can execute: mockXHR()
+ *
+ * Currently MockJs will be used in the production environment,
+ * please remove it before going online ! ! !
+ */
+if (process.env.NODE_ENV === 'production') {
+ const { mockXHR } = require('../mock')
+ mockXHR()
+}
+
+// set ElementUI lang to EN
+Vue.use(ElementUI, { locale })
+// 如果想要中文版 element-ui,按如下方式声明
+// Vue.use(ElementUI)
+
+Vue.config.productionTip = false
+
+new Vue({
+ el: '#app',
+ router,
+ store,
+ render: h => h(App)
+})
diff --git a/frontend/src/permission.js b/frontend/src/permission.js
new file mode 100644
index 0000000000000000000000000000000000000000..fa1ea1936eed8e6e705baa9f7c612e9b9a8ba907
--- /dev/null
+++ b/frontend/src/permission.js
@@ -0,0 +1,64 @@
+import router from './router'
+import store from './store'
+import { Message } from 'element-ui'
+import NProgress from 'nprogress' // progress bar
+import 'nprogress/nprogress.css' // progress bar style
+import { getToken } from '@/utils/auth' // get token from cookie
+import getPageTitle from '@/utils/get-page-title'
+
+NProgress.configure({ showSpinner: false }) // NProgress Configuration
+
+const whiteList = ['/login'] // no redirect whitelist
+
+router.beforeEach(async(to, from, next) => {
+ // start progress bar
+ NProgress.start()
+
+ // set page title
+ document.title = getPageTitle(to.meta.title)
+
+ // determine whether the user has logged in
+ const hasToken = getToken()
+
+ if (hasToken) {
+ if (to.path === '/login') {
+ // if is logged in, redirect to the home page
+ next({ path: '/' })
+ NProgress.done()
+ } else {
+ const hasGetUserInfo = store.getters.name
+ if (hasGetUserInfo) {
+ next()
+ } else {
+ try {
+ // get user info
+ await store.dispatch('user/getInfo')
+
+ next()
+ } catch (error) {
+ // remove token and go to login page to re-login
+ await store.dispatch('user/resetToken')
+ Message.error(error || 'Has Error')
+ next(`/login?redirect=${to.path}`)
+ NProgress.done()
+ }
+ }
+ }
+ } else {
+ /* has no token*/
+
+ if (whiteList.indexOf(to.path) !== -1) {
+ // in the free login whitelist, go directly
+ next()
+ } else {
+ // other pages that do not have permission to access are redirected to the login page.
+ next(`/login?redirect=${to.path}`)
+ NProgress.done()
+ }
+ }
+})
+
+router.afterEach(() => {
+ // finish progress bar
+ NProgress.done()
+})
diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..be7f23b6fbe80ad0e2bc06d0ea16870df255d402
--- /dev/null
+++ b/frontend/src/router/index.js
@@ -0,0 +1,128 @@
+import Vue from 'vue'
+import Router from 'vue-router'
+
+//Vue全局使用Router
+Vue.use(Router)
+
+/* Layout */
+import Layout from '@/layout'
+import { fetchMenuList } from '@/api/menu'
+
+
+/**
+ * Note: sub-menu only appear when route children.length >= 1
+ * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
+ *
+ * hidden: true if set true, item will not show in the sidebar(default is false)
+ * alwaysShow: true if set true, will always show the root menu
+ * if not set alwaysShow, when item has more than one children route,
+ * it will becomes nested mode, otherwise not show the root menu
+ * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
+ * name:'router-name' the name is used by (must set!!!)
+ * meta : {
+ roles: ['admin','editor'] control the page roles (you can set multiple roles)
+ title: 'title' the name show in sidebar and breadcrumb (recommend set)
+ icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
+ breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
+ activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
+ }
+ */
+
+/**
+ * constantRoutes
+ * a base page that does not have permission requirements
+ * all roles can be accessed
+ */
+let constantRoutes = [
+ {
+ path: '/login',
+ component: () => import('@/views/login/index'),
+ hidden: true
+ },
+
+ {
+ path: '/404',
+ component: () => import('@/views/404'),
+ hidden: true
+ },
+
+ {
+ path: '/',
+ component: Layout,
+ redirect: '/dashboard',
+ children: [{
+ path: 'dashboard',
+ name: 'Dashboard',
+ component: () => import('@/views/dashboard/index'),
+ meta: { title: 'Dashboard', icon: 'dashboard' }
+ }]
+ },
+
+ {
+ path: '/stock',
+ component: Layout,
+ redirect: '#',
+ name: 'stock-data-table',
+ meta: { title: 'Example', icon: 'el-icon-s-help' },
+ children: [
+ {
+ path: 'table/:tableName',
+ name: 'Table',
+ component: () => import('@/views/table/index'),
+ meta: { title: 'Table', icon: 'table' }
+ }
+ ]
+ },
+
+
+]
+
+fetchMenuList().then(response => {
+
+ let menu_data = response.data
+ for (const menu of menu_data) {
+ console.info(menu)
+ var childrenList = []
+ for (const childrenMenu of menu.children) {
+ var tmpChildren = {
+ path: childrenMenu.path,
+ name: childrenMenu.name,
+ component: () => import('@/views/table/index'),
+ meta: { title: childrenMenu.name , icon: 'table' }
+ }
+ childrenList.push(tmpChildren)
+ }
+ var tmp_menu = {
+ path: '/stock'+menu.name,
+ alwaysShow: true,
+ component: Layout,
+ name: menu.name,
+ redirect: '/#'+menu.name ,
+ meta: { title: menu.name , icon: 'el-icon-s-help' },
+ children: childrenList
+ }
+
+ constantRoutes.push(tmp_menu)
+ constantRoutes.push( { path: '*', redirect: '/404', hidden: true })
+
+ }
+})
+
+// // 404 page must be placed at the end !!!
+// constantRoutes.push( { path: '*', redirect: '/404', hidden: true })
+
+const createRouter = () => new Router({
+ // mode: 'history', // require service support
+ scrollBehavior: () => ({ y: 0 }),
+ routes: constantRoutes
+})
+
+const router = createRouter()
+
+// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
+export function resetRouter() {
+ const newRouter = createRouter()
+ router.matcher = newRouter.matcher // reset router
+}
+
+export default router
diff --git a/frontend/src/settings.js b/frontend/src/settings.js
new file mode 100644
index 0000000000000000000000000000000000000000..ae3c4949a90d81fe8637934e39f383747b6bb798
--- /dev/null
+++ b/frontend/src/settings.js
@@ -0,0 +1,16 @@
+module.exports = {
+
+ title: 'Vue Admin Template',
+
+ /**
+ * @type {boolean} true | false
+ * @description Whether fix the header
+ */
+ fixedHeader: false,
+
+ /**
+ * @type {boolean} true | false
+ * @description Whether show the logo in sidebar
+ */
+ sidebarLogo: false
+}
diff --git a/frontend/src/store/getters.js b/frontend/src/store/getters.js
new file mode 100644
index 0000000000000000000000000000000000000000..5ab7b4c8ba23fe62a23208cafeca2b9a3a5a2a40
--- /dev/null
+++ b/frontend/src/store/getters.js
@@ -0,0 +1,8 @@
+const getters = {
+ sidebar: state => state.app.sidebar,
+ device: state => state.app.device,
+ token: state => state.user.token,
+ avatar: state => state.user.avatar,
+ name: state => state.user.name
+}
+export default getters
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..6be466a5d2a89799b809407f360556360e8f5f83
--- /dev/null
+++ b/frontend/src/store/index.js
@@ -0,0 +1,19 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+import getters from './getters'
+import app from './modules/app'
+import settings from './modules/settings'
+import user from './modules/user'
+
+Vue.use(Vuex)
+
+const store = new Vuex.Store({
+ modules: {
+ app,
+ settings,
+ user
+ },
+ getters
+})
+
+export default store
diff --git a/frontend/src/store/modules/app.js b/frontend/src/store/modules/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..7ea7e33228290b58942fddac8cef5ac1d23153dd
--- /dev/null
+++ b/frontend/src/store/modules/app.js
@@ -0,0 +1,48 @@
+import Cookies from 'js-cookie'
+
+const state = {
+ sidebar: {
+ opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
+ withoutAnimation: false
+ },
+ device: 'desktop'
+}
+
+const mutations = {
+ TOGGLE_SIDEBAR: state => {
+ state.sidebar.opened = !state.sidebar.opened
+ state.sidebar.withoutAnimation = false
+ if (state.sidebar.opened) {
+ Cookies.set('sidebarStatus', 1)
+ } else {
+ Cookies.set('sidebarStatus', 0)
+ }
+ },
+ CLOSE_SIDEBAR: (state, withoutAnimation) => {
+ Cookies.set('sidebarStatus', 0)
+ state.sidebar.opened = false
+ state.sidebar.withoutAnimation = withoutAnimation
+ },
+ TOGGLE_DEVICE: (state, device) => {
+ state.device = device
+ }
+}
+
+const actions = {
+ toggleSideBar({ commit }) {
+ commit('TOGGLE_SIDEBAR')
+ },
+ closeSideBar({ commit }, { withoutAnimation }) {
+ commit('CLOSE_SIDEBAR', withoutAnimation)
+ },
+ toggleDevice({ commit }, device) {
+ commit('TOGGLE_DEVICE', device)
+ }
+}
+
+export default {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+}
diff --git a/frontend/src/store/modules/settings.js b/frontend/src/store/modules/settings.js
new file mode 100644
index 0000000000000000000000000000000000000000..b3f33f8325ecab51b781c7318e7826a4a4476569
--- /dev/null
+++ b/frontend/src/store/modules/settings.js
@@ -0,0 +1,32 @@
+import defaultSettings from '@/settings'
+
+const { showSettings, fixedHeader, sidebarLogo } = defaultSettings
+
+const state = {
+ showSettings: showSettings,
+ fixedHeader: fixedHeader,
+ sidebarLogo: sidebarLogo
+}
+
+const mutations = {
+ CHANGE_SETTING: (state, { key, value }) => {
+ // eslint-disable-next-line no-prototype-builtins
+ if (state.hasOwnProperty(key)) {
+ state[key] = value
+ }
+ }
+}
+
+const actions = {
+ changeSetting({ commit }, data) {
+ commit('CHANGE_SETTING', data)
+ }
+}
+
+export default {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+}
+
diff --git a/frontend/src/store/modules/user.js b/frontend/src/store/modules/user.js
new file mode 100644
index 0000000000000000000000000000000000000000..2f6423fa9cbe31a00b9a7edc5f483a999ec1292d
--- /dev/null
+++ b/frontend/src/store/modules/user.js
@@ -0,0 +1,97 @@
+import { login, logout, getInfo } from '@/api/user'
+import { getToken, setToken, removeToken } from '@/utils/auth'
+import { resetRouter } from '@/router'
+
+const getDefaultState = () => {
+ return {
+ token: getToken(),
+ name: '',
+ avatar: ''
+ }
+}
+
+const state = getDefaultState()
+
+const mutations = {
+ RESET_STATE: (state) => {
+ Object.assign(state, getDefaultState())
+ },
+ SET_TOKEN: (state, token) => {
+ state.token = token
+ },
+ SET_NAME: (state, name) => {
+ state.name = name
+ },
+ SET_AVATAR: (state, avatar) => {
+ state.avatar = avatar
+ }
+}
+
+const actions = {
+ // user login
+ login({ commit }, userInfo) {
+ const { username, password } = userInfo
+ return new Promise((resolve, reject) => {
+ login({ username: username.trim(), password: password }).then(response => {
+ const { data } = response
+ commit('SET_TOKEN', data.token)
+ setToken(data.token)
+ resolve()
+ }).catch(error => {
+ reject(error)
+ })
+ })
+ },
+
+ // get user info
+ getInfo({ commit, state }) {
+ return new Promise((resolve, reject) => {
+ getInfo(state.token).then(response => {
+ const { data } = response
+
+ if (!data) {
+ return reject('Verification failed, please Login again.')
+ }
+
+ const { name, avatar } = data
+
+ commit('SET_NAME', name)
+ commit('SET_AVATAR', avatar)
+ resolve(data)
+ }).catch(error => {
+ reject(error)
+ })
+ })
+ },
+
+ // user logout
+ logout({ commit, state }) {
+ return new Promise((resolve, reject) => {
+ logout(state.token).then(() => {
+ removeToken() // must remove token first
+ resetRouter()
+ commit('RESET_STATE')
+ resolve()
+ }).catch(error => {
+ reject(error)
+ })
+ })
+ },
+
+ // remove token
+ resetToken({ commit }) {
+ return new Promise(resolve => {
+ removeToken() // must remove token first
+ commit('RESET_STATE')
+ resolve()
+ })
+ }
+}
+
+export default {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+}
+
diff --git a/frontend/src/styles/element-ui.scss b/frontend/src/styles/element-ui.scss
new file mode 100644
index 0000000000000000000000000000000000000000..00624119c460a57d7ff146397db37350705af5a4
--- /dev/null
+++ b/frontend/src/styles/element-ui.scss
@@ -0,0 +1,49 @@
+// cover some element-ui styles
+
+.el-breadcrumb__inner,
+.el-breadcrumb__inner a {
+ font-weight: 400 !important;
+}
+
+.el-upload {
+ input[type="file"] {
+ display: none !important;
+ }
+}
+
+.el-upload__input {
+ display: none;
+}
+
+
+// to fixed https://github.com/ElemeFE/element/issues/2461
+.el-dialog {
+ transform: none;
+ left: 0;
+ position: relative;
+ margin: 0 auto;
+}
+
+// refine element ui upload
+.upload-container {
+ .el-upload {
+ width: 100%;
+
+ .el-upload-dragger {
+ width: 100%;
+ height: 200px;
+ }
+ }
+}
+
+// dropdown
+.el-dropdown-menu {
+ a {
+ display: block
+ }
+}
+
+// to fix el-date-picker css style
+.el-range-separator {
+ box-sizing: content-box;
+}
diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss
new file mode 100644
index 0000000000000000000000000000000000000000..3b4da517cd9b276c82ab9b51a85cc0a206f2c102
--- /dev/null
+++ b/frontend/src/styles/index.scss
@@ -0,0 +1,65 @@
+@import './variables.scss';
+@import './mixin.scss';
+@import './transition.scss';
+@import './element-ui.scss';
+@import './sidebar.scss';
+
+body {
+ height: 100%;
+ -moz-osx-font-smoothing: grayscale;
+ -webkit-font-smoothing: antialiased;
+ text-rendering: optimizeLegibility;
+ font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
+}
+
+label {
+ font-weight: 700;
+}
+
+html {
+ height: 100%;
+ box-sizing: border-box;
+}
+
+#app {
+ height: 100%;
+}
+
+*,
+*:before,
+*:after {
+ box-sizing: inherit;
+}
+
+a:focus,
+a:active {
+ outline: none;
+}
+
+a,
+a:focus,
+a:hover {
+ cursor: pointer;
+ color: inherit;
+ text-decoration: none;
+}
+
+div:focus {
+ outline: none;
+}
+
+.clearfix {
+ &:after {
+ visibility: hidden;
+ display: block;
+ font-size: 0;
+ content: " ";
+ clear: both;
+ height: 0;
+ }
+}
+
+// main-container global css
+.app-container {
+ padding: 20px;
+}
diff --git a/frontend/src/styles/mixin.scss b/frontend/src/styles/mixin.scss
new file mode 100644
index 0000000000000000000000000000000000000000..36b74bbd995e7cc5c6baab1ce6808ecfda8c27ae
--- /dev/null
+++ b/frontend/src/styles/mixin.scss
@@ -0,0 +1,28 @@
+@mixin clearfix {
+ &:after {
+ content: "";
+ display: table;
+ clear: both;
+ }
+}
+
+@mixin scrollBar {
+ &::-webkit-scrollbar-track-piece {
+ background: #d3dce6;
+ }
+
+ &::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background: #99a9bf;
+ border-radius: 20px;
+ }
+}
+
+@mixin relative {
+ position: relative;
+ width: 100%;
+ height: 100%;
+}
diff --git a/frontend/src/styles/sidebar.scss b/frontend/src/styles/sidebar.scss
new file mode 100644
index 0000000000000000000000000000000000000000..94760cc76136d17fe1350793dd07b98e85d370bb
--- /dev/null
+++ b/frontend/src/styles/sidebar.scss
@@ -0,0 +1,226 @@
+#app {
+
+ .main-container {
+ min-height: 100%;
+ transition: margin-left .28s;
+ margin-left: $sideBarWidth;
+ position: relative;
+ }
+
+ .sidebar-container {
+ transition: width 0.28s;
+ width: $sideBarWidth !important;
+ background-color: $menuBg;
+ height: 100%;
+ position: fixed;
+ font-size: 0px;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1001;
+ overflow: hidden;
+
+ // reset element-ui css
+ .horizontal-collapse-transition {
+ transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
+ }
+
+ .scrollbar-wrapper {
+ overflow-x: hidden !important;
+ }
+
+ .el-scrollbar__bar.is-vertical {
+ right: 0px;
+ }
+
+ .el-scrollbar {
+ height: 100%;
+ }
+
+ &.has-logo {
+ .el-scrollbar {
+ height: calc(100% - 50px);
+ }
+ }
+
+ .is-horizontal {
+ display: none;
+ }
+
+ a {
+ display: inline-block;
+ width: 100%;
+ overflow: hidden;
+ }
+
+ .svg-icon {
+ margin-right: 16px;
+ }
+
+ .sub-el-icon {
+ margin-right: 12px;
+ margin-left: -2px;
+ }
+
+ .el-menu {
+ border: none;
+ height: 100%;
+ width: 100% !important;
+ }
+
+ // menu hover
+ .submenu-title-noDropdown,
+ .el-submenu__title {
+ &:hover {
+ background-color: $menuHover !important;
+ }
+ }
+
+ .is-active>.el-submenu__title {
+ color: $subMenuActiveText !important;
+ }
+
+ & .nest-menu .el-submenu>.el-submenu__title,
+ & .el-submenu .el-menu-item {
+ min-width: $sideBarWidth !important;
+ background-color: $subMenuBg !important;
+
+ &:hover {
+ background-color: $subMenuHover !important;
+ }
+ }
+ }
+
+ .hideSidebar {
+ .sidebar-container {
+ width: 54px !important;
+ }
+
+ .main-container {
+ margin-left: 54px;
+ }
+
+ .submenu-title-noDropdown {
+ padding: 0 !important;
+ position: relative;
+
+ .el-tooltip {
+ padding: 0 !important;
+
+ .svg-icon {
+ margin-left: 20px;
+ }
+
+ .sub-el-icon {
+ margin-left: 19px;
+ }
+ }
+ }
+
+ .el-submenu {
+ overflow: hidden;
+
+ &>.el-submenu__title {
+ padding: 0 !important;
+
+ .svg-icon {
+ margin-left: 20px;
+ }
+
+ .sub-el-icon {
+ margin-left: 19px;
+ }
+
+ .el-submenu__icon-arrow {
+ display: none;
+ }
+ }
+ }
+
+ .el-menu--collapse {
+ .el-submenu {
+ &>.el-submenu__title {
+ &>span {
+ height: 0;
+ width: 0;
+ overflow: hidden;
+ visibility: hidden;
+ display: inline-block;
+ }
+ }
+ }
+ }
+ }
+
+ .el-menu--collapse .el-menu .el-submenu {
+ min-width: $sideBarWidth !important;
+ }
+
+ // mobile responsive
+ .mobile {
+ .main-container {
+ margin-left: 0px;
+ }
+
+ .sidebar-container {
+ transition: transform .28s;
+ width: $sideBarWidth !important;
+ }
+
+ &.hideSidebar {
+ .sidebar-container {
+ pointer-events: none;
+ transition-duration: 0.3s;
+ transform: translate3d(-$sideBarWidth, 0, 0);
+ }
+ }
+ }
+
+ .withoutAnimation {
+
+ .main-container,
+ .sidebar-container {
+ transition: none;
+ }
+ }
+}
+
+// when menu collapsed
+.el-menu--vertical {
+ &>.el-menu {
+ .svg-icon {
+ margin-right: 16px;
+ }
+ .sub-el-icon {
+ margin-right: 12px;
+ margin-left: -2px;
+ }
+ }
+
+ .nest-menu .el-submenu>.el-submenu__title,
+ .el-menu-item {
+ &:hover {
+ // you can use $subMenuHover
+ background-color: $menuHover !important;
+ }
+ }
+
+ // the scroll bar appears when the subMenu is too long
+ >.el-menu--popup {
+ max-height: 100vh;
+ overflow-y: auto;
+
+ &::-webkit-scrollbar-track-piece {
+ background: #d3dce6;
+ }
+
+ &::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background: #99a9bf;
+ border-radius: 20px;
+ }
+ }
+}
diff --git a/frontend/src/styles/transition.scss b/frontend/src/styles/transition.scss
new file mode 100644
index 0000000000000000000000000000000000000000..4cb27cc811e28605bb6d0657a6257f0c901f6809
--- /dev/null
+++ b/frontend/src/styles/transition.scss
@@ -0,0 +1,48 @@
+// global transition css
+
+/* fade */
+.fade-enter-active,
+.fade-leave-active {
+ transition: opacity 0.28s;
+}
+
+.fade-enter,
+.fade-leave-active {
+ opacity: 0;
+}
+
+/* fade-transform */
+.fade-transform-leave-active,
+.fade-transform-enter-active {
+ transition: all .5s;
+}
+
+.fade-transform-enter {
+ opacity: 0;
+ transform: translateX(-30px);
+}
+
+.fade-transform-leave-to {
+ opacity: 0;
+ transform: translateX(30px);
+}
+
+/* breadcrumb transition */
+.breadcrumb-enter-active,
+.breadcrumb-leave-active {
+ transition: all .5s;
+}
+
+.breadcrumb-enter,
+.breadcrumb-leave-active {
+ opacity: 0;
+ transform: translateX(20px);
+}
+
+.breadcrumb-move {
+ transition: all .5s;
+}
+
+.breadcrumb-leave-active {
+ position: absolute;
+}
diff --git a/frontend/src/styles/variables.scss b/frontend/src/styles/variables.scss
new file mode 100644
index 0000000000000000000000000000000000000000..be5577263874f458b69364b492fd1dd6f26247fa
--- /dev/null
+++ b/frontend/src/styles/variables.scss
@@ -0,0 +1,25 @@
+// sidebar
+$menuText:#bfcbd9;
+$menuActiveText:#409EFF;
+$subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951
+
+$menuBg:#304156;
+$menuHover:#263445;
+
+$subMenuBg:#1f2d3d;
+$subMenuHover:#001528;
+
+$sideBarWidth: 210px;
+
+// the :export directive is the magic sauce for webpack
+// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
+:export {
+ menuText: $menuText;
+ menuActiveText: $menuActiveText;
+ subMenuActiveText: $subMenuActiveText;
+ menuBg: $menuBg;
+ menuHover: $menuHover;
+ subMenuBg: $subMenuBg;
+ subMenuHover: $subMenuHover;
+ sideBarWidth: $sideBarWidth;
+}
diff --git a/frontend/src/utils/auth.js b/frontend/src/utils/auth.js
new file mode 100644
index 0000000000000000000000000000000000000000..059af188c3a0a741d0b23eeaee580549150c79e8
--- /dev/null
+++ b/frontend/src/utils/auth.js
@@ -0,0 +1,15 @@
+import Cookies from 'js-cookie'
+
+const TokenKey = 'vue_admin_template_token'
+
+export function getToken() {
+ return Cookies.get(TokenKey)
+}
+
+export function setToken(token) {
+ return Cookies.set(TokenKey, token)
+}
+
+export function removeToken() {
+ return Cookies.remove(TokenKey)
+}
diff --git a/frontend/src/utils/get-page-title.js b/frontend/src/utils/get-page-title.js
new file mode 100644
index 0000000000000000000000000000000000000000..a6de99dde35f92f0a5d28573d62661f38542b942
--- /dev/null
+++ b/frontend/src/utils/get-page-title.js
@@ -0,0 +1,10 @@
+import defaultSettings from '@/settings'
+
+const title = defaultSettings.title || 'Vue Admin Template'
+
+export default function getPageTitle(pageTitle) {
+ if (pageTitle) {
+ return `${pageTitle} - ${title}`
+ }
+ return `${title}`
+}
diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..4830c04890a16a899c846ff2d5aab320c5f2a0c5
--- /dev/null
+++ b/frontend/src/utils/index.js
@@ -0,0 +1,117 @@
+/**
+ * Created by PanJiaChen on 16/11/18.
+ */
+
+/**
+ * Parse the time to string
+ * @param {(Object|string|number)} time
+ * @param {string} cFormat
+ * @returns {string | null}
+ */
+export function parseTime(time, cFormat) {
+ if (arguments.length === 0 || !time) {
+ return null
+ }
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+ let date
+ if (typeof time === 'object') {
+ date = time
+ } else {
+ if ((typeof time === 'string')) {
+ if ((/^[0-9]+$/.test(time))) {
+ // support "1548221490638"
+ time = parseInt(time)
+ } else {
+ // support safari
+ // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
+ time = time.replace(new RegExp(/-/gm), '/')
+ }
+ }
+
+ if ((typeof time === 'number') && (time.toString().length === 10)) {
+ time = time * 1000
+ }
+ date = new Date(time)
+ }
+ const formatObj = {
+ y: date.getFullYear(),
+ m: date.getMonth() + 1,
+ d: date.getDate(),
+ h: date.getHours(),
+ i: date.getMinutes(),
+ s: date.getSeconds(),
+ a: date.getDay()
+ }
+ const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
+ const value = formatObj[key]
+ // Note: getDay() returns 0 on Sunday
+ if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+ return value.toString().padStart(2, '0')
+ })
+ return time_str
+}
+
+/**
+ * @param {number} time
+ * @param {string} option
+ * @returns {string}
+ */
+export function formatTime(time, option) {
+ if (('' + time).length === 10) {
+ time = parseInt(time) * 1000
+ } else {
+ time = +time
+ }
+ const d = new Date(time)
+ const now = Date.now()
+
+ const diff = (now - d) / 1000
+
+ if (diff < 30) {
+ return '刚刚'
+ } else if (diff < 3600) {
+ // less 1 hour
+ return Math.ceil(diff / 60) + '分钟前'
+ } else if (diff < 3600 * 24) {
+ return Math.ceil(diff / 3600) + '小时前'
+ } else if (diff < 3600 * 24 * 2) {
+ return '1天前'
+ }
+ if (option) {
+ return parseTime(time, option)
+ } else {
+ return (
+ d.getMonth() +
+ 1 +
+ '月' +
+ d.getDate() +
+ '日' +
+ d.getHours() +
+ '时' +
+ d.getMinutes() +
+ '分'
+ )
+ }
+}
+
+/**
+ * @param {string} url
+ * @returns {Object}
+ */
+export function param2Obj(url) {
+ const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
+ if (!search) {
+ return {}
+ }
+ const obj = {}
+ const searchArr = search.split('&')
+ searchArr.forEach(v => {
+ const index = v.indexOf('=')
+ if (index !== -1) {
+ const name = v.substring(0, index)
+ const val = v.substring(index + 1, v.length)
+ obj[name] = val
+ }
+ })
+ return obj
+}
diff --git a/frontend/src/utils/request.js b/frontend/src/utils/request.js
new file mode 100644
index 0000000000000000000000000000000000000000..bf3ef07da75ce3815d7755e95f17a66a84d432be
--- /dev/null
+++ b/frontend/src/utils/request.js
@@ -0,0 +1,86 @@
+import axios from 'axios'
+import { MessageBox, Message } from 'element-ui'
+import store from '@/store'
+import { getToken } from '@/utils/auth'
+
+// create an axios instance
+const service = axios.create({
+ baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
+ withCredentials: true, // send cookies when cross-domain requests
+ timeout: 5000 // request timeout
+})
+
+// request interceptor
+service.interceptors.request.use(
+ config => {
+ // do something before request is sent
+
+ if (store.getters.token) {
+ // let each request carry token
+ // ['X-Token'] is a custom headers key
+ // please modify it according to the actual situation
+ config.headers['X-Token'] = getToken()
+ }
+ return config
+ },
+ error => {
+ // do something with request error
+ console.log(error) // for debug
+ return Promise.reject(error)
+ }
+)
+
+// response interceptor
+service.interceptors.response.use(
+ /**
+ * If you want to get http information such as headers or status
+ * Please return response => response
+ */
+
+ /**
+ * Determine the request status by custom code
+ * Here is just an example
+ * You can also judge the status by HTTP Status Code
+ */
+ response => {
+ const res = response.data
+ console.log('res.code: ' + res.code) // for debug
+
+ // if the custom code is not 20000, it is judged as an error.
+ if (res.code !== 20000) {
+ Message({
+ message: res.message || 'Error',
+ type: 'error',
+ duration: 5 * 1000
+ })
+
+ // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
+ if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
+ // to re-login
+ MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', {
+ confirmButtonText: 'Re-Login',
+ cancelButtonText: 'Cancel',
+ type: 'warning'
+ }).then(() => {
+ store.dispatch('user/resetToken').then(() => {
+ location.reload()
+ })
+ })
+ }
+ return Promise.reject(new Error(res.message || 'Error'))
+ } else {
+ return res
+ }
+ },
+ error => {
+ console.log('err' + error) // for debug
+ Message({
+ message: error.message,
+ type: 'error',
+ duration: 5 * 1000
+ })
+ return Promise.reject(error)
+ }
+)
+
+export default service
diff --git a/frontend/src/utils/scroll-to.js b/frontend/src/utils/scroll-to.js
new file mode 100644
index 0000000000000000000000000000000000000000..c5d8e04e07b21b45da43c4dadd7c65ee0d946289
--- /dev/null
+++ b/frontend/src/utils/scroll-to.js
@@ -0,0 +1,58 @@
+Math.easeInOutQuad = function(t, b, c, d) {
+ t /= d / 2
+ if (t < 1) {
+ return c / 2 * t * t + b
+ }
+ t--
+ return -c / 2 * (t * (t - 2) - 1) + b
+}
+
+// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
+var requestAnimFrame = (function() {
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
+})()
+
+/**
+ * Because it's so fucking difficult to detect the scrolling element, just move them all
+ * @param {number} amount
+ */
+function move(amount) {
+ document.documentElement.scrollTop = amount
+ document.body.parentNode.scrollTop = amount
+ document.body.scrollTop = amount
+}
+
+function position() {
+ return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop
+}
+
+/**
+ * @param {number} to
+ * @param {number} duration
+ * @param {Function} callback
+ */
+export function scrollTo(to, duration, callback) {
+ const start = position()
+ const change = to - start
+ const increment = 20
+ let currentTime = 0
+ duration = (typeof (duration) === 'undefined') ? 500 : duration
+ var animateScroll = function() {
+ // increment the time
+ currentTime += increment
+ // find the value with the quadratic in-out easing function
+ var val = Math.easeInOutQuad(currentTime, start, change, duration)
+ // move the document.body
+ move(val)
+ // do the animation unless its over
+ if (currentTime < duration) {
+ requestAnimFrame(animateScroll)
+ } else {
+ if (callback && typeof (callback) === 'function') {
+ // the animation is done so lets callback
+ callback()
+ }
+ }
+ }
+ animateScroll()
+}
diff --git a/frontend/src/utils/validate.js b/frontend/src/utils/validate.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d962ad4a25007489f5630e0e41b285247ac8cb1
--- /dev/null
+++ b/frontend/src/utils/validate.js
@@ -0,0 +1,20 @@
+/**
+ * Created by PanJiaChen on 16/11/18.
+ */
+
+/**
+ * @param {string} path
+ * @returns {Boolean}
+ */
+export function isExternal(path) {
+ return /^(https?:|mailto:|tel:)/.test(path)
+}
+
+/**
+ * @param {string} str
+ * @returns {Boolean}
+ */
+export function validUsername(str) {
+ const valid_map = ['admin', 'editor']
+ return valid_map.indexOf(str.trim()) >= 0
+}
diff --git a/frontend/src/vendor/Export2Excel.js b/frontend/src/vendor/Export2Excel.js
new file mode 100644
index 0000000000000000000000000000000000000000..d8a2af3d4b4d16fd906a940933cd24e38ad0dee2
--- /dev/null
+++ b/frontend/src/vendor/Export2Excel.js
@@ -0,0 +1,220 @@
+/* eslint-disable */
+import { saveAs } from 'file-saver'
+import XLSX from 'xlsx'
+
+function generateArray(table) {
+ var out = [];
+ var rows = table.querySelectorAll('tr');
+ var ranges = [];
+ for (var R = 0; R < rows.length; ++R) {
+ var outRow = [];
+ var row = rows[R];
+ var columns = row.querySelectorAll('td');
+ for (var C = 0; C < columns.length; ++C) {
+ var cell = columns[C];
+ var colspan = cell.getAttribute('colspan');
+ var rowspan = cell.getAttribute('rowspan');
+ var cellValue = cell.innerText;
+ if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
+
+ //Skip ranges
+ ranges.forEach(function (range) {
+ if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
+ for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
+ }
+ });
+
+ //Handle Row Span
+ if (rowspan || colspan) {
+ rowspan = rowspan || 1;
+ colspan = colspan || 1;
+ ranges.push({
+ s: {
+ r: R,
+ c: outRow.length
+ },
+ e: {
+ r: R + rowspan - 1,
+ c: outRow.length + colspan - 1
+ }
+ });
+ };
+
+ //Handle Value
+ outRow.push(cellValue !== "" ? cellValue : null);
+
+ //Handle Colspan
+ if (colspan)
+ for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
+ }
+ out.push(outRow);
+ }
+ return [out, ranges];
+};
+
+function datenum(v, date1904) {
+ if (date1904) v += 1462;
+ var epoch = Date.parse(v);
+ return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
+}
+
+function sheet_from_array_of_arrays(data, opts) {
+ var ws = {};
+ var range = {
+ s: {
+ c: 10000000,
+ r: 10000000
+ },
+ e: {
+ c: 0,
+ r: 0
+ }
+ };
+ for (var R = 0; R != data.length; ++R) {
+ for (var C = 0; C != data[R].length; ++C) {
+ if (range.s.r > R) range.s.r = R;
+ if (range.s.c > C) range.s.c = C;
+ if (range.e.r < R) range.e.r = R;
+ if (range.e.c < C) range.e.c = C;
+ var cell = {
+ v: data[R][C]
+ };
+ if (cell.v == null) continue;
+ var cell_ref = XLSX.utils.encode_cell({
+ c: C,
+ r: R
+ });
+
+ if (typeof cell.v === 'number') cell.t = 'n';
+ else if (typeof cell.v === 'boolean') cell.t = 'b';
+ else if (cell.v instanceof Date) {
+ cell.t = 'n';
+ cell.z = XLSX.SSF._table[14];
+ cell.v = datenum(cell.v);
+ } else cell.t = 's';
+
+ ws[cell_ref] = cell;
+ }
+ }
+ if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
+ return ws;
+}
+
+function Workbook() {
+ if (!(this instanceof Workbook)) return new Workbook();
+ this.SheetNames = [];
+ this.Sheets = {};
+}
+
+function s2ab(s) {
+ var buf = new ArrayBuffer(s.length);
+ var view = new Uint8Array(buf);
+ for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
+ return buf;
+}
+
+export function export_table_to_excel(id) {
+ var theTable = document.getElementById(id);
+ var oo = generateArray(theTable);
+ var ranges = oo[1];
+
+ /* original data */
+ var data = oo[0];
+ var ws_name = "SheetJS";
+
+ var wb = new Workbook(),
+ ws = sheet_from_array_of_arrays(data);
+
+ /* add ranges to worksheet */
+ // ws['!cols'] = ['apple', 'banan'];
+ ws['!merges'] = ranges;
+
+ /* add worksheet to workbook */
+ wb.SheetNames.push(ws_name);
+ wb.Sheets[ws_name] = ws;
+
+ var wbout = XLSX.write(wb, {
+ bookType: 'xlsx',
+ bookSST: false,
+ type: 'binary'
+ });
+
+ saveAs(new Blob([s2ab(wbout)], {
+ type: "application/octet-stream"
+ }), "test.xlsx")
+}
+
+export function export_json_to_excel({
+ multiHeader = [],
+ header,
+ data,
+ filename,
+ merges = [],
+ autoWidth = true,
+ bookType = 'xlsx'
+} = {}) {
+ /* original data */
+ filename = filename || 'excel-list'
+ data = [...data]
+ data.unshift(header);
+
+ for (let i = multiHeader.length - 1; i > -1; i--) {
+ data.unshift(multiHeader[i])
+ }
+
+ var ws_name = "SheetJS";
+ var wb = new Workbook(),
+ ws = sheet_from_array_of_arrays(data);
+
+ if (merges.length > 0) {
+ if (!ws['!merges']) ws['!merges'] = [];
+ merges.forEach(item => {
+ ws['!merges'].push(XLSX.utils.decode_range(item))
+ })
+ }
+
+ if (autoWidth) {
+ /*设置worksheet每列的最大宽度*/
+ const colWidth = data.map(row => row.map(val => {
+ /*先判断是否为null/undefined*/
+ if (val == null) {
+ return {
+ 'wch': 10
+ };
+ }
+ /*再判断是否为中文*/
+ else if (val.toString().charCodeAt(0) > 255) {
+ return {
+ 'wch': val.toString().length * 2
+ };
+ } else {
+ return {
+ 'wch': val.toString().length
+ };
+ }
+ }))
+ /*以第一行为初始值*/
+ let result = colWidth[0];
+ for (let i = 1; i < colWidth.length; i++) {
+ for (let j = 0; j < colWidth[i].length; j++) {
+ if (result[j]['wch'] < colWidth[i][j]['wch']) {
+ result[j]['wch'] = colWidth[i][j]['wch'];
+ }
+ }
+ }
+ ws['!cols'] = result;
+ }
+
+ /* add worksheet to workbook */
+ wb.SheetNames.push(ws_name);
+ wb.Sheets[ws_name] = ws;
+
+ var wbout = XLSX.write(wb, {
+ bookType: bookType,
+ bookSST: false,
+ type: 'binary'
+ });
+ saveAs(new Blob([s2ab(wbout)], {
+ type: "application/octet-stream"
+ }), `${filename}.${bookType}`);
+}
diff --git a/frontend/src/views/404.vue b/frontend/src/views/404.vue
new file mode 100644
index 0000000000000000000000000000000000000000..1791f55a34ef18dae1cbd583d62f997bf33fffa9
--- /dev/null
+++ b/frontend/src/views/404.vue
@@ -0,0 +1,228 @@
+
+
+
+
+
+
OOPS!
+
+
{{ message }}
+
Please check that the URL you entered is correct, or click the button below to return to the homepage.
+
Back to home
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/dashboard/index.vue b/frontend/src/views/dashboard/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..a41c99ce5aaf21a68f0fefd91f1d9a0db9fa96ef
--- /dev/null
+++ b/frontend/src/views/dashboard/index.vue
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/views/form/index.vue b/frontend/src/views/form/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..f4d66d3bdb73260c97bcb8fa8b9b10d6775dccbc
--- /dev/null
+++ b/frontend/src/views/form/index.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Cancel
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..1db246453d6911cb0c1045ffd9b09865160ded4a
--- /dev/null
+++ b/frontend/src/views/login/index.vue
@@ -0,0 +1,237 @@
+
+
+
+
+
+
Login Form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Login
+
+
+ username: admin
+ password: any
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/index.vue b/frontend/src/views/nested/menu1/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..30cb670118ee7441850a6f8f83bda2b3514d8e0c
--- /dev/null
+++ b/frontend/src/views/nested/menu1/index.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/menu1-1/index.vue b/frontend/src/views/nested/menu1/menu1-1/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..27e173a6b473d2eb308f059384bf9c4790894a5f
--- /dev/null
+++ b/frontend/src/views/nested/menu1/menu1-1/index.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/menu1-2/index.vue b/frontend/src/views/nested/menu1/menu1-2/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..0c86276e0162396768de0d2781927e7d0322130f
--- /dev/null
+++ b/frontend/src/views/nested/menu1/menu1-2/index.vue
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue b/frontend/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..f87d88f4908681b45eae1fbb26389b86b5f9cc1d
--- /dev/null
+++ b/frontend/src/views/nested/menu1/menu1-2/menu1-2-1/index.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue b/frontend/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..d88789f205ed5bbba622bfb1b6291ad827e6004d
--- /dev/null
+++ b/frontend/src/views/nested/menu1/menu1-2/menu1-2-2/index.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu1/menu1-3/index.vue b/frontend/src/views/nested/menu1/menu1-3/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..f7cd0738f1b36e662bf6b088b337c79865878c4c
--- /dev/null
+++ b/frontend/src/views/nested/menu1/menu1-3/index.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/frontend/src/views/nested/menu2/index.vue b/frontend/src/views/nested/menu2/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..19dd48f0edf37f54317f14b0cfb707d00ab04f11
--- /dev/null
+++ b/frontend/src/views/nested/menu2/index.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/frontend/src/views/table/complex-table.vue b/frontend/src/views/table/complex-table.vue
new file mode 100644
index 0000000000000000000000000000000000000000..295c5fc49642abeea4e990f6705d8839fe65dc1c
--- /dev/null
+++ b/frontend/src/views/table/complex-table.vue
@@ -0,0 +1,379 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Search
+
+
+ Add
+
+
+ Export
+
+
+ reviewer
+
+
+
+
+
+
+ {{ row.id }}
+
+
+
+
+ {{ row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}
+
+
+
+
+ {{ row.title }}
+ {{ row.type | typeFilter }}
+
+
+
+
+ {{ row.author }}
+
+
+
+
+ {{ row.reviewer }}
+
+
+
+
+
+
+
+
+
+ {{ row.pageviews }}
+ 0
+
+
+
+
+
+ {{ row.status }}
+
+
+
+
+
+
+ Edit
+
+
+ Publish
+
+
+ Draft
+
+
+ Delete
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/table/index.vue b/frontend/src/views/table/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..ebccabad807326cc7361819faaa0e19286a9a4a8
--- /dev/null
+++ b/frontend/src/views/table/index.vue
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 查看
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/tree/index.vue b/frontend/src/views/tree/index.vue
new file mode 100644
index 0000000000000000000000000000000000000000..89c6b01de2ccba837d3f76aedc0638d88edcf003
--- /dev/null
+++ b/frontend/src/views/tree/index.vue
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/tests/unit/.eslintrc.js b/frontend/tests/unit/.eslintrc.js
new file mode 100644
index 0000000000000000000000000000000000000000..958d51ba27f55d294e6950088886d7ad71199d74
--- /dev/null
+++ b/frontend/tests/unit/.eslintrc.js
@@ -0,0 +1,5 @@
+module.exports = {
+ env: {
+ jest: true
+ }
+}
diff --git a/frontend/tests/unit/components/Breadcrumb.spec.js b/frontend/tests/unit/components/Breadcrumb.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..1d94c8fc7114473c0f9e9875ee727276a109a149
--- /dev/null
+++ b/frontend/tests/unit/components/Breadcrumb.spec.js
@@ -0,0 +1,98 @@
+import { mount, createLocalVue } from '@vue/test-utils'
+import VueRouter from 'vue-router'
+import ElementUI from 'element-ui'
+import Breadcrumb from '@/components/Breadcrumb/index.vue'
+
+const localVue = createLocalVue()
+localVue.use(VueRouter)
+localVue.use(ElementUI)
+
+const routes = [
+ {
+ path: '/',
+ name: 'home',
+ children: [{
+ path: 'dashboard',
+ name: 'dashboard'
+ }]
+ },
+ {
+ path: '/menu',
+ name: 'menu',
+ children: [{
+ path: 'menu1',
+ name: 'menu1',
+ meta: { title: 'menu1' },
+ children: [{
+ path: 'menu1-1',
+ name: 'menu1-1',
+ meta: { title: 'menu1-1' }
+ },
+ {
+ path: 'menu1-2',
+ name: 'menu1-2',
+ redirect: 'noredirect',
+ meta: { title: 'menu1-2' },
+ children: [{
+ path: 'menu1-2-1',
+ name: 'menu1-2-1',
+ meta: { title: 'menu1-2-1' }
+ },
+ {
+ path: 'menu1-2-2',
+ name: 'menu1-2-2'
+ }]
+ }]
+ }]
+ }]
+
+const router = new VueRouter({
+ routes
+})
+
+describe('Breadcrumb.vue', () => {
+ const wrapper = mount(Breadcrumb, {
+ localVue,
+ router
+ })
+ it('dashboard', () => {
+ router.push('/dashboard')
+ const len = wrapper.findAll('.el-breadcrumb__inner').length
+ expect(len).toBe(1)
+ })
+ it('normal route', () => {
+ router.push('/menu/menu1')
+ const len = wrapper.findAll('.el-breadcrumb__inner').length
+ expect(len).toBe(2)
+ })
+ it('nested route', () => {
+ router.push('/menu/menu1/menu1-2/menu1-2-1')
+ const len = wrapper.findAll('.el-breadcrumb__inner').length
+ expect(len).toBe(4)
+ })
+ it('no meta.title', () => {
+ router.push('/menu/menu1/menu1-2/menu1-2-2')
+ const len = wrapper.findAll('.el-breadcrumb__inner').length
+ expect(len).toBe(3)
+ })
+ // it('click link', () => {
+ // router.push('/menu/menu1/menu1-2/menu1-2-2')
+ // const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
+ // const second = breadcrumbArray.at(1)
+ // console.log(breadcrumbArray)
+ // const href = second.find('a').attributes().href
+ // expect(href).toBe('#/menu/menu1')
+ // })
+ // it('noRedirect', () => {
+ // router.push('/menu/menu1/menu1-2/menu1-2-1')
+ // const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
+ // const redirectBreadcrumb = breadcrumbArray.at(2)
+ // expect(redirectBreadcrumb.contains('a')).toBe(false)
+ // })
+ it('last breadcrumb', () => {
+ router.push('/menu/menu1/menu1-2/menu1-2-1')
+ const breadcrumbArray = wrapper.findAll('.el-breadcrumb__inner')
+ const redirectBreadcrumb = breadcrumbArray.at(3)
+ expect(redirectBreadcrumb.contains('a')).toBe(false)
+ })
+})
diff --git a/frontend/tests/unit/components/Hamburger.spec.js b/frontend/tests/unit/components/Hamburger.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..01ea303a5e16f875972722d7665383836b20654c
--- /dev/null
+++ b/frontend/tests/unit/components/Hamburger.spec.js
@@ -0,0 +1,18 @@
+import { shallowMount } from '@vue/test-utils'
+import Hamburger from '@/components/Hamburger/index.vue'
+describe('Hamburger.vue', () => {
+ it('toggle click', () => {
+ const wrapper = shallowMount(Hamburger)
+ const mockFn = jest.fn()
+ wrapper.vm.$on('toggleClick', mockFn)
+ wrapper.find('.hamburger').trigger('click')
+ expect(mockFn).toBeCalled()
+ })
+ it('prop isActive', () => {
+ const wrapper = shallowMount(Hamburger)
+ wrapper.setProps({ isActive: true })
+ expect(wrapper.contains('.is-active')).toBe(true)
+ wrapper.setProps({ isActive: false })
+ expect(wrapper.contains('.is-active')).toBe(false)
+ })
+})
diff --git a/frontend/tests/unit/components/SvgIcon.spec.js b/frontend/tests/unit/components/SvgIcon.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..31467a9f6fba16a81a90923db02da289248e2bc6
--- /dev/null
+++ b/frontend/tests/unit/components/SvgIcon.spec.js
@@ -0,0 +1,22 @@
+import { shallowMount } from '@vue/test-utils'
+import SvgIcon from '@/components/SvgIcon/index.vue'
+describe('SvgIcon.vue', () => {
+ it('iconClass', () => {
+ const wrapper = shallowMount(SvgIcon, {
+ propsData: {
+ iconClass: 'test'
+ }
+ })
+ expect(wrapper.find('use').attributes().href).toBe('#icon-test')
+ })
+ it('className', () => {
+ const wrapper = shallowMount(SvgIcon, {
+ propsData: {
+ iconClass: 'test'
+ }
+ })
+ expect(wrapper.classes().length).toBe(1)
+ wrapper.setProps({ className: 'test' })
+ expect(wrapper.classes().includes('test')).toBe(true)
+ })
+})
diff --git a/frontend/tests/unit/utils/formatTime.spec.js b/frontend/tests/unit/utils/formatTime.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..24e165b42df1d849b994d6f477eea79da9431e51
--- /dev/null
+++ b/frontend/tests/unit/utils/formatTime.spec.js
@@ -0,0 +1,30 @@
+import { formatTime } from '@/utils/index.js'
+
+describe('Utils:formatTime', () => {
+ const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01"
+ const retrofit = 5 * 1000
+
+ it('ten digits timestamp', () => {
+ expect(formatTime((d / 1000).toFixed(0))).toBe('7月13日17时54分')
+ })
+ it('test now', () => {
+ expect(formatTime(+new Date() - 1)).toBe('刚刚')
+ })
+ it('less two minute', () => {
+ expect(formatTime(+new Date() - 60 * 2 * 1000 + retrofit)).toBe('2分钟前')
+ })
+ it('less two hour', () => {
+ expect(formatTime(+new Date() - 60 * 60 * 2 * 1000 + retrofit)).toBe('2小时前')
+ })
+ it('less one day', () => {
+ expect(formatTime(+new Date() - 60 * 60 * 24 * 1 * 1000)).toBe('1天前')
+ })
+ it('more than one day', () => {
+ expect(formatTime(d)).toBe('7月13日17时54分')
+ })
+ it('format', () => {
+ expect(formatTime(d, '{y}-{m}-{d} {h}:{i}')).toBe('2018-07-13 17:54')
+ expect(formatTime(d, '{y}-{m}-{d}')).toBe('2018-07-13')
+ expect(formatTime(d, '{y}/{m}/{d} {h}-{i}')).toBe('2018/07/13 17-54')
+ })
+})
diff --git a/frontend/tests/unit/utils/param2Obj.spec.js b/frontend/tests/unit/utils/param2Obj.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..e106ed88b54ea85bf0c714dc73f8f4c740877d24
--- /dev/null
+++ b/frontend/tests/unit/utils/param2Obj.spec.js
@@ -0,0 +1,14 @@
+import { param2Obj } from '@/utils/index.js'
+describe('Utils:param2Obj', () => {
+ const url = 'https://github.com/PanJiaChen/vue-element-admin?name=bill&age=29&sex=1&field=dGVzdA==&key=%E6%B5%8B%E8%AF%95'
+
+ it('param2Obj test', () => {
+ expect(param2Obj(url)).toEqual({
+ name: 'bill',
+ age: '29',
+ sex: '1',
+ field: window.btoa('test'),
+ key: '测试'
+ })
+ })
+})
diff --git a/frontend/tests/unit/utils/parseTime.spec.js b/frontend/tests/unit/utils/parseTime.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..56045af4a8b471c8e2747db6f8b56daf30bfe9c5
--- /dev/null
+++ b/frontend/tests/unit/utils/parseTime.spec.js
@@ -0,0 +1,35 @@
+import { parseTime } from '@/utils/index.js'
+
+describe('Utils:parseTime', () => {
+ const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01"
+ it('timestamp', () => {
+ expect(parseTime(d)).toBe('2018-07-13 17:54:01')
+ })
+ it('timestamp string', () => {
+ expect(parseTime((d + ''))).toBe('2018-07-13 17:54:01')
+ })
+ it('ten digits timestamp', () => {
+ expect(parseTime((d / 1000).toFixed(0))).toBe('2018-07-13 17:54:01')
+ })
+ it('new Date', () => {
+ expect(parseTime(new Date(d))).toBe('2018-07-13 17:54:01')
+ })
+ it('format', () => {
+ expect(parseTime(d, '{y}-{m}-{d} {h}:{i}')).toBe('2018-07-13 17:54')
+ expect(parseTime(d, '{y}-{m}-{d}')).toBe('2018-07-13')
+ expect(parseTime(d, '{y}/{m}/{d} {h}-{i}')).toBe('2018/07/13 17-54')
+ })
+ it('get the day of the week', () => {
+ expect(parseTime(d, '{a}')).toBe('五') // 星期五
+ })
+ it('get the day of the week', () => {
+ expect(parseTime(+d + 1000 * 60 * 60 * 24 * 2, '{a}')).toBe('日') // 星期日
+ })
+ it('empty argument', () => {
+ expect(parseTime()).toBeNull()
+ })
+
+ it('null', () => {
+ expect(parseTime(null)).toBeNull()
+ })
+})
diff --git a/frontend/tests/unit/utils/validate.spec.js b/frontend/tests/unit/utils/validate.spec.js
new file mode 100644
index 0000000000000000000000000000000000000000..f774905b00e87bc002972c21b8fab5c4b34ecc81
--- /dev/null
+++ b/frontend/tests/unit/utils/validate.spec.js
@@ -0,0 +1,17 @@
+import { validUsername, isExternal } from '@/utils/validate.js'
+
+describe('Utils:validate', () => {
+ it('validUsername', () => {
+ expect(validUsername('admin')).toBe(true)
+ expect(validUsername('editor')).toBe(true)
+ expect(validUsername('xxxx')).toBe(false)
+ })
+ it('isExternal', () => {
+ expect(isExternal('https://github.com/PanJiaChen/vue-element-admin')).toBe(true)
+ expect(isExternal('http://github.com/PanJiaChen/vue-element-admin')).toBe(true)
+ expect(isExternal('github.com/PanJiaChen/vue-element-admin')).toBe(false)
+ expect(isExternal('/dashboard')).toBe(false)
+ expect(isExternal('./dashboard')).toBe(false)
+ expect(isExternal('dashboard')).toBe(false)
+ })
+})
diff --git a/frontend/vue.config.js b/frontend/vue.config.js
new file mode 100644
index 0000000000000000000000000000000000000000..0fdd7a98c479ce693dcd0913f7ef6801c0f0a309
--- /dev/null
+++ b/frontend/vue.config.js
@@ -0,0 +1,127 @@
+'use strict'
+const path = require('path')
+const defaultSettings = require('./src/settings.js')
+
+function resolve(dir) {
+ return path.join(__dirname, dir)
+}
+
+const name = defaultSettings.title || 'vue Admin Template' // page title
+
+// If your port is set to 80,
+// use administrator privileges to execute the command line.
+// For example, Mac: sudo npm run
+// You can change the port by the following methods:
+// port = 9528 npm run dev OR npm run dev --port = 9528
+const port = process.env.port || process.env.npm_config_port || 9528 // dev port
+
+// All configuration item explanations can be find in https://cli.vuejs.org/config/
+module.exports = {
+ /**
+ * You will need to set publicPath if you plan to deploy your site under a sub path,
+ * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
+ * then publicPath should be set to "/bar/".
+ * In most cases please use '/' !!!
+ * Detail: https://cli.vuejs.org/config/#publicpath
+ */
+ publicPath: '/',
+ outputDir: 'dist',
+ assetsDir: 'static',
+ lintOnSave: process.env.NODE_ENV === 'development',
+ productionSourceMap: false,
+ devServer: {
+ host: '0.0.0.0',
+ port: 8080,
+ proxy: {
+ '/api/v1': {
+ target: 'http://backend:9090/api/v1',
+ changeOrigin: true,
+ pathRewrite: {
+ '^/api/v1': ''
+ }
+ }
+ }
+ },
+ configureWebpack: {
+ // provide the app's title in webpack's name field, so that
+ // it can be accessed in index.html to inject the correct title.
+ name: name,
+ resolve: {
+ alias: {
+ '@': resolve('src')
+ }
+ }
+ },
+ chainWebpack(config) {
+ // it can improve the speed of the first screen, it is recommended to turn on preload
+ config.plugin('preload').tap(() => [
+ {
+ rel: 'preload',
+ // to ignore runtime.js
+ // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
+ fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
+ include: 'initial'
+ }
+ ])
+
+ // when there are many pages, it will cause too many meaningless requests
+ config.plugins.delete('prefetch')
+
+ // set svg-sprite-loader
+ config.module
+ .rule('svg')
+ .exclude.add(resolve('src/icons'))
+ .end()
+ config.module
+ .rule('icons')
+ .test(/\.svg$/)
+ .include.add(resolve('src/icons'))
+ .end()
+ .use('svg-sprite-loader')
+ .loader('svg-sprite-loader')
+ .options({
+ symbolId: 'icon-[name]'
+ })
+ .end()
+
+ config
+ .when(process.env.NODE_ENV !== 'development',
+ config => {
+ config
+ .plugin('ScriptExtHtmlWebpackPlugin')
+ .after('html')
+ .use('script-ext-html-webpack-plugin', [{
+ // `runtime` must same as runtimeChunk name. default is `runtime`
+ inline: /runtime\..*\.js$/
+ }])
+ .end()
+ config
+ .optimization.splitChunks({
+ chunks: 'all',
+ cacheGroups: {
+ libs: {
+ name: 'chunk-libs',
+ test: /[\\/]node_modules[\\/]/,
+ priority: 10,
+ chunks: 'initial' // only package third parties that are initially dependent
+ },
+ elementUI: {
+ name: 'chunk-elementUI', // split elementUI into a single package
+ priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
+ test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
+ },
+ commons: {
+ name: 'chunk-commons',
+ test: resolve('src/components'), // can customize your rules
+ minChunks: 3, // minimum common number
+ priority: 5,
+ reuseExistingChunk: true
+ }
+ }
+ })
+ // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
+ config.optimization.runtimeChunk('single')
+ }
+ )
+ }
+}
diff --git a/startStock.sh b/startStock.sh
deleted file mode 100755
index 9775849479f4b3bb36f1c9bf3e56b5499ab803b3..0000000000000000000000000000000000000000
--- a/startStock.sh
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/bin/bash
-
-PWD=`pwd`
-
-DB_IS_RUN=`docker ps --filter "name=mariadb" --filter "status=running" | wc -l `
-if [ $DB_IS_RUN -lt 2 ]; then
-
- #判断文件夹存在不。
- if [ ! -d "${PWD}/data/mysqldb/data" ]; then
- mkdir -p ${PWD}/data/mysqldb/data
- fi
-
- HAS_DB=`docker images mysql:5.7 | wc -l `
- if [ $HAS_DB -ne 2 ];then
- docker pull mysql:5.7
- fi
-
- ####################### 启动数据库 #######################
- #检查mysqldb是否启动
- DB_IS_RUN=`docker ps --filter "name=mysqldb" --filter "status=running" | wc -l `
-
- if [ $DB_IS_RUN -ne 2 ]; then
-
- ####################### 创建数据库 #######################
- docker run --name mysqldb -v ${PWD}/data/mysqldb/data:/var/lib/mysql --restart=always \
- -e MYSQL_ROOT_PASSWORD=mysqldb -e MYSQL_DATABASE=stock_data -e TZ=Asia/Shanghai \
- -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
- echo "starting mysqldb ..."
- echo "wait 60 second , mysqldb is starting ."
- sleep 60
- else
- echo "mysqldb is running !!!"
- fi
-
-
- #检查mysqldb是否启动,等待5秒钟,再次检查mysqldb启动
- DB_IS_RUN=`docker ps --filter "name=mysqldb" --filter "status=running" | wc -l `
- if [ $DB_IS_RUN -ne 2 ]; then
- echo "mysqldb is not running !!!"
- exit 1;
- fi
-fi
-
-#检查stock启动
-STOCK_IS_RUN=`docker ps --filter "name=stock" --filter "status=running" | wc -l `
-if [ $STOCK_IS_RUN -ge 2 ]; then
- echo "stop & rm stock ..."
- docker stop stock && docker rm stock
-fi
-
-sleep 1
-
-echo "starting stock ..."
-# 1 是开发环境。映射本地代码。
-if [ $# == 1 ] ; then
- echo "############# run dev ############# "
- # /data/stock 是代码目录 -v /data/stock:/data/stock 是开发模式。
- mkdir -p notebooks
-
- # 测试使用,自己需注册,申请:https://tushare.pro/user/token
-
- docker run -itd --link=mysqldb --name stock \
- -e LANG=zh_CN.UTF-8 -e LC_CTYPE=zh_CN.UTF-8 -e PYTHONIOENCODING=utf-8 \
- -p 8888:8888 -p 9999:9999 --restart=always \
- -v ${PWD}/jobs:/data/stock/jobs \
- -v ${PWD}/libs:/data/stock/libs \
- -v ${PWD}/web:/data/stock/web \
- -v ${PWD}/supervisor:/data/supervisor \
- -v ${PWD}/notebooks:/data/notebooks \
- -v ${PWD}/data/logs:/data/logs \
- pythonstock/pythonstock:latest
- exit 1;
-else
- echo "############# run online ############# "
- # /data/stock 是代码目录 -v /data/stock:/data/stock 是开发模式。
- docker run -itd --link=mysqldb --name stock \
- -p 8888:8888 -p 9999:9999 --restart=always \
- pythonstock/pythonstock:latest
- exit 1;
-fi
-