完成书签的备份下载
This commit is contained in:
parent
6636b698ff
commit
e6af3742ac
|
|
@ -108,7 +108,7 @@ GRANT ALL ON *.* TO 'test'@'%'; // 给刚创建的test用户数据库所有的
|
||||||
use mybookmarks; //选择刚创建的数据库。
|
use mybookmarks; //选择刚创建的数据库。
|
||||||
source /home/lcq/schema.sql; // 执行schema.sql文件创建数据库表格。注意,将路径换为你schema.sql所在路径。
|
source /home/lcq/schema.sql; // 执行schema.sql文件创建数据库表格。注意,将路径换为你schema.sql所在路径。
|
||||||
```
|
```
|
||||||
3、如果你是全新部署,你可忽略此步骤。如果之前部署过此应用,那么需要执行update.sql文件需要升级。注意:升级之前,请务必备份数据库!确认是否需要运行此升级sql文件也很简单,看一下你之前的数据库mybookmarks下面有没有`tags_bookmarks`这个数据表。如果有,那么需要执行。执行方法还是如上类似`source /home/lcq/update.sql;`。
|
3、如果你是全新部署,你可忽略此步骤。如果之前部署过此应用,那么需要执行update.sql文件需要升级。注意:升级之前,请务必备份数据库!确认是否需要运行此升级sql文件也很简单,看一下你之前的数据库mybookmarks下面有没有`tags_bookmarks`这个数据表。如果有,那么需要执行。执行方法还是如上类似`source /home/lcq/update.sql;`。
|
||||||
4、安装Node.js。Node.js版本至少要求12.0以上。不会的话,请按照上面步骤1、3提供的方法自行解决。
|
4、安装Node.js。Node.js版本至少要求12.0以上。不会的话,请按照上面步骤1、3提供的方法自行解决。
|
||||||
5、克隆代码`git clone git@github.com:luchenqun/my-bookmark.git`,切换到项目根目录下面,执行`npm install`安装package。
|
5、克隆代码`git clone git@github.com:luchenqun/my-bookmark.git`,切换到项目根目录下面,执行`npm install`安装package。
|
||||||
6、在根目录,更新`pm2.json`文件,只需要更新`cwd`项即可。该项为你项目所在的路径。更新`src/config/adapter.js`下面`exports.model`关于你的MySQL的账号密码信息。注意,该账号必须要有写数据库的权限!
|
6、在根目录,更新`pm2.json`文件,只需要更新`cwd`项即可。该项为你项目所在的路径。更新`src/config/adapter.js`下面`exports.model`关于你的MySQL的账号密码信息。注意,该账号必须要有写数据库的权限!
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function md5(str) {
|
||||||
|
|
||||||
module.exports = class extends Base {
|
module.exports = class extends Base {
|
||||||
async __before() {
|
async __before() {
|
||||||
if (['userRegister', 'userLogin', 'noteShare'].indexOf(this.ctx.action) >= 0) {
|
if (['userRegister', 'userLogin', 'noteShare', 'bookmarkDownload'].indexOf(this.ctx.action) >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -508,9 +508,26 @@ module.exports = class extends Base {
|
||||||
|
|
||||||
await fs.ensureFile(filePath);
|
await fs.ensureFile(filePath);
|
||||||
await fs.writeFile(filePath, $.xml());
|
await fs.writeFile(filePath, $.xml());
|
||||||
this.json({ code: 0, data: `runtime/backup/${fileName}` });
|
this.json({ code: 0, data: fileName });
|
||||||
setTimeout(() => fs.remove(filePath), 10000);
|
|
||||||
// await this.download(filePath, fileName)
|
setTimeout(async () => {
|
||||||
|
let exists = await fs.pathExists(filePath);
|
||||||
|
if (exists) {
|
||||||
|
await fs.remove(filePath);
|
||||||
|
}
|
||||||
|
}, 1000 * 60 * 10); // 十分钟内没下载就给删掉
|
||||||
|
}
|
||||||
|
|
||||||
|
async bookmarkDownloadAction() {
|
||||||
|
let fileName = this.get('fileName');
|
||||||
|
let filePath = path.join(think.ROOT_PATH, 'runtime', 'backup', fileName);
|
||||||
|
let exists = await fs.pathExists(filePath);
|
||||||
|
if (exists) {
|
||||||
|
await this.download(filePath);
|
||||||
|
await fs.remove(filePath);
|
||||||
|
} else {
|
||||||
|
this.body = "文件不存在!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文章
|
// 获取文章
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.exportBookmark = async function () {
|
$scope.exportBookmark = async function () {
|
||||||
let data = await get('bookmarkBackup');
|
let fileName = await get('bookmarkBackup');
|
||||||
console.log(data);
|
$window.open(`${document.location.origin}/api/bookmarkDownload?fileName=${fileName}`, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue