Commit 2fafa841 by 庄欣

完成

parent fb7dbea6
...@@ -135,3 +135,33 @@ input[type=radio] { ...@@ -135,3 +135,33 @@ input[type=radio] {
justify-content: center; justify-content: center;
align-content: center; align-content: center;
} }
#___container .mask {
position: absolute;
width: 100%;
height: 100%;
z-index: 999;
top: 0;
background-color: rgba(0,0,0,0.2);
display:flex;
justify-content: center;
align-items: center;
align-content: center;
justify-items: center;
color: #ffffff;
}
.xuanzhuan {
animation: xz 1s linear infinite;
}
@keyframes xz {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
\ No newline at end of file
...@@ -27,6 +27,7 @@ fetch(UI).then(function(res){ ...@@ -27,6 +27,7 @@ fetch(UI).then(function(res){
app = new Vue({ app = new Vue({
el: '#__extend_dom', el: '#__extend_dom',
data: { data: {
loadingimg: chrome.extension.getURL("loading.png"),
closeX: chrome.extension.getURL("close.png"), closeX: chrome.extension.getURL("close.png"),
fade: false, fade: false,
canOpen: false, canOpen: false,
...@@ -56,16 +57,14 @@ fetch(UI).then(function(res){ ...@@ -56,16 +57,14 @@ fetch(UI).then(function(res){
userPermission: "-1", userPermission: "-1",
userToken: "", userToken: "",
err: "", err: "",
loading: true, loading: false,
API: { API: {
addZone: "https://api.mepai.me/manage/youmi/add-zone", addZone: "https://api.mepai.me/manage/youmi/add-zone",
getZone: "https://api.mepai.me/manage/youmi/get-zone", getZone: "https://api.mepai.me/manage/youmi/get-zone",
removeZone: "https://api.mepai.me/manage/youmi/remove-zone", removeZone: "https://api.mepai.me/manage/youmi/remove-zone",
setRemark: "https://api.mepai.me/manage/youmi/set-remark", setRemark: "https://api.mepai.me/manage/youmi/set-remark",
getRemark: "https://api.mepai.me/manage/youmi/get-remark", getRemark: "https://api.mepai.me/manage/youmi/get-remark",
getUserInfo: "https://api.mepai.me/v5/user/info", getUserInfo: "https://api.mepai.me/manage/youmi/user",
getReadingInfo: "https://api.mepai.me/v5/reading/info",
getWorksInfo: "https://api.mepai.me/v5/works/info",
getIsYoumi: "https://api.mepai.me/manage/youmi/is-youmi", getIsYoumi: "https://api.mepai.me/manage/youmi/is-youmi",
auth: "https://api.mepai.me/manage/youmi/is-auth" auth: "https://api.mepai.me/manage/youmi/is-auth"
} }
...@@ -73,12 +72,17 @@ fetch(UI).then(function(res){ ...@@ -73,12 +72,17 @@ fetch(UI).then(function(res){
methods: { methods: {
showUi: function() { showUi: function() {
this.showUiProp = !this.showUiProp; this.showUiProp = !this.showUiProp;
if (this.showUiProp) {
this.openUi();
}
}, },
openUi: function() { openUi: function() {
let $this = this; let $this = this;
let canOpen = this.assertIn(); let canOpen = this.assertIn();
this.canOpen = canOpen; this.canOpen = canOpen;
if (canOpen) { if (canOpen) {
if ($this.type !== null && $this.type !== undefined) {
$this.getData($this.API.getRemark, { $this.getData($this.API.getRemark, {
object_id: $this.objectId, object_id: $this.objectId,
type: $this.type type: $this.type
...@@ -91,6 +95,7 @@ fetch(UI).then(function(res){ ...@@ -91,6 +95,7 @@ fetch(UI).then(function(res){
} }
} }
}); });
}
//获取基本信息并显示在编辑框 //获取基本信息并显示在编辑框
if ($this.isUserInfo) { if ($this.isUserInfo) {
this.getData($this.API.getUserInfo, { this.getData($this.API.getUserInfo, {
...@@ -110,7 +115,7 @@ fetch(UI).then(function(res){ ...@@ -110,7 +115,7 @@ fetch(UI).then(function(res){
}, res => { }, res => {
if (res.code.toString() === "100001") { if (res.code.toString() === "100001") {
if (res.data.toString() !== "{}") { if (res.data.toString() !== "{}") {
$this.useRemark = res.data.remark; $this.userRemark = res.data.remark;
$this.userPermission = res.data.permission.toString(); $this.userPermission = res.data.permission.toString();
$this.userToken = res.data.lock_token $this.userToken = res.data.lock_token
} }
...@@ -118,12 +123,6 @@ fetch(UI).then(function(res){ ...@@ -118,12 +123,6 @@ fetch(UI).then(function(res){
}) })
} }
if ($this.isWorks ) { if ($this.isWorks ) {
/* $this.getData($this.API.getWorksInfo, {
works_id: $this.objectId
}, data => {
let works = data.data;
$this.isYoumi = works.is_youmi;
});*/
$this.getData($this.API.getIsYoumi, { $this.getData($this.API.getIsYoumi, {
object_id: $this.objectId, object_id: $this.objectId,
type : $this.type type : $this.type
...@@ -132,13 +131,6 @@ fetch(UI).then(function(res){ ...@@ -132,13 +131,6 @@ fetch(UI).then(function(res){
}); });
} }
if ($this.isReading) { if ($this.isReading) {
/*$this.getData(this.API.getReadingInfo, {
reading_id: $this.objectId
}, data => {
let reading = data.data;
$this.isYoumi = reading.is_youmi;
});*/
$this.getData($this.API.getIsYoumi, { $this.getData($this.API.getIsYoumi, {
object_id: $this.objectId, object_id: $this.objectId,
type : $this.type type : $this.type
...@@ -202,7 +194,6 @@ fetch(UI).then(function(res){ ...@@ -202,7 +194,6 @@ fetch(UI).then(function(res){
} }
if (res.code.toString() === "100002") { if (res.code.toString() === "100002") {
$this.isAuth = false; $this.isAuth = false;
$this.err = "权限不足";
} }
}); });
}, },
...@@ -223,8 +214,8 @@ fetch(UI).then(function(res){ ...@@ -223,8 +214,8 @@ fetch(UI).then(function(res){
}).then(final => { }).then(final => {
if (final.code.toString() === "100002") { if (final.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限"; $this.err = "请您先在网站登录,或者请确定您的操作权限";
} else { } else if (final.code.toString() === "100001") {
$this.err = final.message; $this.err = "";
} }
return callback(final); return callback(final);
}).catch(e => { }).catch(e => {
...@@ -232,6 +223,8 @@ fetch(UI).then(function(res){ ...@@ -232,6 +223,8 @@ fetch(UI).then(function(res){
}); });
}, },
sendData: function(api, data, callback) { sendData: function(api, data, callback) {
let $this = app;
$this.loading = true;
var header = { var header = {
method: "POST", method: "POST",
headers: { headers: {
...@@ -241,6 +234,7 @@ fetch(UI).then(function(res){ ...@@ -241,6 +234,7 @@ fetch(UI).then(function(res){
body: JSON.stringify(data) body: JSON.stringify(data)
}; };
fetch(api, header).then(res => { fetch(api, header).then(res => {
$this.loading = false;
return res.json() return res.json()
}).then(final => { }).then(final => {
return callback(final); return callback(final);
...@@ -299,13 +293,14 @@ fetch(UI).then(function(res){ ...@@ -299,13 +293,14 @@ fetch(UI).then(function(res){
if (res.code === "100001") { if (res.code === "100001") {
$this.remark = res.data.remark; $this.remark = res.data.remark;
$this.permission = res.data.permission.toString(); $this.permission = res.data.permission.toString();
$this.token = res.data.lock_token $this.token = res.data.lock_token;
} $this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") { if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限"; $this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else { } else {
$this.err = res.message; $this.showToast(res.message);
}
} }
}); });
}, },
...@@ -322,13 +317,14 @@ fetch(UI).then(function(res){ ...@@ -322,13 +317,14 @@ fetch(UI).then(function(res){
if (res.code === "100001") { if (res.code === "100001") {
$this.userRemark = res.data.remark; $this.userRemark = res.data.remark;
$this.userPermission = res.data.permission.toString(); $this.userPermission = res.data.permission.toString();
$this.userToken = res.data.lock_token $this.userToken = res.data.lock_token;
} $this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") { if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限"; $this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else { } else {
$this.err = res.message; $this.showToast(res.message);
}
} }
}); });
}, },
...@@ -340,13 +336,15 @@ fetch(UI).then(function(res){ ...@@ -340,13 +336,15 @@ fetch(UI).then(function(res){
}, res => { }, res => {
if (res.code.toString() === "100001") { if (res.code.toString() === "100001") {
$this.inZone = false; $this.inZone = false;
} $this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") { if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限"; $this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else { } else {
$this.err = res.message; $this.showToast(res.message);
}
} }
}); });
}, },
addZone() { addZone() {
...@@ -357,15 +355,23 @@ fetch(UI).then(function(res){ ...@@ -357,15 +355,23 @@ fetch(UI).then(function(res){
}, res => { }, res => {
if (res.code.toString() === "100001") { if (res.code.toString() === "100001") {
$this.inZone = true; $this.inZone = true;
} $this.showToast("操作成功");
} else {
if (res.code.toString() === "100002") { if (res.code.toString() === "100002") {
$this.err = "请您先在网站登录,或者请确定您的操作权限"; $this.err = "请您先在网站登录,或者请确定您的操作权限";
alert($this.err);
} else { } else {
$this.err = res.message; $this.showToast(res.message);
}
} }
}); });
}, },
showToast(msg) {
let $this = this;
$this.err = msg;
setTimeout(function () {
$this.err = "";
}, 3000);
},
base64Decode(data) { base64Decode(data) {
var rv = window.atob(data); var rv = window.atob(data);
rv = escape(rv); rv = escape(rv);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
} }
], ],
"web_accessible_resources": [ "web_accessible_resources": [
"ui.html", "icon.png","close.png" "ui.html", "icon.png","close.png","loading.png"
], ],
"browser_action": { "browser_action": {
"default_icon": "icon.png", "default_icon": "icon.png",
......
<div v-if="showUiProp" id="___container"> <div v-if="showUiProp" id="___container">
<div class="mask" v-if="loading">
<img class="xuanzhuan" :src="loadingimg" style="width:10%;"></img>
</div>
<div class="x" v-on:click="showUi"><img :src="closeX"></div> <div class="x" v-on:click="showUi"><img :src="closeX"></div>
<div class="danger" v-if="err != ''">{{err}}</div> <div class="danger" v-if="err != ''">{{err}}</div>
<!------------------- 用户开始 --------> <!------------------- 用户开始 -------->
...@@ -49,7 +52,7 @@ ...@@ -49,7 +52,7 @@
</div> </div>
</div> </div>
<div style="display: flex;justify-content: center;justify-items: center"> <div style="display: flex;justify-content: center;justify-items: center">
<button class="btn btn-primary primary large" v-on:click="submitUserRemark">提交用户备注</button> <button class="btn btn-primary primary large" v-on:click="submitUserRemark">提交用户设置</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -92,7 +95,7 @@ ...@@ -92,7 +95,7 @@
</div> </div>
</div> </div>
<div class="form-group" style="display: flex;justify-items: center;justify-content: center"> <div class="form-group" style="display: flex;justify-items: center;justify-content: center">
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交作品备注</button> <button class="btn btn-primary primary large" v-on:click="submitRemark">提交作品设置</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -135,7 +138,7 @@ ...@@ -135,7 +138,7 @@
</div> </div>
</div> </div>
<div class="form-group" style="display: flex;justify-items: center;justify-content: center"> <div class="form-group" style="display: flex;justify-items: center;justify-content: center">
<button class="btn btn-primary primary large" v-on:click="submitRemark">提交文章备注</button> <button class="btn btn-primary primary large" v-on:click="submitRemark">提交文章设置</button>
</div> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment