diff --git a/cmd b/cmd index fddce7e63..9f3470ae4 100755 --- a/cmd +++ b/cmd @@ -160,6 +160,7 @@ run_mysql() { fi docker cp $filename $container_name:/ run_exec mariadb "gunzip < /$inputname | mysql -u$username -p$password $database" + run_exec php "php artisan migrate" judge "还原数据库" fi } diff --git a/electron/build.js b/electron/build.js index 05fa95c2c..3d80b6362 100644 --- a/electron/build.js +++ b/electron/build.js @@ -27,7 +27,7 @@ function startBuild(data, publish) { origin: "./", apiUrl: utils.formatUrl(data.url) + "api/", } - fs.writeFileSync(electronDir + "/config.js", "window.systemInformation = " + JSON.stringify(systemInfo, null, 2), 'utf8'); + fs.writeFileSync(electronDir + "/config.js", "window.systemInfo = " + JSON.stringify(systemInfo, null, 2), 'utf8'); fs.writeFileSync(nativeCachePath, utils.formatUrl(data.url)); fs.writeFileSync(devloadCachePath, "", 'utf8'); // index.html diff --git a/electron/index.html b/electron/index.html index dcaadc04a..a83ea368a 100644 --- a/electron/index.html +++ b/electron/index.html @@ -34,7 +34,7 @@ diff --git a/electron/package.json b/electron/package.json index 35f40b90c..ffac70df2 100644 --- a/electron/package.json +++ b/electron/package.json @@ -51,7 +51,8 @@ "files": [ "public/**/*", "main.js", - "preload.js" + "preload.js", + "utils.js" ], "mac": { "icon": "../resources/assets/statics/public/images/logo-app.png", diff --git a/electron/utils.js b/electron/utils.js index 0383539e9..70286e935 100644 --- a/electron/utils.js +++ b/electron/utils.js @@ -249,7 +249,7 @@ module.exports = { */ getDomain(weburl) { let urlReg = /http(s)?:\/\/([^\/]+)/i; - let domain = weburl.match(urlReg); + let domain = (weburl + "").match(urlReg); return ((domain != null && domain.length > 0) ? domain[2] : ""); }, } diff --git a/package.json b/package.json index 6367c706c..85943682c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,11 @@ "name": "HitoseaTask", "id": "com.hitosea.task", "url": "https://t.hitosea.com/" + }, + { + "name": "Public DooTask", + "id": "com.dootask.public", + "url": "https://public/" } ] }, diff --git a/resources/assets/js/components/AppDown.vue b/resources/assets/js/components/AppDown.vue index 36ca97b2f..8bad19259 100644 --- a/resources/assets/js/components/AppDown.vue +++ b/resources/assets/js/components/AppDown.vue @@ -125,9 +125,9 @@ export default { }, chackReleases() { - let hostName = window.location.hostname; - if (hostName == '127.0.0.1') { - hostName = "www.dootask.com" + let hostName = $A.getDomain(window.systemInfo.apiUrl); + if (hostName == "" || hostName == '127.0.0.1') { + hostName = "public" } if (this.$Electron) { // 客户端(更新) @@ -147,7 +147,7 @@ export default { if (!this.repoData) { return; } - let currentVersion = window.systemInformation.version; + let currentVersion = window.systemInfo.version; let latestVersion = $A.leftDelete(this.releases.tag_name.toLowerCase(), "v") if (this.compareVersion(latestVersion, currentVersion) === 1) { // 有新版本 diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index 4c7bd449b..e68826831 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -2,6 +2,7 @@ * 基础函数 */ (function (window, $, undefined) { + window.systemInfo = window.systemInfo || {}; /** * ============================================================================= @@ -794,7 +795,7 @@ }; } if (this.rightExists(url, '.js')) { - script.src = url + "?hash=" + window.systemInformation.version; + script.src = url + "?hash=" + window.systemInfo.version; } else { script.src = url; } @@ -850,7 +851,7 @@ } script.rel = 'stylesheet'; if (this.rightExists(url, '.css')) { - script.href = url + "?hash=" + window.systemInformation.version; + script.href = url + "?hash=" + window.systemInfo.version; } else { script.href = url; } @@ -928,6 +929,17 @@ return {'<': '<', '>': '>', '&': '&', '"': '"'}[c]; }); }, + + /** + * 正则提取域名 + * @param weburl + * @returns {string|string} + */ + getDomain(weburl) { + let urlReg = /http(s)?:\/\/([^\/]+)/i; + let domain = (weburl + "").match(urlReg); + return ((domain != null && domain.length > 0) ? domain[2] : ""); + }, }); /** diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index b6219bb39..d08c8ebc6 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -22,8 +22,8 @@ str.substring(0, 1) === "/") { return str; } - if (window.systemInformation && typeof window.systemInformation.apiUrl === "string") { - str = window.systemInformation.apiUrl + str; + if (typeof window.systemInfo.apiUrl === "string") { + str = window.systemInfo.apiUrl + str; } else { str = window.location.origin + "/api/" + str; } @@ -34,7 +34,7 @@ }, /** - * 服务器地址 + * 服务地址 * @param str * @returns {string} */ @@ -46,8 +46,8 @@ str.substring(0, 1) === "/") { return str; } - if (window.systemInformation && typeof window.systemInformation.origin === "string") { - str = window.systemInformation.origin + str; + if (typeof window.systemInfo.origin === "string") { + str = window.systemInfo.origin + str; } else { str = window.location.origin + "/" + str; } diff --git a/resources/assets/js/pages/login.vue b/resources/assets/js/pages/login.vue index 558399786..4601385b8 100644 --- a/resources/assets/js/pages/login.vue +++ b/resources/assets/js/pages/login.vue @@ -4,13 +4,13 @@
- +
- +
@@ -56,6 +56,8 @@ export default { return { loadIng: 0, + welcomeTitle: window.systemInfo.title || "Dootask", + codeNeed: false, codeUrl: $A.apiUrl('users/login/codeimg'), @@ -75,8 +77,10 @@ export default { mounted() { this.getDemoAccount(); // - if (!this.$Electron && this.cacheServerUrl) { - this.onServerUrlClear(); + if (this.$Electron) { + this.chackServerUrl(); + } else { + this.clearServerUrl(); } }, deactivated() { @@ -109,6 +113,9 @@ export default { }, methods: { getDemoAccount() { + if (this.isNotServer()) { + return; + } this.$store.dispatch("call", { url: 'system/demo', }).then(({data}) => { @@ -140,7 +147,7 @@ export default { this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random()) }, - onServerUrlInput() { + inputServerUrl() { $A.modalInput({ title: "自定义服务器", value: this.cacheServerUrl, @@ -156,23 +163,44 @@ export default { this.$store.dispatch("call", { url: value + 'system/setting', }).then(() => { - $A.setStorage("cacheServerUrl", value) - window.location.reload(); + this.setServerUrl(value) }).catch(({msg}) => { $A.modalError(msg || "服务器地址无效", 301); cb() }); return; } - $A.setStorage("cacheServerUrl", "") - window.location.reload(); + this.clearServerUrl(); } }); }, - onServerUrlClear() { - $A.setStorage("cacheServerUrl", "") - window.location.reload(); + chackServerUrl() { + return new Promise((resolve, reject) => { + if (this.isNotServer()) { + $A.messageWarning("请设置服务器") + this.inputServerUrl() + reject() + } else { + resolve() + } + }) + }, + + setServerUrl(value) { + if (value != this.cacheServerUrl) { + $A.setStorage("cacheServerUrl", value) + window.location.reload(); + } + }, + + clearServerUrl() { + this.setServerUrl("") + }, + + isNotServer() { + let apiHome = $A.getDomain(window.systemInfo.apiUrl) + return apiHome == "" || apiHome == "public" }, onBlur() { @@ -197,44 +225,46 @@ export default { }, onLogin() { - if (!this.email) { - return; - } - if (!this.password) { - return; - } - if (this.loginType == 'reg') { - if (this.password != this.password2) { - $A.noticeError("确认密码输入不一致"); + this.chackServerUrl().then(() => { + if (!this.email) { return; } - } - this.loadIng++; - this.$store.dispatch("call", { - url: 'users/login', - data: { - type: this.loginType, - email: this.email, - password: this.password, - code: this.code, - invite: this.invite, - }, - }).then(({data}) => { - this.loadIng--; - $A.setStorage("cacheLoginEmail", this.email) - this.$store.dispatch("handleClearCache", data).then(() => { - this.goNext1(); - }).catch(() => { - this.goNext1(); - }); - }).catch(({data, msg}) => { - this.loadIng--; - $A.noticeError(msg); - if (data.code === 'need') { - this.reCode(); - this.codeNeed = true; + if (!this.password) { + return; } - }); + if (this.loginType == 'reg') { + if (this.password != this.password2) { + $A.noticeError("确认密码输入不一致"); + return; + } + } + this.loadIng++; + this.$store.dispatch("call", { + url: 'users/login', + data: { + type: this.loginType, + email: this.email, + password: this.password, + code: this.code, + invite: this.invite, + }, + }).then(({data}) => { + this.loadIng--; + $A.setStorage("cacheLoginEmail", this.email) + this.$store.dispatch("handleClearCache", data).then(() => { + this.goNext1(); + }).catch(() => { + this.goNext1(); + }); + }).catch(({data, msg}) => { + this.loadIng--; + $A.noticeError(msg); + if (data.code === 'need') { + this.reCode(); + this.codeNeed = true; + } + }); + }) }, goNext1() { diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 48a40292d..fef890d80 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -26,8 +26,8 @@ state.cacheProjectParameter = $A.getStorageArray("cacheProjectParameter"); // ServerUrl state.cacheServerUrl = $A.getStorageString("cacheServerUrl") -if (state.cacheServerUrl && window.systemInformation) { - window.systemInformation.apiUrl = state.cacheServerUrl; +if (state.cacheServerUrl) { + window.systemInfo.apiUrl = state.cacheServerUrl; } // Ajax diff --git a/resources/views/main.blade.php b/resources/views/main.blade.php index 9d294032e..7838e5b66 100755 --- a/resources/views/main.blade.php +++ b/resources/views/main.blade.php @@ -17,7 +17,7 @@