资源
源代码
仓库在GitHub.com/maiernte
- 客户端 /yinotebook
- 服务端 /alifun (其中的 server 子目录)
- Markdown 编辑器的 Math插件 /yixuepackage
运行资源
在线网页版
国内:http://maiernte.gitee.io/huahe
国外:http://maiernte.github.io/huahe
文档:http://maiernte.gitee.io/huahedocument (包括安卓版的安装包)
服务及数据
使用阿里的函数计算托管后台服务,OSS托管论坛资源(图片、紧急更换服务器地址的静态文件),论坛的数据mongoDB。
阿里云总入口:https://homenew.console.aliyun.com/
对象存储:通过服务器临时授权访问
- Bucket huaheuser: 用户的案例以及将来个人的私密
- Bucket huaheapp: app 托管代码资源,haute.config.json 列出来每个版本对应的服务器地址,紧急情况可以由软件读取。avatar 里是每个用户的头像,forum 为论坛图片。
数据库:mongoDB数据库后台 登录账号为 [email protected]
编译命令
客户端编译
// Debug localhost
ionic serve
ng serve // ng serve --host 0.0.0.0 允许局域网内访问
// 在线版 国外地址更换为 github.io
ionic build --prod -- --base-href https://maiernte.gitee.io/huahe/
// 安卓版
ionic cordova build android --prod
ionic cordova build android --prod --release (加上release 好像安装时出错)
// ios 模拟器
ionic cordova run ios
编译 ios 版客户端
Gitee中部署在线版客户端
在线版客户端编译完之后,将WWW目录下所有的文件上传到gitee仓库(https://gitee.com/maiernte/huahe),进入仓库,选取工具栏菜单中的“服务 -> Gitee Pages”,然后左下角点击“更新”即可。
ionic build --prod -- --base-href https://maiernte.gitee.io/huahe/
cp -r www/* ../huahegitee/
cp -r www/* ../huahe-github-pages/
sed 's/gitee.io/github.io/g' www/index.html > ../huahe-github-pages/index.html
Github中部署在线版客户端
// Reference: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/
{% math %} git add .
{% endmath %} git status // to see what changes are going to be commited
{% math %} git commit -m 'Some descriptive commit message'
{% endmath %} git push origin master
{% math %} git checkout gh-pages // go to the gh-pages branch
{% endmath %} git rebase master // bring gh-pages up to date with master
{% math %} git push origin gh-pages // commit the changes
{% endmath %} git checkout master // return to the master branch
ionic build --prod -- --base-href https://maiernte.github.io/huahe/
cp -r www/* ../huahe-github-pages/
服务端编译
// 将 Typescript 编译成 javascript
tsc -p ./server/tsconfig.json
// 制作成 npm 包
cp -r ./server/dist/* ./server/node_modules/huahe-server
服务端的部署,将huahe-server文件夹拷贝到 server_deploy/node_modules 目录之下,然后将server_deploy目录下面的的文件和文件夹一起打包zip文(注意不要直接打包server_deploy目录)。上传到OSS,函数计算将代码包读取并部署。
帮助文档编译
帮助文档项目位于 “Gitbook/Library/huaheapp”
// 本地演示
gitbook serve
// 编译
gitbook build
cp -r _book/* ../../publish/huaheapp/
编译后将 _book 目录下的内容上传到gitee的文档项目仓库,更新发布就可以了。
安卓版打包
图标和启动图案
放置两张图片:resources/icon.png 和 resources/splash.png (文档地址)
// 之前可能要安装 cordova-res
ionic cordova resources
ionic cordova resources -ios
ionic cordova resources -android
{% math %} id -un (to get your USERNAME)
mai
{% endmath %} sudo chown -R mai /usr/local/lib/node_modules/
$ npm install -g cordova-res
生成release文件
ionic cordova build android --release
Sign 生成签名文件
// huaheapp 为别名
keytool -genkey -v -keystore release-key.keystore -alias huaheapp -keyalg RSA -keysize 2048 -validity 10000
// 建议新用
keytool -importkeystore -srckeystore release-key.keystore -destkeystore release-key.keystore -deststoretype pkcs12
使用密码为华鹤项目通用密码,保存在 OSS huaheuser/releasse-key.keystore
对APK文件签名
然后我们就可以用下面的命令对 APK 签名了:
// 所有文件都拷贝到同一个目录
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore release-key.keystore app-release-unsigned.apk huaheapp
这个命令中需要传入证书名 release-key.keystore,要签名的 APK android-release-unsigned.apk,和别名 cordova-demo。签名过程中需要先后输入 keystore 和 key 的密码。命令运行完后,这个 APK 就已经改变了。注意这个过程没有生成新文件。
Align 压缩和优化apk
// 搜索 zipalign 文件并拷贝到同样目录
find ~/Library/Android/sdk/build-tools -name "zipalign"
cp /Users/mai/Library/Android/sdk/build-tools/29.0.2/zipalign ./
./zipalign -v 4 app-release-unsigned.apk huaheapp.apk
自动打包
// testing & testing2 为演示密码
cordova build android --release -- --keystore="release-key.keystore" --alias=huaheapp --storePassword=testing --password=testing2
但每次输入命令行参数是很重复的,Cordova 允许我们建立一个 build.json 配置文件来简化操作。文件内容如下:
{
"android": {
"release": {
"keystore": "release-key.keystore",
"alias": "cordova-demo",
"storePassword": "testing",
"password": "testing2"
}
}
}
下次就可以直接用 cordova build --release 了。
iOS 证书和发布
生成测试证实
- 登录进Apple Development 账户后选择生成一个 “ios Development Certificate”
- 上传 Certificate Signing Request (CSR) 文件。参考 创建证书签名请求
- 启动位于
/Applications/Utilities中的“钥匙串访问”。- 选取“钥匙串访问”>“证书助理”>“从证书颁发机构请求证书”。
- 在“证书助理”对话框中,在“用户电子邮件地址”栏位中输入电子邮件地址。
- 在“常用名称”栏位中,输入密钥的名称 (例如,Gita Kumar Dev Key)。
- 将“CA 电子邮件地址”栏位留空。
- 选取“存储到磁盘”,然后点按“继续”。
申请Development描述文件
选择 Profiles 菜单,添加 ios Development Provision 文件。
编译ios版本
1. `ionic cordova build ios --prod` 编译项目,然后用 Xcode 打开
2. 选择左侧项目并在 "Build Settings" 导入证书和设置通用项。
3.  然后点 “Product/Archive”, 推送到Appstore或者下载。
技术性问题
常用文档
- 阿里帮助中心
- Node.js 访问控制
- mongoDB Tutorials
- ionic
- nanoSQL
- CKEditor (内嵌文本编辑器)
- pako (数据压缩) cryptp-js (数据加密)
- npm 打包
- FileSaver.js (文件导出)
- sql.js (sqlite数据库在线读取,源文件在客户端代码 assets/js/sql.js)
- Semantic-ui ng
调错
调试ios上的safari
在Mac上打开“开发”支持,然后将ipad用线连接到Mac。在Mac上运行Safari并导航到相应网站之后,在Mac上的Safari -> 开发 -> 我的ipad -> 网站地址
chrome 调试 Device
ionic cordova run android ,然后在 Chrome 浏览器上 输入,并点击相应机器
chrome://inspect/#devices
特别注意的问题
在ios崩溃
原因是ios屏蔽web-animation。解决方案,在index.html引入js文件
<script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script>
在ios无法使用CKEditor进行文字编辑
原因是ios默认屏蔽HTML的contenteditable属性。解决方案,在使用CKEditor的模块css文件加入以下代码:
* {
-webkit-user-select: none;
user-select: none;
}
input,
ckeditor,
[contenteditable] {
-webkit-user-select: text;
user-select: text;
}